/* 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 TokenPairContractJson } from "../dex/TokenPair.ral.json"; import { getContractByCodeHash, registerContract } from "./contracts"; // Custom types for the contract export namespace TokenPairTypes { export type Fields = { tokenPairFactory: HexString; token0Id: HexString; token1Id: HexString; dexAccount0: HexString; reserve0: bigint; reserve1: bigint; blockTimeStampLast: bigint; price0CumulativeLast: bigint; price1CumulativeLast: bigint; totalSupply: bigint; kLast: bigint; feeCollectorId: HexString; }; export type State = ContractState; export type MintEvent = ContractEvent<{ sender: Address; amount0: bigint; amount1: bigint; liquidity: bigint; totalSupply: bigint; }>; export type BurnEvent = ContractEvent<{ sender: Address; amount0: bigint; amount1: bigint; liquidity: bigint; totalSupply: bigint; }>; export type SwapEvent = ContractEvent<{ sender: Address; amount0In: bigint; amount1In: bigint; amount0Out: bigint; amount1Out: bigint; to: Address; }>; export interface CallMethodTable { getSymbol: { params: Omit, "args">; result: CallContractResult; }; getName: { params: Omit, "args">; result: CallContractResult; }; getDecimals: { params: Omit, "args">; result: CallContractResult; }; getTotalSupply: { params: Omit, "args">; result: CallContractResult; }; uqdiv: { params: CallContractParams<{ a: bigint; b: bigint }>; result: CallContractResult; }; sqrt: { params: CallContractParams<{ y: bigint }>; result: CallContractResult; }; setFeeCollectorId: { params: CallContractParams<{ id: HexString }>; result: CallContractResult; }; getTokenPair: { params: Omit, "args">; result: CallContractResult<[HexString, HexString]>; }; getReserves: { params: Omit, "args">; result: CallContractResult<[bigint, bigint]>; }; getBlockTimeStampLast: { params: Omit, "args">; result: CallContractResult; }; getPrice0CumulativeLast: { params: Omit, "args">; result: CallContractResult; }; getPrice1CumulativeLast: { params: Omit, "args">; result: CallContractResult; }; update: { params: CallContractParams<{ newReserve0: bigint; newReserve1: bigint }>; result: CallContractResult; }; mintFee: { params: CallContractParams<{ reserve0_: bigint; reserve1_: bigint }>; result: CallContractResult<[boolean, bigint]>; }; mint: { params: CallContractParams<{ sender: Address; amount0: bigint; amount1: bigint; }>; result: CallContractResult; }; burn: { params: CallContractParams<{ sender: Address; liquidity: bigint }>; result: CallContractResult<[bigint, bigint]>; }; swap: { params: CallContractParams<{ sender: Address; to: Address; amount0In: bigint; amount1In: bigint; amount0Out: bigint; amount1Out: bigint; }>; result: CallContractResult; }; collectFeeManually: { params: Omit, "args">; result: CallContractResult; }; collectFeeAndUpdateKLast: { params: CallContractParams<{ feeAmount: 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 { getSymbol: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getName: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getDecimals: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getTotalSupply: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; uqdiv: { params: SignExecuteContractMethodParams<{ a: bigint; b: bigint }>; result: SignExecuteScriptTxResult; }; sqrt: { params: SignExecuteContractMethodParams<{ y: bigint }>; result: SignExecuteScriptTxResult; }; setFeeCollectorId: { params: SignExecuteContractMethodParams<{ id: HexString }>; result: SignExecuteScriptTxResult; }; getTokenPair: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getReserves: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getBlockTimeStampLast: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getPrice0CumulativeLast: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; getPrice1CumulativeLast: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; update: { params: SignExecuteContractMethodParams<{ newReserve0: bigint; newReserve1: bigint; }>; result: SignExecuteScriptTxResult; }; mintFee: { params: SignExecuteContractMethodParams<{ reserve0_: bigint; reserve1_: bigint; }>; result: SignExecuteScriptTxResult; }; mint: { params: SignExecuteContractMethodParams<{ sender: Address; amount0: bigint; amount1: bigint; }>; result: SignExecuteScriptTxResult; }; burn: { params: SignExecuteContractMethodParams<{ sender: Address; liquidity: bigint; }>; result: SignExecuteScriptTxResult; }; swap: { params: SignExecuteContractMethodParams<{ sender: Address; to: Address; amount0In: bigint; amount1In: bigint; amount0Out: bigint; amount1Out: bigint; }>; result: SignExecuteScriptTxResult; }; collectFeeManually: { params: Omit, "args">; result: SignExecuteScriptTxResult; }; collectFeeAndUpdateKLast: { params: SignExecuteContractMethodParams<{ feeAmount: bigint }>; result: SignExecuteScriptTxResult; }; } export type SignExecuteMethodParams = SignExecuteMethodTable[T]["params"]; export type SignExecuteMethodResult = SignExecuteMethodTable[T]["result"]; } class Factory extends ContractFactory< TokenPairInstance, TokenPairTypes.Fields > { encodeFields(fields: TokenPairTypes.Fields) { return encodeContractFields( addStdIdToFields(this.contract, fields), this.contract.fieldsSig, [] ); } eventIndex = { Mint: 0, Burn: 1, Swap: 2 }; consts = { MINIMUM_LIQUIDITY: BigInt("1000"), 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): TokenPairInstance { return new TokenPairInstance(address); } tests = { getSymbol: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod(this, "getSymbol", params, getContractByCodeHash); }, getName: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod(this, "getName", params, getContractByCodeHash); }, getDecimals: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod(this, "getDecimals", params, getContractByCodeHash); }, getTotalSupply: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod(this, "getTotalSupply", params, getContractByCodeHash); }, uqdiv: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { a: bigint; b: bigint } > ): Promise> => { return testMethod(this, "uqdiv", params, getContractByCodeHash); }, sqrt: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { y: bigint } > ): Promise> => { return testMethod(this, "sqrt", params, getContractByCodeHash); }, setFeeCollectorId: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { id: HexString } > ): Promise> => { return testMethod( this, "setFeeCollectorId", params, getContractByCodeHash ); }, getTokenPair: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod(this, "getTokenPair", params, getContractByCodeHash); }, getReserves: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod(this, "getReserves", params, getContractByCodeHash); }, getBlockTimeStampLast: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod( this, "getBlockTimeStampLast", params, getContractByCodeHash ); }, getPrice0CumulativeLast: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod( this, "getPrice0CumulativeLast", params, getContractByCodeHash ); }, getPrice1CumulativeLast: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod( this, "getPrice1CumulativeLast", params, getContractByCodeHash ); }, update: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { newReserve0: bigint; newReserve1: bigint } > ): Promise> => { return testMethod(this, "update", params, getContractByCodeHash); }, mintFee: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { reserve0_: bigint; reserve1_: bigint } > ): Promise> => { return testMethod(this, "mintFee", params, getContractByCodeHash); }, mint: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { sender: Address; amount0: bigint; amount1: bigint } > ): Promise> => { return testMethod(this, "mint", params, getContractByCodeHash); }, burn: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { sender: Address; liquidity: bigint } > ): Promise> => { return testMethod(this, "burn", params, getContractByCodeHash); }, swap: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { sender: Address; to: Address; amount0In: bigint; amount1In: bigint; amount0Out: bigint; amount1Out: bigint; } > ): Promise> => { return testMethod(this, "swap", params, getContractByCodeHash); }, collectFeeManually: async ( params: Omit< TestContractParamsWithoutMaps, "args" > ): Promise> => { return testMethod( this, "collectFeeManually", params, getContractByCodeHash ); }, collectFeeAndUpdateKLast: async ( params: TestContractParamsWithoutMaps< TokenPairTypes.Fields, { feeAmount: bigint } > ): Promise> => { return testMethod( this, "collectFeeAndUpdateKLast", params, getContractByCodeHash ); }, }; stateForTest( initFields: TokenPairTypes.Fields, asset?: Asset, address?: string ) { return this.stateForTest_(initFields, asset, address, undefined); } } // Use this object to test and deploy the contract export const TokenPair = new Factory( Contract.fromJson( TokenPairContractJson, "", "3a4ac01ae47b1c84a567e7ef467fc4f7f8e5da32c6546192f0e2b2af3d79891f", [] ) ); registerContract(TokenPair); // Use this class to interact with the blockchain export class TokenPairInstance extends ContractInstance { constructor(address: Address) { super(address); } async fetchState(): Promise { return fetchContractState(TokenPair, this); } async getContractEventsCurrentCount(): Promise { return getContractEventsCurrentCount(this.address); } subscribeMintEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( TokenPair.contract, this, options, "Mint", fromCount ); } subscribeBurnEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( TokenPair.contract, this, options, "Burn", fromCount ); } subscribeSwapEvent( options: EventSubscribeOptions, fromCount?: number ): EventSubscription { return subscribeContractEvent( TokenPair.contract, this, options, "Swap", fromCount ); } subscribeAllEvents( options: EventSubscribeOptions< | TokenPairTypes.MintEvent | TokenPairTypes.BurnEvent | TokenPairTypes.SwapEvent >, fromCount?: number ): EventSubscription { return subscribeContractEvents( TokenPair.contract, this, options, fromCount ); } view = { getSymbol: async ( params?: TokenPairTypes.CallMethodParams<"getSymbol"> ): Promise> => { return callMethod( TokenPair, this, "getSymbol", params === undefined ? {} : params, getContractByCodeHash ); }, getName: async ( params?: TokenPairTypes.CallMethodParams<"getName"> ): Promise> => { return callMethod( TokenPair, this, "getName", params === undefined ? {} : params, getContractByCodeHash ); }, getDecimals: async ( params?: TokenPairTypes.CallMethodParams<"getDecimals"> ): Promise> => { return callMethod( TokenPair, this, "getDecimals", params === undefined ? {} : params, getContractByCodeHash ); }, getTotalSupply: async ( params?: TokenPairTypes.CallMethodParams<"getTotalSupply"> ): Promise> => { return callMethod( TokenPair, this, "getTotalSupply", params === undefined ? {} : params, getContractByCodeHash ); }, uqdiv: async ( params: TokenPairTypes.CallMethodParams<"uqdiv"> ): Promise> => { return callMethod( TokenPair, this, "uqdiv", params, getContractByCodeHash ); }, sqrt: async ( params: TokenPairTypes.CallMethodParams<"sqrt"> ): Promise> => { return callMethod(TokenPair, this, "sqrt", params, getContractByCodeHash); }, setFeeCollectorId: async ( params: TokenPairTypes.CallMethodParams<"setFeeCollectorId"> ): Promise> => { return callMethod( TokenPair, this, "setFeeCollectorId", params, getContractByCodeHash ); }, getTokenPair: async ( params?: TokenPairTypes.CallMethodParams<"getTokenPair"> ): Promise> => { return callMethod( TokenPair, this, "getTokenPair", params === undefined ? {} : params, getContractByCodeHash ); }, getReserves: async ( params?: TokenPairTypes.CallMethodParams<"getReserves"> ): Promise> => { return callMethod( TokenPair, this, "getReserves", params === undefined ? {} : params, getContractByCodeHash ); }, getBlockTimeStampLast: async ( params?: TokenPairTypes.CallMethodParams<"getBlockTimeStampLast"> ): Promise> => { return callMethod( TokenPair, this, "getBlockTimeStampLast", params === undefined ? {} : params, getContractByCodeHash ); }, getPrice0CumulativeLast: async ( params?: TokenPairTypes.CallMethodParams<"getPrice0CumulativeLast"> ): Promise> => { return callMethod( TokenPair, this, "getPrice0CumulativeLast", params === undefined ? {} : params, getContractByCodeHash ); }, getPrice1CumulativeLast: async ( params?: TokenPairTypes.CallMethodParams<"getPrice1CumulativeLast"> ): Promise> => { return callMethod( TokenPair, this, "getPrice1CumulativeLast", params === undefined ? {} : params, getContractByCodeHash ); }, update: async ( params: TokenPairTypes.CallMethodParams<"update"> ): Promise> => { return callMethod( TokenPair, this, "update", params, getContractByCodeHash ); }, mintFee: async ( params: TokenPairTypes.CallMethodParams<"mintFee"> ): Promise> => { return callMethod( TokenPair, this, "mintFee", params, getContractByCodeHash ); }, mint: async ( params: TokenPairTypes.CallMethodParams<"mint"> ): Promise> => { return callMethod(TokenPair, this, "mint", params, getContractByCodeHash); }, burn: async ( params: TokenPairTypes.CallMethodParams<"burn"> ): Promise> => { return callMethod(TokenPair, this, "burn", params, getContractByCodeHash); }, swap: async ( params: TokenPairTypes.CallMethodParams<"swap"> ): Promise> => { return callMethod(TokenPair, this, "swap", params, getContractByCodeHash); }, collectFeeManually: async ( params?: TokenPairTypes.CallMethodParams<"collectFeeManually"> ): Promise> => { return callMethod( TokenPair, this, "collectFeeManually", params === undefined ? {} : params, getContractByCodeHash ); }, collectFeeAndUpdateKLast: async ( params: TokenPairTypes.CallMethodParams<"collectFeeAndUpdateKLast"> ): Promise> => { return callMethod( TokenPair, this, "collectFeeAndUpdateKLast", params, getContractByCodeHash ); }, }; transact = { getSymbol: async ( params: TokenPairTypes.SignExecuteMethodParams<"getSymbol"> ): Promise> => { return signExecuteMethod(TokenPair, this, "getSymbol", params); }, getName: async ( params: TokenPairTypes.SignExecuteMethodParams<"getName"> ): Promise> => { return signExecuteMethod(TokenPair, this, "getName", params); }, getDecimals: async ( params: TokenPairTypes.SignExecuteMethodParams<"getDecimals"> ): Promise> => { return signExecuteMethod(TokenPair, this, "getDecimals", params); }, getTotalSupply: async ( params: TokenPairTypes.SignExecuteMethodParams<"getTotalSupply"> ): Promise> => { return signExecuteMethod(TokenPair, this, "getTotalSupply", params); }, uqdiv: async ( params: TokenPairTypes.SignExecuteMethodParams<"uqdiv"> ): Promise> => { return signExecuteMethod(TokenPair, this, "uqdiv", params); }, sqrt: async ( params: TokenPairTypes.SignExecuteMethodParams<"sqrt"> ): Promise> => { return signExecuteMethod(TokenPair, this, "sqrt", params); }, setFeeCollectorId: async ( params: TokenPairTypes.SignExecuteMethodParams<"setFeeCollectorId"> ): Promise> => { return signExecuteMethod(TokenPair, this, "setFeeCollectorId", params); }, getTokenPair: async ( params: TokenPairTypes.SignExecuteMethodParams<"getTokenPair"> ): Promise> => { return signExecuteMethod(TokenPair, this, "getTokenPair", params); }, getReserves: async ( params: TokenPairTypes.SignExecuteMethodParams<"getReserves"> ): Promise> => { return signExecuteMethod(TokenPair, this, "getReserves", params); }, getBlockTimeStampLast: async ( params: TokenPairTypes.SignExecuteMethodParams<"getBlockTimeStampLast"> ): Promise< TokenPairTypes.SignExecuteMethodResult<"getBlockTimeStampLast"> > => { return signExecuteMethod( TokenPair, this, "getBlockTimeStampLast", params ); }, getPrice0CumulativeLast: async ( params: TokenPairTypes.SignExecuteMethodParams<"getPrice0CumulativeLast"> ): Promise< TokenPairTypes.SignExecuteMethodResult<"getPrice0CumulativeLast"> > => { return signExecuteMethod( TokenPair, this, "getPrice0CumulativeLast", params ); }, getPrice1CumulativeLast: async ( params: TokenPairTypes.SignExecuteMethodParams<"getPrice1CumulativeLast"> ): Promise< TokenPairTypes.SignExecuteMethodResult<"getPrice1CumulativeLast"> > => { return signExecuteMethod( TokenPair, this, "getPrice1CumulativeLast", params ); }, update: async ( params: TokenPairTypes.SignExecuteMethodParams<"update"> ): Promise> => { return signExecuteMethod(TokenPair, this, "update", params); }, mintFee: async ( params: TokenPairTypes.SignExecuteMethodParams<"mintFee"> ): Promise> => { return signExecuteMethod(TokenPair, this, "mintFee", params); }, mint: async ( params: TokenPairTypes.SignExecuteMethodParams<"mint"> ): Promise> => { return signExecuteMethod(TokenPair, this, "mint", params); }, burn: async ( params: TokenPairTypes.SignExecuteMethodParams<"burn"> ): Promise> => { return signExecuteMethod(TokenPair, this, "burn", params); }, swap: async ( params: TokenPairTypes.SignExecuteMethodParams<"swap"> ): Promise> => { return signExecuteMethod(TokenPair, this, "swap", params); }, collectFeeManually: async ( params: TokenPairTypes.SignExecuteMethodParams<"collectFeeManually"> ): Promise< TokenPairTypes.SignExecuteMethodResult<"collectFeeManually"> > => { return signExecuteMethod(TokenPair, this, "collectFeeManually", params); }, collectFeeAndUpdateKLast: async ( params: TokenPairTypes.SignExecuteMethodParams<"collectFeeAndUpdateKLast"> ): Promise< TokenPairTypes.SignExecuteMethodResult<"collectFeeAndUpdateKLast"> > => { return signExecuteMethod( TokenPair, this, "collectFeeAndUpdateKLast", params ); }, }; async multicall( calls: Calls ): Promise>; async multicall( callss: Narrow ): Promise>; async multicall< Callss extends | TokenPairTypes.MultiCallParams | TokenPairTypes.MultiCallParams[] >(callss: Callss): Promise { return await multicallMethods( TokenPair, this, callss, getContractByCodeHash ); } }