diff --git a/cli/commands/create-app.ts b/cli/commands/create-app.ts index 106f52958..0334bd48b 100644 --- a/cli/commands/create-app.ts +++ b/cli/commands/create-app.ts @@ -36,6 +36,7 @@ export default class CreateApp extends Command { ], }, ]); + const supportedNetworksRaw: string[] = response.network; createFolder(`./src/apps/${appName}`); createFolder(`./src/apps/${appName}/assets`); @@ -89,7 +90,7 @@ function formatNetworks(userInputNetworks: string[]): string[] { } function generateDefinitionFile(appName: string, supportedNetworks: string) { - const appId = strings.kebabCase(appName); + const appId = strings.titleCase(appName, true); const appDefinitionName = `${strings.upperCase(appName)}_DEFINITION`; const appClassName = strings.titleCase(appName); @@ -102,6 +103,7 @@ function generateDefinitionFile(appName: string, supportedNetworks: string) { export const ${appDefinitionName} = { id: '${appName}', name: '${appId}', + // Don't forget to add a description for the app description: '', groups: { camelCase: { id: 'kebab-case', type: GroupType.TOKEN }, diff --git a/cli/imports/apps-definition-registry.ts b/cli/imports/apps-definition-registry.ts index 8c31a4313..44def4cf4 100644 --- a/cli/imports/apps-definition-registry.ts +++ b/cli/imports/apps-definition-registry.ts @@ -1,3 +1,4 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable unused-imports/no-unused-imports-ts */ export { default as UNAGII_DEFINITION } from '../../src/apps/unagii/unagii.definition'; +export { default as ENZYME_FINANCE_DEFINITION } from '../../src/apps/enzyme-finance/enzyme-finance.definition'; diff --git a/cli/strings/strings.ts b/cli/strings/strings.ts index 8f8c4c86c..6936407c6 100644 --- a/cli/strings/strings.ts +++ b/cli/strings/strings.ts @@ -6,8 +6,9 @@ import _ from 'lodash'; * @param s given string * @returns TitleCased string */ -const titleCase = (s: string) => { - return _.startCase(s).replace(/\s/g, ''); +const titleCase = (s: string, spaceSeparator = false) => { + const separator = spaceSeparator === true ? ' ' : ''; + return _.startCase(s).replace(/\s/g, separator); }; /** diff --git a/src/apps/enzyme-finance/contracts/abis/enzyme-finance-vault.json b/src/apps/enzyme-finance/contracts/abis/enzyme-finance-vault.json new file mode 100644 index 000000000..7af291ca7 --- /dev/null +++ b/src/apps/enzyme-finance/contracts/abis/enzyme-finance-vault.json @@ -0,0 +1,328 @@ +[ + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "prevAccessor", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "nextAccessor", "type": "address" } + ], + "name": "AccessorSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "target", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "AssetWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "prevMigrator", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "nextMigrator", "type": "address" } + ], + "name": "MigratorSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "prevOwner", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "nextOwner", "type": "address" } + ], + "name": "OwnerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "asset", "type": "address" }], + "name": "TrackedAssetAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "asset", "type": "address" }], + "name": "TrackedAssetRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "prevVaultLib", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "nextVaultLib", "type": "address" } + ], + "name": "VaultLibSet", + "type": "event" + }, + { + "inputs": [{ "internalType": "address", "name": "_asset", "type": "address" }], + "name": "addTrackedAsset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "address", "name": "_spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_asset", "type": "address" }, + { "internalType": "address", "name": "_target", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "approveAssetSpender", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_account", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_target", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "burnShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_contract", "type": "address" }, + { "internalType": "bytes", "name": "_callData", "type": "bytes" } + ], + "name": "callOnContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_who", "type": "address" }], + "name": "canMigrate", + "outputs": [{ "internalType": "bool", "name": "canMigrate_", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getAccessor", + "outputs": [{ "internalType": "address", "name": "accessor_", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCreator", + "outputs": [{ "internalType": "address", "name": "creator_", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMigrator", + "outputs": [{ "internalType": "address", "name": "migrator_", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOwner", + "outputs": [{ "internalType": "address", "name": "owner_", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTrackedAssets", + "outputs": [{ "internalType": "address[]", "name": "trackedAssets_", "type": "address[]" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVaultLib", + "outputs": [{ "internalType": "address", "name": "vaultLib_", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "address", "name": "_accessor", "type": "address" }, + { "internalType": "string", "name": "_fundName", "type": "string" } + ], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_asset", "type": "address" }], + "name": "isTrackedAsset", + "outputs": [{ "internalType": "bool", "name": "isTrackedAsset_", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_target", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "mintShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [{ "internalType": "bytes32", "name": "uuid_", "type": "bytes32" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_asset", "type": "address" }], + "name": "removeTrackedAsset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_nextAccessor", "type": "address" }], + "name": "setAccessor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_nextMigrator", "type": "address" }], + "name": "setMigrator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_nextVaultLib", "type": "address" }], + "name": "setVaultLib", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "symbol_", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "transferShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_asset", "type": "address" }, + { "internalType": "address", "name": "_target", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "withdrawAssetTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/apps/enzyme-finance/contracts/ethers/EnzymeFinanceVault.ts b/src/apps/enzyme-finance/contracts/ethers/EnzymeFinanceVault.ts new file mode 100644 index 000000000..cf5d3d5fe --- /dev/null +++ b/src/apps/enzyme-finance/contracts/ethers/EnzymeFinanceVault.ts @@ -0,0 +1,842 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface EnzymeFinanceVaultInterface extends utils.Interface { + functions: { + 'addTrackedAsset(address)': FunctionFragment; + 'allowance(address,address)': FunctionFragment; + 'approve(address,uint256)': FunctionFragment; + 'approveAssetSpender(address,address,uint256)': FunctionFragment; + 'balanceOf(address)': FunctionFragment; + 'burnShares(address,uint256)': FunctionFragment; + 'callOnContract(address,bytes)': FunctionFragment; + 'canMigrate(address)': FunctionFragment; + 'decimals()': FunctionFragment; + 'getAccessor()': FunctionFragment; + 'getCreator()': FunctionFragment; + 'getMigrator()': FunctionFragment; + 'getOwner()': FunctionFragment; + 'getTrackedAssets()': FunctionFragment; + 'getVaultLib()': FunctionFragment; + 'init(address,address,string)': FunctionFragment; + 'isTrackedAsset(address)': FunctionFragment; + 'mintShares(address,uint256)': FunctionFragment; + 'name()': FunctionFragment; + 'proxiableUUID()': FunctionFragment; + 'removeTrackedAsset(address)': FunctionFragment; + 'setAccessor(address)': FunctionFragment; + 'setMigrator(address)': FunctionFragment; + 'setVaultLib(address)': FunctionFragment; + 'symbol()': FunctionFragment; + 'totalSupply()': FunctionFragment; + 'transfer(address,uint256)': FunctionFragment; + 'transferFrom(address,address,uint256)': FunctionFragment; + 'transferShares(address,address,uint256)': FunctionFragment; + 'withdrawAssetTo(address,address,uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'addTrackedAsset' + | 'allowance' + | 'approve' + | 'approveAssetSpender' + | 'balanceOf' + | 'burnShares' + | 'callOnContract' + | 'canMigrate' + | 'decimals' + | 'getAccessor' + | 'getCreator' + | 'getMigrator' + | 'getOwner' + | 'getTrackedAssets' + | 'getVaultLib' + | 'init' + | 'isTrackedAsset' + | 'mintShares' + | 'name' + | 'proxiableUUID' + | 'removeTrackedAsset' + | 'setAccessor' + | 'setMigrator' + | 'setVaultLib' + | 'symbol' + | 'totalSupply' + | 'transfer' + | 'transferFrom' + | 'transferShares' + | 'withdrawAssetTo', + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'addTrackedAsset', values: [string]): string; + encodeFunctionData(functionFragment: 'allowance', values: [string, string]): string; + encodeFunctionData(functionFragment: 'approve', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'approveAssetSpender', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'balanceOf', values: [string]): string; + encodeFunctionData(functionFragment: 'burnShares', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'callOnContract', values: [string, BytesLike]): string; + encodeFunctionData(functionFragment: 'canMigrate', values: [string]): string; + encodeFunctionData(functionFragment: 'decimals', values?: undefined): string; + encodeFunctionData(functionFragment: 'getAccessor', values?: undefined): string; + encodeFunctionData(functionFragment: 'getCreator', values?: undefined): string; + encodeFunctionData(functionFragment: 'getMigrator', values?: undefined): string; + encodeFunctionData(functionFragment: 'getOwner', values?: undefined): string; + encodeFunctionData(functionFragment: 'getTrackedAssets', values?: undefined): string; + encodeFunctionData(functionFragment: 'getVaultLib', values?: undefined): string; + encodeFunctionData(functionFragment: 'init', values: [string, string, string]): string; + encodeFunctionData(functionFragment: 'isTrackedAsset', values: [string]): string; + encodeFunctionData(functionFragment: 'mintShares', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'name', values?: undefined): string; + encodeFunctionData(functionFragment: 'proxiableUUID', values?: undefined): string; + encodeFunctionData(functionFragment: 'removeTrackedAsset', values: [string]): string; + encodeFunctionData(functionFragment: 'setAccessor', values: [string]): string; + encodeFunctionData(functionFragment: 'setMigrator', values: [string]): string; + encodeFunctionData(functionFragment: 'setVaultLib', values: [string]): string; + encodeFunctionData(functionFragment: 'symbol', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalSupply', values?: undefined): string; + encodeFunctionData(functionFragment: 'transfer', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferFrom', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferShares', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'withdrawAssetTo', values: [string, string, BigNumberish]): string; + + decodeFunctionResult(functionFragment: 'addTrackedAsset', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'allowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approveAssetSpender', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'balanceOf', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'burnShares', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'callOnContract', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'canMigrate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decimals', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getAccessor', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getCreator', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getMigrator', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getOwner', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getTrackedAssets', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getVaultLib', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'init', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'isTrackedAsset', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'mintShares', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'name', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'proxiableUUID', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'removeTrackedAsset', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setAccessor', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setMigrator', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setVaultLib', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'symbol', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transfer', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferFrom', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferShares', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdrawAssetTo', data: BytesLike): Result; + + events: { + 'AccessorSet(address,address)': EventFragment; + 'Approval(address,address,uint256)': EventFragment; + 'AssetWithdrawn(address,address,uint256)': EventFragment; + 'MigratorSet(address,address)': EventFragment; + 'OwnerSet(address,address)': EventFragment; + 'TrackedAssetAdded(address)': EventFragment; + 'TrackedAssetRemoved(address)': EventFragment; + 'Transfer(address,address,uint256)': EventFragment; + 'VaultLibSet(address,address)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'AccessorSet'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Approval'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'AssetWithdrawn'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'MigratorSet'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'OwnerSet'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'TrackedAssetAdded'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'TrackedAssetRemoved'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Transfer'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'VaultLibSet'): EventFragment; +} + +export interface AccessorSetEventObject { + prevAccessor: string; + nextAccessor: string; +} +export type AccessorSetEvent = TypedEvent<[string, string], AccessorSetEventObject>; + +export type AccessorSetEventFilter = TypedEventFilter; + +export interface ApprovalEventObject { + owner: string; + spender: string; + value: BigNumber; +} +export type ApprovalEvent = TypedEvent<[string, string, BigNumber], ApprovalEventObject>; + +export type ApprovalEventFilter = TypedEventFilter; + +export interface AssetWithdrawnEventObject { + asset: string; + target: string; + amount: BigNumber; +} +export type AssetWithdrawnEvent = TypedEvent<[string, string, BigNumber], AssetWithdrawnEventObject>; + +export type AssetWithdrawnEventFilter = TypedEventFilter; + +export interface MigratorSetEventObject { + prevMigrator: string; + nextMigrator: string; +} +export type MigratorSetEvent = TypedEvent<[string, string], MigratorSetEventObject>; + +export type MigratorSetEventFilter = TypedEventFilter; + +export interface OwnerSetEventObject { + prevOwner: string; + nextOwner: string; +} +export type OwnerSetEvent = TypedEvent<[string, string], OwnerSetEventObject>; + +export type OwnerSetEventFilter = TypedEventFilter; + +export interface TrackedAssetAddedEventObject { + asset: string; +} +export type TrackedAssetAddedEvent = TypedEvent<[string], TrackedAssetAddedEventObject>; + +export type TrackedAssetAddedEventFilter = TypedEventFilter; + +export interface TrackedAssetRemovedEventObject { + asset: string; +} +export type TrackedAssetRemovedEvent = TypedEvent<[string], TrackedAssetRemovedEventObject>; + +export type TrackedAssetRemovedEventFilter = TypedEventFilter; + +export interface TransferEventObject { + from: string; + to: string; + value: BigNumber; +} +export type TransferEvent = TypedEvent<[string, string, BigNumber], TransferEventObject>; + +export type TransferEventFilter = TypedEventFilter; + +export interface VaultLibSetEventObject { + prevVaultLib: string; + nextVaultLib: string; +} +export type VaultLibSetEvent = TypedEvent<[string, string], VaultLibSetEventObject>; + +export type VaultLibSetEventFilter = TypedEventFilter; + +export interface EnzymeFinanceVault extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: EnzymeFinanceVaultInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined, + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + addTrackedAsset( + _asset: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + allowance(_owner: string, _spender: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + approve( + arg0: string, + arg1: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + approveAssetSpender( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + balanceOf(_account: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + burnShares( + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + callOnContract( + _contract: string, + _callData: BytesLike, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + canMigrate(_who: string, overrides?: CallOverrides): Promise<[boolean] & { canMigrate_: boolean }>; + + decimals(overrides?: CallOverrides): Promise<[number]>; + + getAccessor(overrides?: CallOverrides): Promise<[string] & { accessor_: string }>; + + getCreator(overrides?: CallOverrides): Promise<[string] & { creator_: string }>; + + getMigrator(overrides?: CallOverrides): Promise<[string] & { migrator_: string }>; + + getOwner(overrides?: CallOverrides): Promise<[string] & { owner_: string }>; + + getTrackedAssets(overrides?: CallOverrides): Promise<[string[]] & { trackedAssets_: string[] }>; + + getVaultLib(overrides?: CallOverrides): Promise<[string] & { vaultLib_: string }>; + + init( + _owner: string, + _accessor: string, + _fundName: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + isTrackedAsset(_asset: string, overrides?: CallOverrides): Promise<[boolean] & { isTrackedAsset_: boolean }>; + + mintShares( + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + name(overrides?: CallOverrides): Promise<[string]>; + + proxiableUUID(overrides?: CallOverrides): Promise<[string] & { uuid_: string }>; + + removeTrackedAsset( + _asset: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setAccessor( + _nextAccessor: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setMigrator( + _nextMigrator: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setVaultLib( + _nextVaultLib: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + symbol(overrides?: CallOverrides): Promise<[string] & { symbol_: string }>; + + totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + transfer( + arg0: string, + arg1: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + arg0: string, + arg1: string, + arg2: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferShares( + _from: string, + _to: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + withdrawAssetTo( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + }; + + addTrackedAsset( + _asset: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + allowance(_owner: string, _spender: string, overrides?: CallOverrides): Promise; + + approve( + arg0: string, + arg1: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + approveAssetSpender( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + balanceOf(_account: string, overrides?: CallOverrides): Promise; + + burnShares( + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + callOnContract( + _contract: string, + _callData: BytesLike, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + canMigrate(_who: string, overrides?: CallOverrides): Promise; + + decimals(overrides?: CallOverrides): Promise; + + getAccessor(overrides?: CallOverrides): Promise; + + getCreator(overrides?: CallOverrides): Promise; + + getMigrator(overrides?: CallOverrides): Promise; + + getOwner(overrides?: CallOverrides): Promise; + + getTrackedAssets(overrides?: CallOverrides): Promise; + + getVaultLib(overrides?: CallOverrides): Promise; + + init( + _owner: string, + _accessor: string, + _fundName: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + isTrackedAsset(_asset: string, overrides?: CallOverrides): Promise; + + mintShares( + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + name(overrides?: CallOverrides): Promise; + + proxiableUUID(overrides?: CallOverrides): Promise; + + removeTrackedAsset( + _asset: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setAccessor( + _nextAccessor: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setMigrator( + _nextMigrator: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setVaultLib( + _nextVaultLib: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + arg0: string, + arg1: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + arg0: string, + arg1: string, + arg2: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferShares( + _from: string, + _to: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + withdrawAssetTo( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + callStatic: { + addTrackedAsset(_asset: string, overrides?: CallOverrides): Promise; + + allowance(_owner: string, _spender: string, overrides?: CallOverrides): Promise; + + approve(arg0: string, arg1: BigNumberish, overrides?: CallOverrides): Promise; + + approveAssetSpender( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + balanceOf(_account: string, overrides?: CallOverrides): Promise; + + burnShares(_target: string, _amount: BigNumberish, overrides?: CallOverrides): Promise; + + callOnContract(_contract: string, _callData: BytesLike, overrides?: CallOverrides): Promise; + + canMigrate(_who: string, overrides?: CallOverrides): Promise; + + decimals(overrides?: CallOverrides): Promise; + + getAccessor(overrides?: CallOverrides): Promise; + + getCreator(overrides?: CallOverrides): Promise; + + getMigrator(overrides?: CallOverrides): Promise; + + getOwner(overrides?: CallOverrides): Promise; + + getTrackedAssets(overrides?: CallOverrides): Promise; + + getVaultLib(overrides?: CallOverrides): Promise; + + init(_owner: string, _accessor: string, _fundName: string, overrides?: CallOverrides): Promise; + + isTrackedAsset(_asset: string, overrides?: CallOverrides): Promise; + + mintShares(_target: string, _amount: BigNumberish, overrides?: CallOverrides): Promise; + + name(overrides?: CallOverrides): Promise; + + proxiableUUID(overrides?: CallOverrides): Promise; + + removeTrackedAsset(_asset: string, overrides?: CallOverrides): Promise; + + setAccessor(_nextAccessor: string, overrides?: CallOverrides): Promise; + + setMigrator(_nextMigrator: string, overrides?: CallOverrides): Promise; + + setVaultLib(_nextVaultLib: string, overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(arg0: string, arg1: BigNumberish, overrides?: CallOverrides): Promise; + + transferFrom(arg0: string, arg1: string, arg2: BigNumberish, overrides?: CallOverrides): Promise; + + transferShares(_from: string, _to: string, _amount: BigNumberish, overrides?: CallOverrides): Promise; + + withdrawAssetTo(_asset: string, _target: string, _amount: BigNumberish, overrides?: CallOverrides): Promise; + }; + + filters: { + 'AccessorSet(address,address)'(prevAccessor?: null, nextAccessor?: null): AccessorSetEventFilter; + AccessorSet(prevAccessor?: null, nextAccessor?: null): AccessorSetEventFilter; + + 'Approval(address,address,uint256)'( + owner?: string | null, + spender?: string | null, + value?: null, + ): ApprovalEventFilter; + Approval(owner?: string | null, spender?: string | null, value?: null): ApprovalEventFilter; + + 'AssetWithdrawn(address,address,uint256)'( + asset?: string | null, + target?: string | null, + amount?: null, + ): AssetWithdrawnEventFilter; + AssetWithdrawn(asset?: string | null, target?: string | null, amount?: null): AssetWithdrawnEventFilter; + + 'MigratorSet(address,address)'(prevMigrator?: null, nextMigrator?: null): MigratorSetEventFilter; + MigratorSet(prevMigrator?: null, nextMigrator?: null): MigratorSetEventFilter; + + 'OwnerSet(address,address)'(prevOwner?: null, nextOwner?: null): OwnerSetEventFilter; + OwnerSet(prevOwner?: null, nextOwner?: null): OwnerSetEventFilter; + + 'TrackedAssetAdded(address)'(asset?: null): TrackedAssetAddedEventFilter; + TrackedAssetAdded(asset?: null): TrackedAssetAddedEventFilter; + + 'TrackedAssetRemoved(address)'(asset?: null): TrackedAssetRemovedEventFilter; + TrackedAssetRemoved(asset?: null): TrackedAssetRemovedEventFilter; + + 'Transfer(address,address,uint256)'(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + Transfer(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + + 'VaultLibSet(address,address)'(prevVaultLib?: null, nextVaultLib?: null): VaultLibSetEventFilter; + VaultLibSet(prevVaultLib?: null, nextVaultLib?: null): VaultLibSetEventFilter; + }; + + estimateGas: { + addTrackedAsset(_asset: string, overrides?: Overrides & { from?: string | Promise }): Promise; + + allowance(_owner: string, _spender: string, overrides?: CallOverrides): Promise; + + approve( + arg0: string, + arg1: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + approveAssetSpender( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + balanceOf(_account: string, overrides?: CallOverrides): Promise; + + burnShares( + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + callOnContract( + _contract: string, + _callData: BytesLike, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + canMigrate(_who: string, overrides?: CallOverrides): Promise; + + decimals(overrides?: CallOverrides): Promise; + + getAccessor(overrides?: CallOverrides): Promise; + + getCreator(overrides?: CallOverrides): Promise; + + getMigrator(overrides?: CallOverrides): Promise; + + getOwner(overrides?: CallOverrides): Promise; + + getTrackedAssets(overrides?: CallOverrides): Promise; + + getVaultLib(overrides?: CallOverrides): Promise; + + init( + _owner: string, + _accessor: string, + _fundName: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + isTrackedAsset(_asset: string, overrides?: CallOverrides): Promise; + + mintShares( + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + name(overrides?: CallOverrides): Promise; + + proxiableUUID(overrides?: CallOverrides): Promise; + + removeTrackedAsset(_asset: string, overrides?: Overrides & { from?: string | Promise }): Promise; + + setAccessor(_nextAccessor: string, overrides?: Overrides & { from?: string | Promise }): Promise; + + setMigrator(_nextMigrator: string, overrides?: Overrides & { from?: string | Promise }): Promise; + + setVaultLib(_nextVaultLib: string, overrides?: Overrides & { from?: string | Promise }): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + arg0: string, + arg1: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + arg0: string, + arg1: string, + arg2: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferShares( + _from: string, + _to: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + withdrawAssetTo( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + }; + + populateTransaction: { + addTrackedAsset( + _asset: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + allowance(_owner: string, _spender: string, overrides?: CallOverrides): Promise; + + approve( + arg0: string, + arg1: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + approveAssetSpender( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + balanceOf(_account: string, overrides?: CallOverrides): Promise; + + burnShares( + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + callOnContract( + _contract: string, + _callData: BytesLike, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + canMigrate(_who: string, overrides?: CallOverrides): Promise; + + decimals(overrides?: CallOverrides): Promise; + + getAccessor(overrides?: CallOverrides): Promise; + + getCreator(overrides?: CallOverrides): Promise; + + getMigrator(overrides?: CallOverrides): Promise; + + getOwner(overrides?: CallOverrides): Promise; + + getTrackedAssets(overrides?: CallOverrides): Promise; + + getVaultLib(overrides?: CallOverrides): Promise; + + init( + _owner: string, + _accessor: string, + _fundName: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + isTrackedAsset(_asset: string, overrides?: CallOverrides): Promise; + + mintShares( + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + name(overrides?: CallOverrides): Promise; + + proxiableUUID(overrides?: CallOverrides): Promise; + + removeTrackedAsset( + _asset: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setAccessor( + _nextAccessor: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setMigrator( + _nextMigrator: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setVaultLib( + _nextVaultLib: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + arg0: string, + arg1: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + arg0: string, + arg1: string, + arg2: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferShares( + _from: string, + _to: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + withdrawAssetTo( + _asset: string, + _target: string, + _amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + }; +} diff --git a/src/apps/enzyme-finance/contracts/ethers/common.ts b/src/apps/enzyme-finance/contracts/ethers/common.ts new file mode 100644 index 000000000..6cfb10425 --- /dev/null +++ b/src/apps/enzyme-finance/contracts/ethers/common.ts @@ -0,0 +1,30 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { Listener } from '@ethersproject/providers'; +import type { Event, EventFilter } from 'ethers'; + +export interface TypedEvent = any, TArgsObject = any> extends Event { + args: TArgsArray & TArgsObject; +} + +export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} + +export interface TypedListener { + (...listenerArg: [...__TypechainArgsArray, TEvent]): void; +} + +type __TypechainArgsArray = T extends TypedEvent ? U : never; + +export interface OnEvent { + (eventFilter: TypedEventFilter, listener: TypedListener): TRes; + (eventName: string, listener: Listener): TRes; +} + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never; + +export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never; diff --git a/src/apps/enzyme-finance/contracts/ethers/factories/EnzymeFinanceVault__factory.ts b/src/apps/enzyme-finance/contracts/ethers/factories/EnzymeFinanceVault__factory.ts new file mode 100644 index 000000000..c454d1661 --- /dev/null +++ b/src/apps/enzyme-finance/contracts/ethers/factories/EnzymeFinanceVault__factory.ts @@ -0,0 +1,709 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { EnzymeFinanceVault, EnzymeFinanceVaultInterface } from '../EnzymeFinanceVault'; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'prevAccessor', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'nextAccessor', + type: 'address', + }, + ], + name: 'AccessorSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'target', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'AssetWithdrawn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'prevMigrator', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'nextMigrator', + type: 'address', + }, + ], + name: 'MigratorSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'prevOwner', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'nextOwner', + type: 'address', + }, + ], + name: 'OwnerSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'TrackedAssetAdded', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'TrackedAssetRemoved', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'prevVaultLib', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'nextVaultLib', + type: 'address', + }, + ], + name: 'VaultLibSet', + type: 'event', + }, + { + inputs: [ + { + internalType: 'address', + name: '_asset', + type: 'address', + }, + ], + name: 'addTrackedAsset', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_owner', + type: 'address', + }, + { + internalType: 'address', + name: '_spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_asset', + type: 'address', + }, + { + internalType: 'address', + name: '_target', + type: 'address', + }, + { + internalType: 'uint256', + name: '_amount', + type: 'uint256', + }, + ], + name: 'approveAssetSpender', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_account', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_target', + type: 'address', + }, + { + internalType: 'uint256', + name: '_amount', + type: 'uint256', + }, + ], + name: 'burnShares', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_contract', + type: 'address', + }, + { + internalType: 'bytes', + name: '_callData', + type: 'bytes', + }, + ], + name: 'callOnContract', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_who', + type: 'address', + }, + ], + name: 'canMigrate', + outputs: [ + { + internalType: 'bool', + name: 'canMigrate_', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'getAccessor', + outputs: [ + { + internalType: 'address', + name: 'accessor_', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getCreator', + outputs: [ + { + internalType: 'address', + name: 'creator_', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getMigrator', + outputs: [ + { + internalType: 'address', + name: 'migrator_', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getOwner', + outputs: [ + { + internalType: 'address', + name: 'owner_', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getTrackedAssets', + outputs: [ + { + internalType: 'address[]', + name: 'trackedAssets_', + type: 'address[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getVaultLib', + outputs: [ + { + internalType: 'address', + name: 'vaultLib_', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_owner', + type: 'address', + }, + { + internalType: 'address', + name: '_accessor', + type: 'address', + }, + { + internalType: 'string', + name: '_fundName', + type: 'string', + }, + ], + name: 'init', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_asset', + type: 'address', + }, + ], + name: 'isTrackedAsset', + outputs: [ + { + internalType: 'bool', + name: 'isTrackedAsset_', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_target', + type: 'address', + }, + { + internalType: 'uint256', + name: '_amount', + type: 'uint256', + }, + ], + name: 'mintShares', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'proxiableUUID', + outputs: [ + { + internalType: 'bytes32', + name: 'uuid_', + type: 'bytes32', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_asset', + type: 'address', + }, + ], + name: 'removeTrackedAsset', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_nextAccessor', + type: 'address', + }, + ], + name: 'setAccessor', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_nextMigrator', + type: 'address', + }, + ], + name: 'setMigrator', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_nextVaultLib', + type: 'address', + }, + ], + name: 'setVaultLib', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: 'symbol_', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_from', + type: 'address', + }, + { + internalType: 'address', + name: '_to', + type: 'address', + }, + { + internalType: 'uint256', + name: '_amount', + type: 'uint256', + }, + ], + name: 'transferShares', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_asset', + type: 'address', + }, + { + internalType: 'address', + name: '_target', + type: 'address', + }, + { + internalType: 'uint256', + name: '_amount', + type: 'uint256', + }, + ], + name: 'withdrawAssetTo', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +]; + +export class EnzymeFinanceVault__factory { + static readonly abi = _abi; + static createInterface(): EnzymeFinanceVaultInterface { + return new utils.Interface(_abi) as EnzymeFinanceVaultInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): EnzymeFinanceVault { + return new Contract(address, _abi, signerOrProvider) as EnzymeFinanceVault; + } +} diff --git a/src/apps/enzyme-finance/contracts/ethers/factories/index.ts b/src/apps/enzyme-finance/contracts/ethers/factories/index.ts new file mode 100644 index 000000000..7ef727776 --- /dev/null +++ b/src/apps/enzyme-finance/contracts/ethers/factories/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { EnzymeFinanceVault__factory } from './EnzymeFinanceVault__factory'; diff --git a/src/apps/enzyme-finance/contracts/ethers/index.ts b/src/apps/enzyme-finance/contracts/ethers/index.ts new file mode 100644 index 000000000..c0f750150 --- /dev/null +++ b/src/apps/enzyme-finance/contracts/ethers/index.ts @@ -0,0 +1,6 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { EnzymeFinanceVault } from './EnzymeFinanceVault'; +export * as factories from './factories'; +export { EnzymeFinanceVault__factory } from './factories/EnzymeFinanceVault__factory'; diff --git a/src/apps/enzyme-finance/contracts/index.ts b/src/apps/enzyme-finance/contracts/index.ts new file mode 100644 index 000000000..d82b782c8 --- /dev/null +++ b/src/apps/enzyme-finance/contracts/index.ts @@ -0,0 +1,22 @@ +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 { EnzymeFinanceVault__factory } from './ethers'; + +type ContractOpts = { address: string; network: Network }; + +@Injectable() +export class EnzymeFinanceContractFactory extends ContractFactory { + constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) { + super((network: Network) => appToolkit.getNetworkProvider(network)); + } + + enzymeFinanceVault({ address, network }: ContractOpts) { + return EnzymeFinanceVault__factory.connect(address, this.appToolkit.getNetworkProvider(network)); + } +} + +export type { EnzymeFinanceVault } from './ethers'; diff --git a/src/apps/enzyme-finance/enzyme-finance.definition.ts b/src/apps/enzyme-finance/enzyme-finance.definition.ts new file mode 100644 index 000000000..abdd35a53 --- /dev/null +++ b/src/apps/enzyme-finance/enzyme-finance.definition.ts @@ -0,0 +1,28 @@ +import { Register } from '~app-toolkit/decorators'; +import { AppDefinition } from '~app/app.definition'; +import { GroupType, ProtocolAction, ProtocolTag } from '~app/app.interface'; +import { Network } from '~types/network.interface'; + +export const ENZYME_FINANCE_DEFINITION = { + id: 'enzyme-finance', + name: 'Enzyme Finance', + description: 'Enzyme empowers you to build and scale vaults based on the investment strategies of your choice.', + groups: { + vault: { id: 'vault', type: GroupType.TOKEN }, + }, + url: 'https://enzyme.finance/', + tags: [ProtocolTag.ASSET_MANAGEMENT], + supportedNetworks: { + [Network.ETHEREUM_MAINNET]: [ProtocolAction.VIEW], + }, + primaryColor: '#8167e0', +}; + +@Register.AppDefinition(ENZYME_FINANCE_DEFINITION.id) +export class EnzymeFinanceAppDefinition extends AppDefinition { + constructor() { + super(ENZYME_FINANCE_DEFINITION); + } +} + +export default ENZYME_FINANCE_DEFINITION; diff --git a/src/apps/enzyme-finance/enzyme-finance.module.ts b/src/apps/enzyme-finance/enzyme-finance.module.ts new file mode 100644 index 000000000..cda7f0027 --- /dev/null +++ b/src/apps/enzyme-finance/enzyme-finance.module.ts @@ -0,0 +1,18 @@ +import { Module } from '@nestjs/common'; + +import { AbstractDynamicApp } from '~app/app.dynamic-module'; + +import { EnzymeFinanceContractFactory } from './contracts'; +import { EnzymeFinanceAppDefinition } from './enzyme-finance.definition'; +import { EthereumEnzymeFinanceBalanceFetcher } from './ethereum/enzyme-finance.balance-fetcher'; +import { EthereumEnzymeFinanceVaultTokenFetcher } from './ethereum/enzyme-finance.vault.token-fetcher'; + +@Module({ + providers: [ + EnzymeFinanceAppDefinition, + EnzymeFinanceContractFactory, + EthereumEnzymeFinanceBalanceFetcher, + EthereumEnzymeFinanceVaultTokenFetcher, + ], +}) +export class EnzymeFinanceAppModule extends AbstractDynamicApp() {} diff --git a/src/apps/enzyme-finance/ethereum/enzyme-finance.balance-fetcher.ts b/src/apps/enzyme-finance/ethereum/enzyme-finance.balance-fetcher.ts new file mode 100644 index 000000000..9fbebf8a0 --- /dev/null +++ b/src/apps/enzyme-finance/ethereum/enzyme-finance.balance-fetcher.ts @@ -0,0 +1,36 @@ +import { Inject } from '@nestjs/common'; + +import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; +import { Register } from '~app-toolkit/decorators'; +import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present'; +import { BalanceFetcher } from '~app/balance-fetcher.interface'; +import { Network } from '~types/network.interface'; + +import { ENZYME_FINANCE_DEFINITION } from '../enzyme-finance.definition'; + +const network = Network.ETHEREUM_MAINNET; + +@Register.BalanceFetcher(ENZYME_FINANCE_DEFINITION.id, network) +export class EthereumEnzymeFinanceBalanceFetcher implements BalanceFetcher { + constructor(@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit) {} + + private async getVaultTokenBalances(address: string) { + return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({ + network, + appId: ENZYME_FINANCE_DEFINITION.id, + groupId: ENZYME_FINANCE_DEFINITION.groups.vault.id, + address, + }); + } + + async getBalances(address: string) { + const [vaultTokenBalances] = await Promise.all([this.getVaultTokenBalances(address)]); + + return presentBalanceFetcherResponse([ + { + label: 'Vaults', + assets: vaultTokenBalances, + }, + ]); + } +} diff --git a/src/apps/enzyme-finance/ethereum/enzyme-finance.vault.token-fetcher.ts b/src/apps/enzyme-finance/ethereum/enzyme-finance.vault.token-fetcher.ts new file mode 100644 index 000000000..3b8d3ff99 --- /dev/null +++ b/src/apps/enzyme-finance/ethereum/enzyme-finance.vault.token-fetcher.ts @@ -0,0 +1,128 @@ +import { Inject } from '@nestjs/common'; +import { gql } from 'graphql-request'; +import _, { compact } from 'lodash'; + +import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; +import { Register } from '~app-toolkit/decorators'; +import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present'; +import { getAppImg } from '~app-toolkit/helpers/presentation/image.present'; +import { CacheOnInterval } from '~cache/cache-on-interval.decorator'; +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 { EnzymeFinanceContractFactory } from '../contracts'; +import { ENZYME_FINANCE_DEFINITION } from '../enzyme-finance.definition'; + +type EnzymeFinanceVaultsResponse = { + funds: { + id: string; + }[]; +}; + +const query = gql` + query fetchEnzymeVaults { + funds(first: 100, orderBy: investmentCount, orderDirection: desc) { + id + } + } +`; + +const appId = ENZYME_FINANCE_DEFINITION.id; +const groupId = ENZYME_FINANCE_DEFINITION.groups.vault.id; +const network = Network.ETHEREUM_MAINNET; + +@Register.TokenPositionFetcher({ appId, groupId, network }) +export class EthereumEnzymeFinanceVaultTokenFetcher implements PositionFetcher { + constructor( + @Inject(EnzymeFinanceContractFactory) private readonly enzymeFinanceContractFactory: EnzymeFinanceContractFactory, + @Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, + ) {} + + @CacheOnInterval({ + key: `studio:${appId}:${groupId}:${network}:addresses`, + timeout: 15 * 60 * 1000, + }) + async getCachedPoolAddresses() { + const endpoint = `https://api.thegraph.com/subgraphs/name/enzymefinance/enzyme`; + const data = await this.appToolkit.helpers.theGraphHelper.request({ endpoint, query }); + return data.funds.map(v => v); + } + + async getPositions() { + const multicall = this.appToolkit.getMulticall(network); + const baseTokens = await this.appToolkit.getBaseTokenPrices(network); + const poolAddresses = await this.getCachedPoolAddresses(); + + const tokens = await Promise.all( + poolAddresses.map(async vault => { + const vaultAddress = vault.id.toLowerCase(); + const tokenContract = this.enzymeFinanceContractFactory.enzymeFinanceVault({ address: vaultAddress, network }); + const [name, symbol, decimals, supplyRaw, trackedAssetAddresses] = await Promise.all([ + multicall.wrap(tokenContract).name(), + multicall.wrap(tokenContract).symbol(), + multicall.wrap(tokenContract).decimals(), + multicall.wrap(tokenContract).totalSupply(), + multicall.wrap(tokenContract).getTrackedAssets(), + ]); + + const totalAssetUnderManagement = _.sum( + await Promise.all( + trackedAssetAddresses.map(async tokenAddressRaw => { + const tokenAddress = tokenAddressRaw.toLowerCase(); + const uTokenContract = this.enzymeFinanceContractFactory.erc20({ address: tokenAddress, network }); + const [tokenAmountRaw, decimals] = await Promise.all([ + multicall.wrap(uTokenContract).balanceOf(vaultAddress), + multicall.wrap(uTokenContract).decimals(), + ]); + + const amount = Number(tokenAmountRaw) / 10 ** decimals; + const baseToken = baseTokens.find(v => v.address === tokenAddress); + if (!baseToken) return 0; + + return baseToken.price * amount; + }), + ), + ); + + const underlyingTokens = trackedAssetAddresses.map(token => { + return baseTokens.find(x => x.address === token.toLowerCase()); + }); + + const supply = Number(supplyRaw) / 10 ** decimals; + // filtering out vaults without depositors + if (supply === 0) return null; + const pricePerShare = 1; + const price = totalAssetUnderManagement / supply; + const tokens = compact(underlyingTokens); + + const label = name; + const secondaryLabel = buildDollarDisplayItem(price); + const images = [getAppImg(appId)]; + const dataProps = {}; + const displayProps = { label, secondaryLabel, images }; + + const token: AppTokenPosition = { + type: ContractType.APP_TOKEN, + address: vaultAddress, + appId, + groupId, + network, + symbol, + decimals, + supply, + price, + pricePerShare, + tokens, + dataProps, + displayProps, + }; + + return token; + }), + ); + + return compact(tokens); + } +}