@azuro-protocol/sdk
Advanced tools
Comparing version 0.4.5 to 0.4.6
@@ -1,1 +0,1 @@ | ||
import{Contract}from"@ethersproject/contracts";import{JsonRpcProvider}from"@ethersproject/providers";import{utils}from"ethers";import axios from"axios";import{formatUnits,parseUnits}from"@ethersproject/units";var CoreABI=[{inputs:[],name:"BetNotAllowed",type:"error"},{inputs:[],name:"BigDifference",type:"error"},{inputs:[],name:"CantAcceptBet",type:"error"},{inputs:[],name:"CantChangeFlag",type:"error"},{inputs:[],name:"ConditionAlreadyCreated",type:"error"},{inputs:[],name:"ConditionAlreadyResolved",type:"error"},{inputs:[],name:"ConditionNotExists",type:"error"},{inputs:[],name:"ConditionNotStarted",type:"error"},{inputs:[],name:"ConditionStarted",type:"error"},{inputs:[],name:"FlagAlreadySet",type:"error"},{inputs:[],name:"IncorrectTimestamp",type:"error"},{inputs:[],name:"NotEnoughLiquidity",type:"error"},{inputs:[],name:"OnlyLp",type:"error"},{inputs:[],name:"OnlyMaintainer",type:"error"},{inputs:[],name:"OnlyOracle",type:"error"},{inputs:[{internalType:"uint64",name:"waitTime",type:"uint64"}],name:"ResolveTooEarly",type:"error"},{inputs:[],name:"SameOutcomes",type:"error"},{inputs:[],name:"SmallBet",type:"error"},{inputs:[],name:"SmallOdds",type:"error"},{inputs:[],name:"WrongDataFormat",type:"error"},{inputs:[],name:"WrongOutcome",type:"error"},{inputs:[],name:"ZeroOdds",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"flag",type:"bool"}],name:"AllConditionsStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oracleConditionId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"timestamp",type:"uint64"}],name:"ConditionCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oracleConditionId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"outcomeWin",type:"uint64"},{indexed:!1,internalType:"uint8",name:"state",type:"uint8"},{indexed:!1,internalType:"uint256",name:"amountForLp",type:"uint256"}],name:"ConditionResolved",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"newTimestamp",type:"uint64"}],name:"ConditionShifted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"bool",name:"flag",type:"bool"}],name:"ConditionStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newLp",type:"address"}],name:"LpChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"maintainer",type:"address"},{indexed:!1,internalType:"bool",name:"active",type:"bool"}],name:"MaintainerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newRatio",type:"uint64"}],name:"MaxBanksRatioChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newOracle",type:"address"}],name:"OracleAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oracle",type:"address"}],name:"OracleRenounced",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{inputs:[],name:"LP",outputs:[{internalType:"contract ILP",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"maintainer",type:"address"},{internalType:"bool",name:"active",type:"bool"}],name:"addMaintainer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"allConditionsStopped",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"bets",outputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"},{internalType:"uint64",name:"createdAt",type:"uint64"},{internalType:"uint64",name:"odds",type:"uint64"},{internalType:"bool",name:"payed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"}],name:"calculateOdds",outputs:[{internalType:"uint64",name:"odds",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"cancelByMaintainer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"oracleConditionId",type:"uint256"}],name:"cancelByOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"a",type:"uint256"},{internalType:"uint256",name:"m",type:"uint256"}],name:"ceil",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint64",name:"newRatio",type:"uint64"}],name:"changeMaxBanksRatio",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"conditions",outputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"uint128",name:"margin",type:"uint128"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64",name:"outcomeWin",type:"uint64"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"enum ICore.ConditionState",name:"state",type:"uint8"},{internalType:"uint48",name:"leaf",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"oracleCondId",type:"uint256"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64[2]",name:"odds",type:"uint64[2]"},{internalType:"uint64[2]",name:"outcomes",type:"uint64[2]"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"}],name:"createCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"defaultMargin",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultReinforcement",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"betId",type:"uint256"}],name:"getBetInfo",outputs:[{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"odds",type:"uint64"},{internalType:"uint64",name:"createdAt",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getCondition",outputs:[{components:[{internalType:"uint128[2]",name:"fundBank",type:"uint128[2]"},{internalType:"uint128[2]",name:"payouts",type:"uint128[2]"},{internalType:"uint128[2]",name:"totalNetBets",type:"uint128[2]"},{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"uint128",name:"margin",type:"uint128"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{internalType:"uint64[2]",name:"outcomes",type:"uint64[2]"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64",name:"outcomeWin",type:"uint64"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"enum ICore.ConditionState",name:"state",type:"uint8"},{internalType:"uint48",name:"leaf",type:"uint48"}],internalType:"struct ICore.Condition",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getConditionFunds",outputs:[{internalType:"uint128[2]",name:"fundBank",type:"uint128[2]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getConditionReinforcement",outputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLockedPayout",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint64",name:"outcomeId",type:"uint64"}],name:"getMargin",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"fund1Bank",type:"uint256"},{internalType:"uint256",name:"fund2Bank",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outcomeIndex",type:"uint256"},{internalType:"uint256",name:"margin",type:"uint256"},{internalType:"uint256",name:"multiplier",type:"uint256"}],name:"getOddsFromBanks",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint64",name:"outcomeId",type:"uint64"}],name:"getReinforcement",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"address",name:"oracle",type:"address"},{internalType:"uint128",name:"margin",type:"uint128"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"isOracle",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint256",name:"outcome",type:"uint256"}],name:"isOutComeCorrect",outputs:[{internalType:"bool",name:"correct",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"lastConditionId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"maintainers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"odds",type:"uint256"},{internalType:"uint256",name:"marginality",type:"uint256"},{internalType:"uint256",name:"multiplier",type:"uint256"}],name:"marginAdjustedOdds",outputs:[{internalType:"uint256",name:"newOdds",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[],name:"maxBanksRatio",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"multiplier",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"oracleConditionIds",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"oracles",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"putBet",outputs:[{internalType:"uint64",name:"",type:"uint64"},{internalType:"uint128",name:"",type:"uint128"},{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"renounceOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"oracleCondId",type:"uint256"},{internalType:"uint64",name:"outcomeWin",type:"uint64"}],name:"resolveCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"resolvePayout",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"lp",type:"address"}],name:"setLp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"setOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint64",name:"newTimestamp",type:"uint64"}],name:"shift",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"x",type:"uint256"}],name:"sqrt",outputs:[{internalType:"uint256",name:"y",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bool",name:"flag",type:"bool"}],name:"stopAllConditions",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"bool",name:"flag",type:"bool"}],name:"stopCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalLockedPayout",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128[]",name:"data",type:"uint128[]"}],name:"updateMargins",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128[]",name:"data",type:"uint128[]"}],name:"updateReinforcements",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"viewPayout",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"}],LpABI=[{inputs:[],name:"AmountMustNotBeZero",type:"error"},{inputs:[],name:"AmountNotSufficient",type:"error"},{inputs:[],name:"ConditionStarted",type:"error"},{inputs:[],name:"IncorrectPercent",type:"error"},{inputs:[],name:"LeafNotExist",type:"error"},{inputs:[],name:"LiquidityIsLocked",type:"error"},{inputs:[],name:"LiquidityNotOwned",type:"error"},{inputs:[],name:"NoDaoReward",type:"error"},{inputs:[],name:"NoLiquidity",type:"error"},{inputs:[],name:"NoWinNoPrize",type:"error"},{inputs:[],name:"NotEnoughReserves",type:"error"},{inputs:[],name:"OnlyBetOwner",type:"error"},{inputs:[],name:"OnlyCore",type:"error"},{inputs:[],name:"PaymentLocked",type:"error"},{inputs:[{internalType:"uint64",name:"waitTime",type:"uint64"}],name:"WithdrawalTimeout",type:"error"},{inputs:[],name:"WrongToken",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"newAzuroBet",type:"address"}],name:"AzuroBetChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"better",type:"address"},{indexed:!1,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"BetterWin",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newDaoFee",type:"uint128"}],name:"DaoRewardChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"uint48",name:"leaf",type:"uint48"}],name:"LiquidityAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"LiquidityRemoved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"requestWallet",type:"address"},{indexed:!1,internalType:"uint256",name:"requestedValueLp",type:"uint256"}],name:"LiquidityRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newMinDepo",type:"uint128"}],name:"MinDepoChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"uint256",name:"betId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"outcomeId",type:"uint64"},{indexed:!1,internalType:"uint128",name:"amount",type:"uint128"},{indexed:!1,internalType:"uint256",name:"odds",type:"uint256"},{indexed:!1,internalType:"uint128",name:"fund1",type:"uint128"},{indexed:!1,internalType:"uint128",name:"fund2",type:"uint128"}],name:"NewBet",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newOracleFee",type:"uint128"}],name:"OracleRewardChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newPeriod",type:"uint64"}],name:"PeriodChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newReinforcementAbility",type:"uint128"}],name:"ReinforcementAbilityChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newWithdrawTimeout",type:"uint64"}],name:"WithdrawTimeoutChanged",type:"event"},{inputs:[{internalType:"uint128",name:"amount",type:"uint128"}],name:"addLiquidity",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"addLiquidityNative",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint128",name:"initReserve",type:"uint128"},{internalType:"uint128",name:"finalReserve",type:"uint128"},{internalType:"uint48",name:"leaf",type:"uint48"},{internalType:"address",name:"oracle",type:"address"}],name:"addReserve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"azuroBet",outputs:[{internalType:"contract IAzuroBet",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcomeId",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"bet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint64",name:"outcomeId",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"betNative",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"newAzuroBet",type:"address"}],name:"changeAzuroBet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newCore",type:"address"}],name:"changeCore",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newDaoFee",type:"uint128"}],name:"changeDaoReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newMinDepo",type:"uint128"}],name:"changeMinDepo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newOracleFee",type:"uint128"}],name:"changeOracleReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newReinforcementAbility",type:"uint128"}],name:"changeReinforcementAbility",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint64",name:"newWithdrawTimeout",type:"uint64"}],name:"changeWithdrawTimeout",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimDaoReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"core",outputs:[{internalType:"contract ICore",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"daoFee",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLeaf",outputs:[{internalType:"uint48",name:"leaf",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"node",type:"uint48"},{internalType:"uint48",name:"begin",type:"uint48"},{internalType:"uint48",name:"end",type:"uint48"},{internalType:"uint48",name:"l",type:"uint48"},{internalType:"uint48",name:"r",type:"uint48"}],name:"getLeavesAmount",outputs:[{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"fromNumber",type:"uint48"}],name:"getParent",outputs:[{internalType:"uint48",name:"parentNumber",type:"uint48"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint128",name:"reinforcementAmount",type:"uint128"}],name:"getPossibilityOfReinforcement",outputs:[{internalType:"bool",name:"status",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"getReserve",outputs:[{internalType:"uint128",name:"reserve",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"address",name:"azuroBetAddress",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint128",name:"amount",type:"uint128"}],name:"lockReserve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"lockedLiquidity",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"minDepo",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"multiplier",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextNode",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"leaf",type:"uint48"}],name:"nodeWithdrawView",outputs:[{internalType:"uint128",name:"withdrawAmount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"oracleFee",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"reinforcementAbility",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalDaoRewards",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"",type:"uint48"}],name:"treeNode",outputs:[{internalType:"uint64",name:"updateId",type:"uint64"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"updateId",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"viewPayout",outputs:[{internalType:"bool",name:"",type:"bool"},{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"depNum",type:"uint48"},{internalType:"uint40",name:"percent",type:"uint40"}],name:"withdrawLiquidity",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"depNum",type:"uint48"},{internalType:"uint40",name:"percent",type:"uint40"}],name:"withdrawLiquidityNative",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"withdrawPayout",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"withdrawPayoutNative",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdrawTimeout",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"",type:"uint48"}],name:"withdrawals",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{stateMutability:"payable",type:"receive"}],AzuroBetABI=[{inputs:[],name:"OnlyLp",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"lp",type:"address"}],name:"LpChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getCoreByToken",outputs:[{internalType:"address",name:"core",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"getTokensByOwner",outputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"lpAddress",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"address",name:"core",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"string",name:"uri",type:"string"}],name:"setBaseURI",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"lp",type:"address"}],name:"setLp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],TestERC20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"dst",type:"address"},{indexed:!1,internalType:"uint256",name:"wad",type:"uint256"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"src",type:"address"},{indexed:!1,internalType:"uint256",name:"wad",type:"uint256"}],name:"Withdrawal",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bool",name:"active",type:"bool"}],name:"addPrivilegedAccounts",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:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"availableToClaim",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",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:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"claim",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"contestsDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"contestsStartDate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],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:"uint256",name:"_contestsDuration",type:"uint256"}],name:"setContestDuration",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"startDate",type:"uint256"}],name:"setContestStartDate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"wad",type:"uint256"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],state={walletProvider:null,selectedChainId:null,readContracts:{},writeContracts:{},contractAddresses:{},tokenDecimals:null,rateDecimals:null},flushState=function(){state.writeContracts={},state.readContracts={},state.tokenDecimals=null,state.rateDecimals=null},setContractAddresses=function(e){state.contractAddresses=e,flushState()},setWalletProvider=function(e){state.walletProvider=e,flushState()},setSelectedChainId=function(e){state.selectedChainId=e},CONTRACTS={core:{get address(){return state.contractAddresses.core},abi:CoreABI,decimals:18},lp:{get address(){return state.contractAddresses.lp},abi:LpABI,decimals:18},bet:{get address(){return state.contractAddresses.bet},abi:AzuroBetABI,decimals:18},token:{get address(){return state.contractAddresses.token},abi:TestERC20ABI,decimals:18}},createContract=function(e,t){var e=CONTRACTS[e.toLowerCase()],n=e.address,e=e.abi;return new Contract(n,e,t)},__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function __rest(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]]);return n}function __awaiter(e,u,p,s){return new(p=p||Promise)(function(n,t){function a(e){try{r(s.next(e))}catch(e){t(e)}}function i(e){try{r(s.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof p?t:new p(function(e){e(t)})).then(a,i)}r((s=s.apply(e,u||[])).next())})}function __generator(a,i){var r,u,p,s={label:0,sent:function(){if(1&p[0])throw p[1];return p[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(n){return function(e){var t=[n,e];if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,u&&(p=2&t[0]?u.return:t[0]?u.throw||((p=u.return)&&p.call(u),0):u.next)&&!(p=p.call(u,t[1])).done)return p;switch(u=0,(t=p?[2&t[0],p.value]:t)[0]){case 0:case 1:p=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,u=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(p=0<(p=s.trys).length&&p[p.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!p||t[1]>p[0]&&t[1]<p[3])){s.label=t[1];break}if(6===t[0]&&s.label<p[1]){s.label=p[1],p=t;break}if(p&&s.label<p[2]){s.label=p[2],s.ops.push(t);break}p[2]&&s.ops.pop(),s.trys.pop();continue}t=i.call(a,s)}catch(e){t=[6,e],u=0}finally{r=p=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var a,i,r=n.call(e),u=[];try{for(;(void 0===t||0<t--)&&!(a=r.next()).done;)u.push(a.value)}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return u}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}var ConditionStatus,config={rpcUrl:null,ipfsGateway:null},configure=function(e){Object.entries(e).forEach(function(e){var e=__read(e,2),t=e[0],e=e[1];config[t]=e})},getProvider=function(e){return 1337===state.selectedChainId?new JsonRpcProvider:state.walletProvider&&e?state.walletProvider.getSigner():new JsonRpcProvider(config.rpcUrl)},getContract=function(e,t){var n=t?state.writeContracts:state.readContracts;return n[e]||(t=getProvider(t),t=createContract(e,t),n[e]=t),n[e]},getTokenDecimals=function(){return __awaiter(void 0,void 0,void 0,function(){var t;return __generator(this,function(e){return null===state.tokenDecimals&&(t=getContract("token"),state.tokenDecimals=t.decimals()),[2,state.tokenDecimals]})})},getRateDecimals=function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){return null===state.rateDecimals&&(state.rateDecimals=9),[2,state.rateDecimals]})})},checkTestTokensClaimable=function(e){return getContract("token").availableToClaim(e)},claimTestTokens=function(e){return getContract("token",!0).claim(e)},fetchBalance=function(e){return getContract("token").balanceOf(e)},fetchGameIpfsData=function(y){return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p,s,o;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,axios.get(""+config.ipfsGateway+y,{timeout:1e4})];case 1:return s=e.sent().data,t=s.entity1Name,n=s.entity1Image,a=s.entity2Name,i=s.entity2Image,o=s.titleCountry,r=s.titleLeague,u=s.sportTypeId,p=s.leagueId,s=s.countryId,[2,{country:o,league:r,participants:[{name:t,image:n},{name:a,image:i}],leagueId:p,countryId:s,sportTypeId:u}];case 2:return o=e.sent(),console.error(o),[2,null];case 3:return[2]}})})},calculateOdd=function(e,t){var n=1/(1-1/e),t=1+t,a=t*(n-1)/(e-1),n=((n-1)/(e-1)+1)*(t-1),e=2-t;return(-1*n+Math.pow(Math.pow(n,2)+4*a*e,.5))/(2*a)+1},calculateInitialOdds=function(e,t){return[calculateOdd(e[0],t),calculateOdd(e[1],t)]},RANGE_SIZE=(!function(e){e[e.CREATED=0]="CREATED",e[e.RESOLVED=1]="RESOLVED",e[e.CANCELED=2]="CANCELED"}(ConditionStatus=ConditionStatus||{}),2e5),makeBlockRanges=function(e,t,n){void 0===n&&(n=RANGE_SIZE);for(var a=[],i=e;i<t;i+=n)i===e||i++,a.push([i,t<i+n?t:i+n]);return a},_calculateInitialOdds=function(e,t){var n=e[0].add(e[1]).toString(),e=e.map(function(e){return n/e.toString()}),t=t.toString()/1e9;return calculateInitialOdds(e,t)},fetchConditions=function(p){return __awaiter(void 0,void 0,void 0,function(){var t,n,o,y,d,a,i,r,u;return __generator(this,function(e){switch(e.label){case 0:return u=(n=p||{}).filters,t=n.from,n=n.rangeWide,r=(u=u||{}).resolved,o=void 0===r||r,r=u.canceled,y=void 0===r||r,u=getProvider(),d=getContract("core"),a=d.filters.ConditionCreated(),t?[4,u.getBlockNumber()]:[3,3];case 1:return r=e.sent(),u=makeBlockRanges(t,r,n),[4,Promise.all(u.map(function(e){var e=__read(e,2),t=e[0],e=e[1];return d.queryFilter(a,t,e)}))];case 2:return i=e.sent().flat(),[3,5];case 3:return[4,d.queryFilter(a,null==p?void 0:p.from)];case 4:i=e.sent(),e.label=5;case 5:return[4,Promise.all(i.map(function(e){var s=e.args.conditionId;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=s.toNumber(),[4,d.getCondition(s)];case 1:return(n=e.sent(),a=n.state,i=n.scopeId.toNumber(),(r=1e3*n.timestamp.toNumber())<=Date.now())?[2]:(o||a!==ConditionStatus.RESOLVED)&&(y||a!==ConditionStatus.CANCELED)?(u=_calculateInitialOdds(n.fundBank,n.margin),p=n.outcomes.map(function(e){return e.toNumber()}),[2,{id:t,outcomes:p,odds:u,gameData:{id:i,state:a,startsAt:r,ipfsHashHex:n.ipfsHash}}]):[2];case 2:return p=e.sent(),console.error(p),[2,null];case 3:return[2]}})})}))];case 6:return[2,{conditions:e.sent().filter(Boolean),latestBlock:i[i.length-1].blockNumber}]}})})},betTypeOdd={1:{outcomeRegistryId:180,marketRegistryId:9,paramId:1},2:{outcomeRegistryId:181,marketRegistryId:9,paramId:1},3:{outcomeRegistryId:7,marketRegistryId:3,paramId:96},4:{outcomeRegistryId:8,marketRegistryId:3,paramId:32},5:{outcomeRegistryId:7,marketRegistryId:3,paramId:94},6:{outcomeRegistryId:8,marketRegistryId:3,paramId:6},7:{outcomeRegistryId:7,marketRegistryId:3,paramId:36},8:{outcomeRegistryId:8,marketRegistryId:3,paramId:5},9:{outcomeRegistryId:7,marketRegistryId:3,paramId:7},10:{outcomeRegistryId:8,marketRegistryId:3,paramId:4},11:{outcomeRegistryId:7,marketRegistryId:3,paramId:1},12:{outcomeRegistryId:8,marketRegistryId:3,paramId:1},13:{outcomeRegistryId:7,marketRegistryId:3,paramId:4},14:{outcomeRegistryId:8,marketRegistryId:3,paramId:7},15:{outcomeRegistryId:7,marketRegistryId:3,paramId:5},16:{outcomeRegistryId:8,marketRegistryId:3,paramId:36},17:{outcomeRegistryId:7,marketRegistryId:3,paramId:6},18:{outcomeRegistryId:8,marketRegistryId:3,paramId:94},19:{outcomeRegistryId:7,marketRegistryId:3,paramId:32},20:{outcomeRegistryId:8,marketRegistryId:3,paramId:96},21:{outcomeRegistryId:9,marketRegistryId:4,paramId:4},22:{outcomeRegistryId:10,marketRegistryId:4,paramId:4},23:{outcomeRegistryId:9,marketRegistryId:4,paramId:5},24:{outcomeRegistryId:10,marketRegistryId:4,paramId:5},25:{outcomeRegistryId:9,marketRegistryId:4,paramId:6},26:{outcomeRegistryId:10,marketRegistryId:4,paramId:6},27:{outcomeRegistryId:9,marketRegistryId:4,paramId:32},28:{outcomeRegistryId:10,marketRegistryId:4,paramId:32},29:{outcomeRegistryId:1,marketRegistryId:1,paramId:1},30:{outcomeRegistryId:2,marketRegistryId:1,paramId:1},31:{outcomeRegistryId:3,marketRegistryId:1,paramId:1},32:{outcomeRegistryId:10009,marketRegistryId:19,paramId:1},33:{outcomeRegistryId:10010,marketRegistryId:19,paramId:1},34:{outcomeRegistryId:10009,marketRegistryId:20,paramId:1},35:{outcomeRegistryId:10010,marketRegistryId:20,paramId:1},36:{outcomeRegistryId:10009,marketRegistryId:21,paramId:1},37:{outcomeRegistryId:10010,marketRegistryId:21,paramId:1},38:{outcomeRegistryId:4,marketRegistryId:2,paramId:1},39:{outcomeRegistryId:5,marketRegistryId:2,paramId:1},40:{outcomeRegistryId:6,marketRegistryId:2,paramId:1},41:{outcomeRegistryId:10009,marketRegistryId:19,paramId:1},42:{outcomeRegistryId:10010,marketRegistryId:19,paramId:1},43:{outcomeRegistryId:1,marketRegistryId:1,paramId:1},44:{outcomeRegistryId:2,marketRegistryId:1,paramId:1},45:{outcomeRegistryId:3,marketRegistryId:1,paramId:1},46:{outcomeRegistryId:4,marketRegistryId:2,paramId:1},47:{outcomeRegistryId:5,marketRegistryId:2,paramId:1},48:{outcomeRegistryId:6,marketRegistryId:2,paramId:1}},stats={latestConditionsBlock:null},getLatestConditionsBlock=function(){return stats.latestConditionsBlock},gamesInfo={},gameBets={},groupBetVariants=function(e){var t={};return e.forEach(function(e){t[e.paramId]||(t[e.paramId]=[]),t[e.paramId].push(e)}),t},groupGames=function(){return Object.keys(gameBets).map(function(e){var e=gameBets[e],t=e.gameId,n=e.marketRegistryId,e=e.betVariants,a=groupBetVariants(e),e=Object.keys(a);return e=1===e.length?[{paramId:null,odds:a[e[0]].sort(function(e,t){return e.outcomeId-t.outcomeId})}]:Object.keys(a).map(function(e){return{paramId:parseInt(e),odds:a[e].sort(function(e,t){return t.outcomeId-e.outcomeId})}}),__assign(__assign({},gamesInfo[t]),{conditions:e,marketRegistryId:n})})},groupOddsByOutcomes=function(e){var u=e.gameId,p=e.conditionId,t=e.outcomes,s=e.odds;return t.map(function(e,t){var n,a,i,r,t=s[t];betTypeOdd[e]?(n=(a=betTypeOdd[e]).outcomeRegistryId,r=a.marketRegistryId,a=a.paramId,gameBets[i=u+"-"+r]||(gameBets[i]={gameId:u,marketRegistryId:r,betVariants:[]}),r={conditionId:p,outcomeId:e,outcomeRegistryId:n,paramId:a,value:t},gameBets[i].betVariants.push(r)):console.warn("Unknown outcomeId "+e+". Please update the Azuro SDK version")})},fetchGames=function(a){return void 0===a&&(a={}),__awaiter(void 0,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return gamesInfo={},gameBets={},[4,fetchConditions(a)];case 1:return t=e.sent(),n=t.conditions,t=t.latestBlock,n.forEach(function(e){var t=e.id,n=e.outcomes,a=e.odds,e=e.gameData;gamesInfo[e.id]=e,groupOddsByOutcomes({gameId:e.id,conditionId:t,outcomes:n,odds:a})}),n=groupGames(),[4,Promise.all(n.map(function(i){return __awaiter(void 0,void 0,void 0,function(){var t,n,a;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),n=i.ipfsHashHex,t=__rest(i,["ipfsHashHex"]),n=utils.arrayify(n),n=utils.base58.encode(__spread([18,32],n)),[4,fetchGameIpfsData(n)];case 1:return(n=e.sent())?[2,__assign(__assign({},n),t)]:[2,null];case 2:return a=e.sent(),console.error(a),[2,null];case 3:return[2]}})})}))];case 2:return n=e.sent(),stats.latestConditionsBlock=t,[2,n.filter(Boolean).sort(function(e,t){return e.startsAt-t.startsAt})]}})})},calculateActualOdds=function(e){var p=e.conditionId,s=e.outcomeId,o=e.betAmount;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u;return __generator(this,function(e){switch(e.label){case 0:return t=parseUnits,n=[String(o)],[4,getTokenDecimals()];case 1:return a=t.apply(void 0,n.concat([e.sent()])),[4,getContract("core").calculateOdds(p,a,s)];case 2:return a=e.sent(),r=formatUnits,u=[a],[4,getRateDecimals()];case 3:return i=r.apply(void 0,u.concat([e.sent()])),[2,parseFloat(i)]}})})},fetchAllowance=function(e){return getContract("token").allowance(e,CONTRACTS.lp.address)},approve=function(e){return getContract("token",!0).approve(CONTRACTS.lp.address,e)},placeBet=function(m){return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p,s,o,d,y,l;return __generator(this,function(e){switch(e.label){case 0:return t=m.conditionId,n=m.outcomeId,s=m.amount,a=m.betRate,i=m.slippage,r=getContract("lp",!0),p=parseUnits,s=[String(s)],[4,getTokenDecimals()];case 1:return u=p.apply(void 0,s.concat([e.sent()])),y=(1+(a-1)*(100-i)/100).toFixed(8),d=parseUnits,y=[y],[4,getRateDecimals()];case 2:return o=d.apply(void 0,y.concat([e.sent()])),l=Math.floor(Date.now()/1e3)+2e3,[2,r.bet(t,u,n,l,o)]}})})},fetchBet=function(B){return __awaiter(void 0,void 0,void 0,function(){var t,n,d,l,m,c,a,i,T,r,u,f,b,I,p,s,o,g,v,w,M,R,k,h,C,x,O,A,_,y;return __generator(this,function(e){switch(e.label){case 0:t=getContract("core"),e.label=1;case 1:return e.trys.push([1,7,,8]),[4,t.bets(B)];case 2:return a=e.sent(),n=a.conditionId,d=a.amount,l=a.outcome,m=a.odds,c=a.payed,a=a.createdAt,[4,t.getCondition(n)];case 3:return r=e.sent(),u=r.scopeId,i=r.state,o=r.ipfsHash,T=r.timestamp,r=r.outcomeWin,u=u.toNumber(),f=n.toNumber(),o=utils.arrayify(o),o=utils.base58.encode(__spread([18,32],o)),[4,fetchGameIpfsData(o)];case 4:return(b=e.sent())?(I=1e3*T.toNumber(),p=l.toNumber(),s=r.toNumber(),betTypeOdd[p]?(o=betTypeOdd[p],g=o.marketRegistryId,v=o.outcomeRegistryId,w=o.paramId,R=parseFloat,k=formatUnits,h=[m],[4,getRateDecimals()]):(console.warn("Unknown outcomeId "+p+". Please update the Azuro SDK version"),[2])):[2];case 5:return M=R.apply(void 0,[k.apply(void 0,h.concat([e.sent()]))]),C=parseFloat,x=formatUnits,O=[d],[4,getTokenDecimals()];case 6:return y=C.apply(void 0,[x.apply(void 0,O.concat([e.sent()]))]),A=void 0,A=i===ConditionStatus.CANCELED?y:0===s?null:s===p?(y*M).toFixed(6):-1*y,_=__assign(__assign({id:u},b),{startsAt:I,state:i}),[2,{nftId:B,conditionId:f,paramId:w,marketRegistryId:g,outcomeRegistryId:v,rate:M,amount:y,result:A,createdAt:1e3*a.toNumber(),isRedeemed:c,gameInfo:_}];case 7:return y=e.sent(),console.error(y),[2,null];case 8:return[2]}})})},fetchUserBets=function(e){var u=e.account;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r;return __generator(this,function(e){switch(e.label){case 0:e.trys.push([0,8,,9]),n=void(t=0),a=[],i=getContract("bet"),e.label=1;case 1:if(0!==t&&!n)return[3,6];e.label=2;case 2:return e.trys.push([2,4,,5]),[4,i.tokenOfOwnerByIndex(u,t++)];case 3:return n=e.sent(),a.push(n.toNumber()),[3,5];case 4:return e.sent(),n=null,[3,5];case 5:return[3,1];case 6:return[4,Promise.all(a.map(fetchBet))];case 7:return[2,e.sent().filter(Boolean).sort(function(e,t){return t.createdAt-e.createdAt})];case 8:return r=e.sent(),console.error(r),[2,[]];case 9:return[2]}})})},redeemBetPrize=function(e){return getContract("lp",!0).withdrawPayout(e)};export{approve,calculateActualOdds,checkTestTokensClaimable,claimTestTokens,configure,fetchAllowance,fetchBalance,fetchGames,fetchUserBets,getLatestConditionsBlock,placeBet,redeemBetPrize as redeemPrize,setContractAddresses,setSelectedChainId,setWalletProvider}; | ||
import{Contract}from"@ethersproject/contracts";import{JsonRpcProvider}from"@ethersproject/providers";import{utils}from"ethers";import axios from"axios";import{formatUnits,parseUnits}from"@ethersproject/units";var CoreABI=[{inputs:[],name:"BetNotAllowed",type:"error"},{inputs:[],name:"BigDifference",type:"error"},{inputs:[],name:"CantAcceptBet",type:"error"},{inputs:[],name:"CantChangeFlag",type:"error"},{inputs:[],name:"ConditionAlreadyCreated",type:"error"},{inputs:[],name:"ConditionAlreadyResolved",type:"error"},{inputs:[],name:"ConditionNotExists",type:"error"},{inputs:[],name:"ConditionNotStarted",type:"error"},{inputs:[],name:"ConditionStarted",type:"error"},{inputs:[],name:"FlagAlreadySet",type:"error"},{inputs:[],name:"IncorrectTimestamp",type:"error"},{inputs:[],name:"NotEnoughLiquidity",type:"error"},{inputs:[],name:"OnlyLp",type:"error"},{inputs:[],name:"OnlyMaintainer",type:"error"},{inputs:[],name:"OnlyOracle",type:"error"},{inputs:[{internalType:"uint64",name:"waitTime",type:"uint64"}],name:"ResolveTooEarly",type:"error"},{inputs:[],name:"SameOutcomes",type:"error"},{inputs:[],name:"SmallBet",type:"error"},{inputs:[],name:"SmallOdds",type:"error"},{inputs:[],name:"WrongDataFormat",type:"error"},{inputs:[],name:"WrongOutcome",type:"error"},{inputs:[],name:"ZeroOdds",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"flag",type:"bool"}],name:"AllConditionsStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oracleConditionId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"timestamp",type:"uint64"}],name:"ConditionCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oracleConditionId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"outcomeWin",type:"uint64"},{indexed:!1,internalType:"uint8",name:"state",type:"uint8"},{indexed:!1,internalType:"uint256",name:"amountForLp",type:"uint256"}],name:"ConditionResolved",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"newTimestamp",type:"uint64"}],name:"ConditionShifted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"bool",name:"flag",type:"bool"}],name:"ConditionStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newLp",type:"address"}],name:"LpChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"maintainer",type:"address"},{indexed:!1,internalType:"bool",name:"active",type:"bool"}],name:"MaintainerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newRatio",type:"uint64"}],name:"MaxBanksRatioChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newOracle",type:"address"}],name:"OracleAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oracle",type:"address"}],name:"OracleRenounced",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{inputs:[],name:"LP",outputs:[{internalType:"contract ILP",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"maintainer",type:"address"},{internalType:"bool",name:"active",type:"bool"}],name:"addMaintainer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"allConditionsStopped",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"bets",outputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"},{internalType:"uint64",name:"createdAt",type:"uint64"},{internalType:"uint64",name:"odds",type:"uint64"},{internalType:"bool",name:"payed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"}],name:"calculateOdds",outputs:[{internalType:"uint64",name:"odds",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"cancelByMaintainer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"oracleConditionId",type:"uint256"}],name:"cancelByOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"a",type:"uint256"},{internalType:"uint256",name:"m",type:"uint256"}],name:"ceil",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint64",name:"newRatio",type:"uint64"}],name:"changeMaxBanksRatio",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"conditions",outputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"uint128",name:"margin",type:"uint128"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64",name:"outcomeWin",type:"uint64"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"enum ICore.ConditionState",name:"state",type:"uint8"},{internalType:"uint48",name:"leaf",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"oracleCondId",type:"uint256"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64[2]",name:"odds",type:"uint64[2]"},{internalType:"uint64[2]",name:"outcomes",type:"uint64[2]"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"}],name:"createCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"defaultMargin",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultReinforcement",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"betId",type:"uint256"}],name:"getBetInfo",outputs:[{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"odds",type:"uint64"},{internalType:"uint64",name:"createdAt",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getCondition",outputs:[{components:[{internalType:"uint128[2]",name:"fundBank",type:"uint128[2]"},{internalType:"uint128[2]",name:"payouts",type:"uint128[2]"},{internalType:"uint128[2]",name:"totalNetBets",type:"uint128[2]"},{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"uint128",name:"margin",type:"uint128"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{internalType:"uint64[2]",name:"outcomes",type:"uint64[2]"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64",name:"outcomeWin",type:"uint64"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"enum ICore.ConditionState",name:"state",type:"uint8"},{internalType:"uint48",name:"leaf",type:"uint48"}],internalType:"struct ICore.Condition",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getConditionFunds",outputs:[{internalType:"uint128[2]",name:"fundBank",type:"uint128[2]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getConditionReinforcement",outputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLockedPayout",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint64",name:"outcomeId",type:"uint64"}],name:"getMargin",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"fund1Bank",type:"uint256"},{internalType:"uint256",name:"fund2Bank",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outcomeIndex",type:"uint256"},{internalType:"uint256",name:"margin",type:"uint256"},{internalType:"uint256",name:"multiplier",type:"uint256"}],name:"getOddsFromBanks",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint64",name:"outcomeId",type:"uint64"}],name:"getReinforcement",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"address",name:"oracle",type:"address"},{internalType:"uint128",name:"margin",type:"uint128"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"isOracle",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint256",name:"outcome",type:"uint256"}],name:"isOutComeCorrect",outputs:[{internalType:"bool",name:"correct",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"lastConditionId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"maintainers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"odds",type:"uint256"},{internalType:"uint256",name:"marginality",type:"uint256"},{internalType:"uint256",name:"multiplier",type:"uint256"}],name:"marginAdjustedOdds",outputs:[{internalType:"uint256",name:"newOdds",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[],name:"maxBanksRatio",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"multiplier",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"oracleConditionIds",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"oracles",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"putBet",outputs:[{internalType:"uint64",name:"",type:"uint64"},{internalType:"uint128",name:"",type:"uint128"},{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"renounceOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"oracleCondId",type:"uint256"},{internalType:"uint64",name:"outcomeWin",type:"uint64"}],name:"resolveCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"resolvePayout",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"lp",type:"address"}],name:"setLp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"setOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint64",name:"newTimestamp",type:"uint64"}],name:"shift",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"x",type:"uint256"}],name:"sqrt",outputs:[{internalType:"uint256",name:"y",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bool",name:"flag",type:"bool"}],name:"stopAllConditions",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"bool",name:"flag",type:"bool"}],name:"stopCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalLockedPayout",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128[]",name:"data",type:"uint128[]"}],name:"updateMargins",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128[]",name:"data",type:"uint128[]"}],name:"updateReinforcements",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"viewPayout",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"}],LpABI=[{inputs:[],name:"AmountMustNotBeZero",type:"error"},{inputs:[],name:"AmountNotSufficient",type:"error"},{inputs:[],name:"ConditionStarted",type:"error"},{inputs:[],name:"IncorrectPercent",type:"error"},{inputs:[],name:"LeafNotExist",type:"error"},{inputs:[],name:"LiquidityIsLocked",type:"error"},{inputs:[],name:"LiquidityNotOwned",type:"error"},{inputs:[],name:"NoDaoReward",type:"error"},{inputs:[],name:"NoLiquidity",type:"error"},{inputs:[],name:"NoWinNoPrize",type:"error"},{inputs:[],name:"NotEnoughReserves",type:"error"},{inputs:[],name:"OnlyBetOwner",type:"error"},{inputs:[],name:"OnlyCore",type:"error"},{inputs:[],name:"PaymentLocked",type:"error"},{inputs:[{internalType:"uint64",name:"waitTime",type:"uint64"}],name:"WithdrawalTimeout",type:"error"},{inputs:[],name:"WrongToken",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"newAzuroBet",type:"address"}],name:"AzuroBetChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"better",type:"address"},{indexed:!1,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"BetterWin",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newDaoFee",type:"uint128"}],name:"DaoRewardChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"uint48",name:"leaf",type:"uint48"}],name:"LiquidityAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"LiquidityRemoved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"requestWallet",type:"address"},{indexed:!1,internalType:"uint256",name:"requestedValueLp",type:"uint256"}],name:"LiquidityRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newMinDepo",type:"uint128"}],name:"MinDepoChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"uint256",name:"betId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"outcomeId",type:"uint64"},{indexed:!1,internalType:"uint128",name:"amount",type:"uint128"},{indexed:!1,internalType:"uint256",name:"odds",type:"uint256"},{indexed:!1,internalType:"uint128",name:"fund1",type:"uint128"},{indexed:!1,internalType:"uint128",name:"fund2",type:"uint128"}],name:"NewBet",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newOracleFee",type:"uint128"}],name:"OracleRewardChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newPeriod",type:"uint64"}],name:"PeriodChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newReinforcementAbility",type:"uint128"}],name:"ReinforcementAbilityChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newWithdrawTimeout",type:"uint64"}],name:"WithdrawTimeoutChanged",type:"event"},{inputs:[{internalType:"uint128",name:"amount",type:"uint128"}],name:"addLiquidity",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"addLiquidityNative",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint128",name:"initReserve",type:"uint128"},{internalType:"uint128",name:"finalReserve",type:"uint128"},{internalType:"uint48",name:"leaf",type:"uint48"},{internalType:"address",name:"oracle",type:"address"}],name:"addReserve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"azuroBet",outputs:[{internalType:"contract IAzuroBet",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcomeId",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"bet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint64",name:"outcomeId",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"betNative",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"newAzuroBet",type:"address"}],name:"changeAzuroBet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newCore",type:"address"}],name:"changeCore",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newDaoFee",type:"uint128"}],name:"changeDaoReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newMinDepo",type:"uint128"}],name:"changeMinDepo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newOracleFee",type:"uint128"}],name:"changeOracleReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newReinforcementAbility",type:"uint128"}],name:"changeReinforcementAbility",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint64",name:"newWithdrawTimeout",type:"uint64"}],name:"changeWithdrawTimeout",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimDaoReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"core",outputs:[{internalType:"contract ICore",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"daoFee",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLeaf",outputs:[{internalType:"uint48",name:"leaf",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"node",type:"uint48"},{internalType:"uint48",name:"begin",type:"uint48"},{internalType:"uint48",name:"end",type:"uint48"},{internalType:"uint48",name:"l",type:"uint48"},{internalType:"uint48",name:"r",type:"uint48"}],name:"getLeavesAmount",outputs:[{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"fromNumber",type:"uint48"}],name:"getParent",outputs:[{internalType:"uint48",name:"parentNumber",type:"uint48"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint128",name:"reinforcementAmount",type:"uint128"}],name:"getPossibilityOfReinforcement",outputs:[{internalType:"bool",name:"status",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"getReserve",outputs:[{internalType:"uint128",name:"reserve",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"address",name:"azuroBetAddress",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint128",name:"amount",type:"uint128"}],name:"lockReserve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"lockedLiquidity",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"minDepo",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"multiplier",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextNode",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"leaf",type:"uint48"}],name:"nodeWithdrawView",outputs:[{internalType:"uint128",name:"withdrawAmount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"oracleFee",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"reinforcementAbility",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalDaoRewards",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"",type:"uint48"}],name:"treeNode",outputs:[{internalType:"uint64",name:"updateId",type:"uint64"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"updateId",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"viewPayout",outputs:[{internalType:"bool",name:"",type:"bool"},{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"depNum",type:"uint48"},{internalType:"uint40",name:"percent",type:"uint40"}],name:"withdrawLiquidity",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"depNum",type:"uint48"},{internalType:"uint40",name:"percent",type:"uint40"}],name:"withdrawLiquidityNative",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"withdrawPayout",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"withdrawPayoutNative",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdrawTimeout",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"",type:"uint48"}],name:"withdrawals",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{stateMutability:"payable",type:"receive"}],AzuroBetABI=[{inputs:[],name:"OnlyLp",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"lp",type:"address"}],name:"LpChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getCoreByToken",outputs:[{internalType:"address",name:"core",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"getTokensByOwner",outputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"lpAddress",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"address",name:"core",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"string",name:"uri",type:"string"}],name:"setBaseURI",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"lp",type:"address"}],name:"setLp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],TestERC20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"dst",type:"address"},{indexed:!1,internalType:"uint256",name:"wad",type:"uint256"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"src",type:"address"},{indexed:!1,internalType:"uint256",name:"wad",type:"uint256"}],name:"Withdrawal",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bool",name:"active",type:"bool"}],name:"addPrivilegedAccounts",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:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"availableToClaim",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",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:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"claim",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"contestsDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"contestsStartDate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],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:"uint256",name:"_contestsDuration",type:"uint256"}],name:"setContestDuration",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"startDate",type:"uint256"}],name:"setContestStartDate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"wad",type:"uint256"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],state={walletProvider:null,selectedChainId:null,readContracts:{},writeContracts:{},contractAddresses:{},tokenDecimals:null,rateDecimals:null},flushState=function(){state.writeContracts={},state.readContracts={},state.tokenDecimals=null,state.rateDecimals=null},setContractAddresses=function(e){state.contractAddresses=e,flushState()},setWalletProvider=function(e){state.walletProvider=e,flushState()},setSelectedChainId=function(e){state.selectedChainId=e},CONTRACTS={core:{get address(){return state.contractAddresses.core},abi:CoreABI,decimals:18},lp:{get address(){return state.contractAddresses.lp},abi:LpABI,decimals:18},bet:{get address(){return state.contractAddresses.bet},abi:AzuroBetABI,decimals:18},token:{get address(){return state.contractAddresses.token},abi:TestERC20ABI,decimals:18}},createContract=function(e,t){var e=CONTRACTS[e.toLowerCase()],n=e.address,e=e.abi;return new Contract(n,e,t)},__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function __rest(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]]);return n}function __awaiter(e,r,p,s){return new(p=p||Promise)(function(n,t){function a(e){try{u(s.next(e))}catch(e){t(e)}}function i(e){try{u(s.throw(e))}catch(e){t(e)}}function u(e){var t;e.done?n(e.value):((t=e.value)instanceof p?t:new p(function(e){e(t)})).then(a,i)}u((s=s.apply(e,r||[])).next())})}function __generator(a,i){var u,r,p,s={label:0,sent:function(){if(1&p[0])throw p[1];return p[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(n){return function(e){var t=[n,e];if(u)throw new TypeError("Generator is already executing.");for(;s;)try{if(u=1,r&&(p=2&t[0]?r.return:t[0]?r.throw||((p=r.return)&&p.call(r),0):r.next)&&!(p=p.call(r,t[1])).done)return p;switch(r=0,(t=p?[2&t[0],p.value]:t)[0]){case 0:case 1:p=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,r=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(p=0<(p=s.trys).length&&p[p.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!p||t[1]>p[0]&&t[1]<p[3])){s.label=t[1];break}if(6===t[0]&&s.label<p[1]){s.label=p[1],p=t;break}if(p&&s.label<p[2]){s.label=p[2],s.ops.push(t);break}p[2]&&s.ops.pop(),s.trys.pop();continue}t=i.call(a,s)}catch(e){t=[6,e],r=0}finally{u=p=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var a,i,u=n.call(e),r=[];try{for(;(void 0===t||0<t--)&&!(a=u.next()).done;)r.push(a.value)}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(i)throw i.error}}return r}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}var ConditionStatus,config={rpcUrl:null,ipfsGateway:null},configure=function(e){Object.entries(e).forEach(function(e){var e=__read(e,2),t=e[0],e=e[1];config[t]=e})},getProvider=function(e){return 1337===state.selectedChainId?new JsonRpcProvider:state.walletProvider&&e?state.walletProvider.getSigner():new JsonRpcProvider(config.rpcUrl)},getContract=function(e,t){var n=t?state.writeContracts:state.readContracts;return n[e]||(t=getProvider(t),t=createContract(e,t),n[e]=t),n[e]},getTokenDecimals=function(){return __awaiter(void 0,void 0,void 0,function(){var t;return __generator(this,function(e){return null===state.tokenDecimals&&(t=getContract("token"),state.tokenDecimals=t.decimals()),[2,state.tokenDecimals]})})},getRateDecimals=function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){return null===state.rateDecimals&&(state.rateDecimals=9),[2,state.rateDecimals]})})},checkTestTokensClaimable=function(e){return getContract("token").availableToClaim(e)},claimTestTokens=function(e){return getContract("token",!0).claim(e)},fetchBalance=function(e){return getContract("token").balanceOf(e)},fetchGameIpfsData=function(y){return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,u,r,p,s,o;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,axios.get(""+config.ipfsGateway+y,{timeout:1e4})];case 1:return s=e.sent().data,t=s.entity1Name,n=s.entity1Image,a=s.entity2Name,i=s.entity2Image,o=s.titleCountry,u=s.titleLeague,r=s.sportTypeId,p=s.leagueId,s=s.countryId,[2,{country:o,league:u,participants:[{name:t,image:n},{name:a,image:i}],leagueId:p,countryId:s,sportTypeId:r}];case 2:return o=e.sent(),console.error(o),[2,null];case 3:return[2]}})})},calculateOdd=function(e,t){var n=1/(1-1/e),t=1+t,a=t*(n-1)/(e-1),n=((n-1)/(e-1)+1)*(t-1),e=2-t;return(-1*n+Math.pow(Math.pow(n,2)+4*a*e,.5))/(2*a)+1},calculateInitialOdds=function(e,t){return[calculateOdd(e[0],t),calculateOdd(e[1],t)]},RANGE_SIZE=(!function(e){e[e.CREATED=0]="CREATED",e[e.RESOLVED=1]="RESOLVED",e[e.CANCELED=2]="CANCELED"}(ConditionStatus=ConditionStatus||{}),2e5),makeBlockRanges=function(e,t,n){void 0===n&&(n=RANGE_SIZE);for(var a=[],i=e;i<t;i+=n)i===e||i++,a.push([i,t<i+n?t:i+n]);return a},_calculateInitialOdds=function(e,t){var n=e[0].add(e[1]).toString(),e=e.map(function(e){return n/e.toString()}),t=t.toString()/1e9;return calculateInitialOdds(e,t)},fetchConditions=function(s){return __awaiter(void 0,void 0,void 0,function(){var t,n,o,y,d,a,i,u,r,p;return __generator(this,function(e){switch(e.label){case 0:return r=(n=s||{}).filters,t=n.from,n=n.rangeWide,u=(r=r||{}).resolved,o=void 0===u||u,u=r.canceled,y=void 0===u||u,r=getProvider(),d=getContract("core"),a=d.filters.ConditionCreated(),t?[4,r.getBlockNumber()]:[3,3];case 1:return u=e.sent(),r=makeBlockRanges(t,u,n),[4,Promise.all(r.map(function(e){var e=__read(e,2),t=e[0],e=e[1];return d.queryFilter(a,t,e)}))];case 2:return i=e.sent().flat(),[3,5];case 3:return[4,d.queryFilter(a,null==s?void 0:s.from)];case 4:i=e.sent(),e.label=5;case 5:return[4,Promise.all(i.map(function(e){var s=e.args.conditionId;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,u,r,p;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=s.toNumber(),[4,d.getCondition(s)];case 1:return(n=e.sent(),a=n.state,i=n.scopeId.toNumber(),(u=1e3*n.timestamp.toNumber())<=Date.now())?[2]:(o||a!==ConditionStatus.RESOLVED)&&(y||a!==ConditionStatus.CANCELED)?(r=_calculateInitialOdds(n.fundBank,n.margin),p=n.outcomes.map(function(e){return e.toNumber()}),[2,{id:t,outcomes:p,odds:r,gameData:{id:i,state:a,startsAt:u,ipfsHashHex:n.ipfsHash}}]):[2];case 2:return p=e.sent(),console.error(p),[2,null];case 3:return[2]}})})}))];case 6:return[2,{conditions:e.sent().filter(Boolean),latestBlock:null===(p=i[i.length-1])||void 0===p?void 0:p.blockNumber}]}})})},betTypeOdd={1:{outcomeRegistryId:180,marketRegistryId:9,paramId:1},2:{outcomeRegistryId:181,marketRegistryId:9,paramId:1},3:{outcomeRegistryId:7,marketRegistryId:3,paramId:96},4:{outcomeRegistryId:8,marketRegistryId:3,paramId:32},5:{outcomeRegistryId:7,marketRegistryId:3,paramId:94},6:{outcomeRegistryId:8,marketRegistryId:3,paramId:6},7:{outcomeRegistryId:7,marketRegistryId:3,paramId:36},8:{outcomeRegistryId:8,marketRegistryId:3,paramId:5},9:{outcomeRegistryId:7,marketRegistryId:3,paramId:7},10:{outcomeRegistryId:8,marketRegistryId:3,paramId:4},11:{outcomeRegistryId:7,marketRegistryId:3,paramId:1},12:{outcomeRegistryId:8,marketRegistryId:3,paramId:1},13:{outcomeRegistryId:7,marketRegistryId:3,paramId:4},14:{outcomeRegistryId:8,marketRegistryId:3,paramId:7},15:{outcomeRegistryId:7,marketRegistryId:3,paramId:5},16:{outcomeRegistryId:8,marketRegistryId:3,paramId:36},17:{outcomeRegistryId:7,marketRegistryId:3,paramId:6},18:{outcomeRegistryId:8,marketRegistryId:3,paramId:94},19:{outcomeRegistryId:7,marketRegistryId:3,paramId:32},20:{outcomeRegistryId:8,marketRegistryId:3,paramId:96},21:{outcomeRegistryId:9,marketRegistryId:4,paramId:4},22:{outcomeRegistryId:10,marketRegistryId:4,paramId:4},23:{outcomeRegistryId:9,marketRegistryId:4,paramId:5},24:{outcomeRegistryId:10,marketRegistryId:4,paramId:5},25:{outcomeRegistryId:9,marketRegistryId:4,paramId:6},26:{outcomeRegistryId:10,marketRegistryId:4,paramId:6},27:{outcomeRegistryId:9,marketRegistryId:4,paramId:32},28:{outcomeRegistryId:10,marketRegistryId:4,paramId:32},29:{outcomeRegistryId:1,marketRegistryId:1,paramId:1},30:{outcomeRegistryId:2,marketRegistryId:1,paramId:1},31:{outcomeRegistryId:3,marketRegistryId:1,paramId:1},32:{outcomeRegistryId:10009,marketRegistryId:19,paramId:1},33:{outcomeRegistryId:10010,marketRegistryId:19,paramId:1},34:{outcomeRegistryId:10009,marketRegistryId:20,paramId:1},35:{outcomeRegistryId:10010,marketRegistryId:20,paramId:1},36:{outcomeRegistryId:10009,marketRegistryId:21,paramId:1},37:{outcomeRegistryId:10010,marketRegistryId:21,paramId:1},38:{outcomeRegistryId:4,marketRegistryId:2,paramId:1},39:{outcomeRegistryId:5,marketRegistryId:2,paramId:1},40:{outcomeRegistryId:6,marketRegistryId:2,paramId:1},41:{outcomeRegistryId:10009,marketRegistryId:19,paramId:1},42:{outcomeRegistryId:10010,marketRegistryId:19,paramId:1},43:{outcomeRegistryId:1,marketRegistryId:1,paramId:1},44:{outcomeRegistryId:2,marketRegistryId:1,paramId:1},45:{outcomeRegistryId:3,marketRegistryId:1,paramId:1},46:{outcomeRegistryId:4,marketRegistryId:2,paramId:1},47:{outcomeRegistryId:5,marketRegistryId:2,paramId:1},48:{outcomeRegistryId:6,marketRegistryId:2,paramId:1}},stats={latestConditionsBlock:null},getLatestConditionsBlock=function(){return stats.latestConditionsBlock},gamesInfo={},gameBets={},groupBetVariants=function(e){var t={};return e.forEach(function(e){t[e.paramId]||(t[e.paramId]=[]),t[e.paramId].push(e)}),t},groupGames=function(){return Object.keys(gameBets).map(function(e){var e=gameBets[e],t=e.gameId,n=e.marketRegistryId,e=e.betVariants,a=groupBetVariants(e),e=Object.keys(a);return e=1===e.length?[{paramId:null,odds:a[e[0]].sort(function(e,t){return e.outcomeId-t.outcomeId})}]:Object.keys(a).map(function(e){return{paramId:parseInt(e),odds:a[e].sort(function(e,t){return t.outcomeId-e.outcomeId})}}),__assign(__assign({},gamesInfo[t]),{conditions:e,marketRegistryId:n})})},groupOddsByOutcomes=function(e){var r=e.gameId,p=e.conditionId,t=e.outcomes,s=e.odds;return t.map(function(e,t){var n,a,i,u,t=s[t];betTypeOdd[e]?(n=(a=betTypeOdd[e]).outcomeRegistryId,u=a.marketRegistryId,a=a.paramId,gameBets[i=r+"-"+u]||(gameBets[i]={gameId:r,marketRegistryId:u,betVariants:[]}),u={conditionId:p,outcomeId:e,outcomeRegistryId:n,paramId:a,value:t},gameBets[i].betVariants.push(u)):console.warn("Unknown outcomeId "+e+". Please update the Azuro SDK version")})},fetchGames=function(a){return void 0===a&&(a={}),__awaiter(void 0,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return gamesInfo={},gameBets={},[4,fetchConditions(a)];case 1:return t=e.sent(),n=t.conditions,t=t.latestBlock,n.forEach(function(e){var t=e.id,n=e.outcomes,a=e.odds,e=e.gameData;gamesInfo[e.id]=e,groupOddsByOutcomes({gameId:e.id,conditionId:t,outcomes:n,odds:a})}),n=groupGames(),[4,Promise.all(n.map(function(i){return __awaiter(void 0,void 0,void 0,function(){var t,n,a;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),n=i.ipfsHashHex,t=__rest(i,["ipfsHashHex"]),n=utils.arrayify(n),n=utils.base58.encode(__spread([18,32],n)),[4,fetchGameIpfsData(n)];case 1:return(n=e.sent())?[2,__assign(__assign({},n),t)]:[2,null];case 2:return a=e.sent(),console.error(a),[2,null];case 3:return[2]}})})}))];case 2:return n=e.sent(),stats.latestConditionsBlock=t,[2,n.filter(Boolean).sort(function(e,t){return e.startsAt-t.startsAt})]}})})},calculateActualOdds=function(e){var p=e.conditionId,s=e.outcomeId,o=e.betAmount;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,u,r;return __generator(this,function(e){switch(e.label){case 0:return t=parseUnits,n=[String(o)],[4,getTokenDecimals()];case 1:return a=t.apply(void 0,n.concat([e.sent()])),[4,getContract("core").calculateOdds(p,a,s)];case 2:return a=e.sent(),u=formatUnits,r=[a],[4,getRateDecimals()];case 3:return i=u.apply(void 0,r.concat([e.sent()])),[2,parseFloat(i)]}})})},fetchAllowance=function(e){return getContract("token").allowance(e,CONTRACTS.lp.address)},approve=function(e){return getContract("token",!0).approve(CONTRACTS.lp.address,e)},placeBet=function(m){return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,u,r,p,s,o,d,y,l;return __generator(this,function(e){switch(e.label){case 0:return t=m.conditionId,n=m.outcomeId,s=m.amount,a=m.betRate,i=m.slippage,u=getContract("lp",!0),p=parseUnits,s=[String(s)],[4,getTokenDecimals()];case 1:return r=p.apply(void 0,s.concat([e.sent()])),y=(1+(a-1)*(100-i)/100).toFixed(8),d=parseUnits,y=[y],[4,getRateDecimals()];case 2:return o=d.apply(void 0,y.concat([e.sent()])),l=Math.floor(Date.now()/1e3)+2e3,[2,u.bet(t,r,n,l,o)]}})})},fetchBet=function(B){return __awaiter(void 0,void 0,void 0,function(){var t,n,d,l,m,c,a,i,T,u,r,f,b,I,p,s,o,g,v,w,M,R,k,h,C,x,O,A,_,y;return __generator(this,function(e){switch(e.label){case 0:t=getContract("core"),e.label=1;case 1:return e.trys.push([1,7,,8]),[4,t.bets(B)];case 2:return a=e.sent(),n=a.conditionId,d=a.amount,l=a.outcome,m=a.odds,c=a.payed,a=a.createdAt,[4,t.getCondition(n)];case 3:return u=e.sent(),r=u.scopeId,i=u.state,o=u.ipfsHash,T=u.timestamp,u=u.outcomeWin,r=r.toNumber(),f=n.toNumber(),o=utils.arrayify(o),o=utils.base58.encode(__spread([18,32],o)),[4,fetchGameIpfsData(o)];case 4:return(b=e.sent())?(I=1e3*T.toNumber(),p=l.toNumber(),s=u.toNumber(),betTypeOdd[p]?(o=betTypeOdd[p],g=o.marketRegistryId,v=o.outcomeRegistryId,w=o.paramId,R=parseFloat,k=formatUnits,h=[m],[4,getRateDecimals()]):(console.warn("Unknown outcomeId "+p+". Please update the Azuro SDK version"),[2])):[2];case 5:return M=R.apply(void 0,[k.apply(void 0,h.concat([e.sent()]))]),C=parseFloat,x=formatUnits,O=[d],[4,getTokenDecimals()];case 6:return y=C.apply(void 0,[x.apply(void 0,O.concat([e.sent()]))]),A=void 0,A=i===ConditionStatus.CANCELED?y:0===s?null:s===p?(y*M).toFixed(6):-1*y,_=__assign(__assign({id:r},b),{startsAt:I,state:i}),[2,{nftId:B,conditionId:f,paramId:w,marketRegistryId:g,outcomeRegistryId:v,rate:M,amount:y,result:A,createdAt:1e3*a.toNumber(),isRedeemed:c,gameInfo:_}];case 7:return y=e.sent(),console.error(y),[2,null];case 8:return[2]}})})},fetchUserBets=function(e){var r=e.account;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,u;return __generator(this,function(e){switch(e.label){case 0:e.trys.push([0,8,,9]),n=void(t=0),a=[],i=getContract("bet"),e.label=1;case 1:if(0!==t&&!n)return[3,6];e.label=2;case 2:return e.trys.push([2,4,,5]),[4,i.tokenOfOwnerByIndex(r,t++)];case 3:return n=e.sent(),a.push(n.toNumber()),[3,5];case 4:return e.sent(),n=null,[3,5];case 5:return[3,1];case 6:return[4,Promise.all(a.map(fetchBet))];case 7:return[2,e.sent().filter(Boolean).sort(function(e,t){return t.createdAt-e.createdAt})];case 8:return u=e.sent(),console.error(u),[2,[]];case 9:return[2]}})})},redeemBetPrize=function(e){return getContract("lp",!0).withdrawPayout(e)};export{approve,calculateActualOdds,checkTestTokensClaimable,claimTestTokens,configure,fetchAllowance,fetchBalance,fetchGames,fetchUserBets,getLatestConditionsBlock,placeBet,redeemBetPrize as redeemPrize,setContractAddresses,setSelectedChainId,setWalletProvider}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var contracts=require("@ethersproject/contracts"),providers=require("@ethersproject/providers"),ethers=require("ethers"),axios=require("axios"),units=require("@ethersproject/units");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var axios__default=_interopDefaultLegacy(axios),CoreABI=[{inputs:[],name:"BetNotAllowed",type:"error"},{inputs:[],name:"BigDifference",type:"error"},{inputs:[],name:"CantAcceptBet",type:"error"},{inputs:[],name:"CantChangeFlag",type:"error"},{inputs:[],name:"ConditionAlreadyCreated",type:"error"},{inputs:[],name:"ConditionAlreadyResolved",type:"error"},{inputs:[],name:"ConditionNotExists",type:"error"},{inputs:[],name:"ConditionNotStarted",type:"error"},{inputs:[],name:"ConditionStarted",type:"error"},{inputs:[],name:"FlagAlreadySet",type:"error"},{inputs:[],name:"IncorrectTimestamp",type:"error"},{inputs:[],name:"NotEnoughLiquidity",type:"error"},{inputs:[],name:"OnlyLp",type:"error"},{inputs:[],name:"OnlyMaintainer",type:"error"},{inputs:[],name:"OnlyOracle",type:"error"},{inputs:[{internalType:"uint64",name:"waitTime",type:"uint64"}],name:"ResolveTooEarly",type:"error"},{inputs:[],name:"SameOutcomes",type:"error"},{inputs:[],name:"SmallBet",type:"error"},{inputs:[],name:"SmallOdds",type:"error"},{inputs:[],name:"WrongDataFormat",type:"error"},{inputs:[],name:"WrongOutcome",type:"error"},{inputs:[],name:"ZeroOdds",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"flag",type:"bool"}],name:"AllConditionsStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oracleConditionId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"timestamp",type:"uint64"}],name:"ConditionCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oracleConditionId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"outcomeWin",type:"uint64"},{indexed:!1,internalType:"uint8",name:"state",type:"uint8"},{indexed:!1,internalType:"uint256",name:"amountForLp",type:"uint256"}],name:"ConditionResolved",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"newTimestamp",type:"uint64"}],name:"ConditionShifted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"bool",name:"flag",type:"bool"}],name:"ConditionStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newLp",type:"address"}],name:"LpChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"maintainer",type:"address"},{indexed:!1,internalType:"bool",name:"active",type:"bool"}],name:"MaintainerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newRatio",type:"uint64"}],name:"MaxBanksRatioChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newOracle",type:"address"}],name:"OracleAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oracle",type:"address"}],name:"OracleRenounced",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{inputs:[],name:"LP",outputs:[{internalType:"contract ILP",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"maintainer",type:"address"},{internalType:"bool",name:"active",type:"bool"}],name:"addMaintainer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"allConditionsStopped",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"bets",outputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"},{internalType:"uint64",name:"createdAt",type:"uint64"},{internalType:"uint64",name:"odds",type:"uint64"},{internalType:"bool",name:"payed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"}],name:"calculateOdds",outputs:[{internalType:"uint64",name:"odds",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"cancelByMaintainer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"oracleConditionId",type:"uint256"}],name:"cancelByOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"a",type:"uint256"},{internalType:"uint256",name:"m",type:"uint256"}],name:"ceil",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint64",name:"newRatio",type:"uint64"}],name:"changeMaxBanksRatio",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"conditions",outputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"uint128",name:"margin",type:"uint128"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64",name:"outcomeWin",type:"uint64"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"enum ICore.ConditionState",name:"state",type:"uint8"},{internalType:"uint48",name:"leaf",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"oracleCondId",type:"uint256"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64[2]",name:"odds",type:"uint64[2]"},{internalType:"uint64[2]",name:"outcomes",type:"uint64[2]"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"}],name:"createCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"defaultMargin",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultReinforcement",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"betId",type:"uint256"}],name:"getBetInfo",outputs:[{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"odds",type:"uint64"},{internalType:"uint64",name:"createdAt",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getCondition",outputs:[{components:[{internalType:"uint128[2]",name:"fundBank",type:"uint128[2]"},{internalType:"uint128[2]",name:"payouts",type:"uint128[2]"},{internalType:"uint128[2]",name:"totalNetBets",type:"uint128[2]"},{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"uint128",name:"margin",type:"uint128"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{internalType:"uint64[2]",name:"outcomes",type:"uint64[2]"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64",name:"outcomeWin",type:"uint64"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"enum ICore.ConditionState",name:"state",type:"uint8"},{internalType:"uint48",name:"leaf",type:"uint48"}],internalType:"struct ICore.Condition",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getConditionFunds",outputs:[{internalType:"uint128[2]",name:"fundBank",type:"uint128[2]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getConditionReinforcement",outputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLockedPayout",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint64",name:"outcomeId",type:"uint64"}],name:"getMargin",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"fund1Bank",type:"uint256"},{internalType:"uint256",name:"fund2Bank",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outcomeIndex",type:"uint256"},{internalType:"uint256",name:"margin",type:"uint256"},{internalType:"uint256",name:"multiplier",type:"uint256"}],name:"getOddsFromBanks",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint64",name:"outcomeId",type:"uint64"}],name:"getReinforcement",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"address",name:"oracle",type:"address"},{internalType:"uint128",name:"margin",type:"uint128"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"isOracle",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint256",name:"outcome",type:"uint256"}],name:"isOutComeCorrect",outputs:[{internalType:"bool",name:"correct",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"lastConditionId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"maintainers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"odds",type:"uint256"},{internalType:"uint256",name:"marginality",type:"uint256"},{internalType:"uint256",name:"multiplier",type:"uint256"}],name:"marginAdjustedOdds",outputs:[{internalType:"uint256",name:"newOdds",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[],name:"maxBanksRatio",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"multiplier",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"oracleConditionIds",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"oracles",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"putBet",outputs:[{internalType:"uint64",name:"",type:"uint64"},{internalType:"uint128",name:"",type:"uint128"},{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"renounceOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"oracleCondId",type:"uint256"},{internalType:"uint64",name:"outcomeWin",type:"uint64"}],name:"resolveCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"resolvePayout",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"lp",type:"address"}],name:"setLp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"setOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint64",name:"newTimestamp",type:"uint64"}],name:"shift",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"x",type:"uint256"}],name:"sqrt",outputs:[{internalType:"uint256",name:"y",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bool",name:"flag",type:"bool"}],name:"stopAllConditions",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"bool",name:"flag",type:"bool"}],name:"stopCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalLockedPayout",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128[]",name:"data",type:"uint128[]"}],name:"updateMargins",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128[]",name:"data",type:"uint128[]"}],name:"updateReinforcements",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"viewPayout",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"}],LpABI=[{inputs:[],name:"AmountMustNotBeZero",type:"error"},{inputs:[],name:"AmountNotSufficient",type:"error"},{inputs:[],name:"ConditionStarted",type:"error"},{inputs:[],name:"IncorrectPercent",type:"error"},{inputs:[],name:"LeafNotExist",type:"error"},{inputs:[],name:"LiquidityIsLocked",type:"error"},{inputs:[],name:"LiquidityNotOwned",type:"error"},{inputs:[],name:"NoDaoReward",type:"error"},{inputs:[],name:"NoLiquidity",type:"error"},{inputs:[],name:"NoWinNoPrize",type:"error"},{inputs:[],name:"NotEnoughReserves",type:"error"},{inputs:[],name:"OnlyBetOwner",type:"error"},{inputs:[],name:"OnlyCore",type:"error"},{inputs:[],name:"PaymentLocked",type:"error"},{inputs:[{internalType:"uint64",name:"waitTime",type:"uint64"}],name:"WithdrawalTimeout",type:"error"},{inputs:[],name:"WrongToken",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"newAzuroBet",type:"address"}],name:"AzuroBetChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"better",type:"address"},{indexed:!1,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"BetterWin",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newDaoFee",type:"uint128"}],name:"DaoRewardChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"uint48",name:"leaf",type:"uint48"}],name:"LiquidityAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"LiquidityRemoved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"requestWallet",type:"address"},{indexed:!1,internalType:"uint256",name:"requestedValueLp",type:"uint256"}],name:"LiquidityRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newMinDepo",type:"uint128"}],name:"MinDepoChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"uint256",name:"betId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"outcomeId",type:"uint64"},{indexed:!1,internalType:"uint128",name:"amount",type:"uint128"},{indexed:!1,internalType:"uint256",name:"odds",type:"uint256"},{indexed:!1,internalType:"uint128",name:"fund1",type:"uint128"},{indexed:!1,internalType:"uint128",name:"fund2",type:"uint128"}],name:"NewBet",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newOracleFee",type:"uint128"}],name:"OracleRewardChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newPeriod",type:"uint64"}],name:"PeriodChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newReinforcementAbility",type:"uint128"}],name:"ReinforcementAbilityChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newWithdrawTimeout",type:"uint64"}],name:"WithdrawTimeoutChanged",type:"event"},{inputs:[{internalType:"uint128",name:"amount",type:"uint128"}],name:"addLiquidity",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"addLiquidityNative",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint128",name:"initReserve",type:"uint128"},{internalType:"uint128",name:"finalReserve",type:"uint128"},{internalType:"uint48",name:"leaf",type:"uint48"},{internalType:"address",name:"oracle",type:"address"}],name:"addReserve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"azuroBet",outputs:[{internalType:"contract IAzuroBet",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcomeId",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"bet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint64",name:"outcomeId",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"betNative",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"newAzuroBet",type:"address"}],name:"changeAzuroBet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newCore",type:"address"}],name:"changeCore",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newDaoFee",type:"uint128"}],name:"changeDaoReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newMinDepo",type:"uint128"}],name:"changeMinDepo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newOracleFee",type:"uint128"}],name:"changeOracleReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newReinforcementAbility",type:"uint128"}],name:"changeReinforcementAbility",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint64",name:"newWithdrawTimeout",type:"uint64"}],name:"changeWithdrawTimeout",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimDaoReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"core",outputs:[{internalType:"contract ICore",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"daoFee",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLeaf",outputs:[{internalType:"uint48",name:"leaf",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"node",type:"uint48"},{internalType:"uint48",name:"begin",type:"uint48"},{internalType:"uint48",name:"end",type:"uint48"},{internalType:"uint48",name:"l",type:"uint48"},{internalType:"uint48",name:"r",type:"uint48"}],name:"getLeavesAmount",outputs:[{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"fromNumber",type:"uint48"}],name:"getParent",outputs:[{internalType:"uint48",name:"parentNumber",type:"uint48"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint128",name:"reinforcementAmount",type:"uint128"}],name:"getPossibilityOfReinforcement",outputs:[{internalType:"bool",name:"status",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"getReserve",outputs:[{internalType:"uint128",name:"reserve",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"address",name:"azuroBetAddress",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint128",name:"amount",type:"uint128"}],name:"lockReserve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"lockedLiquidity",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"minDepo",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"multiplier",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextNode",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"leaf",type:"uint48"}],name:"nodeWithdrawView",outputs:[{internalType:"uint128",name:"withdrawAmount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"oracleFee",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"reinforcementAbility",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalDaoRewards",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"",type:"uint48"}],name:"treeNode",outputs:[{internalType:"uint64",name:"updateId",type:"uint64"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"updateId",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"viewPayout",outputs:[{internalType:"bool",name:"",type:"bool"},{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"depNum",type:"uint48"},{internalType:"uint40",name:"percent",type:"uint40"}],name:"withdrawLiquidity",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"depNum",type:"uint48"},{internalType:"uint40",name:"percent",type:"uint40"}],name:"withdrawLiquidityNative",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"withdrawPayout",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"withdrawPayoutNative",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdrawTimeout",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"",type:"uint48"}],name:"withdrawals",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{stateMutability:"payable",type:"receive"}],AzuroBetABI=[{inputs:[],name:"OnlyLp",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"lp",type:"address"}],name:"LpChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getCoreByToken",outputs:[{internalType:"address",name:"core",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"getTokensByOwner",outputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"lpAddress",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"address",name:"core",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"string",name:"uri",type:"string"}],name:"setBaseURI",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"lp",type:"address"}],name:"setLp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],TestERC20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"dst",type:"address"},{indexed:!1,internalType:"uint256",name:"wad",type:"uint256"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"src",type:"address"},{indexed:!1,internalType:"uint256",name:"wad",type:"uint256"}],name:"Withdrawal",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bool",name:"active",type:"bool"}],name:"addPrivilegedAccounts",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:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"availableToClaim",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",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:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"claim",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"contestsDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"contestsStartDate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],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:"uint256",name:"_contestsDuration",type:"uint256"}],name:"setContestDuration",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"startDate",type:"uint256"}],name:"setContestStartDate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"wad",type:"uint256"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],state={walletProvider:null,selectedChainId:null,readContracts:{},writeContracts:{},contractAddresses:{},tokenDecimals:null,rateDecimals:null},flushState=function(){state.writeContracts={},state.readContracts={},state.tokenDecimals=null,state.rateDecimals=null},setContractAddresses=function(e){state.contractAddresses=e,flushState()},setWalletProvider=function(e){state.walletProvider=e,flushState()},setSelectedChainId=function(e){state.selectedChainId=e},CONTRACTS={core:{get address(){return state.contractAddresses.core},abi:CoreABI,decimals:18},lp:{get address(){return state.contractAddresses.lp},abi:LpABI,decimals:18},bet:{get address(){return state.contractAddresses.bet},abi:AzuroBetABI,decimals:18},token:{get address(){return state.contractAddresses.token},abi:TestERC20ABI,decimals:18}},createContract=function(e,t){var e=CONTRACTS[e.toLowerCase()],n=e.address,e=e.abi;return new contracts.Contract(n,e,t)},__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function __rest(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]]);return n}function __awaiter(e,u,p,s){return new(p=p||Promise)(function(n,t){function a(e){try{r(s.next(e))}catch(e){t(e)}}function i(e){try{r(s.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof p?t:new p(function(e){e(t)})).then(a,i)}r((s=s.apply(e,u||[])).next())})}function __generator(a,i){var r,u,p,s={label:0,sent:function(){if(1&p[0])throw p[1];return p[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(n){return function(e){var t=[n,e];if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,u&&(p=2&t[0]?u.return:t[0]?u.throw||((p=u.return)&&p.call(u),0):u.next)&&!(p=p.call(u,t[1])).done)return p;switch(u=0,(t=p?[2&t[0],p.value]:t)[0]){case 0:case 1:p=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,u=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(p=0<(p=s.trys).length&&p[p.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!p||t[1]>p[0]&&t[1]<p[3])){s.label=t[1];break}if(6===t[0]&&s.label<p[1]){s.label=p[1],p=t;break}if(p&&s.label<p[2]){s.label=p[2],s.ops.push(t);break}p[2]&&s.ops.pop(),s.trys.pop();continue}t=i.call(a,s)}catch(e){t=[6,e],u=0}finally{r=p=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var a,i,r=n.call(e),u=[];try{for(;(void 0===t||0<t--)&&!(a=r.next()).done;)u.push(a.value)}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return u}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}var ConditionStatus,config={rpcUrl:null,ipfsGateway:null},configure=function(e){Object.entries(e).forEach(function(e){var e=__read(e,2),t=e[0],e=e[1];config[t]=e})},getProvider=function(e){return 1337===state.selectedChainId?new providers.JsonRpcProvider:state.walletProvider&&e?state.walletProvider.getSigner():new providers.JsonRpcProvider(config.rpcUrl)},getContract=function(e,t){var n=t?state.writeContracts:state.readContracts;return n[e]||(t=getProvider(t),t=createContract(e,t),n[e]=t),n[e]},getTokenDecimals=function(){return __awaiter(void 0,void 0,void 0,function(){var t;return __generator(this,function(e){return null===state.tokenDecimals&&(t=getContract("token"),state.tokenDecimals=t.decimals()),[2,state.tokenDecimals]})})},getRateDecimals=function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){return null===state.rateDecimals&&(state.rateDecimals=9),[2,state.rateDecimals]})})},checkTestTokensClaimable=function(e){return getContract("token").availableToClaim(e)},claimTestTokens=function(e){return getContract("token",!0).claim(e)},fetchBalance=function(e){return getContract("token").balanceOf(e)},fetchGameIpfsData=function(y){return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p,s,o;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,axios__default.default.get(""+config.ipfsGateway+y,{timeout:1e4})];case 1:return s=e.sent().data,t=s.entity1Name,n=s.entity1Image,a=s.entity2Name,i=s.entity2Image,o=s.titleCountry,r=s.titleLeague,u=s.sportTypeId,p=s.leagueId,s=s.countryId,[2,{country:o,league:r,participants:[{name:t,image:n},{name:a,image:i}],leagueId:p,countryId:s,sportTypeId:u}];case 2:return o=e.sent(),console.error(o),[2,null];case 3:return[2]}})})},calculateOdd=function(e,t){var n=1/(1-1/e),t=1+t,a=t*(n-1)/(e-1),n=((n-1)/(e-1)+1)*(t-1),e=2-t;return(-1*n+Math.pow(Math.pow(n,2)+4*a*e,.5))/(2*a)+1},calculateInitialOdds=function(e,t){return[calculateOdd(e[0],t),calculateOdd(e[1],t)]},RANGE_SIZE=(!function(e){e[e.CREATED=0]="CREATED",e[e.RESOLVED=1]="RESOLVED",e[e.CANCELED=2]="CANCELED"}(ConditionStatus=ConditionStatus||{}),2e5),makeBlockRanges=function(e,t,n){void 0===n&&(n=RANGE_SIZE);for(var a=[],i=e;i<t;i+=n)i===e||i++,a.push([i,t<i+n?t:i+n]);return a},_calculateInitialOdds=function(e,t){var n=e[0].add(e[1]).toString(),e=e.map(function(e){return n/e.toString()}),t=t.toString()/1e9;return calculateInitialOdds(e,t)},fetchConditions=function(p){return __awaiter(void 0,void 0,void 0,function(){var t,n,o,y,d,a,i,r,u;return __generator(this,function(e){switch(e.label){case 0:return u=(n=p||{}).filters,t=n.from,n=n.rangeWide,r=(u=u||{}).resolved,o=void 0===r||r,r=u.canceled,y=void 0===r||r,u=getProvider(),d=getContract("core"),a=d.filters.ConditionCreated(),t?[4,u.getBlockNumber()]:[3,3];case 1:return r=e.sent(),u=makeBlockRanges(t,r,n),[4,Promise.all(u.map(function(e){var e=__read(e,2),t=e[0],e=e[1];return d.queryFilter(a,t,e)}))];case 2:return i=e.sent().flat(),[3,5];case 3:return[4,d.queryFilter(a,null==p?void 0:p.from)];case 4:i=e.sent(),e.label=5;case 5:return[4,Promise.all(i.map(function(e){var s=e.args.conditionId;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=s.toNumber(),[4,d.getCondition(s)];case 1:return(n=e.sent(),a=n.state,i=n.scopeId.toNumber(),(r=1e3*n.timestamp.toNumber())<=Date.now())?[2]:(o||a!==ConditionStatus.RESOLVED)&&(y||a!==ConditionStatus.CANCELED)?(u=_calculateInitialOdds(n.fundBank,n.margin),p=n.outcomes.map(function(e){return e.toNumber()}),[2,{id:t,outcomes:p,odds:u,gameData:{id:i,state:a,startsAt:r,ipfsHashHex:n.ipfsHash}}]):[2];case 2:return p=e.sent(),console.error(p),[2,null];case 3:return[2]}})})}))];case 6:return[2,{conditions:e.sent().filter(Boolean),latestBlock:i[i.length-1].blockNumber}]}})})},betTypeOdd={1:{outcomeRegistryId:180,marketRegistryId:9,paramId:1},2:{outcomeRegistryId:181,marketRegistryId:9,paramId:1},3:{outcomeRegistryId:7,marketRegistryId:3,paramId:96},4:{outcomeRegistryId:8,marketRegistryId:3,paramId:32},5:{outcomeRegistryId:7,marketRegistryId:3,paramId:94},6:{outcomeRegistryId:8,marketRegistryId:3,paramId:6},7:{outcomeRegistryId:7,marketRegistryId:3,paramId:36},8:{outcomeRegistryId:8,marketRegistryId:3,paramId:5},9:{outcomeRegistryId:7,marketRegistryId:3,paramId:7},10:{outcomeRegistryId:8,marketRegistryId:3,paramId:4},11:{outcomeRegistryId:7,marketRegistryId:3,paramId:1},12:{outcomeRegistryId:8,marketRegistryId:3,paramId:1},13:{outcomeRegistryId:7,marketRegistryId:3,paramId:4},14:{outcomeRegistryId:8,marketRegistryId:3,paramId:7},15:{outcomeRegistryId:7,marketRegistryId:3,paramId:5},16:{outcomeRegistryId:8,marketRegistryId:3,paramId:36},17:{outcomeRegistryId:7,marketRegistryId:3,paramId:6},18:{outcomeRegistryId:8,marketRegistryId:3,paramId:94},19:{outcomeRegistryId:7,marketRegistryId:3,paramId:32},20:{outcomeRegistryId:8,marketRegistryId:3,paramId:96},21:{outcomeRegistryId:9,marketRegistryId:4,paramId:4},22:{outcomeRegistryId:10,marketRegistryId:4,paramId:4},23:{outcomeRegistryId:9,marketRegistryId:4,paramId:5},24:{outcomeRegistryId:10,marketRegistryId:4,paramId:5},25:{outcomeRegistryId:9,marketRegistryId:4,paramId:6},26:{outcomeRegistryId:10,marketRegistryId:4,paramId:6},27:{outcomeRegistryId:9,marketRegistryId:4,paramId:32},28:{outcomeRegistryId:10,marketRegistryId:4,paramId:32},29:{outcomeRegistryId:1,marketRegistryId:1,paramId:1},30:{outcomeRegistryId:2,marketRegistryId:1,paramId:1},31:{outcomeRegistryId:3,marketRegistryId:1,paramId:1},32:{outcomeRegistryId:10009,marketRegistryId:19,paramId:1},33:{outcomeRegistryId:10010,marketRegistryId:19,paramId:1},34:{outcomeRegistryId:10009,marketRegistryId:20,paramId:1},35:{outcomeRegistryId:10010,marketRegistryId:20,paramId:1},36:{outcomeRegistryId:10009,marketRegistryId:21,paramId:1},37:{outcomeRegistryId:10010,marketRegistryId:21,paramId:1},38:{outcomeRegistryId:4,marketRegistryId:2,paramId:1},39:{outcomeRegistryId:5,marketRegistryId:2,paramId:1},40:{outcomeRegistryId:6,marketRegistryId:2,paramId:1},41:{outcomeRegistryId:10009,marketRegistryId:19,paramId:1},42:{outcomeRegistryId:10010,marketRegistryId:19,paramId:1},43:{outcomeRegistryId:1,marketRegistryId:1,paramId:1},44:{outcomeRegistryId:2,marketRegistryId:1,paramId:1},45:{outcomeRegistryId:3,marketRegistryId:1,paramId:1},46:{outcomeRegistryId:4,marketRegistryId:2,paramId:1},47:{outcomeRegistryId:5,marketRegistryId:2,paramId:1},48:{outcomeRegistryId:6,marketRegistryId:2,paramId:1}},stats={latestConditionsBlock:null},getLatestConditionsBlock=function(){return stats.latestConditionsBlock},gamesInfo={},gameBets={},groupBetVariants=function(e){var t={};return e.forEach(function(e){t[e.paramId]||(t[e.paramId]=[]),t[e.paramId].push(e)}),t},groupGames=function(){return Object.keys(gameBets).map(function(e){var e=gameBets[e],t=e.gameId,n=e.marketRegistryId,e=e.betVariants,a=groupBetVariants(e),e=Object.keys(a);return e=1===e.length?[{paramId:null,odds:a[e[0]].sort(function(e,t){return e.outcomeId-t.outcomeId})}]:Object.keys(a).map(function(e){return{paramId:parseInt(e),odds:a[e].sort(function(e,t){return t.outcomeId-e.outcomeId})}}),__assign(__assign({},gamesInfo[t]),{conditions:e,marketRegistryId:n})})},groupOddsByOutcomes=function(e){var u=e.gameId,p=e.conditionId,t=e.outcomes,s=e.odds;return t.map(function(e,t){var n,a,i,r,t=s[t];betTypeOdd[e]?(n=(a=betTypeOdd[e]).outcomeRegistryId,r=a.marketRegistryId,a=a.paramId,gameBets[i=u+"-"+r]||(gameBets[i]={gameId:u,marketRegistryId:r,betVariants:[]}),r={conditionId:p,outcomeId:e,outcomeRegistryId:n,paramId:a,value:t},gameBets[i].betVariants.push(r)):console.warn("Unknown outcomeId "+e+". Please update the Azuro SDK version")})},fetchGames=function(a){return void 0===a&&(a={}),__awaiter(void 0,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return gamesInfo={},gameBets={},[4,fetchConditions(a)];case 1:return t=e.sent(),n=t.conditions,t=t.latestBlock,n.forEach(function(e){var t=e.id,n=e.outcomes,a=e.odds,e=e.gameData;gamesInfo[e.id]=e,groupOddsByOutcomes({gameId:e.id,conditionId:t,outcomes:n,odds:a})}),n=groupGames(),[4,Promise.all(n.map(function(i){return __awaiter(void 0,void 0,void 0,function(){var t,n,a;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),n=i.ipfsHashHex,t=__rest(i,["ipfsHashHex"]),n=ethers.utils.arrayify(n),n=ethers.utils.base58.encode(__spread([18,32],n)),[4,fetchGameIpfsData(n)];case 1:return(n=e.sent())?[2,__assign(__assign({},n),t)]:[2,null];case 2:return a=e.sent(),console.error(a),[2,null];case 3:return[2]}})})}))];case 2:return n=e.sent(),stats.latestConditionsBlock=t,[2,n.filter(Boolean).sort(function(e,t){return e.startsAt-t.startsAt})]}})})},calculateActualOdds=function(e){var p=e.conditionId,s=e.outcomeId,o=e.betAmount;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u;return __generator(this,function(e){switch(e.label){case 0:return t=units.parseUnits,n=[String(o)],[4,getTokenDecimals()];case 1:return a=t.apply(void 0,n.concat([e.sent()])),[4,getContract("core").calculateOdds(p,a,s)];case 2:return a=e.sent(),r=units.formatUnits,u=[a],[4,getRateDecimals()];case 3:return i=r.apply(void 0,u.concat([e.sent()])),[2,parseFloat(i)]}})})},fetchAllowance=function(e){return getContract("token").allowance(e,CONTRACTS.lp.address)},approve=function(e){return getContract("token",!0).approve(CONTRACTS.lp.address,e)},placeBet=function(m){return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p,s,o,d,y,l;return __generator(this,function(e){switch(e.label){case 0:return t=m.conditionId,n=m.outcomeId,s=m.amount,a=m.betRate,i=m.slippage,r=getContract("lp",!0),p=units.parseUnits,s=[String(s)],[4,getTokenDecimals()];case 1:return u=p.apply(void 0,s.concat([e.sent()])),y=(1+(a-1)*(100-i)/100).toFixed(8),d=units.parseUnits,y=[y],[4,getRateDecimals()];case 2:return o=d.apply(void 0,y.concat([e.sent()])),l=Math.floor(Date.now()/1e3)+2e3,[2,r.bet(t,u,n,l,o)]}})})},fetchBet=function(B){return __awaiter(void 0,void 0,void 0,function(){var t,n,d,l,m,c,a,i,T,r,u,f,b,I,p,s,o,g,v,w,M,R,h,k,C,x,O,_,A,y;return __generator(this,function(e){switch(e.label){case 0:t=getContract("core"),e.label=1;case 1:return e.trys.push([1,7,,8]),[4,t.bets(B)];case 2:return a=e.sent(),n=a.conditionId,d=a.amount,l=a.outcome,m=a.odds,c=a.payed,a=a.createdAt,[4,t.getCondition(n)];case 3:return r=e.sent(),u=r.scopeId,i=r.state,o=r.ipfsHash,T=r.timestamp,r=r.outcomeWin,u=u.toNumber(),f=n.toNumber(),o=ethers.utils.arrayify(o),o=ethers.utils.base58.encode(__spread([18,32],o)),[4,fetchGameIpfsData(o)];case 4:return(b=e.sent())?(I=1e3*T.toNumber(),p=l.toNumber(),s=r.toNumber(),betTypeOdd[p]?(o=betTypeOdd[p],g=o.marketRegistryId,v=o.outcomeRegistryId,w=o.paramId,R=parseFloat,h=units.formatUnits,k=[m],[4,getRateDecimals()]):(console.warn("Unknown outcomeId "+p+". Please update the Azuro SDK version"),[2])):[2];case 5:return M=R.apply(void 0,[h.apply(void 0,k.concat([e.sent()]))]),C=parseFloat,x=units.formatUnits,O=[d],[4,getTokenDecimals()];case 6:return y=C.apply(void 0,[x.apply(void 0,O.concat([e.sent()]))]),_=void 0,_=i===ConditionStatus.CANCELED?y:0===s?null:s===p?(y*M).toFixed(6):-1*y,A=__assign(__assign({id:u},b),{startsAt:I,state:i}),[2,{nftId:B,conditionId:f,paramId:w,marketRegistryId:g,outcomeRegistryId:v,rate:M,amount:y,result:_,createdAt:1e3*a.toNumber(),isRedeemed:c,gameInfo:A}];case 7:return y=e.sent(),console.error(y),[2,null];case 8:return[2]}})})},fetchUserBets=function(e){var u=e.account;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r;return __generator(this,function(e){switch(e.label){case 0:e.trys.push([0,8,,9]),n=void(t=0),a=[],i=getContract("bet"),e.label=1;case 1:if(0!==t&&!n)return[3,6];e.label=2;case 2:return e.trys.push([2,4,,5]),[4,i.tokenOfOwnerByIndex(u,t++)];case 3:return n=e.sent(),a.push(n.toNumber()),[3,5];case 4:return e.sent(),n=null,[3,5];case 5:return[3,1];case 6:return[4,Promise.all(a.map(fetchBet))];case 7:return[2,e.sent().filter(Boolean).sort(function(e,t){return t.createdAt-e.createdAt})];case 8:return r=e.sent(),console.error(r),[2,[]];case 9:return[2]}})})},redeemBetPrize=function(e){return getContract("lp",!0).withdrawPayout(e)};exports.approve=approve,exports.calculateActualOdds=calculateActualOdds,exports.checkTestTokensClaimable=checkTestTokensClaimable,exports.claimTestTokens=claimTestTokens,exports.configure=configure,exports.fetchAllowance=fetchAllowance,exports.fetchBalance=fetchBalance,exports.fetchGames=fetchGames,exports.fetchUserBets=fetchUserBets,exports.getLatestConditionsBlock=getLatestConditionsBlock,exports.placeBet=placeBet,exports.redeemPrize=redeemBetPrize,exports.setContractAddresses=setContractAddresses,exports.setSelectedChainId=setSelectedChainId,exports.setWalletProvider=setWalletProvider; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var contracts=require("@ethersproject/contracts"),providers=require("@ethersproject/providers"),ethers=require("ethers"),axios=require("axios"),units=require("@ethersproject/units");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var axios__default=_interopDefaultLegacy(axios),CoreABI=[{inputs:[],name:"BetNotAllowed",type:"error"},{inputs:[],name:"BigDifference",type:"error"},{inputs:[],name:"CantAcceptBet",type:"error"},{inputs:[],name:"CantChangeFlag",type:"error"},{inputs:[],name:"ConditionAlreadyCreated",type:"error"},{inputs:[],name:"ConditionAlreadyResolved",type:"error"},{inputs:[],name:"ConditionNotExists",type:"error"},{inputs:[],name:"ConditionNotStarted",type:"error"},{inputs:[],name:"ConditionStarted",type:"error"},{inputs:[],name:"FlagAlreadySet",type:"error"},{inputs:[],name:"IncorrectTimestamp",type:"error"},{inputs:[],name:"NotEnoughLiquidity",type:"error"},{inputs:[],name:"OnlyLp",type:"error"},{inputs:[],name:"OnlyMaintainer",type:"error"},{inputs:[],name:"OnlyOracle",type:"error"},{inputs:[{internalType:"uint64",name:"waitTime",type:"uint64"}],name:"ResolveTooEarly",type:"error"},{inputs:[],name:"SameOutcomes",type:"error"},{inputs:[],name:"SmallBet",type:"error"},{inputs:[],name:"SmallOdds",type:"error"},{inputs:[],name:"WrongDataFormat",type:"error"},{inputs:[],name:"WrongOutcome",type:"error"},{inputs:[],name:"ZeroOdds",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"flag",type:"bool"}],name:"AllConditionsStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oracleConditionId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"timestamp",type:"uint64"}],name:"ConditionCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oracleConditionId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"outcomeWin",type:"uint64"},{indexed:!1,internalType:"uint8",name:"state",type:"uint8"},{indexed:!1,internalType:"uint256",name:"amountForLp",type:"uint256"}],name:"ConditionResolved",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"newTimestamp",type:"uint64"}],name:"ConditionShifted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"bool",name:"flag",type:"bool"}],name:"ConditionStopped",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newLp",type:"address"}],name:"LpChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"maintainer",type:"address"},{indexed:!1,internalType:"bool",name:"active",type:"bool"}],name:"MaintainerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newRatio",type:"uint64"}],name:"MaxBanksRatioChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newOracle",type:"address"}],name:"OracleAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oracle",type:"address"}],name:"OracleRenounced",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{inputs:[],name:"LP",outputs:[{internalType:"contract ILP",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"maintainer",type:"address"},{internalType:"bool",name:"active",type:"bool"}],name:"addMaintainer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"allConditionsStopped",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"bets",outputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"},{internalType:"uint64",name:"createdAt",type:"uint64"},{internalType:"uint64",name:"odds",type:"uint64"},{internalType:"bool",name:"payed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"}],name:"calculateOdds",outputs:[{internalType:"uint64",name:"odds",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"cancelByMaintainer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"oracleConditionId",type:"uint256"}],name:"cancelByOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"a",type:"uint256"},{internalType:"uint256",name:"m",type:"uint256"}],name:"ceil",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint64",name:"newRatio",type:"uint64"}],name:"changeMaxBanksRatio",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"conditions",outputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"uint128",name:"margin",type:"uint128"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64",name:"outcomeWin",type:"uint64"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"enum ICore.ConditionState",name:"state",type:"uint8"},{internalType:"uint48",name:"leaf",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"oracleCondId",type:"uint256"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64[2]",name:"odds",type:"uint64[2]"},{internalType:"uint64[2]",name:"outcomes",type:"uint64[2]"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"}],name:"createCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"defaultMargin",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultReinforcement",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"betId",type:"uint256"}],name:"getBetInfo",outputs:[{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"odds",type:"uint64"},{internalType:"uint64",name:"createdAt",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getCondition",outputs:[{components:[{internalType:"uint128[2]",name:"fundBank",type:"uint128[2]"},{internalType:"uint128[2]",name:"payouts",type:"uint128[2]"},{internalType:"uint128[2]",name:"totalNetBets",type:"uint128[2]"},{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"uint128",name:"margin",type:"uint128"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{internalType:"uint64[2]",name:"outcomes",type:"uint64[2]"},{internalType:"uint128",name:"scopeId",type:"uint128"},{internalType:"uint64",name:"outcomeWin",type:"uint64"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"enum ICore.ConditionState",name:"state",type:"uint8"},{internalType:"uint48",name:"leaf",type:"uint48"}],internalType:"struct ICore.Condition",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getConditionFunds",outputs:[{internalType:"uint128[2]",name:"fundBank",type:"uint128[2]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"}],name:"getConditionReinforcement",outputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLockedPayout",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint64",name:"outcomeId",type:"uint64"}],name:"getMargin",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"fund1Bank",type:"uint256"},{internalType:"uint256",name:"fund2Bank",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"outcomeIndex",type:"uint256"},{internalType:"uint256",name:"margin",type:"uint256"},{internalType:"uint256",name:"multiplier",type:"uint256"}],name:"getOddsFromBanks",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint64",name:"outcomeId",type:"uint64"}],name:"getReinforcement",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint128",name:"reinforcement",type:"uint128"},{internalType:"address",name:"oracle",type:"address"},{internalType:"uint128",name:"margin",type:"uint128"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"isOracle",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint256",name:"outcome",type:"uint256"}],name:"isOutComeCorrect",outputs:[{internalType:"bool",name:"correct",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"lastConditionId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"maintainers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"odds",type:"uint256"},{internalType:"uint256",name:"marginality",type:"uint256"},{internalType:"uint256",name:"multiplier",type:"uint256"}],name:"marginAdjustedOdds",outputs:[{internalType:"uint256",name:"newOdds",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[],name:"maxBanksRatio",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"multiplier",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"oracleConditionIds",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"oracles",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcome",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"putBet",outputs:[{internalType:"uint64",name:"",type:"uint64"},{internalType:"uint128",name:"",type:"uint128"},{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"renounceOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"oracleCondId",type:"uint256"},{internalType:"uint64",name:"outcomeWin",type:"uint64"}],name:"resolveCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"resolvePayout",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"lp",type:"address"}],name:"setLp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oracle",type:"address"}],name:"setOracle",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint64",name:"newTimestamp",type:"uint64"}],name:"shift",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"x",type:"uint256"}],name:"sqrt",outputs:[{internalType:"uint256",name:"y",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bool",name:"flag",type:"bool"}],name:"stopAllConditions",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"bool",name:"flag",type:"bool"}],name:"stopCondition",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalLockedPayout",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128[]",name:"data",type:"uint128[]"}],name:"updateMargins",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128[]",name:"data",type:"uint128[]"}],name:"updateReinforcements",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"viewPayout",outputs:[{internalType:"bool",name:"success",type:"bool"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"}],LpABI=[{inputs:[],name:"AmountMustNotBeZero",type:"error"},{inputs:[],name:"AmountNotSufficient",type:"error"},{inputs:[],name:"ConditionStarted",type:"error"},{inputs:[],name:"IncorrectPercent",type:"error"},{inputs:[],name:"LeafNotExist",type:"error"},{inputs:[],name:"LiquidityIsLocked",type:"error"},{inputs:[],name:"LiquidityNotOwned",type:"error"},{inputs:[],name:"NoDaoReward",type:"error"},{inputs:[],name:"NoLiquidity",type:"error"},{inputs:[],name:"NoWinNoPrize",type:"error"},{inputs:[],name:"NotEnoughReserves",type:"error"},{inputs:[],name:"OnlyBetOwner",type:"error"},{inputs:[],name:"OnlyCore",type:"error"},{inputs:[],name:"PaymentLocked",type:"error"},{inputs:[{internalType:"uint64",name:"waitTime",type:"uint64"}],name:"WithdrawalTimeout",type:"error"},{inputs:[],name:"WrongToken",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"newAzuroBet",type:"address"}],name:"AzuroBetChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"better",type:"address"},{indexed:!1,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"BetterWin",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newDaoFee",type:"uint128"}],name:"DaoRewardChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"uint48",name:"leaf",type:"uint48"}],name:"LiquidityAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"LiquidityRemoved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"requestWallet",type:"address"},{indexed:!1,internalType:"uint256",name:"requestedValueLp",type:"uint256"}],name:"LiquidityRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newMinDepo",type:"uint128"}],name:"MinDepoChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"uint256",name:"betId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"conditionId",type:"uint256"},{indexed:!1,internalType:"uint64",name:"outcomeId",type:"uint64"},{indexed:!1,internalType:"uint128",name:"amount",type:"uint128"},{indexed:!1,internalType:"uint256",name:"odds",type:"uint256"},{indexed:!1,internalType:"uint128",name:"fund1",type:"uint128"},{indexed:!1,internalType:"uint128",name:"fund2",type:"uint128"}],name:"NewBet",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newOracleFee",type:"uint128"}],name:"OracleRewardChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newPeriod",type:"uint64"}],name:"PeriodChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint128",name:"newReinforcementAbility",type:"uint128"}],name:"ReinforcementAbilityChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newWithdrawTimeout",type:"uint64"}],name:"WithdrawTimeoutChanged",type:"event"},{inputs:[{internalType:"uint128",name:"amount",type:"uint128"}],name:"addLiquidity",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"addLiquidityNative",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint128",name:"initReserve",type:"uint128"},{internalType:"uint128",name:"finalReserve",type:"uint128"},{internalType:"uint48",name:"leaf",type:"uint48"},{internalType:"address",name:"oracle",type:"address"}],name:"addReserve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"azuroBet",outputs:[{internalType:"contract IAzuroBet",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"},{internalType:"uint64",name:"outcomeId",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"bet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"conditionId",type:"uint256"},{internalType:"uint64",name:"outcomeId",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"minOdds",type:"uint64"}],name:"betNative",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"newAzuroBet",type:"address"}],name:"changeAzuroBet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newCore",type:"address"}],name:"changeCore",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newDaoFee",type:"uint128"}],name:"changeDaoReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newMinDepo",type:"uint128"}],name:"changeMinDepo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newOracleFee",type:"uint128"}],name:"changeOracleReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint128",name:"newReinforcementAbility",type:"uint128"}],name:"changeReinforcementAbility",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint64",name:"newWithdrawTimeout",type:"uint64"}],name:"changeWithdrawTimeout",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimDaoReward",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"core",outputs:[{internalType:"contract ICore",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"daoFee",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLeaf",outputs:[{internalType:"uint48",name:"leaf",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"node",type:"uint48"},{internalType:"uint48",name:"begin",type:"uint48"},{internalType:"uint48",name:"end",type:"uint48"},{internalType:"uint48",name:"l",type:"uint48"},{internalType:"uint48",name:"r",type:"uint48"}],name:"getLeavesAmount",outputs:[{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"fromNumber",type:"uint48"}],name:"getParent",outputs:[{internalType:"uint48",name:"parentNumber",type:"uint48"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint128",name:"reinforcementAmount",type:"uint128"}],name:"getPossibilityOfReinforcement",outputs:[{internalType:"bool",name:"status",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"getReserve",outputs:[{internalType:"uint128",name:"reserve",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"address",name:"azuroBetAddress",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint128",name:"amount",type:"uint128"}],name:"lockReserve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"lockedLiquidity",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"minDepo",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"multiplier",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextNode",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"leaf",type:"uint48"}],name:"nodeWithdrawView",outputs:[{internalType:"uint128",name:"withdrawAmount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"oracleFee",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"reinforcementAbility",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalDaoRewards",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"",type:"uint48"}],name:"treeNode",outputs:[{internalType:"uint64",name:"updateId",type:"uint64"},{internalType:"uint128",name:"amount",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"updateId",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"viewPayout",outputs:[{internalType:"bool",name:"",type:"bool"},{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"depNum",type:"uint48"},{internalType:"uint40",name:"percent",type:"uint40"}],name:"withdrawLiquidity",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"depNum",type:"uint48"},{internalType:"uint40",name:"percent",type:"uint40"}],name:"withdrawLiquidityNative",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"withdrawPayout",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"withdrawPayoutNative",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdrawTimeout",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint48",name:"",type:"uint48"}],name:"withdrawals",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{stateMutability:"payable",type:"receive"}],AzuroBetABI=[{inputs:[],name:"OnlyLp",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"lp",type:"address"}],name:"LpChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getCoreByToken",outputs:[{internalType:"address",name:"core",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"getTokensByOwner",outputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"lpAddress",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"address",name:"core",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"string",name:"uri",type:"string"}],name:"setBaseURI",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"lp",type:"address"}],name:"setLp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],TestERC20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"dst",type:"address"},{indexed:!1,internalType:"uint256",name:"wad",type:"uint256"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"src",type:"address"},{indexed:!1,internalType:"uint256",name:"wad",type:"uint256"}],name:"Withdrawal",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bool",name:"active",type:"bool"}],name:"addPrivilegedAccounts",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:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"availableToClaim",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",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:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"claim",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"contestsDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"contestsStartDate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],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:"uint256",name:"_contestsDuration",type:"uint256"}],name:"setContestDuration",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"startDate",type:"uint256"}],name:"setContestStartDate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"wad",type:"uint256"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],state={walletProvider:null,selectedChainId:null,readContracts:{},writeContracts:{},contractAddresses:{},tokenDecimals:null,rateDecimals:null},flushState=function(){state.writeContracts={},state.readContracts={},state.tokenDecimals=null,state.rateDecimals=null},setContractAddresses=function(e){state.contractAddresses=e,flushState()},setWalletProvider=function(e){state.walletProvider=e,flushState()},setSelectedChainId=function(e){state.selectedChainId=e},CONTRACTS={core:{get address(){return state.contractAddresses.core},abi:CoreABI,decimals:18},lp:{get address(){return state.contractAddresses.lp},abi:LpABI,decimals:18},bet:{get address(){return state.contractAddresses.bet},abi:AzuroBetABI,decimals:18},token:{get address(){return state.contractAddresses.token},abi:TestERC20ABI,decimals:18}},createContract=function(e,t){var e=CONTRACTS[e.toLowerCase()],n=e.address,e=e.abi;return new contracts.Contract(n,e,t)},__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function __rest(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]]);return n}function __awaiter(e,u,p,s){return new(p=p||Promise)(function(n,t){function a(e){try{r(s.next(e))}catch(e){t(e)}}function i(e){try{r(s.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof p?t:new p(function(e){e(t)})).then(a,i)}r((s=s.apply(e,u||[])).next())})}function __generator(a,i){var r,u,p,s={label:0,sent:function(){if(1&p[0])throw p[1];return p[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(n){return function(e){var t=[n,e];if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,u&&(p=2&t[0]?u.return:t[0]?u.throw||((p=u.return)&&p.call(u),0):u.next)&&!(p=p.call(u,t[1])).done)return p;switch(u=0,(t=p?[2&t[0],p.value]:t)[0]){case 0:case 1:p=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,u=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(p=0<(p=s.trys).length&&p[p.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!p||t[1]>p[0]&&t[1]<p[3])){s.label=t[1];break}if(6===t[0]&&s.label<p[1]){s.label=p[1],p=t;break}if(p&&s.label<p[2]){s.label=p[2],s.ops.push(t);break}p[2]&&s.ops.pop(),s.trys.pop();continue}t=i.call(a,s)}catch(e){t=[6,e],u=0}finally{r=p=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var a,i,r=n.call(e),u=[];try{for(;(void 0===t||0<t--)&&!(a=r.next()).done;)u.push(a.value)}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return u}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}var ConditionStatus,config={rpcUrl:null,ipfsGateway:null},configure=function(e){Object.entries(e).forEach(function(e){var e=__read(e,2),t=e[0],e=e[1];config[t]=e})},getProvider=function(e){return 1337===state.selectedChainId?new providers.JsonRpcProvider:state.walletProvider&&e?state.walletProvider.getSigner():new providers.JsonRpcProvider(config.rpcUrl)},getContract=function(e,t){var n=t?state.writeContracts:state.readContracts;return n[e]||(t=getProvider(t),t=createContract(e,t),n[e]=t),n[e]},getTokenDecimals=function(){return __awaiter(void 0,void 0,void 0,function(){var t;return __generator(this,function(e){return null===state.tokenDecimals&&(t=getContract("token"),state.tokenDecimals=t.decimals()),[2,state.tokenDecimals]})})},getRateDecimals=function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){return null===state.rateDecimals&&(state.rateDecimals=9),[2,state.rateDecimals]})})},checkTestTokensClaimable=function(e){return getContract("token").availableToClaim(e)},claimTestTokens=function(e){return getContract("token",!0).claim(e)},fetchBalance=function(e){return getContract("token").balanceOf(e)},fetchGameIpfsData=function(y){return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p,s,o;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,axios__default.default.get(""+config.ipfsGateway+y,{timeout:1e4})];case 1:return s=e.sent().data,t=s.entity1Name,n=s.entity1Image,a=s.entity2Name,i=s.entity2Image,o=s.titleCountry,r=s.titleLeague,u=s.sportTypeId,p=s.leagueId,s=s.countryId,[2,{country:o,league:r,participants:[{name:t,image:n},{name:a,image:i}],leagueId:p,countryId:s,sportTypeId:u}];case 2:return o=e.sent(),console.error(o),[2,null];case 3:return[2]}})})},calculateOdd=function(e,t){var n=1/(1-1/e),t=1+t,a=t*(n-1)/(e-1),n=((n-1)/(e-1)+1)*(t-1),e=2-t;return(-1*n+Math.pow(Math.pow(n,2)+4*a*e,.5))/(2*a)+1},calculateInitialOdds=function(e,t){return[calculateOdd(e[0],t),calculateOdd(e[1],t)]},RANGE_SIZE=(!function(e){e[e.CREATED=0]="CREATED",e[e.RESOLVED=1]="RESOLVED",e[e.CANCELED=2]="CANCELED"}(ConditionStatus=ConditionStatus||{}),2e5),makeBlockRanges=function(e,t,n){void 0===n&&(n=RANGE_SIZE);for(var a=[],i=e;i<t;i+=n)i===e||i++,a.push([i,t<i+n?t:i+n]);return a},_calculateInitialOdds=function(e,t){var n=e[0].add(e[1]).toString(),e=e.map(function(e){return n/e.toString()}),t=t.toString()/1e9;return calculateInitialOdds(e,t)},fetchConditions=function(s){return __awaiter(void 0,void 0,void 0,function(){var t,n,o,y,d,a,i,r,u,p;return __generator(this,function(e){switch(e.label){case 0:return u=(n=s||{}).filters,t=n.from,n=n.rangeWide,r=(u=u||{}).resolved,o=void 0===r||r,r=u.canceled,y=void 0===r||r,u=getProvider(),d=getContract("core"),a=d.filters.ConditionCreated(),t?[4,u.getBlockNumber()]:[3,3];case 1:return r=e.sent(),u=makeBlockRanges(t,r,n),[4,Promise.all(u.map(function(e){var e=__read(e,2),t=e[0],e=e[1];return d.queryFilter(a,t,e)}))];case 2:return i=e.sent().flat(),[3,5];case 3:return[4,d.queryFilter(a,null==s?void 0:s.from)];case 4:i=e.sent(),e.label=5;case 5:return[4,Promise.all(i.map(function(e){var s=e.args.conditionId;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=s.toNumber(),[4,d.getCondition(s)];case 1:return(n=e.sent(),a=n.state,i=n.scopeId.toNumber(),(r=1e3*n.timestamp.toNumber())<=Date.now())?[2]:(o||a!==ConditionStatus.RESOLVED)&&(y||a!==ConditionStatus.CANCELED)?(u=_calculateInitialOdds(n.fundBank,n.margin),p=n.outcomes.map(function(e){return e.toNumber()}),[2,{id:t,outcomes:p,odds:u,gameData:{id:i,state:a,startsAt:r,ipfsHashHex:n.ipfsHash}}]):[2];case 2:return p=e.sent(),console.error(p),[2,null];case 3:return[2]}})})}))];case 6:return[2,{conditions:e.sent().filter(Boolean),latestBlock:null===(p=i[i.length-1])||void 0===p?void 0:p.blockNumber}]}})})},betTypeOdd={1:{outcomeRegistryId:180,marketRegistryId:9,paramId:1},2:{outcomeRegistryId:181,marketRegistryId:9,paramId:1},3:{outcomeRegistryId:7,marketRegistryId:3,paramId:96},4:{outcomeRegistryId:8,marketRegistryId:3,paramId:32},5:{outcomeRegistryId:7,marketRegistryId:3,paramId:94},6:{outcomeRegistryId:8,marketRegistryId:3,paramId:6},7:{outcomeRegistryId:7,marketRegistryId:3,paramId:36},8:{outcomeRegistryId:8,marketRegistryId:3,paramId:5},9:{outcomeRegistryId:7,marketRegistryId:3,paramId:7},10:{outcomeRegistryId:8,marketRegistryId:3,paramId:4},11:{outcomeRegistryId:7,marketRegistryId:3,paramId:1},12:{outcomeRegistryId:8,marketRegistryId:3,paramId:1},13:{outcomeRegistryId:7,marketRegistryId:3,paramId:4},14:{outcomeRegistryId:8,marketRegistryId:3,paramId:7},15:{outcomeRegistryId:7,marketRegistryId:3,paramId:5},16:{outcomeRegistryId:8,marketRegistryId:3,paramId:36},17:{outcomeRegistryId:7,marketRegistryId:3,paramId:6},18:{outcomeRegistryId:8,marketRegistryId:3,paramId:94},19:{outcomeRegistryId:7,marketRegistryId:3,paramId:32},20:{outcomeRegistryId:8,marketRegistryId:3,paramId:96},21:{outcomeRegistryId:9,marketRegistryId:4,paramId:4},22:{outcomeRegistryId:10,marketRegistryId:4,paramId:4},23:{outcomeRegistryId:9,marketRegistryId:4,paramId:5},24:{outcomeRegistryId:10,marketRegistryId:4,paramId:5},25:{outcomeRegistryId:9,marketRegistryId:4,paramId:6},26:{outcomeRegistryId:10,marketRegistryId:4,paramId:6},27:{outcomeRegistryId:9,marketRegistryId:4,paramId:32},28:{outcomeRegistryId:10,marketRegistryId:4,paramId:32},29:{outcomeRegistryId:1,marketRegistryId:1,paramId:1},30:{outcomeRegistryId:2,marketRegistryId:1,paramId:1},31:{outcomeRegistryId:3,marketRegistryId:1,paramId:1},32:{outcomeRegistryId:10009,marketRegistryId:19,paramId:1},33:{outcomeRegistryId:10010,marketRegistryId:19,paramId:1},34:{outcomeRegistryId:10009,marketRegistryId:20,paramId:1},35:{outcomeRegistryId:10010,marketRegistryId:20,paramId:1},36:{outcomeRegistryId:10009,marketRegistryId:21,paramId:1},37:{outcomeRegistryId:10010,marketRegistryId:21,paramId:1},38:{outcomeRegistryId:4,marketRegistryId:2,paramId:1},39:{outcomeRegistryId:5,marketRegistryId:2,paramId:1},40:{outcomeRegistryId:6,marketRegistryId:2,paramId:1},41:{outcomeRegistryId:10009,marketRegistryId:19,paramId:1},42:{outcomeRegistryId:10010,marketRegistryId:19,paramId:1},43:{outcomeRegistryId:1,marketRegistryId:1,paramId:1},44:{outcomeRegistryId:2,marketRegistryId:1,paramId:1},45:{outcomeRegistryId:3,marketRegistryId:1,paramId:1},46:{outcomeRegistryId:4,marketRegistryId:2,paramId:1},47:{outcomeRegistryId:5,marketRegistryId:2,paramId:1},48:{outcomeRegistryId:6,marketRegistryId:2,paramId:1}},stats={latestConditionsBlock:null},getLatestConditionsBlock=function(){return stats.latestConditionsBlock},gamesInfo={},gameBets={},groupBetVariants=function(e){var t={};return e.forEach(function(e){t[e.paramId]||(t[e.paramId]=[]),t[e.paramId].push(e)}),t},groupGames=function(){return Object.keys(gameBets).map(function(e){var e=gameBets[e],t=e.gameId,n=e.marketRegistryId,e=e.betVariants,a=groupBetVariants(e),e=Object.keys(a);return e=1===e.length?[{paramId:null,odds:a[e[0]].sort(function(e,t){return e.outcomeId-t.outcomeId})}]:Object.keys(a).map(function(e){return{paramId:parseInt(e),odds:a[e].sort(function(e,t){return t.outcomeId-e.outcomeId})}}),__assign(__assign({},gamesInfo[t]),{conditions:e,marketRegistryId:n})})},groupOddsByOutcomes=function(e){var u=e.gameId,p=e.conditionId,t=e.outcomes,s=e.odds;return t.map(function(e,t){var n,a,i,r,t=s[t];betTypeOdd[e]?(n=(a=betTypeOdd[e]).outcomeRegistryId,r=a.marketRegistryId,a=a.paramId,gameBets[i=u+"-"+r]||(gameBets[i]={gameId:u,marketRegistryId:r,betVariants:[]}),r={conditionId:p,outcomeId:e,outcomeRegistryId:n,paramId:a,value:t},gameBets[i].betVariants.push(r)):console.warn("Unknown outcomeId "+e+". Please update the Azuro SDK version")})},fetchGames=function(a){return void 0===a&&(a={}),__awaiter(void 0,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return gamesInfo={},gameBets={},[4,fetchConditions(a)];case 1:return t=e.sent(),n=t.conditions,t=t.latestBlock,n.forEach(function(e){var t=e.id,n=e.outcomes,a=e.odds,e=e.gameData;gamesInfo[e.id]=e,groupOddsByOutcomes({gameId:e.id,conditionId:t,outcomes:n,odds:a})}),n=groupGames(),[4,Promise.all(n.map(function(i){return __awaiter(void 0,void 0,void 0,function(){var t,n,a;return __generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),n=i.ipfsHashHex,t=__rest(i,["ipfsHashHex"]),n=ethers.utils.arrayify(n),n=ethers.utils.base58.encode(__spread([18,32],n)),[4,fetchGameIpfsData(n)];case 1:return(n=e.sent())?[2,__assign(__assign({},n),t)]:[2,null];case 2:return a=e.sent(),console.error(a),[2,null];case 3:return[2]}})})}))];case 2:return n=e.sent(),stats.latestConditionsBlock=t,[2,n.filter(Boolean).sort(function(e,t){return e.startsAt-t.startsAt})]}})})},calculateActualOdds=function(e){var p=e.conditionId,s=e.outcomeId,o=e.betAmount;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u;return __generator(this,function(e){switch(e.label){case 0:return t=units.parseUnits,n=[String(o)],[4,getTokenDecimals()];case 1:return a=t.apply(void 0,n.concat([e.sent()])),[4,getContract("core").calculateOdds(p,a,s)];case 2:return a=e.sent(),r=units.formatUnits,u=[a],[4,getRateDecimals()];case 3:return i=r.apply(void 0,u.concat([e.sent()])),[2,parseFloat(i)]}})})},fetchAllowance=function(e){return getContract("token").allowance(e,CONTRACTS.lp.address)},approve=function(e){return getContract("token",!0).approve(CONTRACTS.lp.address,e)},placeBet=function(m){return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r,u,p,s,o,d,y,l;return __generator(this,function(e){switch(e.label){case 0:return t=m.conditionId,n=m.outcomeId,s=m.amount,a=m.betRate,i=m.slippage,r=getContract("lp",!0),p=units.parseUnits,s=[String(s)],[4,getTokenDecimals()];case 1:return u=p.apply(void 0,s.concat([e.sent()])),y=(1+(a-1)*(100-i)/100).toFixed(8),d=units.parseUnits,y=[y],[4,getRateDecimals()];case 2:return o=d.apply(void 0,y.concat([e.sent()])),l=Math.floor(Date.now()/1e3)+2e3,[2,r.bet(t,u,n,l,o)]}})})},fetchBet=function(B){return __awaiter(void 0,void 0,void 0,function(){var t,n,d,l,m,c,a,i,T,r,u,f,b,I,p,s,o,g,v,w,M,R,h,k,C,x,O,_,A,y;return __generator(this,function(e){switch(e.label){case 0:t=getContract("core"),e.label=1;case 1:return e.trys.push([1,7,,8]),[4,t.bets(B)];case 2:return a=e.sent(),n=a.conditionId,d=a.amount,l=a.outcome,m=a.odds,c=a.payed,a=a.createdAt,[4,t.getCondition(n)];case 3:return r=e.sent(),u=r.scopeId,i=r.state,o=r.ipfsHash,T=r.timestamp,r=r.outcomeWin,u=u.toNumber(),f=n.toNumber(),o=ethers.utils.arrayify(o),o=ethers.utils.base58.encode(__spread([18,32],o)),[4,fetchGameIpfsData(o)];case 4:return(b=e.sent())?(I=1e3*T.toNumber(),p=l.toNumber(),s=r.toNumber(),betTypeOdd[p]?(o=betTypeOdd[p],g=o.marketRegistryId,v=o.outcomeRegistryId,w=o.paramId,R=parseFloat,h=units.formatUnits,k=[m],[4,getRateDecimals()]):(console.warn("Unknown outcomeId "+p+". Please update the Azuro SDK version"),[2])):[2];case 5:return M=R.apply(void 0,[h.apply(void 0,k.concat([e.sent()]))]),C=parseFloat,x=units.formatUnits,O=[d],[4,getTokenDecimals()];case 6:return y=C.apply(void 0,[x.apply(void 0,O.concat([e.sent()]))]),_=void 0,_=i===ConditionStatus.CANCELED?y:0===s?null:s===p?(y*M).toFixed(6):-1*y,A=__assign(__assign({id:u},b),{startsAt:I,state:i}),[2,{nftId:B,conditionId:f,paramId:w,marketRegistryId:g,outcomeRegistryId:v,rate:M,amount:y,result:_,createdAt:1e3*a.toNumber(),isRedeemed:c,gameInfo:A}];case 7:return y=e.sent(),console.error(y),[2,null];case 8:return[2]}})})},fetchUserBets=function(e){var u=e.account;return __awaiter(void 0,void 0,void 0,function(){var t,n,a,i,r;return __generator(this,function(e){switch(e.label){case 0:e.trys.push([0,8,,9]),n=void(t=0),a=[],i=getContract("bet"),e.label=1;case 1:if(0!==t&&!n)return[3,6];e.label=2;case 2:return e.trys.push([2,4,,5]),[4,i.tokenOfOwnerByIndex(u,t++)];case 3:return n=e.sent(),a.push(n.toNumber()),[3,5];case 4:return e.sent(),n=null,[3,5];case 5:return[3,1];case 6:return[4,Promise.all(a.map(fetchBet))];case 7:return[2,e.sent().filter(Boolean).sort(function(e,t){return t.createdAt-e.createdAt})];case 8:return r=e.sent(),console.error(r),[2,[]];case 9:return[2]}})})},redeemBetPrize=function(e){return getContract("lp",!0).withdrawPayout(e)};exports.approve=approve,exports.calculateActualOdds=calculateActualOdds,exports.checkTestTokensClaimable=checkTestTokensClaimable,exports.claimTestTokens=claimTestTokens,exports.configure=configure,exports.fetchAllowance=fetchAllowance,exports.fetchBalance=fetchBalance,exports.fetchGames=fetchGames,exports.fetchUserBets=fetchUserBets,exports.getLatestConditionsBlock=getLatestConditionsBlock,exports.placeBet=placeBet,exports.redeemPrize=redeemBetPrize,exports.setContractAddresses=setContractAddresses,exports.setSelectedChainId=setSelectedChainId,exports.setWalletProvider=setWalletProvider; |
{ | ||
"name": "@azuro-protocol/sdk", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=14.17.4", |
819020