Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bancor/carbon-sdk

Package Overview
Dependencies
Maintainers
2
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bancor/carbon-sdk - npm Package Compare versions

Comparing version 0.0.19-DEV to 0.0.20-DEV

2

dist/sdk.umd.js
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@ethersproject/providers"),require("@ethersproject/bignumber"),require("decimal.js"),require("ethers"),require("@ethersproject/units")):"function"==typeof define&&define.amd?define(["@ethersproject/providers","@ethersproject/bignumber","decimal.js","ethers","@ethersproject/units"],t):(e||self).carbonSdk=t(e.providers,e.bignumber,e.Decimal,e.ethers,e.units)}(this,function(e,t,n,a,r){function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/i(n);function s(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,"symbol"==typeof(r=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,"string");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(a.key))?r:String(r),a)}var r}function u(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},p.apply(this,arguments)}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function d(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l=function(e,t){return e.localeCompare(t)},c=function(e){if(2!==e.length)throw new Error("Invalid number of tokens: expected 2, got "+e.length);if(e[0]===e[1])throw new Error("Cannot create key for identical tokens: "+e[0])},m=function(e,t){return c([e,t]),[e,t].sort(l)},f=function(e,t){return c([e,t]),e+"-"+t},b=function(e,t,n,a,r,i){for(var o,s=d(a.entries());!(o=s()).done;)for(var u=o.value[1],p=0;p<u.length;p++)if(u[p].id===e){if(u[p][0===t?"order0":"order1"]=n,r.set(e.toString(),u[p]),0===i.size)return;var y=[u[p].token0,u[p].token1];0===t&&y.reverse();var l,c=f(y[0],y[1]),m=i.get(c);return void(m?m[u[p].id.toString()]=n:(console.warn("Should not be here, modified order is supposed to already be cached"),i.set(c,((l={})[u[p].id.toString()]=n,l))))}},T=/*#__PURE__*/function(){function e(e){this.pairToStrategies=void 0,this.strategyById=void 0,this.fetcher=void 0,this.cachedOrders=void 0,this.fetcher=e,this.pairToStrategies=new Map,this.strategyById=new Map,this.cachedOrders=new Map}var t=e.prototype;return t.init=function(){try{var e=this;return Promise.resolve(function(e){try{return Promise.resolve(e.getAllTokenPairs()).then(function(t){return Promise.resolve(e.getStrategiesByTokenPairs(t)).then(function(e){for(var n=new Map,a=0;a<t.length;a++){var r=t[a],i=e[a],o=m(r[0],r[1]);n.set(o,i)}return n})})}catch(e){return Promise.reject(e)}}(e.fetcher)).then(function(t){e.pairToStrategies=t,e.fetcher.onStrategyCreated(function(t){return function(e,t,n,a){n.set(e.id.toString(),e);var r=m(e.token0,e.token1);if(t.has(r)?t.get(r).push(e):t.set(r,[e]),0!==a.size)for(var i=[e.token0,e.token1],o=0,s=[i,i.reverse()];o<s.length;o++){var u,p=s[o],y=f(p[0],p[1]),d=p[0]===e.token0?e.order1:e.order0,l=a.get(y);l?l[e.id.toString()]=d:a.set(y,((u={})[e.id.toString()]=d,u))}}(t,e.pairToStrategies,e.strategyById,e.cachedOrders)}),e.fetcher.onStrategyUpdated(function(t){return function(e,t,n,a){b(e.id,0,e.order0,t,n,a),b(e.id,1,e.order1,t,n,a)}(t,e.pairToStrategies,e.strategyById,e.cachedOrders)});for(var n,a=d(e.pairToStrategies.values());!(n=a()).done;){var r=n.value;if(r&&r.length>0)for(var i=0;i<r.length;i++)e.strategyById.set(r[i].id.toString(),r[i])}})}catch(e){return Promise.reject(e)}},t.getOrders=function(e,t){var n;if(0===this.pairToStrategies.size)return console.warn("getOrders was called when no strategies are cached, did you call init?"),{};0===this.cachedOrders.size&&function(e,t){t.clear();for(var n,a=d(e.values());!(n=a()).done;){var r=n.value;if(r.length>0){for(var i=r[0].token0,o=r[0].token1,s={},u={},p=0;p<r.length;p++)r[p].token0===i?(s[r[p].id.toString()]=r[p].order0,u[r[p].id.toString()]=r[p].order1):(s[r[p].id.toString()]=r[p].order1,u[r[p].id.toString()]=r[p].order0);t.set(f(i,o),u),t.set(f(o,i),s)}}}(this.pairToStrategies,this.cachedOrders);var a=f(e,t);return null!=(n=this.cachedOrders.get(a))?n:{}},e}();o.default.set({precision:50,rounding:o.default.ROUND_HALF_DOWN,toExpNeg:-30,toExpPos:30});var v=Math.pow(2,32),h=new o.default(10),g=function(e,t){return h.pow(e-t)},w="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE".toLowerCase(),k=function(e){return e.toLowerCase()===w},M=function(e,n,a){var r=p({},a);return k(e)&&(r.value=n.reduce(function(e,t){return e.add(t.amount)},t.BigNumber.from(0))),r},_=/*#__PURE__*/function(){function e(e){this._contracts=void 0,this._contracts=e}var t=e.prototype;return t.tradeByTargetAmount=function(e,t,n,a,r,i){var o=M(e,n,i);return this._contracts.poolCollection.populateTransaction.tradeByTargetAmount(e,t,n,a,r,o)},t.tradeBySourceAmount=function(e,t,n,a,r,i){var o=M(e,n,i);return this._contracts.poolCollection.populateTransaction.tradeBySourceAmount(e,t,n,a,r,o)},t.createStrategy=function(e,t,n,a,r,i,o,s,u,y,d){var l=p({},d);return k(e)?l.value=n:k(t)&&(l.value=o),this._contracts.poolCollection.populateTransaction.createStrategy(e,t,n,a,r,i,o,s,u,y,l)},t.transferVoucherOwnership=function(e,t){return this._contracts.voucher.populateTransaction.transferOwnership(e,t)},e}(),x=[{inputs:[],name:"AccessDenied",type:"error"},{inputs:[],name:"InvalidAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"previousAdmin",type:"address"},{indexed:!1,internalType:"address",name:"newAdmin",type:"address"}],name:"AdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"beacon",type:"address"}],name:"BeaconUpgraded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"admin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"implementation",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"}],name:"upgradeTo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"},{inputs:[],name:"AlreadyExists",type:"error"},{inputs:[],name:"AlreadyInitialized",type:"error"},{inputs:[],name:"DeadlineExpired",type:"error"},{inputs:[],name:"DoesNotExist",type:"error"},{inputs:[],name:"NotEmpty",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint16",name:"poolType",type:"uint16"},{indexed:!0,internalType:"contract IPoolCollection",name:"poolCollection",type:"address"}],name:"PoolCollectionAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint16",name:"poolType",type:"uint16"},{indexed:!0,internalType:"contract IPoolCollection",name:"poolCollection",type:"address"}],name:"PoolCollectionRemoved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"previousAdminRole",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"newAdminRole",type:"bytes32"}],name:"RoleAdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleGranted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleRevoked",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{inputs:[],name:"DEFAULT_ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"uint256",name:"index",type:"uint256"}],name:"getRoleMember",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleMemberCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"grantRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"hasRole",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"poolCollections",outputs:[{internalType:"contract IPoolCollection[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"data",type:"bytes"}],name:"postUpgrade",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IPoolCollection",name:"poolCollection",type:"address"}],name:"registerPoolCollection",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"renounceRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"revokeRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"roleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[],name:"roleEmergencyStopper",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint16",name:"poolType",type:"uint16"}],name:"unregisterPoolCollection",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"version",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"logic",type:"address"},{internalType:"address",name:"initAdmin",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],stateMutability:"payable",type:"constructor"}],A=/*#__PURE__*/function(){function e(){}return e.createInterface=function(){return new a.utils.Interface(x)},e.connect=function(e,t){return new a.Contract(e,x,t)},e}();A.abi=x;var P=[{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes[]",name:"returnData",type:"bytes[]"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"blockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBlockNumber",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockCoinbase",outputs:[{internalType:"address",name:"coinbase",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockDifficulty",outputs:[{internalType:"uint256",name:"difficulty",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockGasLimit",outputs:[{internalType:"uint256",name:"gaslimit",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"addr",type:"address"}],name:"getEthBalance",outputs:[{internalType:"uint256",name:"balance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryAggregate",outputs:[{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryBlockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],S=/*#__PURE__*/function(){function e(){}return e.createInterface=function(){return new a.utils.Interface(P)},e.connect=function(e,t){return new a.Contract(e,P,t)},e}();S.abi=P;var I=[{inputs:[],name:"AccessDenied",type:"error"},{inputs:[],name:"InvalidAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"previousAdmin",type:"address"},{indexed:!1,internalType:"address",name:"newAdmin",type:"address"}],name:"AdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"beacon",type:"address"}],name:"BeaconUpgraded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"admin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"implementation",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"}],name:"upgradeTo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"},{inputs:[],name:"AlreadyInitialized",type:"error"},{inputs:[],name:"ConstraintUnmet",type:"error"},{inputs:[],name:"DeadlineExpired",type:"error"},{inputs:[],name:"IdenticalAddresses",type:"error"},{inputs:[],name:"InvalidFee",type:"error"},{inputs:[],name:"NativeAmountMismatch",type:"error"},{inputs:[],name:"Overflow",type:"error"},{inputs:[],name:"PoolAlreadyExists",type:"error"},{inputs:[],name:"PoolDoesNotExists",type:"error"},{inputs:[],name:"UnnecessaryNativeTokenReceived",type:"error"},{inputs:[],name:"ZeroValue",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint32",name:"prevFeePPM",type:"uint32"},{indexed:!1,internalType:"uint32",name:"newFeePPM",type:"uint32"}],name:"NetworkFeePPMUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"poolId",type:"uint256"},{indexed:!0,internalType:"contract Token",name:"token0",type:"address"},{indexed:!0,internalType:"contract Token",name:"token1",type:"address"}],name:"PoolCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"previousAdminRole",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"newAdminRole",type:"bytes32"}],name:"RoleAdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleGranted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleRevoked",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"id",type:"uint256"},{indexed:!0,internalType:"address",name:"provider",type:"address"},{indexed:!0,internalType:"contract Token",name:"token0",type:"address"},{indexed:!0,internalType:"contract Token",name:"token1",type:"address"},{components:[{internalType:"uint128",name:"y",type:"uint128"},{internalType:"uint128",name:"z",type:"uint128"},{internalType:"uint64",name:"A",type:"uint64"},{internalType:"uint64",name:"B",type:"uint64"}],indexed:!1,internalType:"struct Order",name:"order0",type:"tuple"},{components:[{internalType:"uint128",name:"y",type:"uint128"},{internalType:"uint128",name:"z",type:"uint128"},{internalType:"uint64",name:"A",type:"uint64"},{internalType:"uint64",name:"B",type:"uint64"}],indexed:!1,internalType:"struct Order",name:"order1",type:"tuple"}],name:"StrategyCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"id",type:"uint256"},{indexed:!0,internalType:"address",name:"provider",type:"address"},{indexed:!0,internalType:"contract Token",name:"token0",type:"address"},{indexed:!0,internalType:"contract Token",name:"token1",type:"address"},{components:[{internalType:"uint128",name:"y",type:"uint128"},{internalType:"uint128",name:"z",type:"uint128"},{internalType:"uint64",name:"A",type:"uint64"},{internalType:"uint64",name:"B",type:"uint64"}],indexed:!1,internalType:"struct Order",name:"order0",type:"tuple"},{components:[{internalType:"uint128",name:"y",type:"uint128"},{internalType:"uint128",name:"z",type:"uint128"},{internalType:"uint64",name:"A",type:"uint64"},{internalType:"uint64",name:"B",type:"uint64"}],indexed:!1,internalType:"struct Order",name:"order1",type:"tuple"}],name:"StrategyUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"trader",type:"address"},{indexed:!0,internalType:"address",name:"sourceToken",type:"address"},{indexed:!0,internalType:"address",name:"targetToken",type:"address"},{indexed:!1,internalType:"uint256",name:"sourceAmount",type:"uint256"},{indexed:!1,internalType:"uint256",name:"targetAmount",type:"uint256"}],name:"TokensTraded",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{inputs:[],name:"DEFAULT_ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"}],name:"createPool",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"}],internalType:"struct Pool",name:"",type:"tuple"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"},{internalType:"uint128",name:"y0",type:"uint128"},{internalType:"uint128",name:"z0",type:"uint128"},{internalType:"uint64",name:"A0",type:"uint64"},{internalType:"uint64",name:"B0",type:"uint64"},{internalType:"uint128",name:"y1",type:"uint128"},{internalType:"uint128",name:"z1",type:"uint128"},{internalType:"uint64",name:"A1",type:"uint64"},{internalType:"uint64",name:"B1",type:"uint64"}],name:"createStrategy",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"uint256",name:"index",type:"uint256"}],name:"getRoleMember",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleMemberCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"grantRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"hasRole",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"networkFeePPM",outputs:[{internalType:"uint32",name:"",type:"uint32"}],stateMutability:"view",type:"function"},{inputs:[],name:"pairs",outputs:[{internalType:"address[2][]",name:"",type:"address[2][]"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"}],name:"pool",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"}],internalType:"struct Pool",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"poolType",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"data",type:"bytes"}],name:"postUpgrade",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"renounceRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"revokeRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"roleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[],name:"roleEmergencyStopper",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint32",name:"newNetworkFeePPM",type:"uint32"}],name:"setNetworkFeePPM",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256[]",name:"ids",type:"uint256[]"}],name:"strategiesByIds",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{components:[{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"}],internalType:"struct Pair",name:"pair",type:"tuple"},{components:[{internalType:"uint128",name:"y",type:"uint128"},{internalType:"uint128",name:"z",type:"uint128"},{internalType:"uint64",name:"A",type:"uint64"},{internalType:"uint64",name:"B",type:"uint64"}],internalType:"struct Order[2]",name:"orders",type:"tuple[2]"}],internalType:"struct Strategy[]",name:"",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"}],name:"strategiesByPool",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{components:[{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"}],internalType:"struct Pair",name:"pair",type:"tuple"},{components:[{internalType:"uint128",name:"y",type:"uint128"},{internalType:"uint128",name:"z",type:"uint128"},{internalType:"uint64",name:"A",type:"uint64"},{internalType:"uint64",name:"B",type:"uint64"}],internalType:"struct Order[2]",name:"orders",type:"tuple[2]"}],internalType:"struct Strategy[]",name:"",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"strategy",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{components:[{internalType:"contract Token",name:"token0",type:"address"},{internalType:"contract Token",name:"token1",type:"address"}],internalType:"struct Pair",name:"pair",type:"tuple"},{components:[{internalType:"uint128",name:"y",type:"uint128"},{internalType:"uint128",name:"z",type:"uint128"},{internalType:"uint64",name:"A",type:"uint64"},{internalType:"uint64",name:"B",type:"uint64"}],internalType:"struct Order[2]",name:"orders",type:"tuple[2]"}],internalType:"struct Strategy",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Token",name:"sourceToken",type:"address"},{internalType:"contract Token",name:"targetToken",type:"address"},{components:[{internalType:"uint256",name:"strategyId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"}],internalType:"struct TradeAction[]",name:"tradeActions",type:"tuple[]"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint128",name:"minReturn",type:"uint128"}],name:"tradeBySourceAmount",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract Token",name:"sourceToken",type:"address"},{internalType:"contract Token",name:"targetToken",type:"address"},{components:[{internalType:"uint256",name:"strategyId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"}],internalType:"struct TradeAction[]",name:"tradeActions",type:"tuple[]"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint128",name:"maxInput",type:"uint128"}],name:"tradeByTargetAmount",outputs:[{internalType:"uint128",name:"",type:"uint128"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"contract Token",name:"sourceToken",type:"address"},{internalType:"contract Token",name:"targetToken",type:"address"},{components:[{internalType:"uint256",name:"strategyId",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"}],internalType:"struct TradeAction[]",name:"tradeActions",type:"tuple[]"},{internalType:"bool",name:"amountByTarget",type:"bool"}],name:"tradeSourceAndTargetAmounts",outputs:[{components:[{internalType:"uint128",name:"sourceAmount",type:"uint128"},{internalType:"uint128",name:"targetAmount",type:"uint128"}],internalType:"struct SourceAndTargetAmounts",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"version",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"logic",type:"address"},{internalType:"address",name:"initAdmin",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],stateMutability:"payable",type:"constructor"}],B=/*#__PURE__*/function(){function e(){}return e.createInterface=function(){return new a.utils.Interface(I)},e.connect=function(e,t){return new a.Contract(e,I,t)},e}();B.abi=I;var O=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"success",type:"bool"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"_disable",type:"bool"}],name:"disableTransfers",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"success",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"version",outputs:[{name:"",type:"string"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"standard",outputs:[{name:"",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"_token",type:"address"},{name:"_to",type:"address"},{name:"_amount",type:"uint256"}],name:"withdrawTokens",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],payable:!1,type:"function"},{constant:!1,inputs:[],name:"acceptOwnership",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_amount",type:"uint256"}],name:"issue",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_amount",type:"uint256"}],name:"destroy",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"success",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"transfersEnabled",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[],name:"newOwner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"",type:"address"},{name:"",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"_newOwner",type:"address"}],name:"transferOwnership",outputs:[],payable:!1,type:"function"},{inputs:[{name:"_name",type:"string"},{name:"_symbol",type:"string"},{name:"_decimals",type:"uint8"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,name:"_token",type:"address"}],name:"NewSmartToken",type:"event"},{anonymous:!1,inputs:[{indexed:!1,name:"_amount",type:"uint256"}],name:"Issuance",type:"event"},{anonymous:!1,inputs:[{indexed:!1,name:"_amount",type:"uint256"}],name:"Destruction",type:"event"},{anonymous:!1,inputs:[{indexed:!1,name:"_prevOwner",type:"address"},{indexed:!1,name:"_newOwner",type:"address"}],name:"OwnerUpdate",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"_from",type:"address"},{indexed:!0,name:"_to",type:"address"},{indexed:!1,name:"_value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"_owner",type:"address"},{indexed:!0,name:"_spender",type:"address"},{indexed:!1,name:"_value",type:"uint256"}],name:"Approval",type:"event"}],C=/*#__PURE__*/function(){function e(){}return e.createInterface=function(){return new a.utils.Interface(O)},e.connect=function(e,t){return new a.Contract(e,O,t)},e}();C.abi=O;var R=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{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:!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:[{internalType:"uint256",name:"strategyId",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:"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:"address",name:"provider",type:"address"},{internalType:"uint256",name:"strategyId",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:[{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:"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"}],D=/*#__PURE__*/function(){function e(){}return e.createInterface=function(){return new a.utils.Interface(R)},e.connect=function(e,t){return new a.Contract(e,R,t)},e}();D.abi=R;var N=/*#__PURE__*/function(){function e(e){this._provider=void 0,this._poolCollection=void 0,this._bancorNetwork=void 0,this._multiCall=void 0,this._voucher=void 0,this._provider=e}return e.prototype.token=function(e){return C.connect(e,this._provider)},u(e,[{key:"poolCollection",get:function(){return this._poolCollection||(this._poolCollection=B.connect("0x1f9344e9e593f9fBFc4a87d1914f5E3973fE54DA",this._provider)),this._poolCollection}},{key:"bancorNetwork",get:function(){return this._bancorNetwork||(this._bancorNetwork=A.connect("0x1365D7de79508AcEa3FF78539a9a50445Cc62D0a",this._provider)),this._bancorNetwork}},{key:"multicall",get:function(){return this._multiCall||(this._multiCall=S.connect("0x5ba1e12693dc8f9c48aad8770482f4739beed696",this._provider)),this._multiCall}},{key:"voucher",get:function(){return this._voucher||(this._voucher=D.connect("0xD88c3AA46a100694926c6a8c969835ee6F773128",this._provider)),this._voucher}}]),e}(),E=function(e){return{id:e[0],token0:e[1][0],token1:e[1][1],order0:{y:e[2][0][0],z:e[2][0][1],A:e[2][0][2],B:e[2][0][3]},order1:{y:e[2][1][0],z:e[2][1][1],A:e[2][1][2],B:e[2][1][3]}}},j=/*#__PURE__*/function(){function e(e){var t=this;this._contracts=void 0,this.getDecimalsByAddress=function(e){try{return k(e)?Promise.resolve(18):Promise.resolve(t._contracts.token(e).decimals())}catch(e){return Promise.reject(e)}},this._contracts=e}var t=e.prototype;return t.multicall=function(e,t){return function(e,t,n){return Promise.resolve(function(a,r){try{var i=(o=e.map(function(e){return{target:e.contractAddress.toLocaleLowerCase(),callData:e.interface.encodeFunctionData(e.methodName,e.methodParameters)}}),Promise.resolve(t.tryAggregate(!1,o,{blockTag:n})).then(function(t){return t.map(function(t,n){return t.success?e[n].interface.decodeFunctionResult(e[n].methodName,t.returnData):[]})}))}catch(e){return}var o;return i&&i.then?i.then(void 0,function(){}):i}())}(e,this._contracts.multicall,t)},t.getStrategyById=function(e){try{return Promise.resolve(this._contracts.poolCollection.strategy(e)).then(E)}catch(e){return Promise.reject(e)}},t.getStrategiesByIds=function(e){try{return Promise.resolve(this._contracts.poolCollection.strategiesByIds(e)).then(function(e){return e.map(function(e){return E(e)})})}catch(e){return Promise.reject(e)}},t.getAllTokenPairs=function(){return this._contracts.poolCollection.pairs()},t.getStrategiesByTokenPair=function(e,t){try{return Promise.resolve(this._contracts.poolCollection.strategiesByPool(e,t)).then(function(e){return e.map(function(e){return E(e)})})}catch(e){return Promise.reject(e)}},t.getStrategiesByTokenPairs=function(e){try{var t=this;return Promise.resolve(t.multicall(e.map(function(e){return{contractAddress:t._contracts.poolCollection.address,interface:t._contracts.poolCollection.interface,methodName:"strategiesByPool",methodParameters:[e[0],e[1]]}}))).then(function(e){return e&&0!==e.length?e.map(function(e){return e[0].map(function(e){return E(e)})}):[]})}catch(e){return Promise.reject(e)}},t.getUserStrategyIds=function(e){try{var t=this;return e?Promise.resolve(t._contracts.voucher.balanceOf(e)).then(function(n){var a=Array.from(Array(n.toNumber()),function(n,a){return{contractAddress:t._contracts.voucher.address,interface:t._contracts.voucher.interface,methodName:"tokenOfOwnerByIndex",methodParameters:[e,a]}});return Promise.resolve(t.multicall(a)).then(function(e){return e?e.map(function(e){return e[0]}):[]})}):Promise.resolve([])}catch(e){return Promise.reject(e)}},t.onStrategyCreated=function(e){return this._contracts.poolCollection.on("StrategyCreated",function(t){var n;try{n=E(t)}catch(e){console.error("StrategyCreated event returned invalid data. skipping.",e,t)}n&&e(n)})},t.onStrategyUpdated=function(e){return this._contracts.poolCollection.on("StrategyUpdated",function(t){var n;try{n=E(t)}catch(e){console.error("StrategyUpdated event returned invalid data. skipping.",e,t)}n&&e(n)})},e}(),U=/*#__PURE__*/function(){function e(e){this._reader=void 0,this._composer=void 0;var t=new N(e);this._reader=new j(t),this._composer=new _(t)}return u(e,[{key:"reader",get:function(){return this._reader}},{key:"composer",get:function(){return this._composer}}]),e}(),F=function(e,t){var n=e.output.mul(t.input),a=t.output.mul(e.input),r=n.lt(a),i=n.gt(a),o=!r&&!i;return+(r||o&&e.output.lt(t.output))-+(i||o&&e.output.gt(t.output))},z=function(e,t){return F(t,e)},q=t.BigNumber.from(0),L=t.BigNumber.from(2).pow(128).sub(1),H=function(e,t){var n=e,a=t.y,r=t.z,i=t.A,o=t.B,s=r.mul(v),u=a.mul(i).add(r.mul(o)),p=u.sub(n.mul(i)),y=function(e,t,n){return e.mul(t).add(n).sub(1).div(n)}(n.mul(s),s,u.mul(p));return y.lt(q)?L:y},Z=function(e,t){var n=function(e,t){var n=e,a=t.z,r=t.A,i=t.B,o=t.y.mul(r).add(a.mul(i)),s=o.mul(n).div(v),u=s.mul(r).add(a.mul(a).mul(v)),p=function(e,t,n){return e.mul(t).div(n)}(o,s,u);return p.gt(L)?q:p}(e,t),a=n.lt(t.y)?n:t.y;return{input:H(a,t),output:a}},G=function(e,t){var n=e.lt(t.y)?e:t.y;return{input:n,output:H(n,t)}},V=function(e,n,a,r,i){for(var o,s=[],u=d(Object.keys(n).map(function(t){return{id:t,rate:r(e,n[t])}}).sort(function(e,t){return i(e.rate,t.rate)}));!(o=u()).done;){var p=o.value,y=p.id,l=p.rate;if(!e.gt(l.input)){if(e.eq(l.input)){a(l)&&s.push({id:t.BigNumber.from(y),input:l.input,output:l.output});break}var c={input:e,output:r(e,n[y]).output};a(c)&&s.push({id:t.BigNumber.from(y),input:c.input,output:c.output});break}a(l)&&(s.push({id:t.BigNumber.from(y),input:l.input,output:l.output}),e=e.sub(l.input))}return s},J=/*#__PURE__*/function(){function e(){this._cachedDecimals=void 0,this._cachedDecimals=new Map}return e.init=function(t){e._fetcher=t,e.getInstance().cachedDecimals.clear()},e.getInstance=function(){if(!e._instance){if(!e._fetcher)throw new Error("Decimals has not been initialized with a fetcher function");e._instance=new e}return e._instance},e.prototype.fetchDecimals=function(t){try{var n=this,a=n._cachedDecimals.get(t);return void 0!==a?Promise.resolve(a):Promise.resolve(e._fetcher(t)).then(function(e){return n._cachedDecimals.set(t,a=e),a})}catch(e){return Promise.reject(e)}},u(e,[{key:"cachedDecimals",get:function(){return this._cachedDecimals}}]),e}();J._instance=void 0,J._fetcher=void 0;var W=function(e,t,n){return new o.default(e).times(g(t,n)).toFixed()},$=function(e,t,n){return 0==+e?"0":new o.default(1).div(e).times(g(n,t)).toFixed()},K=function(e,t){return r.parseUnits(e,t).toString()},Q=function(e,t){var n=r.formatUnits(e,t);return new o.default(n).toFixed()},X=function(e){return e.sqrt().mul(v)},Y=function(e){return e.div(v).pow(2)},ee=function(e){var n=t.BigNumber.from(new o.default(e.liquidity).toFixed()),a=t.BigNumber.from(X(new o.default(e.lowestRate)).floor().toFixed()),r=t.BigNumber.from(X(new o.default(e.highestRate)).floor().toFixed()),i=t.BigNumber.from(X(new o.default(e.marginalRate)).floor().toFixed());if(!(r.gte(i)&&i.gt(a)||r.eq(i)&&i.eq(a)))throw new Error("Invalid order: max must be greater than or equal to mid, and mid must be greater than min \n - or the three should be equal (highestRate: "+e.highestRate+", \n marginalRate: "+e.marginalRate+", lowestRate: "+e.lowestRate+")");var s=r.sub(a);return{y:n,z:s.isZero()?n:n.mul(s).div(i.sub(a)),A:s,B:a}},te=function(e){var t=new o.default(e.y.toString()),n=new o.default(e.z.toString()),a=new o.default(e.A.toString()),r=new o.default(e.B.toString()),i=t.eq(n)?new o.default(1):t.div(n);return{liquidity:t.toString(),lowestRate:Y(r).toString(),highestRate:Y(r.add(a)).toString(),marginalRate:Y(r.add(a.mul(i))).toString()}};/*#__PURE__*/
return function(){function n(t,n){this._api=void 0,this._cachedOrders=void 0;var a=new e.StaticJsonRpcProvider(t,1);this._api=new U(a),J.init(null!=n?n:this._api.reader.getDecimalsByAddress)}var a=n.prototype;return a.startDataSync=function(){try{var e=this;return e._cachedOrders?Promise.resolve():(e._cachedOrders=new T(e._api.reader),Promise.resolve(e._cachedOrders.init()).then(function(){}))}catch(e){return Promise.reject(e)}},a.hasLiquidityByPair=function(e,t){if(!this._cachedOrders)throw new Error("initDataSync must be called prior to this action");for(var n=this._cachedOrders.getOrders(e,t),a=0,r=Object.values(n);a<r.length;a++)if(r[a].y.gt(0))return!0;return!1},a.getLiquidityByPair=function(e,n){try{if(!this._cachedOrders)throw new Error("initDataSync must be called prior to this action");var a=this._cachedOrders.getOrders(e,n),i=Object.entries(a).reduce(function(e,t){return e.add(t[1].y)},t.BigNumber.from(0));return Promise.resolve(J.getInstance().fetchDecimals(e)).then(function(e){return r.formatUnits(i,e)})}catch(e){return Promise.reject(e)}},a.getUserStrategies=function(e){try{var t=this;if(!t._cachedOrders)throw new Error("initDataSync must be called prior to this action");return Promise.resolve(t._api.reader.getUserStrategyIds(e)).then(function(e){var n=t._cachedOrders.strategyById,a=e.map(function(e){return n.get(e.toString())}).filter(function(e){return!!e});return Promise.resolve(Promise.all(a.map(function(e){try{return Promise.resolve(function(e){try{var t=e.token0,n=e.token1,a=e.order0,r=e.order1,i=J.getInstance();return Promise.resolve(i.fetchDecimals(t)).then(function(o){return Promise.resolve(i.fetchDecimals(n)).then(function(i){var s=W(r.lowestRate,o,i),u=W(r.highestRate,o,i),p=$(a.highestRate,i,o),y=$(a.lowestRate,i,o),d=Q(a.liquidity,o),l=Q(r.liquidity,i);return{id:e.id,baseToken:t,quoteToken:n,buyPriceLow:s,buyPriceHigh:u,buyBudget:l,sellPriceLow:p,sellPriceHigh:y,sellBudget:d}})})}catch(e){return Promise.reject(e)}}(function(e){return{id:e.id,token0:e.token0,token1:e.token1,order0:te(e.order0),order1:te(e.order1)}}(e)))}catch(e){return Promise.reject(e)}})))})}catch(e){return Promise.reject(e)}},a.getTradeData=function(e,n,a,i,s){try{var u=this;if(!u._cachedOrders)throw new Error("initDataSync must be called prior to this action");var p=J.getInstance();return Promise.resolve(p.fetchDecimals(e)).then(function(y){return Promise.resolve(p.fetchDecimals(n)).then(function(p){var d,l=u._cachedOrders.getOrders(e,n),c=t.BigNumber.from(r.parseUnits(a,i?p:y));d=i?function(e,t,n){return void 0===n&&(n=function(e){return!0}),V(e,t,n,G,z)}(c,l,s):function(e,t,n){return void 0===n&&(n=function(e){return!0}),V(e,t,n,Z,F)}(c,l,s);var m=[],f=[],b=t.BigNumber.from(0),T=t.BigNumber.from(0);if(d.forEach(function(e){m.push({strategyId:e.id,amount:e.input}),f.push({id:e.id,input:r.formatUnits(e.input,y),output:r.formatUnits(e.output,p)}),T=T.add(e.input),b=b.add(e.output)}),T.isZero()||b.isZero())return{tradeActions:m,actionsTokenRes:f,totalInput:"0",totalOutput:"0",effectiveRate:"0"};var v=new o.default(T.toString()).div(b.toString()).times(g(p,y)).toString();return{tradeActions:m,actionsTokenRes:f,totalInput:r.formatUnits(T,y),totalOutput:r.formatUnits(b,p),effectiveRate:v}})})}catch(e){return Promise.reject(e)}},a.composeTradeByTargetTransaction=function(e,t,n,a,r,i){return this._api.composer.tradeByTargetAmount(e,t,n,a,r,i)},a.composeTradeBySourceTransaction=function(e,t,n,a,r,i){return this._api.composer.tradeBySourceAmount(e,t,n,a,r,i)},a.createBuySellStrategy=function(e,t,n,a,r,i,s,u,p){var y=function(e,t,n,a,r,i,s,u){if(new o.default(n).isNegative()||new o.default(a).isNegative()||new o.default(i).isNegative()||new o.default(s).isNegative())throw new Error("prices cannot be negative");if(new o.default(n).gt(a)||new o.default(i).gt(s))throw new Error("low price must be lower than or equal to high price");if(new o.default(r).isNegative()||new o.default(u).isNegative())throw new Error("budgets cannot be negative");var p=function(e,t,n,a,r,i,o,s){var u=K(s,e),p=$(o,t,e),y=$(i,t,e),d=K(r,t),l=W(n,t,e),c=W(a,t,e);return{order0:{liquidity:u,lowestRate:p,highestRate:y,marginalRate:y},order1:{liquidity:d,lowestRate:l,highestRate:c,marginalRate:c}}}(e.decimals,t.decimals,n,a,r,i,s,u);return{token0:e.address,token1:t.address,order0:p.order0,order1:p.order1}}(e,t,n,a,r,i,s,u),d=function(e){return{token0:e.token0,token1:e.token1,order0:ee(e.order0),order1:ee(e.order1)}}(y);return this._api.composer.createStrategy(d.token0,d.token1,d.order0.y,d.order0.z,d.order0.A,d.order0.B,d.order1.y,d.order1.z,d.order1.A,d.order1.B,p)},u(n,[{key:"isInitialized",get:function(){return void 0!==this._cachedOrders}},{key:"pairs",get:function(){if(!this._cachedOrders)throw new Error("initDataSync must be called prior to this action");return Array.from(this._cachedOrders.pairToStrategies.keys())}}]),n}()});
return function(){function n(t,n){this._api=void 0,this._cachedOrders=void 0;var a=new e.StaticJsonRpcProvider(t,1);this._api=new U(a),J.init(null!=n?n:this._api.reader.getDecimalsByAddress)}var a=n.prototype;return a.startDataSync=function(){try{var e=this;return e._cachedOrders?Promise.resolve():(e._cachedOrders=new T(e._api.reader),Promise.resolve(e._cachedOrders.init()).then(function(){}))}catch(e){return Promise.reject(e)}},a.hasLiquidityByPair=function(e,t){if(!this._cachedOrders)throw new Error("initDataSync must be called prior to this action");for(var n=this._cachedOrders.getOrders(e,t),a=0,r=Object.values(n);a<r.length;a++)if(r[a].y.gt(0))return!0;return!1},a.getLiquidityByPair=function(e,n){try{if(!this._cachedOrders)throw new Error("initDataSync must be called prior to this action");var a=this._cachedOrders.getOrders(e,n),i=Object.entries(a).reduce(function(e,t){return e.add(t[1].y)},t.BigNumber.from(0));return Promise.resolve(J.getInstance().fetchDecimals(n)).then(function(e){return r.formatUnits(i,e)})}catch(e){return Promise.reject(e)}},a.getUserStrategies=function(e){try{var t=this;if(!t._cachedOrders)throw new Error("initDataSync must be called prior to this action");return Promise.resolve(t._api.reader.getUserStrategyIds(e)).then(function(e){var n=t._cachedOrders.strategyById,a=e.map(function(e){return n.get(e.toString())}).filter(function(e){return!!e});return Promise.resolve(Promise.all(a.map(function(e){try{return Promise.resolve(function(e){try{var t=e.token0,n=e.token1,a=e.order0,r=e.order1,i=J.getInstance();return Promise.resolve(i.fetchDecimals(t)).then(function(o){return Promise.resolve(i.fetchDecimals(n)).then(function(i){var s=W(r.lowestRate,o,i),u=W(r.highestRate,o,i),p=$(a.highestRate,i,o),y=$(a.lowestRate,i,o),d=Q(a.liquidity,o),l=Q(r.liquidity,i);return{id:e.id,baseToken:t,quoteToken:n,buyPriceLow:s,buyPriceHigh:u,buyBudget:l,sellPriceLow:p,sellPriceHigh:y,sellBudget:d}})})}catch(e){return Promise.reject(e)}}(function(e){return{id:e.id,token0:e.token0,token1:e.token1,order0:te(e.order0),order1:te(e.order1)}}(e)))}catch(e){return Promise.reject(e)}})))})}catch(e){return Promise.reject(e)}},a.getTradeData=function(e,n,a,i,s){try{var u=this;if(!u._cachedOrders)throw new Error("initDataSync must be called prior to this action");var p=J.getInstance();return Promise.resolve(p.fetchDecimals(e)).then(function(y){return Promise.resolve(p.fetchDecimals(n)).then(function(p){var d,l=u._cachedOrders.getOrders(e,n),c=t.BigNumber.from(r.parseUnits(a,i?p:y));d=i?function(e,t,n){return void 0===n&&(n=function(e){return!0}),V(e,t,n,G,z)}(c,l,s):function(e,t,n){return void 0===n&&(n=function(e){return!0}),V(e,t,n,Z,F)}(c,l,s);var m=[],f=[],b=t.BigNumber.from(0),T=t.BigNumber.from(0);if(d.forEach(function(e){m.push({strategyId:e.id,amount:e.input}),f.push({id:e.id,input:r.formatUnits(e.input,y),output:r.formatUnits(e.output,p)}),T=T.add(e.input),b=b.add(e.output)}),T.isZero()||b.isZero())return{tradeActions:m,actionsTokenRes:f,totalInput:"0",totalOutput:"0",effectiveRate:"0"};var v=new o.default(T.toString()).div(b.toString()).times(g(p,y)).toString();return{tradeActions:m,actionsTokenRes:f,totalInput:r.formatUnits(T,y),totalOutput:r.formatUnits(b,p),effectiveRate:v}})})}catch(e){return Promise.reject(e)}},a.composeTradeByTargetTransaction=function(e,t,n,a,r,i){return this._api.composer.tradeByTargetAmount(e,t,n,a,r,i)},a.composeTradeBySourceTransaction=function(e,t,n,a,r,i){return this._api.composer.tradeBySourceAmount(e,t,n,a,r,i)},a.createBuySellStrategy=function(e,t,n,a,r,i,s,u,p){var y=function(e,t,n,a,r,i,s,u){if(new o.default(n).isNegative()||new o.default(a).isNegative()||new o.default(i).isNegative()||new o.default(s).isNegative())throw new Error("prices cannot be negative");if(new o.default(n).gt(a)||new o.default(i).gt(s))throw new Error("low price must be lower than or equal to high price");if(new o.default(r).isNegative()||new o.default(u).isNegative())throw new Error("budgets cannot be negative");var p=function(e,t,n,a,r,i,o,s){var u=K(s,e),p=$(o,t,e),y=$(i,t,e),d=K(r,t),l=W(n,t,e),c=W(a,t,e);return{order0:{liquidity:u,lowestRate:p,highestRate:y,marginalRate:y},order1:{liquidity:d,lowestRate:l,highestRate:c,marginalRate:c}}}(e.decimals,t.decimals,n,a,r,i,s,u);return{token0:e.address,token1:t.address,order0:p.order0,order1:p.order1}}(e,t,n,a,r,i,s,u),d=function(e){return{token0:e.token0,token1:e.token1,order0:ee(e.order0),order1:ee(e.order1)}}(y);return this._api.composer.createStrategy(d.token0,d.token1,d.order0.y,d.order0.z,d.order0.A,d.order0.B,d.order1.y,d.order1.z,d.order1.A,d.order1.B,p)},u(n,[{key:"isInitialized",get:function(){return void 0!==this._cachedOrders}},{key:"pairs",get:function(){if(!this._cachedOrders)throw new Error("initDataSync must be called prior to this action");return Array.from(this._cachedOrders.pairToStrategies.keys())}}]),n}()});
//# sourceMappingURL=sdk.umd.js.map

@@ -5,3 +5,3 @@ {

"source": "src/index.ts",
"version": "0.0.19-DEV",
"version": "0.0.20-DEV",
"description": "The SDK is a READ-ONLY tool, intended to facilitate working with Carbon contracts. It's a convenient wrapper around our matching algorithm, allowing programs and users get a ready to use transaction data that will allow them to manage strategies and fulfill trades",

@@ -8,0 +8,0 @@ "main": "dist/sdk.umd.js",

@@ -138,3 +138,3 @@ import { PopulatedTransaction } from '@ethersproject/contracts';

);
const decimals = await Decimals.getInstance().fetchDecimals(token0);
const decimals = await Decimals.getInstance().fetchDecimals(token1);

@@ -141,0 +141,0 @@ return formatUnits(liquidityWei, decimals);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc