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

Commit

Permalink
feat(thales): vaults (#2190)
Browse files Browse the repository at this point in the history
Co-authored-by: gaulois <[email protected]>
Co-authored-by: William Poulin <[email protected]>
  • Loading branch information
3 people authored Jan 26, 2023
1 parent 7c95fa7 commit 2f5510f
Show file tree
Hide file tree
Showing 8 changed files with 5,200 additions and 14 deletions.
1,358 changes: 1,358 additions & 0 deletions src/apps/thales/contracts/abis/vaults.json

Large diffs are not rendered by default.

2,378 changes: 2,378 additions & 0 deletions src/apps/thales/contracts/ethers/Vaults.ts

Large diffs are not rendered by default.

1,376 changes: 1,376 additions & 0 deletions src/apps/thales/contracts/ethers/factories/Vaults__factory.ts

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/apps/thales/contracts/ethers/factories/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { EscrowThales__factory } from './EscrowThales__factory';
export { LpStaking__factory } from './LpStaking__factory';
export { StakingThales__factory } from './StakingThales__factory';
export { EscrowThales__factory } from "./EscrowThales__factory";
export { LpStaking__factory } from "./LpStaking__factory";
export { StakingThales__factory } from "./StakingThales__factory";
export { Vaults__factory } from "./Vaults__factory";
16 changes: 9 additions & 7 deletions src/apps/thales/contracts/ethers/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { EscrowThales } from './EscrowThales';
export type { LpStaking } from './LpStaking';
export type { StakingThales } from './StakingThales';
export * as factories from './factories';
export { EscrowThales__factory } from './factories/EscrowThales__factory';
export { LpStaking__factory } from './factories/LpStaking__factory';
export { StakingThales__factory } from './factories/StakingThales__factory';
export type { EscrowThales } from "./EscrowThales";
export type { LpStaking } from "./LpStaking";
export type { StakingThales } from "./StakingThales";
export type { Vaults } from "./Vaults";
export * as factories from "./factories";
export { EscrowThales__factory } from "./factories/EscrowThales__factory";
export { LpStaking__factory } from "./factories/LpStaking__factory";
export { StakingThales__factory } from "./factories/StakingThales__factory";
export { Vaults__factory } from "./factories/Vaults__factory";
8 changes: 5 additions & 3 deletions src/apps/thales/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { ContractFactory } from '~contract/contracts';
import { Network } from '~types/network.interface';

import { EscrowThales__factory } from './ethers';
import { LpStaking__factory } from './ethers';
import { StakingThales__factory } from './ethers';
import { EscrowThales__factory, LpStaking__factory, StakingThales__factory, Vaults__factory } from './ethers';

// eslint-disable-next-line
type ContractOpts = { address: string; network: Network };
Expand All @@ -26,8 +24,12 @@ export class ThalesContractFactory extends ContractFactory {
stakingThales({ address, network }: ContractOpts) {
return StakingThales__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
vaults({ address, network }: ContractOpts) {
return Vaults__factory.connect(address, this.appToolkit.getNetworkProvider(network));
}
}

export type { EscrowThales } from './ethers';
export type { LpStaking } from './ethers';
export type { StakingThales } from './ethers';
export type { Vaults } from './ethers';
67 changes: 67 additions & 0 deletions src/apps/thales/optimism/thales.vault.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Inject } from '@nestjs/common';
import { BigNumberish } from 'ethers';
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { MetaType } from '~position/position.interface';
import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher';
import { GetDisplayPropsParams, GetTokenBalancesParams } from '~position/template/contract-position.template.types';

import { Vaults, ThalesContractFactory } from '../contracts';


let vaultAddressToName = new Map<string, string>([
['0xb484027cb0c538538bad2be492714154f9196f93', 'Thales Discount'],
['0x43318de9e8f65b591598f17add87ae7247649c83', 'Thales Degen Discount'],
['0x6c7fd4321183b542e81bcc7de4dfb88f9dbca29f', 'Thales Safu Discount'],
['0xc922f4cde42dd658a7d3ea852caf7eae47f6cecd', 'Overtime Discount'],
['0xbaac5464bf6e767c9af0e8d4677c01be2065fd5f', 'Overtime Degen Discount'],
['0x43d19841d818b2ccc63a8b44ce8c7def8616d98e', 'Overtime Safu Discount'],
]);

@PositionTemplate()
export class OptimismThalesVaultContractPositionFetcher extends ContractPositionTemplatePositionFetcher<Vaults> {
groupLabel = 'Vault';

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

getContract(address: string): Vaults {
return this.contractFactory.vaults({ network: this.network, address });
}

async getDefinitions() {
let definitions = new Array;
for (let vaultAddress of vaultAddressToName.keys()) {
definitions.push({ address: vaultAddress })
}
return definitions;
}

async getTokenDefinitions() {
return [
{
address: '0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9', // sUSD
metaType: MetaType.SUPPLIED,
network: this.network,
},
];
}

async getLabel({ contractPosition }: GetDisplayPropsParams<Vaults>) {
return `${vaultAddressToName.get(contractPosition.address)} Vault`;
}

async getTokenBalancesPerPosition({
address,
contract,
}: GetTokenBalancesParams<Vaults>): Promise<BigNumberish[]> {
const currentRound = await contract.round();
const currentBalance = await contract.getBalancesPerRound(Number(currentRound), address);
const pendingdeposit = await contract.getBalancesPerRound(Number(currentRound) + 1, address);
return [Number(currentBalance) + Number(pendingdeposit)];
}
}
4 changes: 3 additions & 1 deletion src/apps/thales/thales.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { ThalesContractFactory } from './contracts';
import { OptimismThalesEscrowContractPositionFetcher } from './optimism/thales.escrow.contract-position-fetcher';
import { OptimismThalesPool2ContractPositionFetcher } from './optimism/thales.pool2.contract-position-fetcher';
import { OptimismThalesStakingContractPositionFetcher } from './optimism/thales.staking.contract-position-fetcher';
import { OptimismThalesVaultContractPositionFetcher } from './optimism/thales.vault.contract-position-fetcher';

@Module({
providers: [
ThalesContractFactory,
OptimismThalesStakingContractPositionFetcher,
OptimismThalesEscrowContractPositionFetcher,
OptimismThalesPool2ContractPositionFetcher,
OptimismThalesVaultContractPositionFetcher,
],
})
export class ThalesAppModule extends AbstractApp() {}
export class ThalesAppModule extends AbstractApp() { }

0 comments on commit 2f5510f

Please sign in to comment.