diff --git a/packages/contract-helpers/src/token-wrapper/index.ts b/packages/contract-helpers/src/token-wrapper/index.ts new file mode 100644 index 00000000..ba1d59ef --- /dev/null +++ b/packages/contract-helpers/src/token-wrapper/index.ts @@ -0,0 +1,158 @@ +import { Signature, SignatureLike, splitSignature } from '@ethersproject/bytes'; +import { BigNumber, PopulatedTransaction, providers } from 'ethers'; +import BaseService from '../commons/BaseService'; +import { + BaseTokenWrapper, + BaseTokenWrapperInterface, + IBaseTokenWrapper, +} from './typechain/TokenWrapper'; +import { BaseTokenWrapper__factory } from './typechain/TokenWrapper_factory'; + +interface SupplyTokenWithPermitParams { + amount: string; + onBehalfOf: string; + referralCode: string; + deadline: string; + signature: SignatureLike; +} + +export interface TokenWrapperServiceInterface { + getTokenInForTokenOut: (amount: string) => Promise; + getTokenOutForTokenIn: (amount: string) => Promise; + supplyToken: ( + amount: string, + onBehalfOf: string, + referralCode: string, + ) => PopulatedTransaction; + supplyTokenWithPermit: ({ + amount, + onBehalfOf, + referralCode, + deadline, + signature, + }: SupplyTokenWithPermitParams) => PopulatedTransaction; + withdrawToken: (amount: string, user: string) => PopulatedTransaction; + withdrawTokenWithPermit: ( + amount: string, + user: string, + deadline: string, + signature: SignatureLike, + ) => PopulatedTransaction; +} + +export class TokenWrapperService + extends BaseService + implements TokenWrapperServiceInterface +{ + readonly tokenWrapperAddress: string; + readonly contractInterface: BaseTokenWrapperInterface; + + private readonly _contract: BaseTokenWrapper; + + constructor(provider: providers.Provider, tokenWrapperAddress: string) { + super(provider, BaseTokenWrapper__factory); + this.tokenWrapperAddress = tokenWrapperAddress; + this.contractInterface = BaseTokenWrapper__factory.createInterface(); + this._contract = BaseTokenWrapper__factory.connect( + tokenWrapperAddress, + provider, + ); + + this.getTokenInForTokenOut = this.getTokenInForTokenOut.bind(this); + this.getTokenOutForTokenIn = this.getTokenOutForTokenIn.bind(this); + this.supplyToken = this.supplyToken.bind(this); + this.supplyTokenWithPermit = this.supplyTokenWithPermit.bind(this); + this.withdrawToken = this.withdrawToken.bind(this); + this.withdrawTokenWithPermit = this.withdrawTokenWithPermit.bind(this); + } + + public async getTokenInForTokenOut(amount: string): Promise { + return this._contract.getTokenInForTokenOut(amount); + } + + public async getTokenOutForTokenIn(amount: string): Promise { + return this._contract.getTokenOutForTokenIn(amount); + } + + public supplyToken(amount: string, onBehalfOf: string, referralCode: string) { + const data = this.contractInterface.encodeFunctionData('supplyToken', [ + amount, + onBehalfOf, + referralCode, + ]); + + return { + to: this.tokenWrapperAddress, + from: onBehalfOf, + data, + }; + } + + public supplyTokenWithPermit({ + amount, + onBehalfOf, + referralCode, + deadline, + signature, + }: SupplyTokenWithPermitParams) { + const sig: Signature = splitSignature(signature); + + const permitStruct: IBaseTokenWrapper.PermitSignatureStruct = { + deadline, + v: sig.v, + r: sig.r, + s: sig.s, + }; + + const data = this.contractInterface.encodeFunctionData( + 'supplyTokenWithPermit', + [amount, onBehalfOf, referralCode, permitStruct], + ); + + return { + to: this.tokenWrapperAddress, + from: onBehalfOf, + data, + }; + } + + public withdrawToken(amount: string, user: string) { + const data = this.contractInterface.encodeFunctionData('withdrawToken', [ + amount, + user, + ]); + + return { + to: this.tokenWrapperAddress, + from: user, + data, + }; + } + + public withdrawTokenWithPermit( + amount: string, + user: string, + deadline: string, + signature: SignatureLike, + ) { + const sig: Signature = splitSignature(signature); + + const permitStruct: IBaseTokenWrapper.PermitSignatureStruct = { + deadline, + v: sig.v, + r: sig.r, + s: sig.s, + }; + + const data = this.contractInterface.encodeFunctionData( + 'withdrawTokenWithPermit', + [amount, user, permitStruct], + ); + + return { + to: this.tokenWrapperAddress, + from: user, + data, + }; + } +} diff --git a/packages/contract-helpers/src/token-wrapper/token-wrapper.test.ts b/packages/contract-helpers/src/token-wrapper/token-wrapper.test.ts new file mode 100644 index 00000000..5a73df95 --- /dev/null +++ b/packages/contract-helpers/src/token-wrapper/token-wrapper.test.ts @@ -0,0 +1,99 @@ +import { providers } from 'ethers'; +import { TokenWrapperService } from './index'; + +describe('SavingsDaiTokenWrapperService', () => { + const tokenWrapperAddress = '0x0000000000000000000000000000000000000001'; + const provider = new providers.JsonRpcProvider(); + describe('Initialization', () => { + it('should initialize SavingsDaiTokenWrapperService', () => { + expect( + () => new TokenWrapperService(provider, tokenWrapperAddress), + ).not.toThrow(); + }); + it('generates supply token tx', () => { + const onBehalfOf = '0x0000000000000000000000000000000000000004'; + const tokenWrapperService = new TokenWrapperService( + provider, + tokenWrapperAddress, + ); + const tx = tokenWrapperService.supplyToken( + '10000000000000000000', + onBehalfOf, + '0', + ); + expect(tx.to).toEqual(tokenWrapperAddress); + expect(tx.from).toEqual(onBehalfOf); + expect(tx.data).toEqual( + '0x1461e2160000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000', + ); + }); + it('generates supply with permit tx', () => { + const onBehalfOf = '0x0000000000000000000000000000000000000004'; + const tokenWrapperService = new TokenWrapperService( + provider, + tokenWrapperAddress, + ); + const tx = tokenWrapperService.supplyTokenWithPermit({ + amount: '10000000000000000000', + onBehalfOf, + referralCode: '0', + deadline: '10000', + signature: + '0x532f8df4e2502bd869fb35e9301156f9b307380afdcc25cfbc87b2e939f16f7e47c326dc26eb918d327358797ee67ad7415d871ef7eaf0d4f6352d3ad021fbb41c', + }); + expect(tx.to).toEqual(tokenWrapperAddress); + expect(tx.from).toEqual(onBehalfOf); + expect(tx.data).toEqual( + '0x4f4663a10000000000000000000000000000000000000000000000008ac7230489e80000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000000000001c532f8df4e2502bd869fb35e9301156f9b307380afdcc25cfbc87b2e939f16f7e47c326dc26eb918d327358797ee67ad7415d871ef7eaf0d4f6352d3ad021fbb4', + ); + }); + it('generates withdraw token tx', () => { + const user = '0x0000000000000000000000000000000000000004'; + const tokenWrapperService = new TokenWrapperService( + provider, + tokenWrapperAddress, + ); + const tx = tokenWrapperService.withdrawToken( + '10000000000000000000', + user, + ); + expect(tx.to).toEqual(tokenWrapperAddress); + expect(tx.from).toEqual(user); + expect(tx.data).toEqual( + '0xbe4b17720000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000000000000000000004', + ); + }); + it('generates withdraw token with permit tx', () => { + const user = '0x0000000000000000000000000000000000000004'; + const tokenWrapperService = new TokenWrapperService( + provider, + tokenWrapperAddress, + ); + const tx = tokenWrapperService.withdrawTokenWithPermit( + '10000000000000000000', + user, + '10000', + '0x532f8df4e2502bd869fb35e9301156f9b307380afdcc25cfbc87b2e939f16f7e47c326dc26eb918d327358797ee67ad7415d871ef7eaf0d4f6352d3ad021fbb41c', + ); + expect(tx.to).toEqual(tokenWrapperAddress); + expect(tx.from).toEqual(user); + expect(tx.data).toEqual( + '0xe94875ca0000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000000000001c532f8df4e2502bd869fb35e9301156f9b307380afdcc25cfbc87b2e939f16f7e47c326dc26eb918d327358797ee67ad7415d871ef7eaf0d4f6352d3ad021fbb4', + ); + }); + }); + describe('get token preview', () => { + it('should not throw for token in', async () => { + const service = new TokenWrapperService(provider, tokenWrapperAddress); + await expect( + service.getTokenInForTokenOut('10000000000000000000'), + ).rejects.toThrow(); + }); + it('should not throw for token out', async () => { + const service = new TokenWrapperService(provider, tokenWrapperAddress); + await expect( + service.getTokenOutForTokenIn('10000000000000000000'), + ).rejects.toThrow(); + }); + }); +}); diff --git a/packages/contract-helpers/src/token-wrapper/typechain/TokenWrapper.d.ts b/packages/contract-helpers/src/token-wrapper/typechain/TokenWrapper.d.ts new file mode 100644 index 00000000..b5f72bcb --- /dev/null +++ b/packages/contract-helpers/src/token-wrapper/typechain/TokenWrapper.d.ts @@ -0,0 +1,573 @@ +/* Autogenerated file. Do not edit manually. */ +/* 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 declare namespace IBaseTokenWrapper { + export type PermitSignatureStruct = { + deadline: BigNumberish; + v: BigNumberish; + r: BytesLike; + s: BytesLike; + }; + + export type PermitSignatureStructOutput = [ + BigNumber, + number, + string, + string, + ] & { deadline: BigNumber; v: number; r: string; s: string }; +} + +export interface BaseTokenWrapperInterface extends utils.Interface { + functions: { + 'POOL()': FunctionFragment; + 'TOKEN_IN()': FunctionFragment; + 'TOKEN_OUT()': FunctionFragment; + 'getTokenInForTokenOut(uint256)': FunctionFragment; + 'getTokenOutForTokenIn(uint256)': FunctionFragment; + 'owner()': FunctionFragment; + 'renounceOwnership()': FunctionFragment; + 'rescueETH(address,uint256)': FunctionFragment; + 'rescueTokens(address,address,uint256)': FunctionFragment; + 'supplyToken(uint256,address,uint16)': FunctionFragment; + 'supplyTokenWithPermit(uint256,address,uint16,(uint256,uint8,bytes32,bytes32))': FunctionFragment; + 'transferOwnership(address)': FunctionFragment; + 'withdrawToken(uint256,address)': FunctionFragment; + 'withdrawTokenWithPermit(uint256,address,(uint256,uint8,bytes32,bytes32))': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'POOL' + | 'TOKEN_IN' + | 'TOKEN_OUT' + | 'getTokenInForTokenOut' + | 'getTokenOutForTokenIn' + | 'owner' + | 'renounceOwnership' + | 'rescueETH' + | 'rescueTokens' + | 'supplyToken' + | 'supplyTokenWithPermit' + | 'transferOwnership' + | 'withdrawToken' + | 'withdrawTokenWithPermit', + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'POOL', values?: undefined): string; + encodeFunctionData(functionFragment: 'TOKEN_IN', values?: undefined): string; + encodeFunctionData(functionFragment: 'TOKEN_OUT', values?: undefined): string; + encodeFunctionData( + functionFragment: 'getTokenInForTokenOut', + values: [BigNumberish], + ): string; + encodeFunctionData( + functionFragment: 'getTokenOutForTokenIn', + values: [BigNumberish], + ): string; + encodeFunctionData(functionFragment: 'owner', values?: undefined): string; + encodeFunctionData( + functionFragment: 'renounceOwnership', + values?: undefined, + ): string; + encodeFunctionData( + functionFragment: 'rescueETH', + values: [string, BigNumberish], + ): string; + encodeFunctionData( + functionFragment: 'rescueTokens', + values: [string, string, BigNumberish], + ): string; + encodeFunctionData( + functionFragment: 'supplyToken', + values: [BigNumberish, string, BigNumberish], + ): string; + encodeFunctionData( + functionFragment: 'supplyTokenWithPermit', + values: [ + BigNumberish, + string, + BigNumberish, + IBaseTokenWrapper.PermitSignatureStruct, + ], + ): string; + encodeFunctionData( + functionFragment: 'transferOwnership', + values: [string], + ): string; + encodeFunctionData( + functionFragment: 'withdrawToken', + values: [BigNumberish, string], + ): string; + encodeFunctionData( + functionFragment: 'withdrawTokenWithPermit', + values: [BigNumberish, string, IBaseTokenWrapper.PermitSignatureStruct], + ): string; + + decodeFunctionResult(functionFragment: 'POOL', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'TOKEN_IN', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'TOKEN_OUT', data: BytesLike): Result; + decodeFunctionResult( + functionFragment: 'getTokenInForTokenOut', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'getTokenOutForTokenIn', + data: BytesLike, + ): Result; + decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result; + decodeFunctionResult( + functionFragment: 'renounceOwnership', + data: BytesLike, + ): Result; + decodeFunctionResult(functionFragment: 'rescueETH', data: BytesLike): Result; + decodeFunctionResult( + functionFragment: 'rescueTokens', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'supplyToken', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'supplyTokenWithPermit', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'transferOwnership', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'withdrawToken', + data: BytesLike, + ): Result; + decodeFunctionResult( + functionFragment: 'withdrawTokenWithPermit', + data: BytesLike, + ): Result; + + events: { + 'OwnershipTransferred(address,address)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'OwnershipTransferred'): EventFragment; +} + +export interface OwnershipTransferredEventObject { + previousOwner: string; + newOwner: string; +} +export type OwnershipTransferredEvent = TypedEvent< + [string, string], + OwnershipTransferredEventObject +>; + +export type OwnershipTransferredEventFilter = + TypedEventFilter; + +export interface BaseTokenWrapper extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: BaseTokenWrapperInterface; + + 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: { + POOL(overrides?: CallOverrides): Promise<[string]>; + + TOKEN_IN(overrides?: CallOverrides): Promise<[string]>; + + TOKEN_OUT(overrides?: CallOverrides): Promise<[string]>; + + getTokenInForTokenOut( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise<[BigNumber]>; + + getTokenOutForTokenIn( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise<[BigNumber]>; + + owner(overrides?: CallOverrides): Promise<[string]>; + + renounceOwnership( + overrides?: Overrides & { from?: string }, + ): Promise; + + rescueETH( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + supplyToken( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + supplyTokenWithPermit( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: Overrides & { from?: string }, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: Overrides & { from?: string }, + ): Promise; + + withdrawToken( + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string }, + ): Promise; + + withdrawTokenWithPermit( + amount: BigNumberish, + to: string, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: Overrides & { from?: string }, + ): Promise; + }; + + POOL(overrides?: CallOverrides): Promise; + + TOKEN_IN(overrides?: CallOverrides): Promise; + + TOKEN_OUT(overrides?: CallOverrides): Promise; + + getTokenInForTokenOut( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + getTokenOutForTokenIn( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership( + overrides?: Overrides & { from?: string }, + ): Promise; + + rescueETH( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + supplyToken( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + supplyTokenWithPermit( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: Overrides & { from?: string }, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: Overrides & { from?: string }, + ): Promise; + + withdrawToken( + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string }, + ): Promise; + + withdrawTokenWithPermit( + amount: BigNumberish, + to: string, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: Overrides & { from?: string }, + ): Promise; + + callStatic: { + POOL(overrides?: CallOverrides): Promise; + + TOKEN_IN(overrides?: CallOverrides): Promise; + + TOKEN_OUT(overrides?: CallOverrides): Promise; + + getTokenInForTokenOut( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + getTokenOutForTokenIn( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: CallOverrides): Promise; + + rescueETH( + to: string, + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + supplyToken( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + supplyTokenWithPermit( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: CallOverrides, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: CallOverrides, + ): Promise; + + withdrawToken( + amount: BigNumberish, + to: string, + overrides?: CallOverrides, + ): Promise; + + withdrawTokenWithPermit( + amount: BigNumberish, + to: string, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: CallOverrides, + ): Promise; + }; + + filters: { + 'OwnershipTransferred(address,address)'( + previousOwner?: string | null, + newOwner?: string | null, + ): OwnershipTransferredEventFilter; + OwnershipTransferred( + previousOwner?: string | null, + newOwner?: string | null, + ): OwnershipTransferredEventFilter; + }; + + estimateGas: { + POOL(overrides?: CallOverrides): Promise; + + TOKEN_IN(overrides?: CallOverrides): Promise; + + TOKEN_OUT(overrides?: CallOverrides): Promise; + + getTokenInForTokenOut( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + getTokenOutForTokenIn( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership( + overrides?: Overrides & { from?: string }, + ): Promise; + + rescueETH( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + supplyToken( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + supplyTokenWithPermit( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: Overrides & { from?: string }, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: Overrides & { from?: string }, + ): Promise; + + withdrawToken( + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string }, + ): Promise; + + withdrawTokenWithPermit( + amount: BigNumberish, + to: string, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: Overrides & { from?: string }, + ): Promise; + }; + + populateTransaction: { + POOL(overrides?: CallOverrides): Promise; + + TOKEN_IN(overrides?: CallOverrides): Promise; + + TOKEN_OUT(overrides?: CallOverrides): Promise; + + getTokenInForTokenOut( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + getTokenOutForTokenIn( + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership( + overrides?: Overrides & { from?: string }, + ): Promise; + + rescueETH( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + rescueTokens( + token: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + supplyToken( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + overrides?: Overrides & { from?: string }, + ): Promise; + + supplyTokenWithPermit( + amount: BigNumberish, + onBehalfOf: string, + referralCode: BigNumberish, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: Overrides & { from?: string }, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: Overrides & { from?: string }, + ): Promise; + + withdrawToken( + amount: BigNumberish, + to: string, + overrides?: Overrides & { from?: string }, + ): Promise; + + withdrawTokenWithPermit( + amount: BigNumberish, + to: string, + signature: IBaseTokenWrapper.PermitSignatureStruct, + overrides?: Overrides & { from?: string }, + ): Promise; + }; +} diff --git a/packages/contract-helpers/src/token-wrapper/typechain/TokenWrapper_factory.ts b/packages/contract-helpers/src/token-wrapper/typechain/TokenWrapper_factory.ts new file mode 100644 index 00000000..ad60a6b8 --- /dev/null +++ b/packages/contract-helpers/src/token-wrapper/typechain/TokenWrapper_factory.ts @@ -0,0 +1,343 @@ +/* Autogenerated file. Do not edit manually. */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { + BaseTokenWrapper, + BaseTokenWrapperInterface, +} from './TokenWrapper'; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + inputs: [], + name: 'POOL', + outputs: [ + { + internalType: 'contract IPool', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'TOKEN_IN', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'TOKEN_OUT', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'getTokenInForTokenOut', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'getTokenOutForTokenIn', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'rescueETH', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract IERC20', + name: 'token', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'rescueTokens', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + ], + name: 'supplyToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'onBehalfOf', + type: 'address', + }, + { + internalType: 'uint16', + name: 'referralCode', + type: 'uint16', + }, + { + components: [ + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + internalType: 'struct IBaseTokenWrapper.PermitSignature', + name: 'signature', + type: 'tuple', + }, + ], + name: 'supplyTokenWithPermit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + ], + name: 'withdrawToken', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + components: [ + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + internalType: 'struct IBaseTokenWrapper.PermitSignature', + name: 'signature', + type: 'tuple', + }, + ], + name: 'withdrawTokenWithPermit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export class BaseTokenWrapper__factory { + static readonly abi = _abi; + static createInterface(): BaseTokenWrapperInterface { + return new utils.Interface(_abi) as BaseTokenWrapperInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider, + ): BaseTokenWrapper { + return new Contract(address, _abi, signerOrProvider) as BaseTokenWrapper; + } +}