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

Commit

Permalink
fix(lodestar-v0): Rename Lodestar to Lodestar-v0 (#2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Sep 1, 2023
1 parent 4e521ae commit 36c418f
Show file tree
Hide file tree
Showing 23 changed files with 136 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,63 @@ import {
GetTokenBalancesParams,
} from '~position/template/contract-position.template.types';

import { LodestarComptroller, LodestarContractFactory, LodestarIToken } from '../contracts';
import { LodestarV0Comptroller, LodestarV0ContractFactory, LodestarV0IToken } from '../contracts';

@PositionTemplate()
export class ArbitrumLodestarBorrowContractPositionFetcher extends CompoundBorrowContractPositionFetcher<
LodestarIToken,
LodestarComptroller
export class ArbitrumLodestarV0BorrowContractPositionFetcher extends CompoundBorrowContractPositionFetcher<
LodestarV0IToken,
LodestarV0Comptroller
> {
groupLabel = 'Lending';
comptrollerAddress = '0x92a62f8c4750d7fbdf9ee1db268d18169235117b';

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

getCompoundCTokenContract(address: string) {
return this.contractFactory.lodestarIToken({ address, network: this.network });
return this.contractFactory.lodestarV0IToken({ address, network: this.network });
}

getCompoundComptrollerContract(address: string) {
return this.contractFactory.lodestarComptroller({ address, network: this.network });
return this.contractFactory.lodestarV0Comptroller({ address, network: this.network });
}

async getMarkets({ contract }: GetMarketsParams<LodestarComptroller>) {
async getMarkets({ contract }: GetMarketsParams<LodestarV0Comptroller>) {
return contract.getAllMarkets();
}

async getUnderlyingAddress({ contract }: GetTokenDefinitionsParams<LodestarIToken>) {
async getUnderlyingAddress({ contract }: GetTokenDefinitionsParams<LodestarV0IToken>) {
return contract.underlying();
}

async getExchangeRate({ contract }: GetDataPropsParams<LodestarIToken, CompoundBorrowTokenDataProps>) {
async getExchangeRate({ contract }: GetDataPropsParams<LodestarV0IToken, CompoundBorrowTokenDataProps>) {
return contract.callStatic.exchangeRateCurrent();
}

async getBorrowRate({ contract }: GetDataPropsParams<LodestarIToken, CompoundBorrowTokenDataProps>) {
async getBorrowRate({ contract }: GetDataPropsParams<LodestarV0IToken, CompoundBorrowTokenDataProps>) {
return contract.borrowRatePerBlock().catch(() => 0);
}

async getCash({ contract }: GetDataPropsParams<LodestarIToken, CompoundBorrowTokenDataProps>) {
async getCash({ contract }: GetDataPropsParams<LodestarV0IToken, CompoundBorrowTokenDataProps>) {
return contract.getCash();
}

async getCTokenSupply({ contract }: GetDataPropsParams<LodestarIToken, CompoundBorrowTokenDataProps>) {
async getCTokenSupply({ contract }: GetDataPropsParams<LodestarV0IToken, CompoundBorrowTokenDataProps>) {
return contract.totalSupply();
}

async getCTokenDecimals({ contract }: GetDataPropsParams<LodestarIToken, CompoundBorrowTokenDataProps>) {
async getCTokenDecimals({ contract }: GetDataPropsParams<LodestarV0IToken, CompoundBorrowTokenDataProps>) {
return contract.decimals();
}

async getBorrowBalance({ address, contract }: GetTokenBalancesParams<LodestarIToken, CompoundBorrowTokenDataProps>) {
async getBorrowBalance({
address,
contract,
}: GetTokenBalancesParams<LodestarV0IToken, CompoundBorrowTokenDataProps>) {
return contract.callStatic.borrowBalanceCurrent(address);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import {
} from '~apps/compound/common/compound.claimable.contract-position-fetcher';
import { ContractPosition } from '~position/position.interface';

import { LodestarComptroller, LodestarContractFactory } from '../contracts';
import { LodestarLens } from '../contracts/ethers/LodestarLens';
import { LodestarV0Comptroller, LodestarV0ContractFactory, LodestarV0Lens } from '../contracts';

@PositionTemplate()
export class ArbitrumLodestarClaimableContractPositionFetcher extends CompoundClaimableContractPositionFetcher<
LodestarComptroller,
LodestarLens
export class ArbitrumLodestarV0ClaimableContractPositionFetcher extends CompoundClaimableContractPositionFetcher<
LodestarV0Comptroller,
LodestarV0Lens
> {
groupLabel = 'Claimable';

Expand All @@ -25,25 +24,25 @@ export class ArbitrumLodestarClaimableContractPositionFetcher extends CompoundCl

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

getCompoundComptrollerContract(address: string): LodestarComptroller {
return this.contractFactory.lodestarComptroller({ address, network: this.network });
getCompoundComptrollerContract(address: string): LodestarV0Comptroller {
return this.contractFactory.lodestarV0Comptroller({ address, network: this.network });
}

getCompoundLensContract(address: string): LodestarLens {
return this.contractFactory.lodestarLens({ address, network: this.network });
getCompoundLensContract(address: string): LodestarV0Lens {
return this.contractFactory.lodestarV0Lens({ address, network: this.network });
}

async getClaimableBalance(
address: string,
{
contract,
contractPosition,
}: { contract: LodestarLens; contractPosition: ContractPosition<CompoundClaimablePositionDataProps> },
}: { contract: LodestarV0Lens; contractPosition: ContractPosition<CompoundClaimablePositionDataProps> },
): Promise<BigNumberish> {
const [rewardToken] = contractPosition.tokens;
const { address: comptrollerAddress } = contractPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { PresenterTemplate } from '~app-toolkit/decorators/presenter-template.de
import { CompoundPositionPresenter } from '~apps/compound/common/compound.position-presenter';

@PresenterTemplate()
export class ArbitrumLodestarPositionPresenter extends CompoundPositionPresenter {}
export class ArbitrumLodestarV0PositionPresenter extends CompoundPositionPresenter {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,48 @@ import {
GetUnderlyingTokensParams,
} from '~position/template/app-token.template.types';

import { LodestarComptroller, LodestarContractFactory, LodestarIToken } from '../contracts';
import { LodestarV0Comptroller, LodestarV0ContractFactory, LodestarV0IToken } from '../contracts';

@PositionTemplate()
export class ArbitrumLodestarSupplyTokenFetcher extends CompoundSupplyTokenFetcher<
LodestarIToken,
LodestarComptroller
export class ArbitrumLodestarV0SupplyTokenFetcher extends CompoundSupplyTokenFetcher<
LodestarV0IToken,
LodestarV0Comptroller
> {
groupLabel = 'Lending';
comptrollerAddress = '0x92a62f8c4750d7fbdf9ee1db268d18169235117b';

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

getCompoundCTokenContract(address: string) {
return this.contractFactory.lodestarIToken({ address, network: this.network });
return this.contractFactory.lodestarV0IToken({ address, network: this.network });
}

getCompoundComptrollerContract(address: string) {
return this.contractFactory.lodestarComptroller({ address, network: this.network });
return this.contractFactory.lodestarV0Comptroller({ address, network: this.network });
}

async getMarkets({ contract }: GetMarketsParams<LodestarComptroller>) {
async getMarkets({ contract }: GetMarketsParams<LodestarV0Comptroller>) {
return contract.getAllMarkets();
}

async getUnderlyingAddress({ contract }: GetUnderlyingTokensParams<LodestarIToken>) {
async getUnderlyingAddress({ contract }: GetUnderlyingTokensParams<LodestarV0IToken>) {
return contract.underlying();
}

async getExchangeRate({ contract }: GetPricePerShareParams<LodestarIToken>) {
async getExchangeRate({ contract }: GetPricePerShareParams<LodestarV0IToken>) {
return contract.callStatic.exchangeRateCurrent();
}

async getSupplyRate({ contract }: GetDataPropsParams<LodestarIToken>) {
async getSupplyRate({ contract }: GetDataPropsParams<LodestarV0IToken>) {
return contract.supplyRatePerBlock().catch(() => 0);
}

async getLabel({ appToken, contract }: GetDisplayPropsParams<LodestarIToken>): Promise<DisplayProps['label']> {
async getLabel({ appToken, contract }: GetDisplayPropsParams<LodestarV0IToken>): Promise<DisplayProps['label']> {
const [underlyingToken] = appToken.tokens;
const [symbol, name] = await Promise.all([contract.symbol(), contract.name()]);
if (!name.startsWith(`${symbol}-`)) return underlyingToken.symbol;
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi
import type { Listener, Provider } from '@ethersproject/providers';
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent, PromiseOrValue } from './common';

export interface LodestarComptrollerInterface extends utils.Interface {
export interface LodestarV0ComptrollerInterface extends utils.Interface {
functions: {
'_become(address)': FunctionFragment;
'_borrowGuardianPaused()': FunctionFragment;
Expand Down Expand Up @@ -746,12 +746,12 @@ export type NewSupplyCapGuardianEvent = TypedEvent<[string, string], NewSupplyCa

export type NewSupplyCapGuardianEventFilter = TypedEventFilter<NewSupplyCapGuardianEvent>;

export interface LodestarComptroller extends BaseContract {
export interface LodestarV0Comptroller extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: LodestarComptrollerInterface;
interface: LodestarV0ComptrollerInterface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi
import type { Listener, Provider } from '@ethersproject/providers';
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent, PromiseOrValue } from './common';

export interface LodestarITokenInterface extends utils.Interface {
export interface LodestarV0ITokenInterface extends utils.Interface {
functions: {
'NO_ERROR()': FunctionFragment;
'_acceptAdmin()': FunctionFragment;
Expand Down Expand Up @@ -485,12 +485,12 @@ export type TransferEvent = TypedEvent<[string, string, BigNumber], TransferEven

export type TransferEventFilter = TypedEventFilter<TransferEvent>;

export interface LodestarIToken extends BaseContract {
export interface LodestarV0IToken extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: LodestarITokenInterface;
interface: LodestarV0ITokenInterface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export declare namespace CompoundLens {
};
}

export interface LodestarLensInterface extends utils.Interface {
export interface LodestarV0LensInterface extends utils.Interface {
functions: {
'cTokenBalances(address,address)': FunctionFragment;
'cTokenBalancesAll(address[],address)': FunctionFragment;
Expand Down Expand Up @@ -391,12 +391,12 @@ export type lodeMetaDataEvent = TypedEvent<[BigNumber, BigNumber], lodeMetaDataE

export type lodeMetaDataEventFilter = TypedEventFilter<lodeMetaDataEvent>;

export interface LodestarLens extends BaseContract {
export interface LodestarV0Lens extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: LodestarLensInterface;
interface: LodestarV0LensInterface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { Contract, Signer, utils } from 'ethers';
import type { Provider } from '@ethersproject/providers';
import type { LodestarComptroller, LodestarComptrollerInterface } from '../LodestarComptroller';
import type { LodestarV0Comptroller, LodestarV0ComptrollerInterface } from '../LodestarV0Comptroller';

const _abi = [
{
Expand Down Expand Up @@ -2249,12 +2249,12 @@ const _abi = [
},
];

export class LodestarComptroller__factory {
export class LodestarV0Comptroller__factory {
static readonly abi = _abi;
static createInterface(): LodestarComptrollerInterface {
return new utils.Interface(_abi) as LodestarComptrollerInterface;
static createInterface(): LodestarV0ComptrollerInterface {
return new utils.Interface(_abi) as LodestarV0ComptrollerInterface;
}
static connect(address: string, signerOrProvider: Signer | Provider): LodestarComptroller {
return new Contract(address, _abi, signerOrProvider) as LodestarComptroller;
static connect(address: string, signerOrProvider: Signer | Provider): LodestarV0Comptroller {
return new Contract(address, _abi, signerOrProvider) as LodestarV0Comptroller;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { Contract, Signer, utils } from 'ethers';
import type { Provider } from '@ethersproject/providers';
import type { LodestarIToken, LodestarITokenInterface } from '../LodestarIToken';
import type { LodestarV0IToken, LodestarV0ITokenInterface } from '../LodestarV0IToken';

const _abi = [
{
Expand Down Expand Up @@ -1678,12 +1678,12 @@ const _abi = [
},
];

export class LodestarIToken__factory {
export class LodestarV0IToken__factory {
static readonly abi = _abi;
static createInterface(): LodestarITokenInterface {
return new utils.Interface(_abi) as LodestarITokenInterface;
static createInterface(): LodestarV0ITokenInterface {
return new utils.Interface(_abi) as LodestarV0ITokenInterface;
}
static connect(address: string, signerOrProvider: Signer | Provider): LodestarIToken {
return new Contract(address, _abi, signerOrProvider) as LodestarIToken;
static connect(address: string, signerOrProvider: Signer | Provider): LodestarV0IToken {
return new Contract(address, _abi, signerOrProvider) as LodestarV0IToken;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { Contract, Signer, utils } from 'ethers';
import type { Provider } from '@ethersproject/providers';
import type { LodestarLens, LodestarLensInterface } from '../LodestarLens';
import type { LodestarV0Lens, LodestarV0LensInterface } from '../LodestarV0Lens';

const _abi = [
{
Expand Down Expand Up @@ -890,12 +890,12 @@ const _abi = [
},
];

export class LodestarLens__factory {
export class LodestarV0Lens__factory {
static readonly abi = _abi;
static createInterface(): LodestarLensInterface {
return new utils.Interface(_abi) as LodestarLensInterface;
static createInterface(): LodestarV0LensInterface {
return new utils.Interface(_abi) as LodestarV0LensInterface;
}
static connect(address: string, signerOrProvider: Signer | Provider): LodestarLens {
return new Contract(address, _abi, signerOrProvider) as LodestarLens;
static connect(address: string, signerOrProvider: Signer | Provider): LodestarV0Lens {
return new Contract(address, _abi, signerOrProvider) as LodestarV0Lens;
}
}
6 changes: 6 additions & 0 deletions src/apps/lodestar-v0/contracts/ethers/factories/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { LodestarV0Comptroller__factory } from './LodestarV0Comptroller__factory';
export { LodestarV0IToken__factory } from './LodestarV0IToken__factory';
export { LodestarV0Lens__factory } from './LodestarV0Lens__factory';
10 changes: 10 additions & 0 deletions src/apps/lodestar-v0/contracts/ethers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { LodestarV0Comptroller } from './LodestarV0Comptroller';
export type { LodestarV0IToken } from './LodestarV0IToken';
export type { LodestarV0Lens } from './LodestarV0Lens';
export * as factories from './factories';
export { LodestarV0Comptroller__factory } from './factories/LodestarV0Comptroller__factory';
export { LodestarV0IToken__factory } from './factories/LodestarV0IToken__factory';
export { LodestarV0Lens__factory } from './factories/LodestarV0Lens__factory';
31 changes: 31 additions & 0 deletions src/apps/lodestar-v0/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Injectable, Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { ContractFactory } from '~contract/contracts';
import { Network } from '~types/network.interface';

import { LodestarV0Comptroller__factory, LodestarV0IToken__factory, LodestarV0Lens__factory } from './ethers';

// eslint-disable-next-line
type ContractOpts = { address: string; network: Network };

@Injectable()
export class LodestarV0ContractFactory extends ContractFactory {
constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) {
super((network: Network) => appToolkit.getNetworkProvider(network));
}

lodestarV0Comptroller({ address, network }: ContractOpts) {
return LodestarV0Comptroller__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
lodestarV0IToken({ address, network }: ContractOpts) {
return LodestarV0IToken__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
lodestarV0Lens({ address, network }: ContractOpts) {
return LodestarV0Lens__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
}

export type { LodestarV0Comptroller } from './ethers';
export type { LodestarV0IToken } from './ethers';
export type { LodestarV0Lens } from './ethers';
Loading

0 comments on commit 36c418f

Please sign in to comment.