@primitivefi/rmm-ethers
Advanced tools
Comparing version 0.0.6-beta.1 to 0.0.7-beta.1
@@ -69,2 +69,3 @@ import { LogDescription } from '@ethersproject/abi'; | ||
positionDescriptor: any[]; | ||
primitiveEngine: any; | ||
}; | ||
@@ -71,0 +72,0 @@ declare type RmmContractsKey = keyof _RmmContracts; |
@@ -7,3 +7,3 @@ import { EthersRmmConnection } from './EthersRmmConnection'; | ||
import { Signer } from 'ethers'; | ||
import { EthersCallOverrides, EthersTransactionOverrides, EthersTransactionReceipt, FailedReceipt } from '.'; | ||
import { EngineAddress, EthersCallOverrides, EthersTransactionOverrides, EthersTransactionReceipt, FailedReceipt } from '.'; | ||
import { Position } from './Position'; | ||
@@ -62,2 +62,4 @@ import { EngineCreationParams, TransactionFailedError, PositionAllocateParams, PositionAdjustmentDetails, PositionTransferParams, PositionBatchTransferParams, PositionRemoveParams, EngineCreationDetails } from './TransactableRmm'; | ||
getPosition(pool: Pool, address: string, overrides?: EthersCallOverrides): Promise<Position>; | ||
/** {@inheritdoc ReadableRmm.getEngine} */ | ||
getEngine(riskyAddress: string, stableAddress: string, overrides?: EthersCallOverrides): Promise<EngineAddress>; | ||
} |
import { Pool } from '@primitivefi/rmm-sdk'; | ||
import { Wei } from 'web3-units'; | ||
import { EthersCallOverrides, EthersProvider, EthersRmmConnection, EthersSigner } from '.'; | ||
import { EngineAddress, EthersCallOverrides, EthersProvider, EthersRmmConnection, EthersSigner } from '.'; | ||
import { Position } from './Position'; | ||
@@ -19,2 +19,4 @@ /** | ||
getPosition(pool: Pool, address: string, overrides?: EthersCallOverrides): Promise<Position>; | ||
/** Gets an Engine address from calling the Primitive Factory. */ | ||
getEngine(riskyAddress: string, stableAddress: string, overrides?: EthersCallOverrides): Promise<EngineAddress>; | ||
} | ||
@@ -46,2 +48,4 @@ /** | ||
getPosition(pool: Pool, address: string, overrides?: EthersCallOverrides): Promise<Position>; | ||
/** {@inheritdoc ReadableRmm.getEngine} */ | ||
getEngine(riskyAddress: string, stableAddress: string, overrides?: EthersCallOverrides): Promise<EngineAddress>; | ||
} |
@@ -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("@ethersproject/abstract-signer"),i=require("@ethersproject/logger"),o=require("web3-units"),a=(t=require("assert"))&&"object"==typeof t&&"default"in t?t.default:t;function u(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).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){u(o,n,i,a,s,"next",t)}function s(t){u(o,n,i,a,s,"throw",t)}a(void 0)}))}}function c(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&&c(t.prototype,e),r&&c(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(){return(f=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 l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,d(t,e)}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function d(t,e){return(d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function v(){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 y(t,e,r){return(y=v()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&d(i,r.prototype),i}).apply(null,arguments)}function m(t){var e="function"==typeof Map?new Map:void 0;return(m=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 y(t,arguments,h(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,t)})(t)}var g,w=function(t){function e(e,r,n){return t.call(this,e,r,n)||this}return l(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.Contract),_={primitiveFactory:r.FactoryManager.ABI,primitiveManager:r.PeripheryManager.ABI,positionRenderer:r.PositionRendererManager.ABI,positionDescriptor:r.PositionDescriptorManager.ABI},b=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 w(e,_[r],t)}))},x=(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 s(t,e,r,n){var i=Object.create((e&&e.prototype instanceof f?e:f).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===p)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 s=c(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===p)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(t,r,o),i}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var p={};function f(){}function l(){}function h(){}var d={};u(d,i,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(P([])));y&&y!==e&&r.call(y,i)&&(d=y);var m=h.prototype=f.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 s=c(t[i],t,o);if("throw"!==s.type){var p=s.arg,f=p.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(f).then((function(t){p.value=t,a(p)}),(function(t){return n("throw",t,a,u)}))}u(s.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 p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;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,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}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 P(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:S}}function S(){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(s(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=P,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"),s=r.call(o,"finallyLoc");if(u&&s){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(!s)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,p):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),p},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),p}},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:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(g={exports:{}}),g.exports),E=["deploymentDate"],P={},S=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,E);return f({provider:t,signer:e,deploymentDate:new Date(i),_contracts:r},o)},T=function(t){return t._contracts},R=function(t){if(n.Signer.isSigner(t)){if(null==t||!t.provider)throw new Error("No provider");return[t.provider,t]}return[t,void 0]};function k(t,e,r){var n=P[r];if(!n)throw new Error("No deployment found for chainId: "+r);var i=n;return S(t,e,b(null!=e?e:t,i),i)}var L,O=function(){var t=s(x.mark((function t(e){var r,n,i;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=R(e),n=r[0],i=r[1],t.next=3,n.getNetwork();case 3:return t.abrupt("return",k(n,i,t.sent.chainId));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),j=function(){function t(t,e){void 0===e&&(e=o.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):o.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(o.parseWei(1))}}]),t}(),q={status:"pending"},I=function(t){return{status:"failed",rawReceipt:t}},F=function(t,e,r){return f({status:"succeeded",rawReceipt:t,details:e},r?{toString:r}:{})},N=function(t){return t.send()},A=function(){function t(t){this._populate=t}var e=t.prototype;return e.allocate=function(){var t=s(x.mark((function t(e,r){return x.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(x.mark((function t(e,r){return x.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(x.mark((function t(e,r){return x.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(x.mark((function t(e,r){return x.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(x.mark((function t(e,r){return x.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}();(L=exports._RawErrorReason||(exports._RawErrorReason={})).TRANSACTION_FAILED="transaction failed",L.TRANSACTION_CANCELLED="cancelled",L.TRANSACTION_REPLACED="replaced",L.TRANSACTION_REPRICED="repriced";var C=function(t,e){return e in t},M=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?F(t,this._parse(t),void 0):I(t):q},e._waitForRawReceipt=function(){var t=s(x.mark((function t(e){return x.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(!C(r=t.t0,"code")||r.code!==i.ErrorCode.CALL_EXCEPTION||!C(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(x.mark((function t(){return x.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(x.mark((function t(){var e;return x.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}(),B=function(){function t(t,e,r){this.rawPopulatedTransaction=t,this._connection=e,this._parse=r}return t.prototype.send=function(){var t=s(x.mark((function t(){return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=M,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}(),D=function(){function t(t){this._readable=t}var e=t.prototype;return e._wrap=function(t){return new B(t,this._readable.connection,(function(){}))},e._wrapPositionChange=function(t,e){var n=T(this._readable.connection).primitiveManager;return new B(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 j(t.pool)]:n.extractEvents(i,"Allocate").map((function(e){return new j(t.pool,r.weiToWei(e.args.delLiquidity.toString()))})))[0];return a||(a=n.extractEvents(i,"Remove").map((function(e){return new j(t.pool,r.weiToWei(e.args.delLiquidity.toString()))}))[0]),{params:t,newPosition:a}}))},e._applyGasLimit=function(){var t=s(x.mark((function t(e,r,n){var i,o,a,u;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=(o=(i=function(){return f({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=f({},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(x.mark((function t(e,n){var i,o;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=T(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(x.mark((function t(e,n){var i,o;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=T(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(x.mark((function t(e,n){var i,a;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=T(this._readable.connection),a=i.primitiveFactory,t.next=3,this._applyGasLimit(a,{calldata:r.FactoryManager.encodeDeploy(e.risky,e.stable),value:o.toBN(0)._hex},n);case 3:return t.abrupt("return",new B(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(x.mark((function t(e,n){var i,o;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=T(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(x.mark((function t(e,n){var i,o;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=T(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}(),G=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){a(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&&(a(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}(),U=function(t){function e(e,r,n){var i;return(i=t.call(this,r)||this).name=e,i.failedReceipt=n,i}return l(e,t),e}(m(Error));function W(t){var e=Buffer.from(t.substring(29),"base64").toString();return JSON.parse(e)}function V(t){var e=W(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,f({},{address:e.riskyAddress,name:e.riskyName,symbol:e.riskySymbol,decimals:e.riskyDecimals}),f({},i),f({},o),f({},a),n,void 0)}var Y=function(){function t(t){this.connection=t}t._from=function(e){return new t(e)},t.connect=function(){var e=s(x.mark((function e(r){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,O(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 T(this.connection).primitiveManager.uri(t).then(V)},e.getLiquidityBalance=function(t,e,n){return T(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 j(t,e)}))},t}(),Q=function(t){function e(e,r){return t.call(this,"EthersTransactionFailedError",e,r)||this}return l(e,t),e}(U),J=function(){var t=s(x.mark((function t(e){var r;return x.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 Q("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 D(t),this.send=new A(this.populate)}t._from=function(e){return new t(Y._from(e))},t.connect=function(){var e=s(x.mark((function e(r){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O(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(J)},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(J)},e.remove=function(t,e){return this.send.remove(t,e).then(J)},e.safeTransfer=function(t,e){return this.send.safeTransfer(t,e).then(J)},e.safeBatchTransfer=function(t,e){return this.send.safeBatchTransfer(t,e).then(J)},e.createEngine=function(t,e){return this.send.createEngine(t,e).then(J)},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)},t}(),exports.EthersTransactionFailedError=Q,exports.PopulatableEthersRmm=D,exports.PopulatedEthersSignerTransaction=B,exports.Position=j,exports.ReadableEthersRmm=Y,exports.RmmStore=G,exports.SendableEthersRmm=A,exports.SentEthersRmmTransaction=M,exports.TransactionFailedError=U,exports._RmmContract=w,exports._RmmContractAbis=_,exports._connect=O,exports._connectToContracts=b,exports._connectToDeployment=function(t,e){var r=R(e);return S(r[0],r[1],b(e,t),t)},exports._connectToNetwork=k,exports._failedReceipt=I,exports._getContracts=T,exports._pendingReceipt=q,exports._successfulReceipt=F,exports.connectionFrom=S,exports.parseTokenURI=W,exports.poolify=V; | ||
"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.Contract),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; | ||
//# sourceMappingURL=rmm-ethers.cjs.production.min.js.map |
@@ -127,2 +127,4 @@ import { AllocateOptions } from '@primitivefi/rmm-sdk'; | ||
getPosition(pool: Pool, address: string, overrides?: EthersCallOverrides): Promise<Position>; | ||
/** {@inheritdoc ReadableRmm.getEngine} */ | ||
getEngine(riskyAddress: string, stableAddress: string, overrides?: EthersCallOverrides): Promise<EngineAddress>; | ||
} | ||
@@ -530,2 +532,4 @@ | ||
getPosition(pool: Pool, address: string, overrides?: EthersCallOverrides): Promise<Position>; | ||
/** {@inheritdoc ReadableRmm.getEngine} */ | ||
getEngine(riskyAddress: string, stableAddress: string, overrides?: EthersCallOverrides): Promise<EngineAddress>; | ||
} | ||
@@ -547,2 +551,4 @@ | ||
getPosition(pool: Pool, address: string, overrides?: EthersCallOverrides): Promise<Position>; | ||
/** Gets an Engine address from calling the Primitive Factory. */ | ||
getEngine(riskyAddress: string, stableAddress: string, overrides?: EthersCallOverrides): Promise<EngineAddress>; | ||
} | ||
@@ -564,2 +570,3 @@ | ||
positionDescriptor: any[]; | ||
primitiveEngine: any; | ||
}; | ||
@@ -566,0 +573,0 @@ |
export type { AccessControl } from "./AccessControl"; | ||
export type { ERC20 } from "./ERC20"; | ||
export type { IERC20 } from "./IERC20"; | ||
export type { IERC20Permit } from "./IERC20Permit"; | ||
export type { TestERC20 } from "./TestERC20"; | ||
export type { TestToken } from "./TestToken"; | ||
export type { USDC } from "./USDC"; | ||
export type { PositionDescriptor } from "./PositionDescriptor"; | ||
@@ -13,3 +16,6 @@ export type { PositionRenderer } from "./PositionRenderer"; | ||
export { IERC20__factory } from "./factories/IERC20__factory"; | ||
export { IERC20Permit__factory } from "./factories/IERC20Permit__factory"; | ||
export { TestERC20__factory } from "./factories/TestERC20__factory"; | ||
export { TestToken__factory } from "./factories/TestToken__factory"; | ||
export { USDC__factory } from "./factories/USDC__factory"; | ||
export { PositionDescriptor__factory } from "./factories/PositionDescriptor__factory"; | ||
@@ -16,0 +22,0 @@ export { PositionRenderer__factory } from "./factories/PositionRenderer__factory"; |
{ | ||
"name": "@primitivefi/rmm-ethers", | ||
"version": "0.0.6-beta.1", | ||
"version": "0.0.7-beta.1", | ||
"description": "Primitive RMM Protocol ethers-based implementation.", | ||
@@ -47,3 +47,3 @@ "repository": { | ||
"@primitivefi/hardhat-dodoc": "^0.1.3", | ||
"@primitivefi/rmm-sdk": "^1.0.1-beta.5", | ||
"@primitivefi/rmm-sdk": "^1.0.2-beta.5", | ||
"@typechain/ethers-v5": "^8.0.5", | ||
@@ -50,0 +50,0 @@ "@typechain/hardhat": "^3.1.0", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
760146
41
8496
3