@primitivefi/rmm-ethers
Advanced tools
Comparing version 0.0.10-beta.1 to 0.0.11-beta.1
import { LogDescription } from '@ethersproject/abi'; | ||
import { BaseContract, ContractInterface } from '@ethersproject/contracts'; | ||
import { Contract, ContractInterface } from '@ethersproject/contracts'; | ||
import { Log } from '@ethersproject/abstract-provider'; | ||
@@ -13,3 +13,4 @@ import { PrimitiveManager } from '@primitivefi/rmm-manager/typechain/PrimitiveManager'; | ||
} | ||
export declare class _RmmContract extends BaseContract { | ||
export declare class _RmmContract { | ||
readonly contract: Contract; | ||
constructor(addressOrName: string, contractInterface: ContractInterface, signerOrProvider?: EthersSigner | EthersProvider); | ||
@@ -25,3 +26,3 @@ extractEvents(logs: Log[], name: string): _TypedLogDescription<unknown>[]; | ||
} ? U : never>; | ||
declare type TypedContract<T extends BaseContract, U, V> = _TypeSafeContract<T> & U & {}; | ||
declare type TypedContract<T, U, V> = _TypeSafeContract<T> & U & {}; | ||
interface ManagerContract extends _TypedRmmContract<PrimitiveManager> { | ||
@@ -28,0 +29,0 @@ extractEvents(logs: Log[], name: 'Allocate'): _TypedLogDescription<{ |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("@ethersproject/contracts"),r=require("@primitivefi/rmm-sdk"),n=require("ethers/lib/utils"),i=require("@ethersproject/abstract-signer"),o=require("@ethersproject/logger"),a=require("web3-units"),u=(t=require("assert"))&&"object"==typeof t&&"default"in t?t.default:t;function c(t,e,r,n,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,i)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){c(o,n,i,a,u,"next",t)}function u(t){c(o,n,i,a,u,"throw",t)}a(void 0)}))}}function f(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t,e,r){return e&&f(t.prototype,e),r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(){return(l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,v(t,e)}function d(t){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function v(t,e){return(v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function m(t,e,r){return(m=y()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&v(i,r.prototype),i}).apply(null,arguments)}function g(t){var e="function"==typeof Map?new Map:void 0;return(g=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return m(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),v(r,t)})(t)}var w,_,b=function(t){function e(e,r,n){return t.call(this,e,r,n)||this}return h(e,t),e.prototype.extractEvents=function(t,e){var r=this;return t.filter((function(t){return t.address===r.address})).map((function(t){return r.interface.parseLog(t)})).filter((function(t){return t.name===e}))},e}(e.BaseContract),x={primitiveFactory:r.FactoryManager.ABI,primitiveManager:r.PeripheryManager.ABI,positionRenderer:r.PositionRendererManager.ABI,positionDescriptor:r.PositionDescriptorManager.ABI,primitiveEngine:r.Engine.ABI},E=function(t,e){return function(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var r=t[0];return[r,e(t[1],r)]})))}(e.addresses,(function(e,r){return new b(e,x[r],t)}))},R=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),o=new E(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var u=_(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,o),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function p(){}function l(){}function h(){}var d={};u(d,i,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(R([])));y&&y!==e&&r.call(y,i)&&(d=y);var m=h.prototype=p.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(i,o){function a(){return new e((function(n,a){!function n(i,o,a,u){var c=s(t[i],t,o);if("throw"!==c.type){var f=c.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(p).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function R(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return l.prototype=h,u(m,"constructor",h),u(h,"constructor",l),l.displayName=u(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,o,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new w(c(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),u(m,a,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=R,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:R(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(_={exports:{}}),_.exports),P={chainId:4,version:"8f32bf1f18a8aa99f5cdadda762848859ac92562",deploymentDate:1641426815622,_isDev:!1,startBlock:9940950,addresses:{primitiveFactory:"0x9462c3CBA453223C865a559e417a9677Ddf4E663",positionRenderer:"0xA96b4BcEb743607196A7D13fC6006745340E594F",positionDescriptor:"0xC31bf91214Dd213718136640075B3C02b540f5E8",primitiveManager:"0x7B327A50bFcC42E04a7DE50573F12574AE9ce7fd"}},S={chainId:5,version:"8f32bf1f18a8aa99f5cdadda762848859ac92562",deploymentDate:1641431431884,_isDev:!1,startBlock:9941257,addresses:{primitiveFactory:"0xc28E69C140fE578f1E22dEd2b0728601aaaC7a18",positionRenderer:"0xC262a03AECd5704B3f2E92b90D66aE6ED17361ee",positionDescriptor:"0x47BF926c0F1cD81e2009fF255D4435b0B276216B",primitiveManager:"0x4A32cb4dC3bF7973c828D7dC5Eab87d11e77d62D"}},T={chainId:42,version:"8f32bf1f18a8aa99f5cdadda762848859ac92562",deploymentDate:1641431491145,_isDev:!1,startBlock:29121097,addresses:{primitiveFactory:"0xD3fE1455Cc6c8A4706433e598174eC29bD6DeB94",positionRenderer:"0x8a7F79fC8eedF41bd65430C0E75291c6eBd91AeA",positionDescriptor:"0xc82E6e0475d95a589f165Ab53bad754a2cb73A1B",primitiveManager:"0x6F10fc808D191341B8eb52879BD41eCa5Cf08024"}},k=["deploymentDate"],L=((w={})[P.chainId]=P,w[S.chainId]=S,w[T.chainId]=T,w),O=function(t,e,r,n){var i=n.deploymentDate,o=function(t,e){if(null==t)return{};var r,n,i={},o=Object.keys(t);for(n=0;n<o.length;n++)e.indexOf(r=o[n])>=0||(i[r]=t[r]);return i}(n,k);return l({provider:t,signer:e,deploymentDate:new Date(i),_contracts:r},o)},C=function(t){return t._contracts},A=function(t){if(i.Signer.isSigner(t)){if(null==t||!t.provider)throw new Error("No provider");return[t.provider,t]}return[t,void 0]};function F(t,e,r){var n=L[r];if(!n)throw new Error("No deployment found for chainId: "+r);var i=n;return O(t,e,E(null!=e?e:t,i),i)}var D,I=function(){var t=s(R.mark((function t(e){var r,n,i;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=A(e),n=r[0],i=r[1],t.next=3,n.getNetwork();case 3:return t.abrupt("return",F(n,i,t.sent.chainId));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),B=function(){function t(t,e){void 0===e&&(e=a.parseWei(0)),this.pool=t,this.liquidity=e}var e=t.prototype;return e.valueOf=function(t){switch(t){case r.PoolSides.RISKY:return this.value.values[0];case r.PoolSides.STABLE:return this.value.values[1];case r.PoolSides.RMM_LP:return this.totalValue}},e.equals=function(t){return this.liquidity.eq(t.liquidity)},e.add=function(e){return new t(this.pool,this.liquidity.add(e.liquidity))},e.sub=function(e){var r=e.liquidity;return new t(this.pool,this.liquidity.gt(r)?this.liquidity.sub(r):a.parseWei(0))},p(t,[{key:"isEmpty",get:function(){return this.liquidity.raw.isZero()}},{key:"balance0",get:function(){return this.pool.liquidityQuote(this.liquidity,r.PoolSides.RMM_LP).delRisky}},{key:"balance1",get:function(){return this.pool.liquidityQuote(this.liquidity,r.PoolSides.RMM_LP).delStable}},{key:"value",get:function(){var t,e,r,n;return this.pool.getCurrentLiquidityValue(null!=(t=null!=(e=null==(r=this.pool.referencePriceOfRisky)?void 0:r.float)?e:null==(n=this.pool.reportedPriceOfRisky)?void 0:n.float)?t:0)}},{key:"totalValue",get:function(){return this.value.valuePerLiquidity.mul(this.liquidity).div(a.parseWei(1))}}]),t}(),j={status:"pending"},q=function(t){return{status:"failed",rawReceipt:t}},M=function(t,e,r){return l({status:"succeeded",rawReceipt:t,details:e},r?{toString:r}:{})},N=function(t){return t.send()},G=function(){function t(t){this._populate=t}var e=t.prototype;return e.allocate=function(){var t=s(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.allocate(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.remove=function(){var t=s(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.remove(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.safeTransfer=function(){var t=s(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.safeTransfer(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.safeBatchTransfer=function(){var t=s(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.safeBatchTransfer(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.createEngine=function(){var t=s(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.createEngine(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),t}();(D=exports._RawErrorReason||(exports._RawErrorReason={})).TRANSACTION_FAILED="transaction failed",D.TRANSACTION_CANCELLED="cancelled",D.TRANSACTION_REPLACED="replaced",D.TRANSACTION_REPRICED="repriced";var U=function(t,e){return e in t},W=function(){function t(t,e,r){this.rawSentTransaction=t,this._connection=e,this._parse=r}var e=t.prototype;return e._receiptFrom=function(t){return t?t.status?M(t,this._parse(t),void 0):q(t):j},e._waitForRawReceipt=function(){var t=s(R.mark((function t(e){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.rawSentTransaction.wait(e);case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),!(t.t0 instanceof Error)){t.next=11;break}if(!U(r=t.t0,"code")||r.code!==o.ErrorCode.CALL_EXCEPTION||!U(r,"reason")||r.reason!==exports._RawErrorReason.TRANSACTION_FAILED){t.next=11;break}return t.abrupt("return",t.t0.receipt);case 11:throw t.t0;case 12:case"end":return t.stop()}var r}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),e.getReceipt=function(){var t=s(R.mark((function t(){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this._waitForRawReceipt(0);case 3:return t.t1=t.sent,t.abrupt("return",t.t0._receiptFrom.call(t.t0,t.t1));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.waitForReceipt=function(){var t=s(R.mark((function t(){var e;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this._waitForRawReceipt();case 3:if(t.t1=t.sent,"pending"!==(e=t.t0._receiptFrom.call(t.t0,t.t1)).status){t.next=7;break}throw new Error("Still pending");case 7:return t.abrupt("return",e);case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),V=function(){function t(t,e,r){this.rawPopulatedTransaction=t,this._connection=e,this._parse=r}return t.prototype.send=function(){var t=s(R.mark((function t(){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=W,t.next=3,this._connection.signer.sendTransaction(this.rawPopulatedTransaction);case 3:return t.t1=t.sent,t.t2=this._connection,t.t3=this._parse,t.abrupt("return",new t.t0(t.t1,t.t2,t.t3));case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),Y=function(){function t(t){this._readable=t}var e=t.prototype;return e._wrap=function(t){return new V(t,this._readable.connection,(function(){}))},e._wrapPositionChange=function(t,e){var n=C(this._readable.connection).primitiveManager;return new V(e,this._readable.connection,(function(e){var i=e.logs,o=!1;try{o=n.extractEvents(i,"Create").map((function(e){return e.args.poolId===t.pool.poolId}))[0]}catch(t){}var a=(o?[new B(t.pool)]:n.extractEvents(i,"Allocate").map((function(e){return new B(t.pool,r.weiToWei(e.args.delLiquidity.toString()))})))[0];return a||(a=n.extractEvents(i,"Remove").map((function(e){return new B(t.pool,r.weiToWei(e.args.delLiquidity.toString()))}))[0]),{params:t,newPosition:a}}))},e._applyGasLimit=function(){var t=s(R.mark((function t(e,r,n){var i,o,a,u;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=(o=(i=function(){return l({to:e.address,data:r.calldata,value:r.value},n)})())&&o.gasLimit){t.next=8;break}return t.next=5,e.signer.estimateGas(o);case 5:a=t.sent.mul(150).div(100),n=l({},n,{gasLimit:a});case 8:return u=i(),t.next=11,e.signer.populateTransaction(u);case 11:return t.abrupt("return",t.sent);case 13:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.allocate=function(){var t=s(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveManager,t.next=3,this._applyGasLimit(o,r.PeripheryManager.allocateCallParameters(e.pool,e.options),n);case 3:return t.abrupt("return",this._wrapPositionChange(e,t.sent));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.remove=function(){var t=s(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveManager,t.next=3,this._applyGasLimit(o,r.PeripheryManager.removeCallParameters(e.pool,e.options),n);case 3:return t.abrupt("return",this._wrapPositionChange(e,t.sent));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.createEngine=function(){var t=s(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveFactory,t.next=3,this._applyGasLimit(o,{calldata:r.FactoryManager.encodeDeploy(e.risky,e.stable),value:a.toBN(0)._hex},n);case 3:return t.abrupt("return",new V(t.sent,this._readable.connection,(function(t){return{params:e,engine:""}})));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.safeTransfer=function(){var t=s(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveManager,t.next=3,this._applyGasLimit(o,r.PeripheryManager.safeTransferFromParameters(e.options),n);case 3:return t.abrupt("return",this._wrap(t.sent));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.safeBatchTransfer=function(){var t=s(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveManager,t.next=3,this._applyGasLimit(o,r.PeripheryManager.batchTransferFromParameters(e.options),n);case 3:return t.abrupt("return",this._wrap(t.sent));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),t}(),Q=function(){function t(){this.logging=!1,this._loaded=!1,this._listeners=new Set}var e=t.prototype;return e.start=function(){var t=this,e=this._doStart();return function(){e(),t._cancelUpdateIfScheduled()}},e._cancelUpdateIfScheduled=function(){void 0!==this._updateTimeoutId&&clearTimeout(this._updateTimeoutId)},e._scheduleUpdate=function(){var t=this;this._cancelUpdateIfScheduled(),this._updateTimeoutId=setTimeout((function(){t._updateTimeoutId=void 0,t._update()}),35e3)},e._logUpdate=function(t,e,r){return this.logging&&console.log(t+" updated to "+(r?r(e):e)),e},e._updateIfChanged=function(t,e,r,n,i){return void 0===n||t(r,n)?r:this._logUpdate(e,n,i)},e._reduce=function(t,e){return{}},e._derive=function(t){return function(t){if(null==t)throw new TypeError("Cannot destructure undefined")}(t),{}},e._reduceDerived=function(t,e){return{}},e._notify=function(t){var e=this;[].concat(this._listeners).forEach((function(r){e._listeners.has(r)&&r(t)}))},e.subscribe=function(t){var e,r=this,n=(e=t,function(){return e.apply(void 0,arguments)});return this._listeners.add(n),function(){r._listeners.delete(n)}},e._load=function(){},e._update=function(t,e){u(this._baseState&&this._derivedState);var r,n,i=this.state;t&&(this._baseState=this._reduce(this._baseState,t)),this._derivedState=this._reduceDerived(this._derivedState,this._derive(this._baseState)),e&&(u(this._extraState),this._extraState=this._reduceExtra(this._extraState,e)),this._scheduleUpdate(),this._notify({newState:this.state,oldState:i,stateChange:(r=this.state,n=i,Object.fromEntries(Object.entries(r).filter((function(t){return t[1]!==n[t[0]]}))))})},p(t,[{key:"state",get:function(){return Object.assign({},this._baseState,this._derivedState,this._extraState)}}]),t}(),J=function(t){function e(e,r,n){var i;return(i=t.call(this,r)||this).name=e,i.failedReceipt=n,i}return h(e,t),e}(g(Error));function K(t){var e=Buffer.from(t.substring(29),"base64").toString();return JSON.parse(e)}function X(t){var e=K(t).properties,n=e.invariant,i={address:e.stableAddress,name:e.stableName,symbol:e.stableSymbol,decimals:e.stableDecimals},o={strike:e.strike,sigma:e.sigma,maturity:e.maturity,lastTimestamp:e.lastTimestamp,gamma:e.gamma},a={reserveRisky:e.reserveRisky,reserveStable:e.reserveStable,liquidity:e.liquidity};return new r.Pool(e.chainId,e.factory,l({},{address:e.riskyAddress,name:e.riskyName,symbol:e.riskySymbol,decimals:e.riskyDecimals}),l({},i),l({},o),l({},a),n,void 0)}var Z=function(){function t(t){this.connection=t}t._from=function(e){return new t(e)},t.connect=function(){var e=s(R.mark((function e(r){return R.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,I(r);case 3:return e.t1=e.sent,e.abrupt("return",e.t0._from.call(e.t0,e.t1));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var e=t.prototype;return e.getPool=function(t,e){return C(this.connection).primitiveManager.uri(t).then(X)},e.getLiquidityBalance=function(t,e,n){return C(this.connection).primitiveManager.balanceOf(e,t).then((function(t){return r.weiToWei(t.toString())}))},e.getPosition=function(t,e,r){return this.getLiquidityBalance(t.poolId,e,r).then((function(e){return new B(t,e)}))},e.getEngine=function(t,e,r){return C(this.connection).primitiveFactory.getEngine(n.getAddress(t),n.getAddress(e)).then((function(t){return t}))},t}(),z=function(t){function e(e,r){return t.call(this,"EthersTransactionFailedError",e,r)||this}return h(e,t),e}(J),H=function(){var t=s(R.mark((function t(e){var r;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.waitForReceipt();case 2:if("succeeded"===(r=t.sent).status){t.next=5;break}throw new z("Transaction failed",r);case 5:return t.abrupt("return",r.details);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();exports.EthersRmm=function(){function t(t){this._readable=t,this.connection=t.connection,this.populate=new Y(t),this.send=new G(this.populate)}t._from=function(e){return new t(Z._from(e))},t.connect=function(){var e=s(R.mark((function e(r){return R.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,I(r);case 2:return e.abrupt("return",t._from(e.sent));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var e=t.prototype;return e.allocate=function(t,e){return this.send.allocate(t,e).then(H)},e.createPool=function(t,e){if(!t.options.createPool)throw new Error("Attempting to create pool without flagging createPool.");return this.send.allocate(t,e).then(H)},e.remove=function(t,e){return this.send.remove(t,e).then(H)},e.safeTransfer=function(t,e){return this.send.safeTransfer(t,e).then(H)},e.safeBatchTransfer=function(t,e){return this.send.safeBatchTransfer(t,e).then(H)},e.createEngine=function(t,e){return this.send.createEngine(t,e).then(H)},e.getPool=function(t,e){return this._readable.getPool(t,e)},e.getLiquidityBalance=function(t,e,r){return this._readable.getLiquidityBalance(t,e,r)},e.getPosition=function(t,e,r){return this._readable.getPosition(t,e,r)},e.getEngine=function(t,e,r){return this._readable.getEngine(t,e,r)},t}(),exports.EthersTransactionFailedError=z,exports.PopulatableEthersRmm=Y,exports.PopulatedEthersSignerTransaction=V,exports.Position=B,exports.ReadableEthersRmm=Z,exports.RmmStore=Q,exports.SendableEthersRmm=G,exports.SentEthersRmmTransaction=W,exports.TransactionFailedError=J,exports._RmmContract=b,exports._RmmContractAbis=x,exports._connect=I,exports._connectToContracts=E,exports._connectToDeployment=function(t,e){var r=A(e);return O(r[0],r[1],E(e,t),t)},exports._connectToNetwork=F,exports._failedReceipt=q,exports._getContracts=C,exports._pendingReceipt=j,exports._successfulReceipt=M,exports.connectionFrom=O,exports.parseTokenURI=K,exports.poolify=X; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("@ethersproject/contracts"),r=require("@primitivefi/rmm-sdk"),n=require("ethers/lib/utils"),i=require("@ethersproject/abstract-signer"),o=require("@ethersproject/logger"),a=require("web3-units"),c=(t=require("assert"))&&"object"==typeof t&&"default"in t?t.default:t,u=function(){function t(t,r,n){this.contract=new e.Contract(t,r,n)}return t.prototype.extractEvents=function(t,e){var r=this;return t.filter((function(t){return t.address===r.contract.address})).map((function(t){return r.contract.interface.parseLog(t)})).filter((function(t){return t.name===e}))},t}(),s={primitiveFactory:r.FactoryManager.ABI,primitiveManager:r.PeripheryManager.ABI,positionRenderer:r.PositionRendererManager.ABI,positionDescriptor:r.PositionDescriptorManager.ABI,primitiveEngine:r.Engine.ABI},f=function(t,e){return function(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var r=t[0];return[r,e(t[1],r)]})))}(e.addresses,(function(e,r){return new u(e,s[r],t)}))};function p(t,e,r,n,i,o,a){try{var c=t[o](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,i)}function l(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){p(o,n,i,a,c,"next",t)}function c(t){p(o,n,i,a,c,"throw",t)}a(void 0)}))}}function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function d(t,e,r){return e&&h(t.prototype,e),r&&h(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function v(){return(v=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function y(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,g(t,e)}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function g(t,e){return(g=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function w(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function _(t,e,r){return(_=w()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&g(i,r.prototype),i}).apply(null,arguments)}function b(t){var e="function"==typeof Map?new Map:void 0;return(b=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return _(t,arguments,m(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,t)})(t)}var x,E,R=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),o=new E(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=_(a,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,o),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function p(){}function l(){}function h(){}var d={};c(d,i,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(R([])));y&&y!==e&&r.call(y,i)&&(d=y);var m=h.prototype=p.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(i,o){function a(){return new e((function(n,a){!function n(i,o,a,c){var u=s(t[i],t,o);if("throw"!==u.type){var f=u.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(p).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function R(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return l.prototype=h,c(m,"constructor",h),c(h,"constructor",l),l.displayName=c(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),c(w.prototype,o,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new w(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),c(m,a,"Generator"),c(m,i,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=R,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var c=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:R(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(E={exports:{}}),E.exports),P={chainId:4,version:"8f32bf1f18a8aa99f5cdadda762848859ac92562",deploymentDate:1641426815622,_isDev:!1,startBlock:9940950,addresses:{primitiveFactory:"0x9462c3CBA453223C865a559e417a9677Ddf4E663",positionRenderer:"0xA96b4BcEb743607196A7D13fC6006745340E594F",positionDescriptor:"0xC31bf91214Dd213718136640075B3C02b540f5E8",primitiveManager:"0x7B327A50bFcC42E04a7DE50573F12574AE9ce7fd"}},S={chainId:5,version:"8f32bf1f18a8aa99f5cdadda762848859ac92562",deploymentDate:1641431431884,_isDev:!1,startBlock:9941257,addresses:{primitiveFactory:"0xc28E69C140fE578f1E22dEd2b0728601aaaC7a18",positionRenderer:"0xC262a03AECd5704B3f2E92b90D66aE6ED17361ee",positionDescriptor:"0x47BF926c0F1cD81e2009fF255D4435b0B276216B",primitiveManager:"0x4A32cb4dC3bF7973c828D7dC5Eab87d11e77d62D"}},T={chainId:42,version:"8f32bf1f18a8aa99f5cdadda762848859ac92562",deploymentDate:1641431491145,_isDev:!1,startBlock:29121097,addresses:{primitiveFactory:"0xD3fE1455Cc6c8A4706433e598174eC29bD6DeB94",positionRenderer:"0x8a7F79fC8eedF41bd65430C0E75291c6eBd91AeA",positionDescriptor:"0xc82E6e0475d95a589f165Ab53bad754a2cb73A1B",primitiveManager:"0x6F10fc808D191341B8eb52879BD41eCa5Cf08024"}},k=["deploymentDate"],L=((x={})[P.chainId]=P,x[S.chainId]=S,x[T.chainId]=T,x),O=function(t,e,r,n){var i=n.deploymentDate,o=function(t,e){if(null==t)return{};var r,n,i={},o=Object.keys(t);for(n=0;n<o.length;n++)e.indexOf(r=o[n])>=0||(i[r]=t[r]);return i}(n,k);return v({provider:t,signer:e,deploymentDate:new Date(i),_contracts:r},o)},C=function(t){return t._contracts},A=function(t){if(i.Signer.isSigner(t)){if(null==t||!t.provider)throw new Error("No provider");return[t.provider,t]}return[t,void 0]};function F(t,e,r){var n=L[r];if(!n)throw new Error("No deployment found for chainId: "+r);var i=n;return O(t,e,f(null!=e?e:t,i),i)}var D,I=function(){var t=l(R.mark((function t(e){var r,n,i;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=A(e),n=r[0],i=r[1],t.next=3,n.getNetwork();case 3:return t.abrupt("return",F(n,i,t.sent.chainId));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),B=function(){function t(t,e){void 0===e&&(e=a.parseWei(0)),this.pool=t,this.liquidity=e}var e=t.prototype;return e.valueOf=function(t){switch(t){case r.PoolSides.RISKY:return this.value.values[0];case r.PoolSides.STABLE:return this.value.values[1];case r.PoolSides.RMM_LP:return this.totalValue}},e.equals=function(t){return this.liquidity.eq(t.liquidity)},e.add=function(e){return new t(this.pool,this.liquidity.add(e.liquidity))},e.sub=function(e){var r=e.liquidity;return new t(this.pool,this.liquidity.gt(r)?this.liquidity.sub(r):a.parseWei(0))},d(t,[{key:"isEmpty",get:function(){return this.liquidity.raw.isZero()}},{key:"balance0",get:function(){return this.pool.liquidityQuote(this.liquidity,r.PoolSides.RMM_LP).delRisky}},{key:"balance1",get:function(){return this.pool.liquidityQuote(this.liquidity,r.PoolSides.RMM_LP).delStable}},{key:"value",get:function(){var t,e,r,n;return this.pool.getCurrentLiquidityValue(null!=(t=null!=(e=null==(r=this.pool.referencePriceOfRisky)?void 0:r.float)?e:null==(n=this.pool.reportedPriceOfRisky)?void 0:n.float)?t:0)}},{key:"totalValue",get:function(){return this.value.valuePerLiquidity.mul(this.liquidity).div(a.parseWei(1))}}]),t}(),j={status:"pending"},q=function(t){return{status:"failed",rawReceipt:t}},M=function(t,e,r){return v({status:"succeeded",rawReceipt:t,details:e},r?{toString:r}:{})},N=function(t){return t.send()},G=function(){function t(t){this._populate=t}var e=t.prototype;return e.allocate=function(){var t=l(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.allocate(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.remove=function(){var t=l(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.remove(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.safeTransfer=function(){var t=l(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.safeTransfer(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.safeBatchTransfer=function(){var t=l(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.safeBatchTransfer(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.createEngine=function(){var t=l(R.mark((function t(e,r){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._populate.createEngine(e,r).then(N));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),t}();(D=exports._RawErrorReason||(exports._RawErrorReason={})).TRANSACTION_FAILED="transaction failed",D.TRANSACTION_CANCELLED="cancelled",D.TRANSACTION_REPLACED="replaced",D.TRANSACTION_REPRICED="repriced";var U=function(t,e){return e in t},W=function(){function t(t,e,r){this.rawSentTransaction=t,this._connection=e,this._parse=r}var e=t.prototype;return e._receiptFrom=function(t){return t?t.status?M(t,this._parse(t),void 0):q(t):j},e._waitForRawReceipt=function(){var t=l(R.mark((function t(e){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.rawSentTransaction.wait(e);case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),!(t.t0 instanceof Error)){t.next=11;break}if(!U(r=t.t0,"code")||r.code!==o.ErrorCode.CALL_EXCEPTION||!U(r,"reason")||r.reason!==exports._RawErrorReason.TRANSACTION_FAILED){t.next=11;break}return t.abrupt("return",t.t0.receipt);case 11:throw t.t0;case 12:case"end":return t.stop()}var r}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),e.getReceipt=function(){var t=l(R.mark((function t(){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this._waitForRawReceipt(0);case 3:return t.t1=t.sent,t.abrupt("return",t.t0._receiptFrom.call(t.t0,t.t1));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.waitForReceipt=function(){var t=l(R.mark((function t(){var e;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,this._waitForRawReceipt();case 3:if(t.t1=t.sent,"pending"!==(e=t.t0._receiptFrom.call(t.t0,t.t1)).status){t.next=7;break}throw new Error("Still pending");case 7:return t.abrupt("return",e);case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),V=function(){function t(t,e,r){this.rawPopulatedTransaction=t,this._connection=e,this._parse=r}return t.prototype.send=function(){var t=l(R.mark((function t(){return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=W,t.next=3,this._connection.signer.sendTransaction(this.rawPopulatedTransaction);case 3:return t.t1=t.sent,t.t2=this._connection,t.t3=this._parse,t.abrupt("return",new t.t0(t.t1,t.t2,t.t3));case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),Y=function(){function t(t){this._readable=t}var e=t.prototype;return e._wrap=function(t){return new V(t,this._readable.connection,(function(){}))},e._wrapPositionChange=function(t,e){var n=C(this._readable.connection).primitiveManager;return new V(e,this._readable.connection,(function(e){var i=e.logs,o=!1;try{o=n.extractEvents(i,"Create").map((function(e){return e.args.poolId===t.pool.poolId}))[0]}catch(t){}var a=(o?[new B(t.pool)]:n.extractEvents(i,"Allocate").map((function(e){return new B(t.pool,r.weiToWei(e.args.delLiquidity.toString()))})))[0];return a||(a=n.extractEvents(i,"Remove").map((function(e){return new B(t.pool,r.weiToWei(e.args.delLiquidity.toString()))}))[0]),{params:t,newPosition:a}}))},e._applyGasLimit=function(){var t=l(R.mark((function t(e,r,n){var i,o,a,c;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=(o=(i=function(){return v({to:e.address,data:r.calldata,value:r.value},n)})())&&o.gasLimit){t.next=8;break}return t.next=5,e.signer.estimateGas(o);case 5:a=t.sent.mul(150).div(100),n=v({},n,{gasLimit:a});case 8:return c=i(),t.next=11,e.signer.populateTransaction(c);case 11:return t.abrupt("return",t.sent);case 13:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.allocate=function(){var t=l(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveManager,t.next=3,this._applyGasLimit(o.contract,r.PeripheryManager.allocateCallParameters(e.pool,e.options),n);case 3:return t.abrupt("return",this._wrapPositionChange(e,t.sent));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.remove=function(){var t=l(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveManager,t.next=3,this._applyGasLimit(o.contract,r.PeripheryManager.removeCallParameters(e.pool,e.options),n);case 3:return t.abrupt("return",this._wrapPositionChange(e,t.sent));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.createEngine=function(){var t=l(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveFactory,t.next=3,this._applyGasLimit(o.contract,{calldata:r.FactoryManager.encodeDeploy(e.risky,e.stable),value:a.toBN(0)._hex},n);case 3:return t.abrupt("return",new V(t.sent,this._readable.connection,(function(t){return{params:e,engine:""}})));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.safeTransfer=function(){var t=l(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveManager,t.next=3,this._applyGasLimit(o.contract,r.PeripheryManager.safeTransferFromParameters(e.options),n);case 3:return t.abrupt("return",this._wrap(t.sent));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.safeBatchTransfer=function(){var t=l(R.mark((function t(e,n){var i,o;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=C(this._readable.connection),o=i.primitiveManager,t.next=3,this._applyGasLimit(o.contract,r.PeripheryManager.batchTransferFromParameters(e.options),n);case 3:return t.abrupt("return",this._wrap(t.sent));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),t}(),Q=function(){function t(){this.logging=!1,this._loaded=!1,this._listeners=new Set}var e=t.prototype;return e.start=function(){var t=this,e=this._doStart();return function(){e(),t._cancelUpdateIfScheduled()}},e._cancelUpdateIfScheduled=function(){void 0!==this._updateTimeoutId&&clearTimeout(this._updateTimeoutId)},e._scheduleUpdate=function(){var t=this;this._cancelUpdateIfScheduled(),this._updateTimeoutId=setTimeout((function(){t._updateTimeoutId=void 0,t._update()}),35e3)},e._logUpdate=function(t,e,r){return this.logging&&console.log(t+" updated to "+(r?r(e):e)),e},e._updateIfChanged=function(t,e,r,n,i){return void 0===n||t(r,n)?r:this._logUpdate(e,n,i)},e._reduce=function(t,e){return{}},e._derive=function(t){return function(t){if(null==t)throw new TypeError("Cannot destructure undefined")}(t),{}},e._reduceDerived=function(t,e){return{}},e._notify=function(t){var e=this;[].concat(this._listeners).forEach((function(r){e._listeners.has(r)&&r(t)}))},e.subscribe=function(t){var e,r=this,n=(e=t,function(){return e.apply(void 0,arguments)});return this._listeners.add(n),function(){r._listeners.delete(n)}},e._load=function(){},e._update=function(t,e){c(this._baseState&&this._derivedState);var r,n,i=this.state;t&&(this._baseState=this._reduce(this._baseState,t)),this._derivedState=this._reduceDerived(this._derivedState,this._derive(this._baseState)),e&&(c(this._extraState),this._extraState=this._reduceExtra(this._extraState,e)),this._scheduleUpdate(),this._notify({newState:this.state,oldState:i,stateChange:(r=this.state,n=i,Object.fromEntries(Object.entries(r).filter((function(t){return t[1]!==n[t[0]]}))))})},d(t,[{key:"state",get:function(){return Object.assign({},this._baseState,this._derivedState,this._extraState)}}]),t}(),J=function(t){function e(e,r,n){var i;return(i=t.call(this,r)||this).name=e,i.failedReceipt=n,i}return y(e,t),e}(b(Error));function K(t){var e=Buffer.from(t.substring(29),"base64").toString();return JSON.parse(e)}function X(t){var e=K(t).properties,n=e.invariant,i={address:e.stableAddress,name:e.stableName,symbol:e.stableSymbol,decimals:e.stableDecimals},o={strike:e.strike,sigma:e.sigma,maturity:e.maturity,lastTimestamp:e.lastTimestamp,gamma:e.gamma},a={reserveRisky:e.reserveRisky,reserveStable:e.reserveStable,liquidity:e.liquidity};return new r.Pool(e.chainId,e.factory,v({},{address:e.riskyAddress,name:e.riskyName,symbol:e.riskySymbol,decimals:e.riskyDecimals}),v({},i),v({},o),v({},a),n,void 0)}var Z=function(){function t(t){this.connection=t}t._from=function(e){return new t(e)},t.connect=function(){var e=l(R.mark((function e(r){return R.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,I(r);case 3:return e.t1=e.sent,e.abrupt("return",e.t0._from.call(e.t0,e.t1));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var e=t.prototype;return e.getPool=function(t,e){return C(this.connection).primitiveManager.contract.uri(t).then(X)},e.getLiquidityBalance=function(t,e,n){return C(this.connection).primitiveManager.contract.balanceOf(e,t).then((function(t){return r.weiToWei(t.toString())}))},e.getPosition=function(t,e,r){return this.getLiquidityBalance(t.poolId,e,r).then((function(e){return new B(t,e)}))},e.getEngine=function(t,e,r){return C(this.connection).primitiveFactory.contract.getEngine(n.getAddress(t),n.getAddress(e)).then((function(t){return t}))},t}(),z=function(t){function e(e,r){return t.call(this,"EthersTransactionFailedError",e,r)||this}return y(e,t),e}(J),H=function(){var t=l(R.mark((function t(e){var r;return R.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.waitForReceipt();case 2:if("succeeded"===(r=t.sent).status){t.next=5;break}throw new z("Transaction failed",r);case 5:return t.abrupt("return",r.details);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();exports.EthersRmm=function(){function t(t){this._readable=t,this.connection=t.connection,this.populate=new Y(t),this.send=new G(this.populate)}t._from=function(e){return new t(Z._from(e))},t.connect=function(){var e=l(R.mark((function e(r){return R.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,I(r);case 2:return e.abrupt("return",t._from(e.sent));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var e=t.prototype;return e.allocate=function(t,e){return this.send.allocate(t,e).then(H)},e.createPool=function(t,e){if(!t.options.createPool)throw new Error("Attempting to create pool without flagging createPool.");return this.send.allocate(t,e).then(H)},e.remove=function(t,e){return this.send.remove(t,e).then(H)},e.safeTransfer=function(t,e){return this.send.safeTransfer(t,e).then(H)},e.safeBatchTransfer=function(t,e){return this.send.safeBatchTransfer(t,e).then(H)},e.createEngine=function(t,e){return this.send.createEngine(t,e).then(H)},e.getPool=function(t,e){return this._readable.getPool(t,e)},e.getLiquidityBalance=function(t,e,r){return this._readable.getLiquidityBalance(t,e,r)},e.getPosition=function(t,e,r){return this._readable.getPosition(t,e,r)},e.getEngine=function(t,e,r){return this._readable.getEngine(t,e,r)},t}(),exports.EthersTransactionFailedError=z,exports.PopulatableEthersRmm=Y,exports.PopulatedEthersSignerTransaction=V,exports.Position=B,exports.ReadableEthersRmm=Z,exports.RmmStore=Q,exports.SendableEthersRmm=G,exports.SentEthersRmmTransaction=W,exports.TransactionFailedError=J,exports._RmmContract=u,exports._RmmContractAbis=s,exports._connect=I,exports._connectToContracts=f,exports._connectToDeployment=function(t,e){var r=A(e);return O(r[0],r[1],f(e,t),t)},exports._connectToNetwork=F,exports._failedReceipt=q,exports._getContracts=C,exports._pendingReceipt=j,exports._successfulReceipt=M,exports.connectionFrom=O,exports.parseTokenURI=K,exports.poolify=X; | ||
//# sourceMappingURL=rmm-ethers.cjs.production.min.js.map |
import { AllocateOptions } from '@primitivefi/rmm-sdk'; | ||
import { BaseContract } from '@ethersproject/contracts'; | ||
import { BatchTransferOptions } from '@primitivefi/rmm-sdk'; | ||
@@ -7,2 +6,3 @@ import { BigNumber } from 'ethers'; | ||
import { BlockTag } from '@ethersproject/abstract-provider'; | ||
import { Contract } from '@ethersproject/contracts'; | ||
import { ContractInterface } from '@ethersproject/contracts'; | ||
@@ -557,3 +557,4 @@ import { Log } from '@ethersproject/abstract-provider'; | ||
export declare class _RmmContract extends BaseContract { | ||
export declare class _RmmContract { | ||
readonly contract: Contract; | ||
constructor(addressOrName: string, contractInterface: ContractInterface, signerOrProvider?: EthersSigner | EthersProvider); | ||
@@ -779,3 +780,3 @@ extractEvents(logs: Log[], name: string): _TypedLogDescription<unknown>[]; | ||
declare type TypedContract<T extends BaseContract, U, V> = _TypeSafeContract<T> & U & {}; | ||
declare type TypedContract<T, U, V> = _TypeSafeContract<T> & U & {}; | ||
@@ -782,0 +783,0 @@ export declare interface _TypedLogDescription<T> extends Omit<LogDescription, 'args'> { |
{ | ||
"name": "@primitivefi/rmm-ethers", | ||
"version": "0.0.10-beta.1", | ||
"version": "0.0.11-beta.1", | ||
"description": "Primitive RMM Protocol ethers-based implementation.", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
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 too big to display
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
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
761278
8498