@bancor/carbon-sdk
Advanced tools
Comparing version 0.0.20-DEV to 0.0.21-DEV
@@ -10,6 +10,6 @@ import { BigNumber } from './numerics'; | ||
*/ | ||
export declare const formatStrategy: (strategy: DecodedStrategy & { | ||
export declare function formatStrategy(strategy: DecodedStrategy & { | ||
id: BigNumber; | ||
}) => Promise<FriendlyStrategy>; | ||
export declare const buildStrategyObject: (baseToken: { | ||
}): Promise<FriendlyStrategy>; | ||
export declare function buildStrategyObject(baseToken: { | ||
address: string; | ||
@@ -20,13 +20,24 @@ decimals: number; | ||
decimals: number; | ||
}, buyPriceLow: string, buyPriceHigh: string, buyBudget: string, sellPriceLow: string, sellPriceHigh: string, sellBudget: string) => DecodedStrategy; | ||
}, buyPriceLow: string, // in quote tkn per 1 base tkn | ||
buyPriceHigh: string, // in quote tkn per 1 base tkn | ||
buyBudget: string, // in quote tkn | ||
sellPriceLow: string, // in quote tkn per 1 base tkn | ||
sellPriceHigh: string, // in quote tkn per 1 base tkn | ||
sellBudget: string): DecodedStrategy; | ||
declare function normalizeRate(amount: string, amountTokenDecimals: number, otherTokenDecimals: number): string; | ||
declare function normalizeInvertedRate(amount: string, amountTokenDecimals: number, otherTokenDecimals: number): string; | ||
declare function createOrders(baseTokenDecimals: number, quoteTokenDecimals: number, buyPriceLow: string, buyPriceHigh: string, buyBudget: string, sellPriceLow: string, sellPriceHigh: string, sellBudget: string): { | ||
order0: DecodedOrder; | ||
order1: DecodedOrder; | ||
}; | ||
declare function parseUnits(amount: string, decimals: number): string; | ||
declare function formatUnits(amount: string, decimals: number): string; | ||
export declare const EXPORTED_FOR_TESTS: { | ||
formatUnits: (amount: string, decimals: number) => string; | ||
parseUnits: (amount: string, decimals: number) => string; | ||
normalizeRate: (amount: string, amountTokenDecimals: number, otherTokenDecimals: number) => string; | ||
normalizeInvertedRate: (amount: string, amountTokenDecimals: number, otherTokenDecimals: number) => string; | ||
createOrders: (baseTokenDecimals: number, quoteTokenDecimals: number, buyPriceLow: string, buyPriceHigh: string, buyBudget: string, sellPriceLow: string, sellPriceHigh: string, sellBudget: string) => { | ||
order0: DecodedOrder; | ||
order1: DecodedOrder; | ||
}; | ||
formatUnits: typeof formatUnits; | ||
parseUnits: typeof parseUnits; | ||
normalizeRate: typeof normalizeRate; | ||
normalizeInvertedRate: typeof normalizeInvertedRate; | ||
createOrders: typeof createOrders; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=friendlyUtils.d.ts.map |
@@ -23,3 +23,3 @@ import { PopulatedTransaction } from '@ethersproject/contracts'; | ||
private _api; | ||
private _cachedOrders; | ||
private _cache; | ||
/** | ||
@@ -54,2 +54,5 @@ * Creates a new Sdk instance. | ||
* | ||
* @param {string} sourceToken - address of the token the trade sells. | ||
* @param {string} targetToken - address of the token the trade buys. | ||
* | ||
* @returns {Boolean} true or false. | ||
@@ -59,12 +62,13 @@ * @throws {Error} If `startDataSync` has not been called. | ||
*/ | ||
hasLiquidityByPair(token0: string, token1: string): boolean; | ||
hasLiquidityByPair(sourceToken: string, targetToken: string): boolean; | ||
/** | ||
* Returns liquidity for a given pair. | ||
* | ||
* @param {string} token0 the first token of the pair | ||
* @param {string} token1 the second token of the pair | ||
* @param {string} sourceToken - address of the token the trade sells. | ||
* @param {string} targetToken - address of the token the trade buys. | ||
* | ||
* @returns {Promise<String>} liquidity value as string | ||
* @throws {Error} If `startDataSync` has not been called. | ||
*/ | ||
getLiquidityByPair(token0: string, token1: string): Promise<string>; | ||
getLiquidityByPair(sourceToken: string, targetToken: string): Promise<string>; | ||
/** | ||
@@ -108,4 +112,4 @@ * Gets the strategies that are owned by the user. | ||
actionsTokenRes: FriendlyAction[]; | ||
totalInput: string; | ||
totalOutput: string; | ||
totalSourceAmount: string; | ||
totalTargetAmount: string; | ||
effectiveRate: string; | ||
@@ -112,0 +116,0 @@ }>; |
@@ -1,3 +0,2 @@ | ||
!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(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}()}); | ||
!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){if(!n.has(e.id.toString())){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:{}},t.getStrategyById=function(e){return this._strategyById.get(e.toString())},u(e,[{key:"pairs",get:function(){return Array.from(this._pairToStrategies.keys())}}]),e}();o.default.set({precision:50,rounding:o.default.ROUND_HALF_DOWN,toExpNeg:-30,toExpPos:30});var g=Math.pow(2,32),v=new o.default(10),h=function(e,t){return v.pow(e-t)},w="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE".toLowerCase(),k=function(e){return e.toLowerCase()===w},_=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},A=/*#__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=_(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=_(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}(),M=[{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"}],S=/*#__PURE__*/function(){function e(){}return e.createInterface=function(){return new a.utils.Interface(M)},e.connect=function(e,t){return new a.Contract(e,M,t)},e}();S.abi=M;var x=[{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"}],P=/*#__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}();P.abi=x;var B=[{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"}],I=/*#__PURE__*/function(){function e(){}return e.createInterface=function(){return new a.utils.Interface(B)},e.connect=function(e,t){return new a.Contract(e,B,t)},e}();I.abi=B;var D=[{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(D)},e.connect=function(e,t){return new a.Contract(e,D,t)},e}();C.abi=D;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"}],O=/*#__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}();O.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=I.connect("0x1f9344e9e593f9fBFc4a87d1914f5E3973fE54DA",this._provider)),this._poolCollection}},{key:"bancorNetwork",get:function(){return this._bancorNetwork||(this._bancorNetwork=S.connect("0x1365D7de79508AcEa3FF78539a9a50445Cc62D0a",this._provider)),this._bancorNetwork}},{key:"multicall",get:function(){return this._multiCall||(this._multiCall=P.connect("0x5ba1e12693dc8f9c48aad8770482f4739beed696",this._provider)),this._multiCall}},{key:"voucher",get:function(){return this._voucher||(this._voucher=O.connect("0xD88c3AA46a100694926c6a8c969835ee6F773128",this._provider)),this._voucher}}]),e}(),E="production"!==process.env.NODE_ENV,j=/*#__PURE__*/function(){function e(e){this._prefix=void 0,this._prefix="[SDK]["+e+"]:"}var t=e.prototype;return t.log=function(){var e;(e=console).log.apply(e,[this._prefix].concat([].slice.call(arguments)))},t.debug=function(){var e;E&&(e=console).log.apply(e,[this._prefix].concat([].slice.call(arguments)))},e}(),U=new j("Reader.ts"),z=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]}}},q=/*#__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(z)}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 z(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 z(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 z(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,n,a,r,i,o){var s=i.y,u=i.z,p=i.A,y=i.B,d=o.y,l=o.z,c=o.A,m=o.B;U.debug("StrategyCreated fired with",arguments);var f={id:t,token0:a,token1:r,order0:{y:s,z:u,A:p,B:y},order1:{y:d,z:l,A:c,B:m}};U.debug("StrategyCreated parsed strategy:",f),e(f)})},t.onStrategyUpdated=function(e){return this._contracts.poolCollection.on("StrategyUpdated",function(t,n,a,r,i,o){var s=i.y,u=i.z,p=i.A,y=i.B,d=o.y,l=o.z,c=o.A,m=o.B;U.debug("StrategyUpdated fired with",arguments);var f={id:t,token0:a,token1:r,order0:{y:s,z:u,A:p,B:y},order1:{y:d,z:l,A:c,B:m}};U.debug("StrategyUpdated parsed strategy:",f),e(f)})},e}(),F=/*#__PURE__*/function(){function e(e){this._reader=void 0,this._composer=void 0;var t=new N(e);this._reader=new q(t),this._composer=new A(t)}return u(e,[{key:"reader",get:function(){return this._reader}},{key:"composer",get:function(){return this._composer}}]),e}(),L=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))},H=function(e,t){return L(t,e)},W=t.BigNumber.from(0),Z=t.BigNumber.from(2).pow(128).sub(1),G=function(e,t){var n=e,a=t.y,r=t.z,i=t.A,o=t.B,s=r.mul(g),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(W)?Z:y},V=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(g),u=s.mul(r).add(a.mul(a).mul(g)),p=function(e,t,n){return e.mul(t).div(n)}(o,s,u);return p.gt(Z)?W:p}(e,t),a=n.lt(t.y)?n:t.y;return{input:G(a,t),output:a}},K=function(e,t){var n=e.lt(t.y)?e:t.y;return{input:n,output:G(n,t)}},J=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},$=function(e,t,n){return void 0===n&&(n=function(e){return!0}),J(e,t,n,V,L)},Q=function(e,t,n){return void 0===n&&(n=function(e){return!0}),J(e,t,n,K,H)},X=/*#__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}();X._instance=void 0,X._fetcher=void 0;var Y=function(e){try{var t=arguments;ee.debug("formatStrategy called",t);var n=e.id,a=e.token0,r=e.token1,i=e.order0,o=e.order1,s=X.getInstance();return Promise.resolve(s.fetchDecimals(a)).then(function(e){return Promise.resolve(s.fetchDecimals(r)).then(function(t){var s=ne(o.lowestRate,e,t),u=ne(o.highestRate,e,t),p=ae(i.highestRate,t,e),y=ae(i.lowestRate,t,e),d=oe(i.liquidity,e),l=oe(o.liquidity,t);return ee.debug("formatStrategy info:",{id:n,token0:a,token1:r,order0:i,order1:o,decimals0:e,decimals1:t,baseToken:a,quoteToken:r,buyPriceLow:s,buyPriceHigh:u,buyBudget:l,sellPriceLow:p,sellPriceHigh:y,sellBudget:d}),{id:n,baseToken:a,quoteToken:r,buyPriceLow:s,buyPriceHigh:u,buyBudget:l,sellPriceLow:p,sellPriceHigh:y,sellBudget:d}})})}catch(e){return Promise.reject(e)}},ee=new j("friendlyUtils.ts");function te(e,t,n,a,r,i,s,u){if(ee.debug("buildStrategyObject called",arguments),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=re(e.decimals,t.decimals,n,a,r,i,s,u),y=p.order0,d=p.order1;return ee.debug("buildStrategyObject info:",{token0:e.address,token1:t.address,order0:y,order1:d}),{token0:e.address,token1:t.address,order0:y,order1:d}}function ne(e,t,n){return new o.default(e).times(h(t,n)).toFixed()}function ae(e,t,n){return 0==+e?"0":new o.default(1).div(e).times(h(n,t)).toFixed()}function re(e,t,n,a,r,i,o,s){ee.debug("createOrders called",arguments);var u=ie(s,e),p=ae(o,t,e),y=ae(i,t,e),d=ie(r,t),l=ne(n,t,e),c=ne(a,t,e),m={liquidity:u,lowestRate:p,highestRate:y,marginalRate:y},f={liquidity:d,lowestRate:l,highestRate:c,marginalRate:c};return ee.debug("createOrders info:",{order0:m,order1:f}),{order0:m,order1:f}}function ie(e,t){return r.parseUnits(e,t).toString()}function oe(e,t){var n=r.formatUnits(e,t);return new o.default(n).toFixed()}var se=function(e){return e.sqrt().mul(g)},ue=function(e){return e.div(g).pow(2)},pe=function(e){var n=t.BigNumber.from(new o.default(e.liquidity).toFixed()),a=t.BigNumber.from(se(new o.default(e.lowestRate)).floor().toFixed()),r=t.BigNumber.from(se(new o.default(e.highestRate)).floor().toFixed()),i=t.BigNumber.from(se(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}},ye=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:ue(r).toString(),highestRate:ue(r.add(a)).toString(),marginalRate:ue(r.add(a.mul(i))).toString()}},de=function(e){return{token0:e.token0,token1:e.token1,order0:pe(e.order0),order1:pe(e.order1)}},le=function(e){return{id:e.id,token0:e.token0,token1:e.token1,order0:ye(e.order0),order1:ye(e.order1)}},ce=new j("index.ts"),me=/*#__PURE__*/function(){function n(t,n){this._api=void 0,this._cache=void 0,ce.debug("SDK class constructor called with",arguments);var a=new e.StaticJsonRpcProvider(t,1);this._api=new F(a),X.init(null!=n?n:this._api.reader.getDecimalsByAddress)}var a=n.prototype;return a.startDataSync=function(){try{var e=this;return ce.debug("startDataSync called"),e._cache?(ce.debug("startDataSync was already called before"),Promise.resolve()):(e._cache=new T(e._api.reader),Promise.resolve(e._cache.init()).then(function(){}))}catch(e){return Promise.reject(e)}},a.hasLiquidityByPair=function(e,t){if(ce.debug("hasLiquidityByPair called",arguments),!this._cache)throw ce.log("hasLiquidityByPair called before startDataSync"),new Error("startDataSync must be called prior to this action");var n=this._cache.getOrders(e,t),a=void 0!==Object.values(n).find(function(e){return e.y.gt(0)});return ce.debug("hasLiquidityByPair info:",{orders:n,hasLiq:a}),a},a.getLiquidityByPair=function(e,n){try{var a=arguments,i=this;if(ce.debug("getLiquidityByPair called",a),!i._cache)throw ce.log("getLiquidityByPair called before startDataSync"),new Error("startDataSync must be called prior to this action");var o=i._cache.getOrders(e,n),s=Object.values(o).reduce(function(e,t){return e.add(t.y)},t.BigNumber.from(0));return Promise.resolve(X.getInstance().fetchDecimals(n)).then(function(e){var t=r.formatUnits(s,e);return ce.debug("getLiquidityByPair info:",{orders:o,liquidityWei:s,targetToken:n,decimals:e,liquidity:t}),t})}catch(e){return Promise.reject(e)}},a.getUserStrategies=function(e){try{var t=arguments,n=this;if(ce.debug("getUserStrategies called",t),!n._cache)throw ce.log("getUserStrategies called before startDataSync"),new Error("startDataSync must be called prior to this action");return Promise.resolve(n._api.reader.getUserStrategyIds(e)).then(function(e){var t=e.map(function(e){var t;return null==(t=n._cache)?void 0:t.getStrategyById(e)}).filter(function(e){return!!e}),a=t.map(le);return Promise.resolve(Promise.all(a.map(function(e){try{return Promise.resolve(Y(e))}catch(e){return Promise.reject(e)}}))).then(function(n){return ce.debug("getUserStrategies info:",{ids:e,encodedStrategies:t,decodedStrategies:a,strategies:n}),n})})}catch(e){return Promise.reject(e)}},a.getTradeData=function(e,n,a,i,s){try{var u=arguments,p=this;if(ce.debug("getTradeData called",u),!p._cache)throw ce.log("getTradeData called before startDataSync"),new Error("startDataSync must be called prior to this action");var y=X.getInstance();return Promise.resolve(y.fetchDecimals(e)).then(function(u){return Promise.resolve(y.fetchDecimals(n)).then(function(y){var d,l=p._cache.getOrders(e,n),c=t.BigNumber.from(r.parseUnits(a,i?y:u));d=i?Q(c,l,s):$(c,l,s);var m=[],f=[],b=t.BigNumber.from(0),T=t.BigNumber.from(0);d.forEach(function(e){m.push({strategyId:e.id,amount:e.input}),f.push({id:e.id,sourceAmount:r.formatUnits(i?e.output:e.input,u),targetAmount:r.formatUnits(i?e.input:e.output,y)}),T=T.add(e.input),b=b.add(e.output)});var g,v=i?b:T,w=i?T:b;if(v.isZero()||w.isZero())g={tradeActions:m,actionsTokenRes:f,totalSourceAmount:"0",totalTargetAmount:"0",effectiveRate:"0"};else{var k=new o.default(w.toString()).div(v.toString()).times(h(u,y)).toString();g={tradeActions:m,actionsTokenRes:f,totalSourceAmount:r.formatUnits(v,u),totalTargetAmount:r.formatUnits(w,y),effectiveRate:k}}return ce.debug("getTradeData info:",{sourceDecimals:u,targetDecimals:y,orders:l,amount:a,amountWei:c,actionsWei:d,res:g}),g})})}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,o,s,u){ce.debug("createBuySellStrategy called",arguments);var p=te(e,t,n,a,r,i,o,s),y=de(p);return ce.debug("createBuySellStrategy info:",{strategy:p,encStrategy:y}),this._api.composer.createStrategy(y.token0,y.token1,y.order0.y,y.order0.z,y.order0.A,y.order0.B,y.order1.y,y.order1.z,y.order1.A,y.order1.B,u)},u(n,[{key:"isInitialized",get:function(){return void 0!==this._cache}},{key:"pairs",get:function(){if(ce.debug("pairs called"),!this._cache)throw ce.log("pairs called before startDataSync"),new Error("startDataSync must be called prior to this action");return this._cache.pairs}}]),n}();return me}); | ||
//# sourceMappingURL=sdk.umd.js.map |
@@ -5,3 +5,3 @@ { | ||
"source": "src/index.ts", | ||
"version": "0.0.20-DEV", | ||
"version": "0.0.21-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", |
@@ -8,2 +8,4 @@ import { BigNumber } from '../numerics'; | ||
import { isETHAddress } from './utils'; | ||
import { Logger } from '../logger'; | ||
const logger = new Logger('Reader.ts'); | ||
@@ -124,16 +126,30 @@ const toStrategy = (res: StrategyStructOutput): EncodedStrategy => { | ||
'StrategyCreated', | ||
(res: StrategyStructOutput) => { | ||
let strategy: EncodedStrategy | undefined; | ||
try { | ||
strategy = toStrategy(res); | ||
} catch (e: unknown) { | ||
console.error( | ||
'StrategyCreated event returned invalid data. skipping.', | ||
e, | ||
res | ||
); | ||
} | ||
if (strategy) { | ||
listener(strategy); | ||
} | ||
function ( | ||
id: BigNumber, | ||
provider: string, | ||
token0: string, | ||
token1: string, | ||
{ y: y0, z: z0, A: A0, B: B0 }, | ||
{ y: y1, z: z1, A: A1, B: B1 } | ||
) { | ||
logger.debug('StrategyCreated fired with', arguments); | ||
const strategy = { | ||
id, | ||
token0, | ||
token1, | ||
order0: { | ||
y: y0, | ||
z: z0, | ||
A: A0, | ||
B: B0, | ||
}, | ||
order1: { | ||
y: y1, | ||
z: z1, | ||
A: A1, | ||
B: B1, | ||
}, | ||
}; | ||
logger.debug('StrategyCreated parsed strategy:', strategy); | ||
listener(strategy); | ||
} | ||
@@ -146,16 +162,30 @@ ); | ||
'StrategyUpdated', | ||
(res: StrategyStructOutput) => { | ||
let strategy: EncodedStrategy | undefined; | ||
try { | ||
strategy = toStrategy(res); | ||
} catch (e: unknown) { | ||
console.error( | ||
'StrategyUpdated event returned invalid data. skipping.', | ||
e, | ||
res | ||
); | ||
} | ||
if (strategy) { | ||
listener(strategy); | ||
} | ||
function ( | ||
id: BigNumber, | ||
provider: string, | ||
token0: string, | ||
token1: string, | ||
{ y: y0, z: z0, A: A0, B: B0 }, | ||
{ y: y1, z: z1, A: A1, B: B1 } | ||
) { | ||
logger.debug('StrategyUpdated fired with', arguments); | ||
const strategy = { | ||
id, | ||
token0, | ||
token1, | ||
order0: { | ||
y: y0, | ||
z: z0, | ||
A: A0, | ||
B: B0, | ||
}, | ||
order1: { | ||
y: y1, | ||
z: z1, | ||
A: A1, | ||
B: B1, | ||
}, | ||
}; | ||
logger.debug('StrategyUpdated parsed strategy:', strategy); | ||
listener(strategy); | ||
} | ||
@@ -162,0 +192,0 @@ ); |
@@ -8,2 +8,4 @@ import { BigNumber, Decimal, tenPow } from './numerics'; | ||
import { Decimals } from './decimals'; | ||
import { Logger } from './logger'; | ||
const logger = new Logger('friendlyUtils.ts'); | ||
@@ -17,6 +19,7 @@ /** | ||
*/ | ||
export const formatStrategy = async ( | ||
export async function formatStrategy( | ||
strategy: DecodedStrategy & { id: BigNumber } | ||
): Promise<FriendlyStrategy> => { | ||
const { token0, token1, order0, order1 } = strategy; | ||
): Promise<FriendlyStrategy> { | ||
logger.debug('formatStrategy called', arguments); | ||
const { id, token0, token1, order0, order1 } = strategy; | ||
const decimals = Decimals.getInstance(); | ||
@@ -40,4 +43,22 @@ const decimals0 = await decimals.fetchDecimals(token0); | ||
logger.debug('formatStrategy info:', { | ||
id, | ||
token0, | ||
token1, | ||
order0, | ||
order1, | ||
decimals0, | ||
decimals1, | ||
baseToken: token0, | ||
quoteToken: token1, | ||
buyPriceLow, | ||
buyPriceHigh, | ||
buyBudget, | ||
sellPriceLow, | ||
sellPriceHigh, | ||
sellBudget, | ||
}); | ||
return { | ||
id: strategy.id, | ||
id, | ||
baseToken: token0, | ||
@@ -52,5 +73,5 @@ quoteToken: token1, | ||
}; | ||
}; | ||
} | ||
export const buildStrategyObject = ( | ||
export function buildStrategyObject( | ||
baseToken: { address: string; decimals: number }, | ||
@@ -64,3 +85,4 @@ quoteToken: { address: string; decimals: number }, | ||
sellBudget: string // in base tkn | ||
): DecodedStrategy => { | ||
): DecodedStrategy { | ||
logger.debug('buildStrategyObject called', arguments); | ||
if ( | ||
@@ -98,2 +120,9 @@ new Decimal(buyPriceLow).isNegative() || | ||
logger.debug('buildStrategyObject info:', { | ||
token0: baseToken.address, | ||
token1: quoteToken.address, | ||
order0, | ||
order1, | ||
}); | ||
return { | ||
@@ -105,19 +134,19 @@ token0: baseToken.address, | ||
}; | ||
}; | ||
} | ||
const normalizeRate = ( | ||
function normalizeRate( | ||
amount: string, | ||
amountTokenDecimals: number, | ||
otherTokenDecimals: number | ||
) => { | ||
) { | ||
return new Decimal(amount) | ||
.times(tenPow(amountTokenDecimals, otherTokenDecimals)) | ||
.toFixed(); | ||
}; | ||
} | ||
const normalizeInvertedRate = ( | ||
function normalizeInvertedRate( | ||
amount: string, | ||
amountTokenDecimals: number, | ||
otherTokenDecimals: number | ||
) => { | ||
) { | ||
if (+amount === 0) return '0'; | ||
@@ -129,5 +158,5 @@ | ||
.toFixed(); | ||
}; | ||
} | ||
const createOrders = ( | ||
function createOrders( | ||
baseTokenDecimals: number, | ||
@@ -141,3 +170,4 @@ quoteTokenDecimals: number, | ||
sellBudget: string | ||
): { order0: DecodedOrder; order1: DecodedOrder } => { | ||
): { order0: DecodedOrder; order1: DecodedOrder } { | ||
logger.debug('createOrders called', arguments); | ||
// order 0 is selling the base token | ||
@@ -192,11 +222,12 @@ // convert base token liquidity (budget) to wei | ||
}; | ||
logger.debug('createOrders info:', { order0, order1 }); | ||
return { order0, order1 }; | ||
}; | ||
} | ||
// A take on parseUnits that supports floating point | ||
const parseUnits = (amount: string, decimals: number): string => { | ||
function parseUnits(amount: string, decimals: number): string { | ||
return _parseUnits(amount, decimals).toString(); | ||
}; | ||
} | ||
const formatUnits = (amount: string, decimals: number): string => { | ||
function formatUnits(amount: string, decimals: number): string { | ||
const res = _formatUnits(amount, decimals); | ||
@@ -206,3 +237,3 @@ | ||
return new Decimal(res).toFixed(); | ||
}; | ||
} | ||
@@ -209,0 +240,0 @@ export const EXPORTED_FOR_TESTS = { |
180
src/index.ts
import { PopulatedTransaction } from '@ethersproject/contracts'; | ||
import { StaticJsonRpcProvider } from '@ethersproject/providers'; | ||
import { CachedOrders } from './orders'; | ||
import { Cache } from './cache'; | ||
import { Api } from './chain'; | ||
@@ -23,2 +23,4 @@ import { matchBySourceAmount, matchByTargetAmount } from './match'; | ||
import { BigNumberish, PayableOverrides } from 'ethers'; | ||
import { Logger } from './logger'; | ||
const logger = new Logger('index.ts'); | ||
@@ -50,3 +52,3 @@ export { | ||
private _api: Api; | ||
private _cachedOrders: CachedOrders | undefined; | ||
private _cache: Cache | undefined; | ||
@@ -65,2 +67,3 @@ /** | ||
) { | ||
logger.debug('SDK class constructor called with', arguments); | ||
const provider = new StaticJsonRpcProvider(rpcUrl, 1); | ||
@@ -80,9 +83,13 @@ this._api = new Api(provider); | ||
public async startDataSync(): Promise<void> { | ||
if (this._cachedOrders) return; | ||
this._cachedOrders = new CachedOrders(this._api.reader); | ||
await this._cachedOrders.init(); | ||
logger.debug('startDataSync called'); | ||
if (this._cache) { | ||
logger.debug('startDataSync was already called before'); | ||
return; | ||
} | ||
this._cache = new Cache(this._api.reader); | ||
await this._cache.init(); | ||
} | ||
public get isInitialized(): boolean { | ||
return this._cachedOrders !== undefined; | ||
return this._cache !== undefined; | ||
} | ||
@@ -97,6 +104,8 @@ | ||
public get pairs(): TokenPair[] { | ||
if (!this._cachedOrders) { | ||
throw new Error(`initDataSync must be called prior to this action`); | ||
logger.debug('pairs called'); | ||
if (!this._cache) { | ||
logger.log('pairs called before startDataSync'); | ||
throw new Error('startDataSync must be called prior to this action'); | ||
} | ||
return Array.from(this._cachedOrders.pairToStrategies.keys()); | ||
return this._cache.pairs; | ||
} | ||
@@ -107,2 +116,5 @@ | ||
* | ||
* @param {string} sourceToken - address of the token the trade sells. | ||
* @param {string} targetToken - address of the token the trade buys. | ||
* | ||
* @returns {Boolean} true or false. | ||
@@ -112,14 +124,16 @@ * @throws {Error} If `startDataSync` has not been called. | ||
*/ | ||
public hasLiquidityByPair(token0: string, token1: string) { | ||
if (!this._cachedOrders) { | ||
throw new Error(`initDataSync must be called prior to this action`); | ||
public hasLiquidityByPair(sourceToken: string, targetToken: string): boolean { | ||
logger.debug('hasLiquidityByPair called', arguments); | ||
if (!this._cache) { | ||
logger.log('hasLiquidityByPair called before startDataSync'); | ||
throw new Error(`startDataSync must be called prior to this action`); | ||
} | ||
const orders = this._cachedOrders.getOrders(token0, token1); | ||
for (const { y } of Object.values(orders)) { | ||
if (y.gt(0)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
const orders = this._cache.getOrders(sourceToken, targetToken); | ||
const hasLiq = | ||
Object.values(orders).find((order) => order.y.gt(0)) !== undefined; | ||
logger.debug('hasLiquidityByPair info:', { | ||
orders, | ||
hasLiq, | ||
}); | ||
return hasLiq; | ||
} | ||
@@ -130,20 +144,34 @@ | ||
* | ||
* @param {string} token0 the first token of the pair | ||
* @param {string} token1 the second token of the pair | ||
* @param {string} sourceToken - address of the token the trade sells. | ||
* @param {string} targetToken - address of the token the trade buys. | ||
* | ||
* @returns {Promise<String>} liquidity value as string | ||
* @throws {Error} If `startDataSync` has not been called. | ||
*/ | ||
public async getLiquidityByPair(token0: string, token1: string) { | ||
if (!this._cachedOrders) { | ||
throw new Error(`initDataSync must be called prior to this action`); | ||
public async getLiquidityByPair( | ||
sourceToken: string, | ||
targetToken: string | ||
): Promise<string> { | ||
logger.debug('getLiquidityByPair called', arguments); | ||
if (!this._cache) { | ||
logger.log('getLiquidityByPair called before startDataSync'); | ||
throw new Error(`startDataSync must be called prior to this action`); | ||
} | ||
const orders = this._cachedOrders.getOrders(token0, token1); | ||
const liquidityWei = Object.entries(orders).reduce( | ||
(acc, [_, { y }]) => acc.add(y), | ||
const orders = this._cache.getOrders(sourceToken, targetToken); | ||
const liquidityWei = Object.values(orders).reduce( | ||
(acc, { y }) => acc.add(y), | ||
BigNumber.from(0) | ||
); | ||
const decimals = await Decimals.getInstance().fetchDecimals(token1); | ||
const decimals = await Decimals.getInstance().fetchDecimals(targetToken); | ||
return formatUnits(liquidityWei, decimals); | ||
const liquidity = formatUnits(liquidityWei, decimals); | ||
logger.debug('getLiquidityByPair info:', { | ||
orders, | ||
liquidityWei, | ||
targetToken, | ||
decimals, | ||
liquidity, | ||
}); | ||
return liquidity; | ||
} | ||
@@ -161,17 +189,26 @@ | ||
public async getUserStrategies(user: string): Promise<FriendlyStrategy[]> { | ||
if (!this._cachedOrders) { | ||
throw new Error(`initDataSync must be called prior to this action`); | ||
logger.debug('getUserStrategies called', arguments); | ||
if (!this._cache) { | ||
logger.log('getUserStrategies called before startDataSync'); | ||
throw new Error(`startDataSync must be called prior to this action`); | ||
} | ||
const ids = await this._api.reader.getUserStrategyIds(user); | ||
const strategyById = this._cachedOrders.strategyById; | ||
const encodedStrategies = ids | ||
.map((id) => strategyById.get(id.toString())) | ||
.map((id) => this._cache?.getStrategyById(id)) | ||
.filter((strategy) => !!strategy) as EncodedStrategy[]; | ||
const decodedStrategies = encodedStrategies.map(decodeStrategy); | ||
const strategies = await Promise.all( | ||
encodedStrategies.map(async (strategy) => { | ||
return await formatStrategy(decodeStrategy(strategy)); | ||
decodedStrategies.map(async (strategy) => { | ||
return await formatStrategy(strategy); | ||
}) | ||
); | ||
logger.debug('getUserStrategies info:', { | ||
ids, | ||
encodedStrategies, | ||
decodedStrategies, | ||
strategies, | ||
}); | ||
return strategies; | ||
@@ -214,8 +251,10 @@ } | ||
actionsTokenRes: FriendlyAction[]; | ||
totalInput: string; | ||
totalOutput: string; | ||
totalSourceAmount: string; | ||
totalTargetAmount: string; | ||
effectiveRate: string; | ||
}> { | ||
if (!this._cachedOrders) { | ||
throw new Error(`initDataSync must be called prior to this action`); | ||
logger.debug('getTradeData called', arguments); | ||
if (!this._cache) { | ||
logger.log('getTradeData called before startDataSync'); | ||
throw new Error(`startDataSync must be called prior to this action`); | ||
} | ||
@@ -225,3 +264,3 @@ const decimals = Decimals.getInstance(); | ||
const targetDecimals = await decimals.fetchDecimals(targetToken); | ||
const orders = this._cachedOrders.getOrders(sourceToken, targetToken); | ||
const orders = this._cache.getOrders(sourceToken, targetToken); | ||
@@ -251,4 +290,10 @@ const amountWei = BigNumber.from( | ||
id: action.id, | ||
input: formatUnits(action.input, sourceDecimals), | ||
output: formatUnits(action.output, targetDecimals), | ||
sourceAmount: formatUnits( | ||
tradeByTargetAmount ? action.output : action.input, | ||
sourceDecimals | ||
), | ||
targetAmount: formatUnits( | ||
tradeByTargetAmount ? action.input : action.output, | ||
targetDecimals | ||
), | ||
}); | ||
@@ -258,25 +303,41 @@ totalInput = totalInput.add(action.input); | ||
}); | ||
let totalSourceAmount = tradeByTargetAmount ? totalOutput : totalInput; | ||
let totalTargetAmount = tradeByTargetAmount ? totalInput : totalOutput; | ||
if (totalInput.isZero() || totalOutput.isZero()) { | ||
return { | ||
let res; | ||
if (totalSourceAmount.isZero() || totalTargetAmount.isZero()) { | ||
res = { | ||
tradeActions, | ||
actionsTokenRes, | ||
totalInput: '0', | ||
totalOutput: '0', | ||
totalSourceAmount: '0', | ||
totalTargetAmount: '0', | ||
effectiveRate: '0', | ||
}; | ||
} else { | ||
const effectiveRate = new Decimal(totalTargetAmount.toString()) | ||
.div(totalSourceAmount.toString()) | ||
.times(tenPow(sourceDecimals, targetDecimals)) | ||
.toString(); | ||
res = { | ||
tradeActions, | ||
actionsTokenRes, | ||
totalSourceAmount: formatUnits(totalSourceAmount, sourceDecimals), | ||
totalTargetAmount: formatUnits(totalTargetAmount, targetDecimals), | ||
effectiveRate, | ||
}; | ||
} | ||
const effectiveRate = new Decimal(totalInput.toString()) | ||
.div(totalOutput.toString()) | ||
.times(tenPow(targetDecimals, sourceDecimals)) | ||
.toString(); | ||
logger.debug('getTradeData info:', { | ||
sourceDecimals, | ||
targetDecimals, | ||
orders, | ||
amount, | ||
amountWei, | ||
actionsWei, | ||
res, | ||
}); | ||
return { | ||
tradeActions, | ||
actionsTokenRes, | ||
totalInput: formatUnits(totalInput, sourceDecimals), | ||
totalOutput: formatUnits(totalOutput, targetDecimals), | ||
effectiveRate, | ||
}; | ||
return res; | ||
} | ||
@@ -465,2 +526,3 @@ | ||
): Promise<PopulatedTransaction> { | ||
logger.debug('createBuySellStrategy called', arguments); | ||
const strategy: DecodedStrategy = buildStrategyObject( | ||
@@ -478,2 +540,4 @@ baseToken, | ||
logger.debug('createBuySellStrategy info:', { strategy, encStrategy }); | ||
return this._api.composer.createStrategy( | ||
@@ -480,0 +544,0 @@ encStrategy.token0, |
@@ -66,4 +66,4 @@ import { BigNumber } from './numerics'; | ||
id: BigNumber; | ||
input: string; | ||
output: string; | ||
sourceAmount: string; | ||
targetAmount: string; | ||
}; |
@@ -9,7 +9,7 @@ import { assert, expect } from 'chai'; | ||
StrategyById, | ||
} from '../src/orders/types'; | ||
} from '../src/cache/types'; | ||
import { | ||
applyModifiedOrderToCache, | ||
createPairToStrategiesMap, | ||
} from '../src/orders/cache-ops'; | ||
} from '../src/cache/cache-ops'; | ||
import { OrdersMap } from '../src/match'; | ||
@@ -16,0 +16,0 @@ import { EncodedStrategy, TokenPair } from '../src/types'; |
import { expect } from 'chai'; | ||
import { toPairKey, toDirectionKey } from '../src/orders/utils'; | ||
import { toPairKey, toDirectionKey } from '../src/cache/utils'; | ||
@@ -4,0 +4,0 @@ describe('toPairKey', () => { |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2031599
131
35051
4