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 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bastion-protocol): To templates (#1733)
- Loading branch information
1 parent
93df2f3
commit 4e0a394
Showing
24 changed files
with
854 additions
and
872 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...ion-protocol/aurora/bastion-protocol.aurora-ecosystem-borrow.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,81 @@ | ||
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 { | ||
CompoundBorrowContractPositionFetcher, | ||
CompoundBorrowTokenDataProps, | ||
GetMarketsParams, | ||
} from '~apps/compound/common/compound.borrow.contract-position-fetcher'; | ||
import { | ||
GetDataPropsParams, | ||
GetTokenBalancesParams, | ||
GetTokenDefinitionsParams, | ||
} from '~position/template/contract-position.template.types'; | ||
|
||
import { BastionProtocolComptroller, BastionProtocolContractFactory, BastionProtocolCtoken } from '../contracts'; | ||
|
||
@PositionTemplate() | ||
export class AuroraBastionProtocolAuroraEcosystemBorrowContractPositionFetcher extends CompoundBorrowContractPositionFetcher< | ||
BastionProtocolCtoken, | ||
BastionProtocolComptroller | ||
> { | ||
groupLabel = 'Aurora Ecosystem Realm'; | ||
comptrollerAddress = '0xe1cf09bda2e089c63330f0ffe3f6d6b790835973'; | ||
|
||
constructor( | ||
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, | ||
@Inject(BastionProtocolContractFactory) protected readonly contractFactory: BastionProtocolContractFactory, | ||
) { | ||
super(appToolkit); | ||
} | ||
|
||
getCompoundCTokenContract(address: string) { | ||
return this.contractFactory.bastionProtocolCtoken({ address, network: this.network }); | ||
} | ||
|
||
getCompoundComptrollerContract(address: string) { | ||
return this.contractFactory.bastionProtocolComptroller({ address, network: this.network }); | ||
} | ||
|
||
async getMarkets({ contract }: GetMarketsParams<BastionProtocolComptroller>) { | ||
return contract.getAllMarkets(); | ||
} | ||
|
||
async getUnderlyingAddress({ contract }: GetTokenDefinitionsParams<BastionProtocolCtoken>) { | ||
return contract.underlying(); | ||
} | ||
|
||
async getExchangeRate({ contract }: GetDataPropsParams<BastionProtocolCtoken, CompoundBorrowTokenDataProps>) { | ||
return contract.callStatic.exchangeRateCurrent(); | ||
} | ||
|
||
async getExchangeRateMantissa(params: GetDataPropsParams<BastionProtocolCtoken, CompoundBorrowTokenDataProps>) { | ||
const [underlyingToken] = params.contractPosition.tokens; | ||
const auTokenDecimals = await this.getCTokenDecimals(params); | ||
return 18 + underlyingToken.decimals - auTokenDecimals; | ||
} | ||
|
||
async getBorrowRate({ contract }: GetDataPropsParams<BastionProtocolCtoken, CompoundBorrowTokenDataProps>) { | ||
return contract.callStatic.borrowRatePerBlock().catch(() => 0); | ||
} | ||
|
||
async getCash({ contract }: GetDataPropsParams<BastionProtocolCtoken, CompoundBorrowTokenDataProps>) { | ||
return contract.getCash(); | ||
} | ||
|
||
async getCTokenSupply({ contract }: GetDataPropsParams<BastionProtocolCtoken, CompoundBorrowTokenDataProps>) { | ||
return contract.totalSupply(); | ||
} | ||
|
||
async getCTokenDecimals({ contract }: GetDataPropsParams<BastionProtocolCtoken, CompoundBorrowTokenDataProps>) { | ||
return contract.decimals(); | ||
} | ||
|
||
async getBorrowBalance({ | ||
address, | ||
contract, | ||
}: GetTokenBalancesParams<BastionProtocolCtoken, CompoundBorrowTokenDataProps>) { | ||
return contract.callStatic.borrowBalanceCurrent(address); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/apps/bastion-protocol/aurora/bastion-protocol.aurora-ecosystem-supply.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,52 @@ | ||
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 { CompoundSupplyTokenFetcher, GetMarketsParams } from '~apps/compound/common/compound.supply.token-fetcher'; | ||
import { | ||
GetUnderlyingTokensParams, | ||
GetPricePerShareParams, | ||
GetDataPropsParams, | ||
} from '~position/template/app-token.template.types'; | ||
|
||
import { BastionProtocolComptroller, BastionProtocolContractFactory, BastionProtocolCtoken } from '../contracts'; | ||
|
||
@PositionTemplate() | ||
export class AuroraBastionProtocolAuroraEcosystemSupplyTokenFetcher extends CompoundSupplyTokenFetcher< | ||
BastionProtocolCtoken, | ||
BastionProtocolComptroller | ||
> { | ||
groupLabel = 'Aurora Ecosystem Realm'; | ||
comptrollerAddress = '0xe1cf09bda2e089c63330f0ffe3f6d6b790835973'; | ||
|
||
constructor( | ||
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, | ||
@Inject(BastionProtocolContractFactory) protected readonly contractFactory: BastionProtocolContractFactory, | ||
) { | ||
super(appToolkit); | ||
} | ||
|
||
getCompoundCTokenContract(address: string): BastionProtocolCtoken { | ||
return this.contractFactory.bastionProtocolCtoken({ address, network: this.network }); | ||
} | ||
|
||
getCompoundComptrollerContract(address: string) { | ||
return this.contractFactory.bastionProtocolComptroller({ address, network: this.network }); | ||
} | ||
|
||
async getMarkets({ contract }: GetMarketsParams<BastionProtocolComptroller>) { | ||
return contract.getAllMarkets(); | ||
} | ||
|
||
async getUnderlyingAddress({ contract }: GetUnderlyingTokensParams<BastionProtocolCtoken>) { | ||
return contract.underlying(); | ||
} | ||
|
||
async getExchangeRate({ contract }: GetPricePerShareParams<BastionProtocolCtoken>) { | ||
return contract.callStatic.exchangeRateCurrent(); | ||
} | ||
|
||
async getSupplyRate({ contract }: GetDataPropsParams<BastionProtocolCtoken>) { | ||
return contract.supplyRatePerBlock(); | ||
} | ||
} |
153 changes: 0 additions & 153 deletions
153
src/apps/bastion-protocol/aurora/bastion-protocol.balance-fetcher.ts
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...ion-protocol/aurora/bastion-protocol.borrow-aurora-ecosystem.contract-position-fetcher.ts
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
...pps/bastion-protocol/aurora/bastion-protocol.borrow-main-hub.contract-position-fetcher.ts
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
...s/bastion-protocol/aurora/bastion-protocol.borrow-multichain.contract-position-fetcher.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.