/* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ import { Address, Contract, ContractState, TestContractResult, HexString, ContractFactory, EventSubscribeOptions, EventSubscription, CallContractParams, CallContractResult, TestContractParams, ContractEvent, subscribeContractEvent, subscribeContractEvents, testMethod, callMethod, multicallMethods, fetchContractState, Asset, ContractInstance, getContractEventsCurrentCount, TestContractParamsWithoutMaps, TestContractResultWithoutMaps, SignExecuteContractMethodParams, SignExecuteScriptTxResult, signExecuteMethod, addStdIdToFields, encodeContractFields, Narrow, } from "@alephium/web3"; import { default as RouterContractJson } from "../dex/Router.ral.json"; import { getContractByCodeHash, registerContract } from "./contracts"; // Custom types for the contract export namespace RouterTypes { export type State = Omit, "fields">; export interface CallMethodTable { addLiquidity_: { params: CallContractParams<{ reserve0: bigint; reserve1: bigint; amount0Desired: bigint; amount1Desired: bigint; amount0Min: bigint; amount1Min: bigint; }>; result: CallContractResult<[bigint, bigint]>; }; addLiquidity: { params: CallContractParams<{ tokenPair: HexString; sender: Address; amount0Desired: bigint; amount1Desired: bigint; amount0Min: bigint; amount1Min: bigint; deadline: bigint; }>; result: CallContractResult<[bigint, bigint, bigint]>; }; removeLiquidity: { params: CallContractParams<{ tokenPairId: HexString; sender: Address; liquidity: bigint; amount0Min: bigint; amount1Min: bigint; deadline: bigint; }>; result: CallContractResult<[bigint, bigint]>; }; getReserveInAndReserveOut: { params: CallContractParams<{ tokenPair: HexString; tokenInId: HexString; }>; result: CallContractResult<[bigint, bigint]>; }; swapExactTokenForToken: { params: CallContractParams<{ tokenPair: HexString; sender: Address; tokenInId: HexString; amountIn: bigint; amountOutMin: bigint; to: Address; deadline: bigint; }>; result: CallContractResult; }; swapTokenForExactToken: { params: CallContractParams<{ tokenPair: HexString; sender: Address; tokenInId: HexString; amountInMax: bigint; amountOut: bigint; to: Address; deadline: bigint; }>; result: CallContractResult; }; swap: { params: CallContractParams<{ tokenPair: HexString; sender: Address; to: Address; tokenInId: HexString; amountIn: bigint; amountOut: bigint; }>; result: CallContractResult; }; } export type CallMethodParams = CallMethodTable[T]["params"]; export type CallMethodResult = CallMethodTable[T]["result"]; export type MultiCallParams = Partial<{ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"]; }>; export type MultiCallResults = { [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable ? CallMethodTable[MaybeName]["result"] : undefined; }; export type MulticallReturnType = { [index in keyof Callss]: MultiCallResults; }; export interface SignExecuteMethodTable { addLiquidity_: { params: SignExecuteContractMethodParams<{ reserve0: bigint; reserve1: bigint; amount0Desired: bigint; amount1Desired: bigint; amount0Min: bigint; amount1Min: bigint; }>; result: SignExecuteScriptTxResult; }; addLiquidity: { params: SignExecuteContractMethodParams<{ tokenPair: HexString; sender: Address; amount0Desired: bigint; amount1Desired: bigint; amount0Min: bigint; amount1Min: bigint; deadline: bigint; }>; result: SignExecuteScriptTxResult; }; removeLiquidity: { params: SignExecuteContractMethodParams<{ tokenPairId: HexString; sender: Address; liquidity: bigint; amount0Min: bigint; amount1Min: bigint; deadline: bigint; }>; result: SignExecuteScriptTxResult; }; getReserveInAndReserveOut: { params: SignExecuteContractMethodParams<{ tokenPair: HexString; tokenInId: HexString; }>; result: SignExecuteScriptTxResult; }; swapExactTokenForToken: { params: SignExecuteContractMethodParams<{ tokenPair: HexString; sender: Address; tokenInId: HexString; amountIn: bigint; amountOutMin: bigint; to: Address; deadline: bigint; }>; result: SignExecuteScriptTxResult; }; swapTokenForExactToken: { params: SignExecuteContractMethodParams<{ tokenPair: HexString; sender: Address; tokenInId: HexString; amountInMax: bigint; amountOut: bigint; to: Address; deadline: bigint; }>; result: SignExecuteScriptTxResult; }; swap: { params: SignExecuteContractMethodParams<{ tokenPair: HexString; sender: Address; to: Address; tokenInId: HexString; amountIn: bigint; amountOut: bigint; }>; result: SignExecuteScriptTxResult; }; } export type SignExecuteMethodParams = SignExecuteMethodTable[T]["params"]; export type SignExecuteMethodResult = SignExecuteMethodTable[T]["result"]; } class Factory extends ContractFactory { encodeFields() { return encodeContractFields({}, this.contract.fieldsSig, []); } consts = { ErrorCodes: { ReserveOverflow: BigInt("0"), InsufficientInitLiquidity: BigInt("1"), InsufficientLiquidityMinted: BigInt("2"), InsufficientLiquidityBurned: BigInt("3"), InvalidToAddress: BigInt("4"), InsufficientLiquidity: BigInt("5"), InvalidTokenInId: BigInt("6"), InvalidCalleeId: BigInt("7"), InvalidK: BigInt("8"), InsufficientOutputAmount: BigInt("9"), InsufficientInputAmount: BigInt("10"), IdenticalTokenIds: BigInt("11"), Expired: BigInt("12"), InsufficientToken0Amount: BigInt("13"), InsufficientToken1Amount: BigInt("14"), TokenNotExist: BigInt("15"), InvalidCaller: BigInt("16"), FeeCollectorNotEnabled: BigInt("17"), InvalidAccount: BigInt("18"), }, }; at(address: string): RouterInstance { return new RouterInstance(address); } tests = { addLiquidity_: async ( params: Omit< TestContractParamsWithoutMaps< never, { reserve0: bigint; reserve1: bigint; amount0Desired: bigint; amount1Desired: bigint; amount0Min: bigint; amount1Min: bigint; } >, "initialFields" > ): Promise> => { return testMethod(this, "addLiquidity_", params, getContractByCodeHash); }, addLiquidity: async ( params: Omit< TestContractParamsWithoutMaps< never, { tokenPair: HexString; sender: Address; amount0Desired: bigint; amount1Desired: bigint; amount0Min: bigint; amount1Min: bigint; deadline: bigint; } >, "initialFields" > ): Promise> => { return testMethod(this, "addLiquidity", params, getContractByCodeHash); }, removeLiquidity: async ( params: Omit< TestContractParamsWithoutMaps< never, { tokenPairId: HexString; sender: Address; liquidity: bigint; amount0Min: bigint; amount1Min: bigint; deadline: bigint; } >, "initialFields" > ): Promise> => { return testMethod(this, "removeLiquidity", params, getContractByCodeHash); }, getReserveInAndReserveOut: async ( params: Omit< TestContractParamsWithoutMaps< never, { tokenPair: HexString; tokenInId: HexString } >, "initialFields" > ): Promise> => { return testMethod( this, "getReserveInAndReserveOut", params, getContractByCodeHash ); }, swapExactTokenForToken: async ( params: Omit< TestContractParamsWithoutMaps< never, { tokenPair: HexString; sender: Address; tokenInId: HexString; amountIn: bigint; amountOutMin: bigint; to: Address; deadline: bigint; } >, "initialFields" > ): Promise> => { return testMethod( this, "swapExactTokenForToken", params, getContractByCodeHash ); }, swapTokenForExactToken: async ( params: Omit< TestContractParamsWithoutMaps< never, { tokenPair: HexString; sender: Address; tokenInId: HexString; amountInMax: bigint; amountOut: bigint; to: Address; deadline: bigint; } >, "initialFields" > ): Promise> => { return testMethod( this, "swapTokenForExactToken", params, getContractByCodeHash ); }, swap: async ( params: Omit< TestContractParamsWithoutMaps< never, { tokenPair: HexString; sender: Address; to: Address; tokenInId: HexString; amountIn: bigint; amountOut: bigint; } >, "initialFields" > ): Promise> => { return testMethod(this, "swap", params, getContractByCodeHash); }, }; stateForTest(initFields: {}, asset?: Asset, address?: string) { return this.stateForTest_(initFields, asset, address, undefined); } } // Use this object to test and deploy the contract export const Router = new Factory( Contract.fromJson( RouterContractJson, "", "e1ef7a11988dd23f3815d376e474266e3e9f69c9ad289974b9c45ed4ad986a6d", [] ) ); registerContract(Router); // Use this class to interact with the blockchain export class RouterInstance extends ContractInstance { constructor(address: Address) { super(address); } async fetchState(): Promise { return fetchContractState(Router, this); } view = { addLiquidity_: async ( params: RouterTypes.CallMethodParams<"addLiquidity_"> ): Promise> => { return callMethod( Router, this, "addLiquidity_", params, getContractByCodeHash ); }, addLiquidity: async ( params: RouterTypes.CallMethodParams<"addLiquidity"> ): Promise> => { return callMethod( Router, this, "addLiquidity", params, getContractByCodeHash ); }, removeLiquidity: async ( params: RouterTypes.CallMethodParams<"removeLiquidity"> ): Promise> => { return callMethod( Router, this, "removeLiquidity", params, getContractByCodeHash ); }, getReserveInAndReserveOut: async ( params: RouterTypes.CallMethodParams<"getReserveInAndReserveOut"> ): Promise> => { return callMethod( Router, this, "getReserveInAndReserveOut", params, getContractByCodeHash ); }, swapExactTokenForToken: async ( params: RouterTypes.CallMethodParams<"swapExactTokenForToken"> ): Promise> => { return callMethod( Router, this, "swapExactTokenForToken", params, getContractByCodeHash ); }, swapTokenForExactToken: async ( params: RouterTypes.CallMethodParams<"swapTokenForExactToken"> ): Promise> => { return callMethod( Router, this, "swapTokenForExactToken", params, getContractByCodeHash ); }, swap: async ( params: RouterTypes.CallMethodParams<"swap"> ): Promise> => { return callMethod(Router, this, "swap", params, getContractByCodeHash); }, }; transact = { addLiquidity_: async ( params: RouterTypes.SignExecuteMethodParams<"addLiquidity_"> ): Promise> => { return signExecuteMethod(Router, this, "addLiquidity_", params); }, addLiquidity: async ( params: RouterTypes.SignExecuteMethodParams<"addLiquidity"> ): Promise> => { return signExecuteMethod(Router, this, "addLiquidity", params); }, removeLiquidity: async ( params: RouterTypes.SignExecuteMethodParams<"removeLiquidity"> ): Promise> => { return signExecuteMethod(Router, this, "removeLiquidity", params); }, getReserveInAndReserveOut: async ( params: RouterTypes.SignExecuteMethodParams<"getReserveInAndReserveOut"> ): Promise< RouterTypes.SignExecuteMethodResult<"getReserveInAndReserveOut"> > => { return signExecuteMethod( Router, this, "getReserveInAndReserveOut", params ); }, swapExactTokenForToken: async ( params: RouterTypes.SignExecuteMethodParams<"swapExactTokenForToken"> ): Promise< RouterTypes.SignExecuteMethodResult<"swapExactTokenForToken"> > => { return signExecuteMethod(Router, this, "swapExactTokenForToken", params); }, swapTokenForExactToken: async ( params: RouterTypes.SignExecuteMethodParams<"swapTokenForExactToken"> ): Promise< RouterTypes.SignExecuteMethodResult<"swapTokenForExactToken"> > => { return signExecuteMethod(Router, this, "swapTokenForExactToken", params); }, swap: async ( params: RouterTypes.SignExecuteMethodParams<"swap"> ): Promise> => { return signExecuteMethod(Router, this, "swap", params); }, }; async multicall( calls: Calls ): Promise>; async multicall( callss: Narrow ): Promise>; async multicall< Callss extends RouterTypes.MultiCallParams | RouterTypes.MultiCallParams[] >(callss: Callss): Promise { return await multicallMethods(Router, this, callss, getContractByCodeHash); } }