@aurigami/sdk 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/consts/constants.d.ts +1 -0
- package/dist/entities/auriEnv.d.ts +2 -1
- package/dist/entities/tokenAmount.d.ts +1 -0
- package/dist/helpers/helpers.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/sdk.cjs.development.js +81 -37
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +80 -39
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/consts/constants.ts +8 -0
- package/src/consts/symbols.ts +3 -1
- package/src/entities/auriEnv.ts +13 -1
- package/src/entities/tokenAmount.ts +5 -1
- package/src/helpers/graphql-helpers.ts +4 -6
- package/src/helpers/helpers.ts +10 -0
- package/src/index.ts +1 -0
- package/src/types/index.ts +5 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("bignumber.js")),r=require("ethers"),n=require("ethers/lib/utils"),a=e(require("@aurigami/contracts/deployments/aurora_mainnet.json")),o=e(require("@aurigami/contracts/deployments/aurora_testnet.json")),i=e(require("@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json")),u=e(require("@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json")),s=e(require("@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json")),c=e(require("@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json")),p=e(require("@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json")),f=e(require("@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json")),l=e(require("@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json")),d=e(require("@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json")),h=e(require("@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json")),w=e(require("@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json")),m=e(require("@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json")),v=e(require("@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json")),y=e(require("@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json")),b=e(require("@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json")),g=e(require("@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json")),k=require("@ethersproject/abstract-signer"),x=e(require("axios")),A=e(require("node-fetch")),L="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",C={auTokens:[{name:"auUSDC",address:a.auTokens.USDC.toLowerCase(),underlying:"0xb12bfca5a55806aaf64e99521918a4bf0fc40802".toLowerCase()},{name:"auETH",address:a.auTokens.ETH.toLowerCase(),underlying:L.toLowerCase()},{name:"auWBTC",address:a.auTokens.WBTC.toLowerCase(),underlying:"0xf4eb217ba2454613b15dbdea6e5f22276410e89e".toLowerCase()},{name:"auUSDT",address:a.auTokens.USDT.toLowerCase(),underlying:"0x4988a896b1227218e4a686fde5eabdcabd91571f".toLowerCase()},{name:"auDAI",address:a.auTokens.DAI.toLowerCase(),underlying:"0xe3520349f477a5f6eb06107066048508498a291b".toLowerCase()},{name:"auWNEAR",address:a.auTokens.WNEAR.toLowerCase(),underlying:"0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d".toLowerCase()},{name:"auSTNEAR",address:a.auTokens.STNEAR.toLowerCase(),underlying:"0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30".toLowerCase()},{name:"auAURORA",address:a.auTokens.AURORA.toLowerCase(),underlying:"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase()},{name:"auTRI",address:a.auTokens.TRI.toLowerCase(),underlying:"0xFa94348467f64D5A457F75F8bc40495D33c65aBB".toLowerCase()},{name:"auPLY",address:a.auTokens.PLY.toLowerCase(),underlying:"0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f".toLowerCase()},{name:"auUSN",address:a.auTokens.USN.toLowerCase(),underlying:"0x5183e1b1091804bc2602586919e6880ac1cf2896".toLowerCase()}],misc:{COMPTROLLER:a.comptroller.toLowerCase(),oracle:a.oracle.toLowerCase(),AURIFAIRLAUNCH:a.fairLaunch.toLowerCase(),AURILENS:a.auriLens.toLowerCase(),ETHREPAYHELPER:a.ethRepayHelper.toLowerCase(),AURI_AIRDROP:a.auriAirdrop.toLowerCase(),MULTICALL:a.multicall.toLowerCase(),TEAM_MULTISIG:"0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE".toLowerCase(),PLY_TOKEN_LOCK:a.plyTokenLock.toLowerCase(),REFERRAL:a.referralDirectory.toLowerCase(),AURI_INTERNAL_LENS:a.auriInternalLens.toLowerCase()},tokens:{AURORA:"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),PLY:"0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f".toLowerCase(),stNEAR:"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30".toLowerCase(),USDC:"0xb12bfca5a55806aaf64e99521918a4bf0fc40802".toLowerCase(),WNEAR:"0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d".toLowerCase(),TRI:"0xFa94348467f64D5A457F75F8bc40495D33c65aBB".toLowerCase(),META:"0xc21ff01229e982d7c8b8691163b0a3cb8f357453".toLowerCase(),PULP:a.PULP.toLowerCase(),PLYWNEAR:a.ply_wnear_lp.toLowerCase(),USN:"0x5183e1b1091804bc2602586919e6880ac1cf2896".toLowerCase()}},E=new Set([].concat(C.auTokens.map((function(e){return e.underlying})),[C.tokens.AURORA,C.tokens.TRI,C.tokens.META,C.tokens.stNEAR])),R=new t(1),P=["0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f","0x04Ac48711BCdc45b4d223fb021E09DA73c71095e","0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d","0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30","0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79","0xFa94348467f64D5A457F75F8bc40495D33c65aBB"],T=[0],S=r.BigNumber.from(2).pow(256).sub(1),B=Object.fromEntries(Object.entries({"0xb12bfca5a55806aaf64e99521918a4bf0fc40802":"36375","0x4988a896b1227218e4a686fde5eabdcabd91571f":"14550","0xf4eb217ba2454613b15dbdea6e5f22276410e89e":"3638","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE":"14550","0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d":"3638"}).map((function(e){var t=e[1];return[e[0].toLowerCase(),t]}))),_={},N=Object.fromEntries([[C.tokens.USN.toLowerCase(),"1"]]),D={"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":18,"0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f":18,"0x3195949f267702723bc614cae037cdc8d1e94786":8,"0xfa94348467f64d5a457f75f8bc40495d33c65abb":18,"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30":24,"0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d":24,"0x6ea6c03061bddce23d4ec60b6e6e880c33d24dca":8,"0xca9511b610ba5fc7e311fdef9ce16050ee4449e9":8,"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79":18,"0xcfb6b0498cb7555e7e21502e0f449bf28760adbb":8,"0x4f0d864b1abf4b701799a0b30b57a22dfeb5917b":8,"0xad5a2437ff55ed7a8cad3b797b3ec7c5a19b1c54":8,"0x4988a896b1227218e4a686fde5eabdcabd91571f":6,"0xb12bfca5a55806aaf64e99521918a4bf0fc40802":6,"0xe3520349f477a5f6eb06107066048508498a291b":18,"0x8888682e24dd4df7b7ff2b91fccb575737e433bf":8,"0xae4fac24dcdae0132c6d04f564dcf059616e9423":8,"0xce4166363e3a584dac84a47bcd3414b43efcdd1c":8,"0xf4eb217ba2454613b15dbdea6e5f22276410e89e":8,"0xc21ff01229e982d7c8b8691163b0a3cb8f357453":24,"0x04ac48711bcdc45b4d223fb021e09da73c71095e":18,"0x044b6b0cd3bb13d2b9057781df4459c66781dce7":18,"0x5183e1b1091804bc2602586919e6880ac1cf2896":18};function O(e,t,r,n,a,o,i){try{var u=e[o](i),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,a)}function U(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){O(o,n,a,i,u,"next",e)}function u(e){O(o,n,a,i,u,"throw",e)}i(void 0)}))}}function I(){return(I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function F(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function W(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return M(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?M(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var j,Y=function(e){this._networkConnection=e},q=function(e){function t(t){if(!(t.signer instanceof k.Signer))throw Error("Signer is not provided when constructing BlockchainEntityReadWrite");return e.call(this,t)||this}return F(t,e),t}(Y),H=function(){function e(){}var t=e.prototype;return t.read=function(e){return new Y(e)},t.readWrite=function(e){return new q(e)},e}(),G=function(e){function t(t){var r;return(r=e.call(this,t)||this).comptroller=r.getContract(C.misc.COMPTROLLER,d.abi),r.auriFairLaunch=r.getContract(C.misc.AURIFAIRLAUNCH,c.abi),r.auriLens=r.getContract(C.misc.AURILENS,p.abi),r.ply=r.getContract(C.tokens.PLY,w.abi),r.pulp=r.getContract(C.tokens.PULP,b.abi),r.auriInternalLens=r.getContract(C.misc.AURI_INTERNAL_LENS,m.abi),r}return F(t,e),t.prototype.getContract=function(e,t){return new r.Contract(e,t,this._networkConnection.provider)},t}(Y),K=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var a=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return{value:void 0,done:!0}}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var u=g(i,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(e,t,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)}}}(e,r,o),a}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var p={};function f(){}function l(){}function d(){}var h={};u(h,a,(function(){return this}));var w=Object.getPrototypeOf,m=w&&w(w(L([])));m&&m!==t&&r.call(m,a)&&(h=m);var v=d.prototype=f.prototype=Object.create(h);function y(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(a,o){function i(){return new t((function(n,i){!function n(a,o,i,u){var s=c(e[a],e,o);if("throw"!==s.type){var p=s.arg,f=p.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,i,u)}),(function(e){n("throw",e,i,u)})):t.resolve(f).then((function(e){p.value=e,i(p)}),(function(e){return n("throw",e,i,u)}))}u(s.arg)}(a,o,n,i)}))}return n=n?n.then(i,i):i()}}function g(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,g(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,p;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function L(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return l.prototype=d,u(v,"constructor",d),u(d,"constructor",l),l.displayName=u(d,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,u(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},y(b.prototype),u(b.prototype,o,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new b(s(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},y(v),u(v,i,"Generator"),u(v,a,(function(){return this})),u(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=L,A.prototype={constructor:A,reset:function(e){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),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=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(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;x(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:L(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(j={exports:{}}),j.exports),V=Object.fromEntries(C.auTokens.map((function(e){return[e.address.toLowerCase(),e.name]})));function Q(e,t,r){return Z.apply(this,arguments)}function Z(){return(Z=U(K.mark((function e(t,r,n){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n={}),n=I({},n,{module:t,action:r}),e.next=4,x.get("https://api.aurorascan.dev/api?"+new URLSearchParams(n),{headers:{"Content-Type":"application/json"}});case 4:return e.abrupt("return",e.sent.data.result);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var z="https://explorer.mainnet.aurora.dev/graphiql";function J(e){return $.apply(this,arguments)}function $(){return($=U(K.mark((function e(t){var r;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,A(z,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({query:t})});case 2:return r=e.sent,e.next=5,r.json();case 5:return e.abrupt("return",e.sent.data);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function X(e,t){if(void 0===t&&(t=""),!e)throw t="Assertion failed"+(t?": "+t:""),new Error(t)}function ee(e){return JSON.stringify(e,null," ")}function te(e){return r.BigNumber.from(10).pow(e).toString()}var re=function(e,t){return e.toLowerCase()==t.toLowerCase()},ne=function(){return Math.trunc(Date.now()/1e3)};function ae(e){try{return r.utils.getAddress(e)}catch(t){throw new Error("Invalid address: "+e)}}function oe(e){var t=e.toLowerCase();return X(null!=D[t],"Decimal not found for "+e),D[t]}function ie(e){var t=e.toLowerCase();return X(null!=V[t],"Symbol not found for "+e),V[t]}function ue(e,r,n){return e.isZero()?new t(0):r.lte(0)?e:e.multipliedBy(n).dividedBy(r)}function se(e,t){return ce.apply(this,arguments)}function ce(){return(ce=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getBlock(r);case 2:return e.abrupt("return",e.sent.timestamp);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function pe(e,t){return fe.apply(this,arguments)}function fe(){return(fe=U(K.mark((function e(t,r){var n,a,o,i,u;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=200,a=[],o=0;case 3:if(!(o<r.length)){e.next=14;break}return i=r.slice(o,o+n),u=i.map(function(){var e=U(K.mark((function e(r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",se(t,r));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.t0=a,e.next=9,Promise.all(u);case 9:e.t1=e.sent,a=e.t0.concat.call(e.t0,e.t1);case 11:o+=n,e.next=3;break;case 14:return e.abrupt("return",a);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function le(e,t){return de.apply(this,arguments)}function de(){return(de=U(K.mark((function e(t,r){var n,a,o,i,u,s;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=r.map((function(e){return"b"+e+": block(number: "+e+") { timestamp }"})),o=0;o<a.length;o+=100)i="{ "+a.slice(o,o+100).join("\n")+" }",n.push(J(i));return e.next=6,Promise.all(n);case 6:return u=e.sent.reduce((function(e,t){return I({},e,t)})),(s=r.filter((function(e){return!u["b"+e]}))).length>0&&s.join(", "),e.next=11,pe(t,s);case 11:return e.sent.forEach((function(e,t){u["b"+s[t]]={timestamp:new Date(1e3*e).toISOString()}})),e.abrupt("return",r.map((function(e){return Math.trunc(new Date(u["b"+e].timestamp).getTime()/1e3)})));case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e,t){return we.apply(this,arguments)}function we(){return(we=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Q("block","getblocknobytime",{timestamp:r,closest:"before"});case 2:if(e.t0=parseInt(e.sent),e.t0){e.next=8;break}return e.next=7,t.getBlockNumber();case 7:e.t0=e.sent;case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function me(e){}var ve=function(e,t){this.address=e.toLowerCase(),this.decimals=t},ye=new ve(C.tokens.PLY,oe(C.tokens.PLY)),be=new ve(C.tokens.PLYWNEAR,oe(C.tokens.PLYWNEAR)),ge=function(){function e(e,r,n){void 0===n&&(n=!0),this.rawAmnt=n?r:new t(r).times(te(e.decimals)).toFixed(0),this.token=e}var r=e.prototype;return r.formattedAmount=function(){return new t(this.rawAmnt).div(te(this.token.decimals)).toString()},r.rawAmount=function(){return this.rawAmnt},e.fromAddressAndAmount=function(t,r,n){return void 0===n&&(n=!0),new e(new ve(t,oe(t)),r,n)},e}(),ke=new ve("0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",6),xe=new ve("0x8729438eb15e2c8b576fcc6aecda6a148776c0f5",18),Ae=new ve("0xE530dC2095Ef5653205CF5ea79F8979a7028065c",18),Le=new ge(ke,"123.456",!1),Ce=new ge(ke,"0"),Ee=new ge(ke,"456.123",!1),Re=new ge(ke,"1000.123",!1),Pe={market:"0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f",depositBalance:Ee,borrowBalance:Ce,isCollateral:!0,maxWithdrawableAmount:Le,collateralRatio:.5,underlyingPrice:"1"};function Te(e,t){return Se.apply(this,arguments)}function Se(){return(Se=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),e.next=3,x.get("https://api.aurigami.finance/app/"+t+"?"+new URLSearchParams(r),{headers:{"Content-Type":"application/json"}});case 3:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Be(e,t,r,n){return _e.apply(this,arguments)}function _e(){return(_e=U(K.mark((function e(t,r,n,a){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),void 0===n&&(n=1),void 0===a&&(a=50),r=I({},r,{page:n,limit:a}),e.next=6,x.get("https://api.aurigami.finance/app/"+t+"?"+new URLSearchParams(r),{headers:{"Content-Type":"application/json"}});case 6:return e.abrupt("return",e.sent.data);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ne(e){return De.apply(this,arguments)}function De(){return(De=U(K.mark((function e(r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,x.get("https://api.coingecko.com/api/v3/simple/price?ids="+r+"&vs_currencies=usd").then((function(e){return e.data}));case 2:return e.abrupt("return",new t(e.sent[r].usd));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Oe(e){return Ue.apply(this,arguments)}function Ue(){return(Ue=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.toLowerCase(),e.next=e.t0===C.tokens.AURORA?3:e.t0===C.tokens.TRI?4:e.t0===C.tokens.META?5:6;break;case 3:return e.abrupt("return",Ne("aurora-near"));case 4:return e.abrupt("return",Ne("trisolaris"));case 5:return e.abrupt("return",Ne("meta-pool"));case 6:throw Error("Unknown token "+t+" in fetchPriceFromCoingecko");case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ie(e,t){return Fe.apply(this,arguments)}function Fe(){return(Fe=U(K.mark((function e(t,n){var a,o,i;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new r.Contract(t,v.abi,n),(o=[]).push(a.token0()),o.push(a.token1()),o.push(a.getReserves()),o.push(a.totalSupply()),e.next=8,Promise.all(o);case 8:return e.abrupt("return",{token0:(i=e.sent)[0],token1:i[1],reserve0:i[2].reserve0,reserve1:i[2].reserve1,totalSupply:i[3]});case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Me(e,t){return We.apply(this,arguments)}function We(){return(We=U(K.mark((function e(r,n){var a,o,i,u;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=function(){return(u=U(K.mark((function e(r){var i,u,s;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.reserve.isZero()){e.next=2;break}return e.abrupt("return",new t(0));case 2:return e.next=4,Ze(r.address,n);case 4:return i=e.sent,u=oe(r.address),s=i.multipliedBy(r.reserve.toString()).multipliedBy(2),e.abrupt("return",s.multipliedBy(te(o)).dividedBy(new t(a.totalSupply.toString())).dividedBy(te(u)));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)},i=function(e){return u.apply(this,arguments)},e.next=4,Ie(r,n);case 4:return a=e.sent,o=oe(r),e.prev=6,e.next=9,i({address:a.token0,reserve:a.reserve0});case 9:return e.abrupt("return",e.sent);case 12:return e.prev=12,e.t0=e.catch(6),e.prev=15,e.next=18,i({address:a.token1,reserve:a.reserve1});case 18:return e.abrupt("return",e.sent);case 21:throw e.prev=21,e.t1=e.catch(15),Error("Unable to fetch price for both tokens of LP "+r);case 25:case"end":return e.stop()}}),e,null,[[6,12],[15,21]])})))).apply(this,arguments)}function je(e,r){return new t(e.toString()).div(te(36-r))}function Ye(e,t,r){return qe.apply(this,arguments)}function qe(){return(qe=U(K.mark((function e(t,n,a){var o;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new r.Contract(C.misc.oracle,f.abi,a),e.next=3,o.getUnderlyingPrice(t);case 3:return e.abrupt("return",je(e.sent,n));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function He(e){return Ge.apply(this,arguments)}function Ge(){return(Ge=U(K.mark((function e(t){var n,a,o;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new r.Contract(C.misc.AURILENS,p.abi,t),a=C.auTokens.map((function(e){return e.address})),o=C.auTokens.map((function(e){return oe(e.underlying)})),e.next=5,n.auTokenUnderlyingPriceAll(a);case 5:return e.abrupt("return",e.sent.map((function(e,t){return{auToken:e.auToken,underlyingPrice:je(e.underlyingPrice,o[t])}})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ke(){return Ve.apply(this,arguments)}function Ve(){return(Ve=U(K.mark((function e(){var r,n,a,o,i;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=x.get("https://validators.narwallets.com/metrics_json").then((function(e){return e.data})),n=Ne("near"),e.next=4,Promise.all([r,n]);case 4:return o=(a=e.sent)[1],i=new t(a[0].st_near_price),e.abrupt("return",i.multipliedBy(o));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Qe(e){return(e=e.toLowerCase())==C.tokens.AURORA||e==C.tokens.TRI||e==C.tokens.META}function Ze(e,t){return ze.apply(this,arguments)}function ze(){return(ze=U(K.mark((function e(t,r){var n;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(X(E.has(t.toLocaleLowerCase()),"Address "+t+" is not whitelisted for price fetching"),!re(t,C.tokens.stNEAR)){e.next=3;break}return e.abrupt("return",Ke());case 3:if(!Qe(t)){e.next=5;break}return e.abrupt("return",Oe(t));case 5:if(void 0===(n=C.auTokens.find((function(e){return re(e.underlying,t)})))){e.next=10;break}return e.abrupt("return",Ye(n.address,oe(t),r));case 10:throw Error("Unable to fetch price for "+t);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Je(e,t){return $e.apply(this,arguments)}function $e(){return($e=U(K.mark((function e(r,n){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r.toLowerCase()in N)){e.next=4;break}return e.abrupt("return",new t(N[r.toLowerCase()]));case 4:if(!re(r,C.tokens.PLYWNEAR)){e.next=8;break}return e.abrupt("return",Me(r,n));case 8:if(!re(r,C.tokens.PLY)){e.next=12;break}return e.abrupt("return",Xe(n));case 12:if(!re(r,C.tokens.PULP)){e.next=14;break}return e.abrupt("return",tt(n));case 14:return e.abrupt("return",Ze(r,n));case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Xe(e){return et.apply(this,arguments)}function et(){return(et=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",nt(C.tokens.PLYWNEAR,t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function tt(e){return rt.apply(this,arguments)}function rt(){return(rt=U(K.mark((function e(r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new t(0));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function nt(e,t){return at.apply(this,arguments)}function at(){return(at=U(K.mark((function e(r,n){var a,o,i;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ie(r,n);case 2:if(!(a=e.sent).reserve1.isZero()){e.next=5;break}return e.abrupt("return",new t(0));case 5:return o=oe(a.token0),i=oe(a.token1),e.next=9,Je(a.token1,n);case 9:return e.abrupt("return",e.sent.multipliedBy(a.reserve1.toString()).multipliedBy(te(o)).dividedBy(te(i)).dividedBy(a.reserve0.toString()));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ot(e,t){return it.apply(this,arguments)}function it(){return(it=U(K.mark((function e(r,n){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("0"!=r.rawAmount()){e.next=2;break}return e.abrupt("return",new t(0));case 2:return e.next=4,Je(r.token.address,n);case 4:return e.abrupt("return",ut(r,e.sent));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ut(e,r){return new t(e.formattedAmount()).multipliedBy(r)}function st(e,t){return ct.apply(this,arguments)}function ct(){return(ct=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ot(t,r);case 2:return e.abrupt("return",{tokenAmount:t,currencyAmount:{currency:"USD",amount:e.sent.toFixed(10)}});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var pt,ft,lt=function(e){function t(t,n){var a;return(a=e.call(this,n)||this).auToken=new r.Contract(t,l.abi,a._networkConnection.provider),a}F(t,e);var n=t.prototype;return n.queryERC20TransfersOf=function(){var e=U(K.mark((function e(t,r,n){var a,o,i,u=this;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=[this.auToken.filters.Transfer(t,null),this.auToken.filters.Transfer(null,t)],e.next=3,Promise.all(a.map((function(e){return u.auToken.queryFilter(e,r,n)})));case 3:return o=e.sent.flat(),(i=o.map((function(e){return{from:e.args[0],to:e.args[1],amount:e.args[2],blockNumber:e.blockNumber}}))).sort((function(e,t){return e.blockNumber-t.blockNumber})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),n.queryERC20BalanceAt=function(){var e=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.auToken.balanceOf(t,{blockTag:r+1}));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t}(Y),dt={__proto__:null,getApi:Te,getPaginatedApi:Be,getQuery:Q,queryGraphQL:J,assert:X,formatObject:ee,decimalFactor:te,isSameAddress:re,getCurrentTimestamp:ne,validateAndParseAddress:ae,getDecimal:oe,getSymbol:ie,calcLMRewardApr:ue,getBlockTimestamp:se,getBlocksTimestampViaRPC:pe,getBlocksTimestamp:le,getBlockBeforeTimestamp:he,devLog:me,fetchPriceFromCoingeckoAPI:Ne,fetchPriceFromCoingecko:Oe,fetchLPPositions:Ie,fetchLPPrice:Me,fetchPriceFromOracle:Ye,fetchUnderlyingTokensPrices:He,fetchStNEARPrice:Ke,fetchPrice:Je,fetchPLYPrice:Xe,fetchPULPPrice:tt,fetchToken0PriceByLP:nt,fetchValuation:ot,calcValuation:ut,valuateToken:st,TransferEventQuery:lt},ht=function(e){function t(t){var n;return(n=e.call(this,t)||this).airDrop=new r.Contract(C.misc.AURI_AIRDROP,s.abi,t.provider),n}return F(t,e),t.prototype.getRedeemableReward=function(){var e=U(K.mark((function e(t,n,a){var o;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new ve(n,oe(n)),e.next=3,this.airDrop.getRedeemableReward(r.utils.formatBytes32String(t),n,a);case 3:return e.abrupt("return",new ge(o,e.sent.toString()));case 5:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t}(Y),wt=function(e){function t(){return e.apply(this,arguments)||this}F(t,e);var n=t.prototype;return n.redeemMultiple=function(){var e=U(K.mark((function e(t,n){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return X(t.length==n.length,"campaigns and tokens must have the same length"),e.t0=this.airDrop.connect(this._networkConnection.signer),e.t1=t.map((function(e){return r.utils.formatBytes32String(e)})),e.t2=n,e.next=6,this._networkConnection.signer.getAddress();case 6:return e.t3=e.sent,e.abrupt("return",e.t0.redeem.call(e.t0,e.t1,e.t2,e.t3));case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),n.redeemSingle=function(){var e=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.redeemMultiple([t],[r]));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t}(ht),mt=function(e){function t(){return e.call(this)||this}F(t,e);var r=t.prototype;return r.read=function(e){return new ht(e)},r.readWrite=function(e){return new wt(e)},t}(H);(pt=exports.ComptrollerRewardType||(exports.ComptrollerRewardType={}))[pt.PLY=0]="PLY",pt[pt.AURORA=1]="AURORA",(ft=exports.MarketAction||(exports.MarketAction={}))[ft.Deposit=0]="Deposit",ft[ft.Borrow=1]="Borrow",ft[ft.Withdraw=2]="Withdraw",ft[ft.Repay=3]="Repay",ft[ft.EnableCollateral=4]="EnableCollateral",ft[ft.DisableCollateral=5]="DisableCollateral";var vt=function(e){function n(t,n,a){var o;return(o=e.call(this,t)||this).env=new G(t),o.auToken=re(a,L)?new r.Contract(n,u.abi,t.provider):new r.Contract(n,i.abi,t.provider),o.underlying=new ve(a,oe(a)),o}F(n,e);var a=n.prototype;return a.getRewardSpeeds=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriLens.getRewardSpeeds(this.env.comptroller.address,this.auToken.address);case 2:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getTotalTokenBorrowed=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=ge,e.t1=this.underlying,e.next=4,this.auToken.totalBorrows();case 4:return e.t2=e.sent.toString(),e.abrupt("return",new e.t0(e.t1,e.t2));case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getTotalTokenDeposited=function(){var e=U(K.mark((function e(){var t,n,a,o=this;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=[]).push(this.getTotalTokenBorrowed().then((function(e){n=e}))),t.push(this.auToken.getCash().then((function(e){a=new ge(o.underlying,e.toString())}))),e.next=5,Promise.all(t);case 5:return e.abrupt("return",new ge(this.underlying,r.BigNumber.from(a.rawAmount()).add(n.rawAmount()).toString()));case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getDepositAPY=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auToken.supplyRatePerTimestamp();case 2:return e.abrupt("return",new t(e.sent.toString()).multipliedBy(31536e3).div(te(18)));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getBorrowAPY=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auToken.borrowRatePerTimestamp();case 2:return e.abrupt("return",new t(e.sent.toString()).multipliedBy(31536e3).div(te(18)));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getCollateralRatio=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.comptroller.markets(this.auToken.address).then((function(e){return new t(e.collateralFactorMantissa.toString()).div(te(18))})));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getBorrowPlyAPY=function(){var e=U(K.mark((function e(){var t,r,n,a,o;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=[]).push(this.getTotalTokenBorrowed().then((function(e){r=e}))),t.push(this.env.comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY,this.auToken.address,!1).then((function(e){n=new ge(ye,e.toString())}))),t.push(Je(C.tokens.PLY,this._networkConnection.provider).then((function(e){a=e}))),t.push(Je(this.underlying.address,this._networkConnection.provider).then((function(e){o=e}))),e.next=7,Promise.all(t);case 7:return e.abrupt("return",ue(a.multipliedBy(n.formattedAmount()),o.multipliedBy(r.formattedAmount()),31536e3));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getDepositPlyAPY=function(){var e=U(K.mark((function e(){var t,r,n,a,o;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=[]).push(this.getTotalTokenDeposited().then((function(e){r=e}))),t.push(this.env.comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY,this.auToken.address,!0).then((function(e){n=new ge(ye,e.toString())}))),t.push(Je(C.tokens.PLY,this._networkConnection.provider).then((function(e){a=e}))),t.push(Je(this.underlying.address,this._networkConnection.provider).then((function(e){o=e}))),e.next=7,Promise.all(t);case 7:return e.abrupt("return",ue(a.multipliedBy(n.formattedAmount()),o.multipliedBy(r.formattedAmount()),31536e3));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getDetails=function(){var e=U(K.mark((function e(){var r,n,a,o,i,u,s,c,p,f,l,d,h,w;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=[]).push(this.getTotalTokenDeposited().then((function(e){n=e}))),r.push(this.getTotalTokenBorrowed().then((function(e){a=e}))),r.push(this.getDepositAPY().then((function(e){o=e.toNumber()}))),r.push(this.getBorrowAPY().then((function(e){i=e.toNumber()}))),r.push(this.getCollateralRatio().then((function(e){u=e.toNumber()}))),r.push(this.getRewardSpeeds().then((function(e){p=e}))),r.push(Je(C.tokens.PLY,this._networkConnection.provider).then((function(e){s=e}))),r.push(Je(this.underlying.address,this._networkConnection.provider).then((function(e){c=e}))),e.next=11,Promise.all(r);case 11:return f=ue(ut(new ge(ye,p.plyRewardBorrowSpeed.toString()),s),c.multipliedBy(a.formattedAmount()),31536e3),l=ue(ut(new ge(ye,p.plyRewardSupplySpeed.toString()),s),c.multipliedBy(n.formattedAmount()),31536e3),e.t0=dt,e.next=16,ot(this.getDepositNEARRewardPerWeek(),this._networkConnection.provider);case 16:return e.t1=e.sent,e.t2=c.multipliedBy(n.formattedAmount()),d=e.t0.calcLMRewardApr.call(e.t0,e.t1,e.t2,52),e.t3=dt,e.next=22,ot(this.getBorrowNEARRewardPerWeek(),this._networkConnection.provider);case 22:return e.t4=e.sent,e.t5=c.multipliedBy(a.formattedAmount()),h=e.t3.calcLMRewardApr.call(e.t3,e.t4,e.t5,52),w=re(this.underlying.address,C.tokens.stNEAR)?ue(new t(5e4),c.multipliedBy(n.formattedAmount()),12):new t(0),e.abrupt("return",{auTokenAddress:this.auToken.address,totalTokenDeposited:n,totalTokenBorrowed:a,depositApy:o,depositPlyApy:l.toNumber(),borrowApy:i,borrowPlyApy:-1*f.toNumber(),collateralRatio:u,depositPlyPerWeek:new ge(ye,p.plyRewardSupplySpeed.mul(86400).mul(7).toString()),borrowPlyPerWeek:new ge(ye,p.plyRewardBorrowSpeed.mul(86400).mul(7).toString()),depositNEARApy:d.toNumber(),borrowNEARApy:-1*h.toNumber(),depositMETAApy:w.toNumber()});case 27:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getUserBorrowBalance=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auToken.callStatic.borrowBalanceCurrent(t);case 2:return e.abrupt("return",new ge(this.underlying,e.sent.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getUserDepositBalance=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auToken.callStatic.balanceOfUnderlying(t);case 2:return e.abrupt("return",new ge(this.underlying,e.sent.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getDepositNEARRewardPerWeek=function(){var e=new ve(C.tokens.WNEAR,oe(C.tokens.WNEAR)),t=ne();if(t<=1651845600&&t>1650636e3){var r,n=null!=(r=B[this.underlying.address.toLocaleLowerCase()])?r:"0";return new ge(e,n,!1)}return new ge(e,"0")},a.getBorrowNEARRewardPerWeek=function(){var e=new ve(C.tokens.WNEAR,oe(C.tokens.WNEAR)),t=ne();if(t<=1651845600&&t>1650636e3){var r,n=null!=(r=_[this.underlying.address.toLocaleLowerCase()])?r:"0";return new ge(e,n,!1)}return new ge(e,"0")},n}(Y),yt=function(e){function n(t,n,a){var o;return(o=e.call(this,t,n,a)||this)._EthRepayHelper=new r.Contract(C.misc.ETHREPAYHELPER,h.abi,t.provider),o}F(n,e);var a=n.prototype;return a.deposit=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!re(t.token.address,L)){e.next=4;break}return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).mint({value:t.rawAmount()}));case 4:return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).mint(t.rawAmount()));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.borrow=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).borrow(t.rawAmount()));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.withdraw=function(){var e=U(K.mark((function e(r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!new t(r.rawAmount()).lt(0)){e.next=2;break}return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).redeemUnderlying(S));case 2:return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).redeemUnderlying(r.rawAmount()));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.repay=function(){var e=U(K.mark((function e(r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!re(r.token.address,L)){e.next=4;break}return e.abrupt("return",this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({value:r.rawAmount()}));case 4:if(!new t(r.rawAmount()).lt(0)){e.next=8;break}return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).repayBorrow(S));case 8:return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).repayBorrow(r.rawAmount()));case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.enableCollateral=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.disableCollateral=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n}(vt),bt=function(e){function t(t,r){var n;return(n=e.call(this)||this).address=ae(t),n.underlying=ae(r),n}F(t,e);var r=t.prototype;return r.read=function(e){return new vt(e,this.address,this.underlying)},r.readWrite=function(e){return new yt(e,this.address,this.underlying)},t}(H),gt=function(e){function t(t){var n;return(n=e.call(this,t)||this).multicall=new r.Contract(C.misc.MULTICALL,y.abi,t.provider),n}return F(t,e),t.prototype.aggregate=function(){var e=U(K.mark((function e(t){var n,a,o,i,u,s,c,p;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=[],a=0;case 2:if(!(a<t.length)){e.next=11;break}return i=t[a],e.next=6,(o=i.contract.populateTransaction)[i.method].apply(o,i.args);case 6:n.push({target:(u=e.sent).to,callData:u.data});case 8:a++,e.next=2;break;case 11:return e.next=13,this.multicall.callStatic.aggregate(n);case 13:for(s=e.sent,c=[],p=0;p<t.length;p++)c.push(r.ethers.utils.defaultAbiCoder.decode(t[p].returnTypes,s.returnData[p]));return e.abrupt("return",c);case 17:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(Y),kt=r.BigNumber.from(1e4),xt=function(e){function n(t){var r;(r=e.call(this,t)||this).env=new G(t);var n=C.tokens.PLY,a=C.tokens.PULP;return r.plyToken=new ve(n,oe(n)),r.pulpToken=new ve(a,oe(a)),r}F(n,e);var a=n.prototype;return a.getPlyBalance=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.ply.balanceOf(t);case 2:return e.abrupt("return",new ge(this.plyToken,e.sent.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getPulpBalance=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.pulp.balanceOf(t);case 2:return e.abrupt("return",new ge(this.pulpToken,e.sent.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getUnclaimedPlyReward=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriLens.callStatic.claimRewards(this.env.comptroller.address,this.env.auriFairLaunch.address,T,{from:t});case 2:return e.abrupt("return",new ge(this.plyToken,e.sent.plyAccrured.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getWeek=function(e){return r.BigNumber.from(e-1651759200).div(604800).toNumber()},a.getLockingDetails=function(){var e=U(K.mark((function e(n){var a,o,i,u,s,c,p,f,l,d,h,w,m;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.getWeek(ne()),(o=[]).push(this.env.auriLens.getPercentLock(this.env.pulp.address,n,a)),o.push(this.env.auriLens.getPercentLock(this.env.pulp.address,n,a+1)),o.push(this.getUnclaimedPlyReward(n)),e.next=7,Promise.all(o);case 7:return u=r.BigNumber.from((i=e.sent)[0]),s=r.BigNumber.from(i[1]),c=i[2],e.next=13,this.env.pulp.calcLockAmount(n,c.rawAmount());case 13:return f=(p=e.sent)[0],l=p[1],d=s.mul(c.rawAmount()).div(kt),h=r.BigNumber.from(c.rawAmount()).sub(d),w=kt.sub(u).toString(),m=kt.sub(s).toString(),e.abrupt("return",{vestingStart:1651759200,currentUnlockPortion:new t(w).dividedBy(100).toNumber(),accruedPly:c,currentPly:new ge(this.plyToken,l.toString()),currentPulp:new ge(this.pulpToken,f.toString()),nextUnlockPortion:new t(m).dividedBy(100).toNumber(),nextPly:new ge(this.plyToken,d.toString()),nextPulp:new ge(this.pulpToken,h.toString())});case 21:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getTimestampToUnlock=function(){var e=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriLens.getWeekToUnlock(this.env.pulp.address,t,100*r);case 2:return e.abrupt("return",1651759200+604800*e.sent.toNumber());case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),a.getNextWeekTimestamp=function(){return 1651759200+604800*(this.getWeek(ne())+1)},a.getUnlockPortionAt=function(){var e=U(K.mark((function e(t,r){var n;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriLens.getPercentLock(this.env.pulp.address,t,this.getWeek(r));case 2:return n=kt.sub(e.sent),e.abrupt("return",n.toNumber()/100);case 5:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),n}(Y),At=function(e){function t(t){return e.call(this,t)||this}F(t,e);var r=t.prototype;return r.redeem=function(){var e=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.pulp.connect(this._networkConnection.signer).redeem(t,r.rawAmount()));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.selfRedeem=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._networkConnection.signer.getAddress();case 2:return e.abrupt("return",this.redeem(e.sent,t));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(xt),Lt=function(e){function t(){return e.call(this)||this}F(t,e);var r=t.prototype;return r.read=function(e){return new xt(e)},r.readWrite=function(e){return new At(e)},t}(H),Ct=function(e){function t(t){var r;return(r=e.call(this,t)||this).env=new G(t),r}F(t,e);var n=t.prototype;return n.getPLYWNEARPoolDetails=function(){var e=U(K.mark((function e(){var t,r,n,a,o,i,u,s,c;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriFairLaunch.getPoolInfo(0).then((function(e){t=e.totalStake,r=e.rewardPerSeconds}));case 2:return n=new ge(be,t.toString()),e.next=5,ot(n,this._networkConnection.provider);case 5:for(a=e.sent,o=[],i=0;i<r.length;i++)s=new ve(u=P[i],oe(u)),o.push(ot(new ge(s,r[i].toString()),this._networkConnection.provider));return c=[],e.next=11,Promise.all(o);case 11:return e.sent.forEach((function(e,t){var r=P[t],n=ue(e,a,31536e3).toFixed(10);c.push({address:r,apy:n})})),e.abrupt("return",{totalStakedLiquidity:n,APYs:c});case 13:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.stakeBalanceOf=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriFairLaunch.getUserInfo(0,t);case 2:return e.abrupt("return",new ge(be,e.sent.amount.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.LpBalanceOf=function(){var e=U(K.mark((function e(t){var n;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new r.Contract(C.tokens.PLYWNEAR,w.abi,this._networkConnection.provider),e.next=3,n.balanceOf(t);case 3:return e.abrupt("return",new ge(be,e.sent.toString()));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.unclaimedRewardsOf=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriFairLaunch.callStatic.updateAndGetUserInfo(0,t,{from:t});case 2:return e.abrupt("return",e.sent.unclaimedRewards.map((function(e,t){return ge.fromAddressAndAmount(P[t],e.toString())})));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(Y),Et=function(e){function t(){return e.apply(this,arguments)||this}F(t,e);var n=t.prototype;return n.stake=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.auriFairLaunch.connect(this._networkConnection.signer).deposit(0,t.rawAmount()));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.unstake=function(){var e=U(K.mark((function e(t){var n,a,o,i;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._networkConnection.signer.getAddress();case 2:return n=e.sent,a=r.BigNumber.from(t.rawAmount()),e.t0=r.BigNumber,e.next=7,this.stakeBalanceOf(n);case 7:return e.t1=e.sent.rawAmount(),o=e.t0.from.call(e.t0,e.t1),i=a.lt(o)?a:o.sub(1),e.abrupt("return",this.env.auriFairLaunch.connect(this._networkConnection.signer).withdraw(0,i));case 11:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(Ct),Rt=function(e){function t(){return e.call(this)||this}F(t,e);var r=t.prototype;return r.read=function(e){return new Ct(e)},r.readWrite=function(e){return new Et(e)},t}(H),Pt=function(e){function n(t){var r;return(r=e.call(this,t)||this).stakingRead=new Ct(t),r.env=new G(t),r}F(n,e);var a=n.prototype;return a.getUserDetails=function(){var e=U(K.mark((function e(r){var n,a,o,i,u,s,c,p,f,l,d,h,w,m,v,y,b,g,k,x,A,L=this;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=C.auTokens.length,a=[],i=[],u=new t(0),s=[],c=function(){var e=f.value,t={};a.push(t),t.market=e.underlying;var n=new vt(L._networkConnection,e.address,e.underlying);i.push(n.getUserDepositBalance(r).then((function(e){t.depositBalance=e}))),i.push(n.getUserBorrowBalance(r).then((function(e){t.borrowBalance=e}))),i.push(n.getCollateralRatio().then((function(e){t.collateralRatio=e.toNumber()}))),s.push(Je(n.underlying.address,L._networkConnection.provider).then((function(e){return t.underlyingPrice=e.toString(),e})))},p=W(C.auTokens);!(f=p()).done;)c();return i.push(this.env.comptroller.getAssetsIn(r).then((function(e){o=e}))),e.next=10,Promise.all(i);case 10:return e.next=12,Promise.all(s);case 12:for(l=e.sent,d=[],h=function(){var e=C.auTokens[w];a[w].isCollateral=void 0!==o.find((function(t){return re(e.address,t)})),d.push(ut(a[w].depositBalance,l[w]))},w=0;w<n;w++)h();return u=d.reduce((function(e,t,r){return a[r].isCollateral?e.plus(t.multipliedBy(a[r].collateralRatio)):e}),new t(0)),e.next=19,this.env.comptroller.getAccountLiquidity(r);case 19:for((m=u.minus(new t(e.sent[0].toString()).div(te(18)))).lt("0.00001")&&(m=new t(0)),v=u.multipliedBy(R),y=m.div(R),b=v.lte(m)?new t(0):v.minus(m),w=0;w<n;w++)k=new vt(this._networkConnection,(g=C.auTokens[w]).address,g.underlying),x=u.minus(y).gt(0)?u.minus(y):new t(0),A=x.div(a[w].collateralRatio).div(l[w]),a[w].maxWithdrawableAmount=a[w].isCollateral&&A.lt(a[w].depositBalance.formattedAmount())?new ge(k.underlying,A.toFixed(24),!1):new ge(k.underlying,a[w].depositBalance.rawAmount());return e.t0=a,e.t1={currency:"USD",amount:v.toFixed(10)},e.next=30,new xt(this._networkConnection).getLockingDetails(r);case 30:return e.t2=e.sent,e.t3={currency:"USD",amount:b.toFixed(10)},e.abrupt("return",{markets:e.t0,borrowLimit:e.t1,userLockingDetails:e.t2,borrowableAmount:e.t3});case 33:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getTokenPrice=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Je(t.address,this._networkConnection.provider);case 2:return e.abrupt("return",{currency:"USD",amount:e.sent.toFixed(10)});case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.calcHypotheticalStats=function(e){var r=e.userMarketDetail,n=e.currentBorrowValuation,a=e.action,o=e.tokenAmount,i=new t(e.currentBorrowLimit.amount),u=new t(n.amount);switch(a){case exports.MarketAction.EnableCollateral:case exports.MarketAction.DisableCollateral:var s=ut(r.depositBalance,new t(r.underlyingPrice)).multipliedBy(r.collateralRatio).multipliedBy(R);i=a==exports.MarketAction.EnableCollateral?i.plus(s):i.minus(s);break;case exports.MarketAction.Deposit:case exports.MarketAction.Withdraw:s=ut(o,new t(r.underlyingPrice)).multipliedBy(r.collateralRatio).multipliedBy(R),i=a==exports.MarketAction.Deposit?i.plus(s):i.minus(s);break;case exports.MarketAction.Borrow:case exports.MarketAction.Repay:var c=ut(o,new t(r.underlyingPrice));u=a==exports.MarketAction.Borrow?u.plus(c):u.minus(c)}return{newBorrowLimit:{amount:i.toFixed(10),currency:"USD"},newBorrowUtilization:i.eq(0)?u.eq(0)?0:9999.99:u.div(i).toNumber()}},a.getPlyCirculatingSupply=function(){var e=U(K.mark((function e(){var t,n,a,o;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new gt(this._networkConnection),n={contract:this.env.ply,method:"balanceOf",returnTypes:["uint256"]},e.next=4,t.aggregate([I({},n,{method:"totalSupply",args:[]}),I({},n,{args:[C.misc.TEAM_MULTISIG]}),I({},n,{args:[C.misc.COMPTROLLER]}),I({},n,{args:[C.misc.AURIFAIRLAUNCH]}),I({},n,{args:[C.misc.PLY_TOKEN_LOCK]})]);case 4:return a=e.sent,o=r.BigNumber.from(0),a.forEach((function(e,t){o=0===t?e[0]:o.sub(e[0])})),e.abrupt("return",new ge(ye,o.toString()));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getUtilisation=function(){var e=U(K.mark((function e(r){var n,a,o;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriInternalLens.getAccountLiquidity(r);case 2:return a=new t((n=e.sent).sumBorrowPlusEffects.toString()),o=new t(n.sumCollateral.toString()),e.abrupt("return",a.dividedBy(o));case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.sneakAccounts=function(){var e=U(K.mark((function e(n,a){var o,i,u,s,c,p,d,h,w,m,v,y,b,g,k,x,A,L=this;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.BigNumber.from(10).pow(18),i=new t(.1),u=this.env.getContract(C.misc.oracle,f.abi),s=a.map((function(e){return L.env.getContract(e,l.abi)})),e.next=6,u.getUnderlyingPrices(a);case 6:return c=e.sent,e.next=9,this.env.auriInternalLens.callStatic.getExchangeRates(a);case 9:p=e.sent,d=[],h=W(n);case 12:if((w=h()).done){e.next=33;break}m=w.value,v=[],y=0;case 16:if(!(y<s.length)){e.next=30;break}return e.next=19,s[y].getAccountSnapshot(m);case 19:if(g=(b=e.sent)[0].mul(p[y]).div(o).mul(c[y]).div(o),k=b[1].mul(c[y]).div(o),x=new t(g.toString()).dividedBy(o.toString()),A=new t(k.toString()).dividedBy(o.toString()),!x.lt(i)&&!A.lt(i)){e.next=26;break}return e.abrupt("continue",27);case 26:v.push({token:ie(a[y]),deposit:x,borrow:A});case 27:++y,e.next=16;break;case 30:d.push({address:m,tokens:v});case 31:e.next=12;break;case 33:return e.abrupt("return",d);case 34:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),n}(Y),Tt=function(e){function t(t){var n;return(n=e.call(this,t)||this).referral=new r.Contract(C.misc.REFERRAL,g.abi,t.provider),n}F(t,e);var n=t.prototype;return n.generateReferralCode=function(){for(var e="abcdefghijklmnopqrstuvwxyz",t=e+e.toUpperCase()+"1234567890",r="",n=0;n<10;n++)r+=t[Math.floor(Math.random()*t.length)];return r},n.getUserReferralCode=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.referral.userReferralCode(t);case 2:return e.abrupt("return",r.ethers.utils.parseBytes32String(e.sent));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getReferralCodeUsed=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.referral.referralCodeUsed(t);case 2:return e.abrupt("return",r.ethers.utils.parseBytes32String(e.sent));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getReferralCodeOwner=function(){var e=U(K.mark((function e(t){var n;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.ethers.utils.formatBytes32String(t),e.abrupt("return",this.referral.referralCodeOwner(n));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getReferralsList=function(){var e=U(K.mark((function e(t){var r,n,a,o;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Be("/referral/list",{address:t});case 2:return n=(r=e.sent).items.map((function(e){return e.blockNumber})),e.next=6,le(this._networkConnection.provider,n);case 6:return a=e.sent,o=r.items.map((function(e,t){return{user:e.user,timestamp:a[t]}})),e.abrupt("return",o);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(Y),St=function(e){function t(){return e.apply(this,arguments)||this}F(t,e);var n=t.prototype;return n.registerNewReferralCode=function(){var e=U(K.mark((function e(){var t;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.ethers.utils.formatBytes32String(this.generateReferralCode()),e.abrupt("return",this.referral.connect(this._networkConnection.signer).registerNewUserReferralCode(t));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.useReferralCode=function(){var e=U(K.mark((function e(t){var n;return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.ethers.utils.formatBytes32String(t),e.abrupt("return",this.referral.connect(this._networkConnection.signer).registerReferralCodeUsed(n));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(Tt),Bt=function(e){function t(){return e.call(this)||this}F(t,e);var r=t.prototype;return r.read=function(e){return new Tt(e)},r.readWrite=function(e){return new St(e)},t}(H),_t=function(e){function t(t){var r;return(r=e.call(this,t)||this).env=new G(t),r._stakingRead=new Ct(t),r._misc=new Pt(t),r}F(t,e);var r=t.prototype;return r.getUserDetails=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.getUserDetails(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.getPLYWNEARPoolDetails=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._stakingRead.getPLYWNEARPoolDetails());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getTokenPrice=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.getTokenPrice(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.stakeBalanceOf=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._stakingRead.stakeBalanceOf(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.LpBalanceOf=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._stakingRead.LpBalanceOf(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.unclaimedRewardsOf=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._stakingRead.unclaimedRewardsOf(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.calcHypotheticalStats=function(e){return this._misc.calcHypotheticalStats({userMarketDetail:e.userMarketDetail,currentBorrowLimit:e.currentBorrowLimit,currentBorrowValuation:e.currentBorrowValuation,action:e.action,tokenAmount:e.tokenAmount})},r.getPlyCirculatingSupply=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.getPlyCirculatingSupply());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getUtilisation=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.getUtilisation(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.sneakAccounts=function(){var e=U(K.mark((function e(t,r){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.sneakAccounts(t,r));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t}(Y),Nt=function(e){function t(){return e.apply(this,arguments)||this}F(t,e);var r=t.prototype;return r.claim=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this.env.comptroller.connect(this._networkConnection.signer),e.next=3,this._networkConnection.signer.getAddress();case 3:return e.t1=e.sent,e.abrupt("return",e.t0["claimReward(uint8,address)"].call(e.t0,0,e.t1));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.claimLpRewards=function(){var e=U(K.mark((function e(){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this.env.auriFairLaunch.connect(this._networkConnection.signer),e.next=3,this._networkConnection.signer.getAddress();case 3:return e.t1=e.sent,e.t2=S,e.abrupt("return",e.t0.harvest.call(e.t0,e.t1,0,e.t2));case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.stake=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Et(this._networkConnection).stake(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.unstake=function(){var e=U(K.mark((function e(t){return K.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Et(this._networkConnection).unstake(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(_t),Dt=function(e){function t(){return e.call(this)||this}F(t,e);var r=t.prototype;return r.read=function(e){return new _t(e)},r.readWrite=function(e){return new Nt(e)},t}(H);r.ethers.utils.Logger.setLogLevel(n.Logger.levels.ERROR),t.config({DECIMAL_PLACES:50}),exports.MAINNET_ADDRESSES=a,exports.TESTNET_ADDRESSES=o,exports.AIRDROP_END_TIMESTAMP=1651068e3,exports.AIRDROP_KEEP_THRESHOLD=604800,exports.AIRDROP_START_TIMESTAMP=1649858400,exports.ALL_STAKING_POOLS=T,exports.AURORA_CHAINID=1313161554,exports.Airdrop=mt,exports.AirdropRead=ht,exports.AirdropReadWrite=wt,exports.AuriEnv=G,exports.BORROW_LIMIT_BUFFER=R,exports.BORROW_NEAR_REWARDS_PER_WEEK=_,exports.BlockchainEntity=H,exports.BlockchainEntityRead=Y,exports.BlockchainEntityReadWrite=q,exports.DECIMAL_PRECISION=10,exports.DEPOSIT_NEAR_REWARDS_PER_WEEK=B,exports.ETHAddress=L,exports.HARDCODE_PRICE_TOKENS=N,exports.INF=S,exports.MiscRead=Pt,exports.MoneyMarket=bt,exports.MoneyMarketRead=vt,exports.MoneyMarketReadWrite=yt,exports.ONE_DAY=86400,exports.ONE_WEEK=604800,exports.ONE_YEAR=31536e3,exports.PLYToken=ye,exports.PLYWNEARToken=be,exports.PLYWNEAR_POOL_ID=0,exports.PLYWNEAR_REWARD_TOKENS=P,exports.PRICE_WHITELISTED=E,exports.Papermill=Lt,exports.PapermillRead=xt,exports.PapermillReadWrite=At,exports.REWARD_CLAIM_START=1651759200,exports.Referral=Bt,exports.ReferralRead=Tt,exports.ReferralReadWrite=St,exports.SDK=Dt,exports.SdkRead=_t,exports.SdkReadWrite=Nt,exports.Staking=Rt,exports.StakingRead=Ct,exports.StakingReadWrite=Et,exports.Token=ve,exports.TokenAmount=ge,exports.TransferEventQuery=lt,exports.assert=X,exports.calcLMRewardApr=ue,exports.calcValuation=ut,exports.decimalFactor=te,exports.decimalRecords=D,exports.devLog=me,exports.dummyAddress="0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE",exports.dummyMarketAddress="0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f",exports.dummyPly=xe,exports.dummyPlyAurora=Ae,exports.dummyToken=ke,exports.dummyTokenAmount=Le,exports.dummyTokenAmount2=Ee,exports.dummyTokenAmount3=Re,exports.dummyUserMarketDetails=Pe,exports.dummyZeroTokenAmount=Ce,exports.fetchLPPositions=Ie,exports.fetchLPPrice=Me,exports.fetchPLYPrice=Xe,exports.fetchPULPPrice=tt,exports.fetchPrice=Je,exports.fetchPriceFromCoingecko=Oe,exports.fetchPriceFromCoingeckoAPI=Ne,exports.fetchPriceFromOracle=Ye,exports.fetchStNEARPrice=Ke,exports.fetchToken0PriceByLP=nt,exports.fetchUnderlyingTokensPrices=He,exports.fetchValuation=ot,exports.formatObject=ee,exports.getApi=Te,exports.getBlockBeforeTimestamp=he,exports.getBlockTimestamp=se,exports.getBlocksTimestamp=le,exports.getBlocksTimestampViaRPC=pe,exports.getCurrentTimestamp=ne,exports.getDecimal=oe,exports.getPaginatedApi=Be,exports.getQuery=Q,exports.getSymbol=ie,exports.isSameAddress=re,exports.networkAddresses=C,exports.queryGraphQL=J,exports.symbolRecords=V,exports.validateAndParseAddress=ae,exports.valuateToken=st;
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("bignumber.js")),r=require("ethers"),n=require("ethers/lib/utils"),a=e(require("@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json")),o=e(require("@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json")),i=e(require("@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json")),u=e(require("@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json")),s=e(require("@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json")),c=e(require("@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json")),p=e(require("@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json")),f=e(require("@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json")),l=e(require("@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json")),d=e(require("@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json")),h=e(require("@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json")),w=e(require("@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json")),m=e(require("@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json")),v=e(require("@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json")),y=e(require("@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json")),g=e(require("@aurigami/contracts/deployments/aurora_mainnet.json")),b=e(require("@aurigami/contracts/deployments/aurora_testnet.json")),k=require("@ethersproject/abstract-signer"),x=e(require("axios")),A={__proto__:null,AuriOracleABI:c,AuTokenABI:p,IUniswapV2PairABI:w,AuriAirdropABI:i,AuriFairLaunchABI:u,AuriLensABI:s,ComptrollerABI:f,EIP20InterfaceABI:d,ReferralDirectoryABI:y,AuErc20ABI:a,AuETHABI:o,EthRepayHelperABI:l,Multicall2ABI:m,PulpABI:v,AuriInternalLensABI:h},L="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",C={auTokens:[{name:"auUSDC",address:g.auTokens.USDC.toLowerCase(),underlying:"0xb12bfca5a55806aaf64e99521918a4bf0fc40802".toLowerCase()},{name:"auETH",address:g.auTokens.ETH.toLowerCase(),underlying:L.toLowerCase()},{name:"auWBTC",address:g.auTokens.WBTC.toLowerCase(),underlying:"0xf4eb217ba2454613b15dbdea6e5f22276410e89e".toLowerCase()},{name:"auUSDT",address:g.auTokens.USDT.toLowerCase(),underlying:"0x4988a896b1227218e4a686fde5eabdcabd91571f".toLowerCase()},{name:"auDAI",address:g.auTokens.DAI.toLowerCase(),underlying:"0xe3520349f477a5f6eb06107066048508498a291b".toLowerCase()},{name:"auWNEAR",address:g.auTokens.WNEAR.toLowerCase(),underlying:"0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d".toLowerCase()},{name:"auSTNEAR",address:g.auTokens.STNEAR.toLowerCase(),underlying:"0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30".toLowerCase()},{name:"auAURORA",address:g.auTokens.AURORA.toLowerCase(),underlying:"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase()},{name:"auTRI",address:g.auTokens.TRI.toLowerCase(),underlying:"0xFa94348467f64D5A457F75F8bc40495D33c65aBB".toLowerCase()},{name:"auPLY",address:g.auTokens.PLY.toLowerCase(),underlying:"0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f".toLowerCase()},{name:"auUSN",address:g.auTokens.USN.toLowerCase(),underlying:"0x5183e1b1091804bc2602586919e6880ac1cf2896".toLowerCase()}],misc:{COMPTROLLER:g.comptroller.toLowerCase(),oracle:g.oracle.toLowerCase(),AURIFAIRLAUNCH:g.fairLaunch.toLowerCase(),AURILENS:g.auriLens.toLowerCase(),ETHREPAYHELPER:g.ethRepayHelper.toLowerCase(),AURI_AIRDROP:g.auriAirdrop.toLowerCase(),MULTICALL:g.multicall.toLowerCase(),TEAM_MULTISIG:"0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE".toLowerCase(),PLY_TOKEN_LOCK:g.plyTokenLock.toLowerCase(),REFERRAL:g.referralDirectory.toLowerCase(),AURI_INTERNAL_LENS:g.auriInternalLens.toLowerCase()},tokens:{AURORA:"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),PLY:"0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f".toLowerCase(),stNEAR:"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30".toLowerCase(),USDC:"0xb12bfca5a55806aaf64e99521918a4bf0fc40802".toLowerCase(),WNEAR:"0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d".toLowerCase(),TRI:"0xFa94348467f64D5A457F75F8bc40495D33c65aBB".toLowerCase(),META:"0xc21ff01229e982d7c8b8691163b0a3cb8f357453".toLowerCase(),PULP:g.PULP.toLowerCase(),PLYWNEAR:g.ply_wnear_lp.toLowerCase(),USN:"0x5183e1b1091804bc2602586919e6880ac1cf2896".toLowerCase()}},E=[g.auTokens.STNEAR.toLowerCase(),g.auTokens.AURORA.toLowerCase(),g.auTokens.TRI.toLowerCase(),g.auTokens.PLY.toLowerCase(),g.auTokens.USN.toLowerCase()],R=new Set([].concat(C.auTokens.map((function(e){return e.underlying})),[C.tokens.AURORA,C.tokens.TRI,C.tokens.META,C.tokens.stNEAR])),P=new t(1),T=["0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f","0x04Ac48711BCdc45b4d223fb021E09DA73c71095e","0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d","0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30","0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79","0xFa94348467f64D5A457F75F8bc40495D33c65aBB"],B=[0],S=r.BigNumber.from(2).pow(256).sub(1),_=Object.fromEntries(Object.entries({"0xb12bfca5a55806aaf64e99521918a4bf0fc40802":"36375","0x4988a896b1227218e4a686fde5eabdcabd91571f":"14550","0xf4eb217ba2454613b15dbdea6e5f22276410e89e":"3638","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE":"14550","0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d":"3638"}).map((function(e){var t=e[1];return[e[0].toLowerCase(),t]}))),N={},D=Object.fromEntries([[C.tokens.USN.toLowerCase(),"1"]]),I={"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":18,"0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f":18,"0x3195949f267702723bc614cae037cdc8d1e94786":8,"0xfa94348467f64d5a457f75f8bc40495d33c65abb":18,"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30":24,"0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d":24,"0x6ea6c03061bddce23d4ec60b6e6e880c33d24dca":8,"0xca9511b610ba5fc7e311fdef9ce16050ee4449e9":8,"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79":18,"0xcfb6b0498cb7555e7e21502e0f449bf28760adbb":8,"0x4f0d864b1abf4b701799a0b30b57a22dfeb5917b":8,"0xad5a2437ff55ed7a8cad3b797b3ec7c5a19b1c54":8,"0x4988a896b1227218e4a686fde5eabdcabd91571f":6,"0xb12bfca5a55806aaf64e99521918a4bf0fc40802":6,"0xe3520349f477a5f6eb06107066048508498a291b":18,"0x8888682e24dd4df7b7ff2b91fccb575737e433bf":8,"0xae4fac24dcdae0132c6d04f564dcf059616e9423":8,"0xce4166363e3a584dac84a47bcd3414b43efcdd1c":8,"0xf4eb217ba2454613b15dbdea6e5f22276410e89e":8,"0xc21ff01229e982d7c8b8691163b0a3cb8f357453":24,"0x04ac48711bcdc45b4d223fb021e09da73c71095e":18,"0x044b6b0cd3bb13d2b9057781df4459c66781dce7":18,"0x5183e1b1091804bc2602586919e6880ac1cf2896":18};function U(e,t,r,n,a,o,i){try{var u=e[o](i),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,a)}function O(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){U(o,n,a,i,u,"next",e)}function u(e){U(o,n,a,i,u,"throw",e)}i(void 0)}))}}function F(){return(F=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function M(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function W(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function j(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return W(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?W(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var Y,q=function(e){this._networkConnection=e},H=function(e){function t(t){if(!(t.signer instanceof k.Signer))throw Error("Signer is not provided when constructing BlockchainEntityReadWrite");return e.call(this,t)||this}return M(t,e),t}(q),G=function(){function e(){}var t=e.prototype;return t.read=function(e){return new q(e)},t.readWrite=function(e){return new H(e)},e}(),K=function(e){function t(t){var r;return(r=e.call(this,t)||this).comptroller=r.getContract(C.misc.COMPTROLLER,f.abi),r.auriFairLaunch=r.getContract(C.misc.AURIFAIRLAUNCH,u.abi),r.auriLens=r.getContract(C.misc.AURILENS,s.abi),r.ply=r.getContract(C.tokens.PLY,d.abi),r.pulp=r.getContract(C.tokens.PULP,v.abi),r.auriInternalLens=r.getContract(C.misc.AURI_INTERNAL_LENS,h.abi),r}M(t,e);var n=t.prototype;return n.getContract=function(e,t){return new r.Contract(e,t,this._networkConnection.provider)},n.getAuTokenContracts=function(){var e=this;return C.auTokens.map((function(t){var r=e.getContract(t.address,p.abi);return r.underlying=t.underlying,r}))},t}(q),V=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var a=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return{value:void 0,done:!0}}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var u=b(i,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(e,t,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)}}}(e,r,o),a}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var p={};function f(){}function l(){}function d(){}var h={};u(h,a,(function(){return this}));var w=Object.getPrototypeOf,m=w&&w(w(L([])));m&&m!==t&&r.call(m,a)&&(h=m);var v=d.prototype=f.prototype=Object.create(h);function y(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var n;this._invoke=function(a,o){function i(){return new t((function(n,i){!function n(a,o,i,u){var s=c(e[a],e,o);if("throw"!==s.type){var p=s.arg,f=p.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,i,u)}),(function(e){n("throw",e,i,u)})):t.resolve(f).then((function(e){p.value=e,i(p)}),(function(e){return n("throw",e,i,u)}))}u(s.arg)}(a,o,n,i)}))}return n=n?n.then(i,i):i()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,p;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function L(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return l.prototype=d,u(v,"constructor",d),u(d,"constructor",l),l.displayName=u(d,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,u(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},y(g.prototype),u(g.prototype,o,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new g(s(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},y(v),u(v,i,"Generator"),u(v,a,(function(){return this})),u(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=L,A.prototype={constructor:A,reset:function(e){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),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=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(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;x(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:L(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(Y={exports:{}}),Y.exports),Q=Object.fromEntries(C.auTokens.map((function(e){return[e.address.toLowerCase(),e.name]})).concat(C.auTokens.map((function(e){return[e.underlying.toLowerCase(),e.name.slice(2)]}))));function Z(e,t,r){return z.apply(this,arguments)}function z(){return(z=O(V.mark((function e(t,r,n){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n={}),n=F({},n,{module:t,action:r}),e.next=4,x.get("https://api.aurorascan.dev/api?"+new URLSearchParams(n),{headers:{"Content-Type":"application/json"}});case 4:return e.abrupt("return",e.sent.data.result);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var J="https://explorer.mainnet.aurora.dev/graphiql";function $(e){return X.apply(this,arguments)}function X(){return(X=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,x.post(J,{query:t});case 2:return e.abrupt("return",e.sent.data.data);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ee(e,t){if(void 0===t&&(t=""),!e)throw t="Assertion failed"+(t?": "+t:""),new Error(t)}function te(e){return JSON.stringify(e,null," ")}function re(e){return r.BigNumber.from(10).pow(e).toString()}var ne=function(e,t){return e.toLowerCase()==t.toLowerCase()},ae=function(){return Math.trunc(Date.now()/1e3)};function oe(e){try{return r.utils.getAddress(e)}catch(t){throw new Error("Invalid address: "+e)}}function ie(e){var t=e.toLowerCase();return ee(null!=I[t],"Decimal not found for "+e),I[t]}function ue(e){var t=e.toLowerCase();return ee(null!=Q[t],"Symbol not found for "+e),Q[t]}function se(e){var t=e.toLowerCase(),r=C.auTokens.filter((function(e){return e.address==t}));if(0==r.length)throw new Error("Underlying not found for "+e);return r[0].underlying}function ce(e,r,n){return e.isZero()?new t(0):r.lte(0)?e:e.multipliedBy(n).dividedBy(r)}function pe(e,t){return fe.apply(this,arguments)}function fe(){return(fe=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getBlock(r);case 2:return e.abrupt("return",e.sent.timestamp);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function le(e,t){return de.apply(this,arguments)}function de(){return(de=O(V.mark((function e(t,r){var n,a,o,i,u;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=200,a=[],o=0;case 3:if(!(o<r.length)){e.next=14;break}return i=r.slice(o,o+n),u=i.map(function(){var e=O(V.mark((function e(r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",pe(t,r));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.t0=a,e.next=9,Promise.all(u);case 9:e.t1=e.sent,a=e.t0.concat.call(e.t0,e.t1);case 11:o+=n,e.next=3;break;case 14:return e.abrupt("return",a);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e,t){return we.apply(this,arguments)}function we(){return(we=O(V.mark((function e(t,r){var n,a,o,i,u,s;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=r.map((function(e){return"b"+e+": block(number: "+e+") { timestamp }"})),o=0;o<a.length;o+=100)i="{ "+a.slice(o,o+100).join("\n")+" }",n.push($(i));return e.next=6,Promise.all(n);case 6:return u=e.sent.reduce((function(e,t){return F({},e,t)})),(s=r.filter((function(e){return!u["b"+e]}))).length>0&&s.join(", "),e.next=11,le(t,s);case 11:return e.sent.forEach((function(e,t){u["b"+s[t]]={timestamp:new Date(1e3*e).toISOString()}})),e.abrupt("return",r.map((function(e){return Math.trunc(new Date(u["b"+e].timestamp).getTime()/1e3)})));case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function me(e,t){return ve.apply(this,arguments)}function ve(){return(ve=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Z("block","getblocknobytime",{timestamp:r,closest:"before"});case 2:if(e.t0=parseInt(e.sent),e.t0){e.next=8;break}return e.next=7,t.getBlockNumber();case 7:e.t0=e.sent;case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(e){}var ge=function(e,t){this.address=e.toLowerCase(),this.decimals=t},be=new ge(C.tokens.PLY,ie(C.tokens.PLY)),ke=new ge(C.tokens.PLYWNEAR,ie(C.tokens.PLYWNEAR)),xe=function(){function e(e,r,n){void 0===n&&(n=!0),this.rawAmnt=n?r:new t(r).times(re(e.decimals)).toFixed(0),this.token=e}var r=e.prototype;return r.formattedAmount=function(){return new t(this.rawAmnt).div(re(this.token.decimals)).toString()},r.formattedAmountWithSymbol=function(){return this.formattedAmount()+" "+ue(this.token.address)},r.rawAmount=function(){return this.rawAmnt},e.fromAddressAndAmount=function(t,r,n){return void 0===n&&(n=!0),new e(new ge(t,ie(t)),r,n)},e}(),Ae=new ge("0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",6),Le=new ge("0x8729438eb15e2c8b576fcc6aecda6a148776c0f5",18),Ce=new ge("0xE530dC2095Ef5653205CF5ea79F8979a7028065c",18),Ee=new xe(Ae,"123.456",!1),Re=new xe(Ae,"0"),Pe=new xe(Ae,"456.123",!1),Te=new xe(Ae,"1000.123",!1),Be={market:"0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f",depositBalance:Pe,borrowBalance:Re,isCollateral:!0,maxWithdrawableAmount:Ee,collateralRatio:.5,underlyingPrice:"1"};function Se(e,t){return _e.apply(this,arguments)}function _e(){return(_e=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),e.next=3,x.get("https://api.aurigami.finance/app/"+t+"?"+new URLSearchParams(r),{headers:{"Content-Type":"application/json"}});case 3:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ne(e,t,r,n){return De.apply(this,arguments)}function De(){return(De=O(V.mark((function e(t,r,n,a){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),void 0===n&&(n=1),void 0===a&&(a=50),r=F({},r,{page:n,limit:a}),e.next=6,x.get("https://api.aurigami.finance/app/"+t+"?"+new URLSearchParams(r),{headers:{"Content-Type":"application/json"}});case 6:return e.abrupt("return",e.sent.data);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ie(e){return Ue.apply(this,arguments)}function Ue(){return(Ue=O(V.mark((function e(r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,x.get("https://api.coingecko.com/api/v3/simple/price?ids="+r+"&vs_currencies=usd").then((function(e){return e.data}));case 2:return e.abrupt("return",new t(e.sent[r].usd));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Oe(e){return Fe.apply(this,arguments)}function Fe(){return(Fe=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.toLowerCase(),e.next=e.t0===C.tokens.AURORA?3:e.t0===C.tokens.TRI?4:e.t0===C.tokens.META?5:6;break;case 3:return e.abrupt("return",Ie("aurora-near"));case 4:return e.abrupt("return",Ie("trisolaris"));case 5:return e.abrupt("return",Ie("meta-pool"));case 6:throw Error("Unknown token "+t+" in fetchPriceFromCoingecko");case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Me(e,t){return We.apply(this,arguments)}function We(){return(We=O(V.mark((function e(t,n){var a,o,i;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new r.Contract(t,w.abi,n),(o=[]).push(a.token0()),o.push(a.token1()),o.push(a.getReserves()),o.push(a.totalSupply()),e.next=8,Promise.all(o);case 8:return e.abrupt("return",{token0:(i=e.sent)[0],token1:i[1],reserve0:i[2].reserve0,reserve1:i[2].reserve1,totalSupply:i[3]});case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function je(e,t){return Ye.apply(this,arguments)}function Ye(){return(Ye=O(V.mark((function e(r,n){var a,o,i,u;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=function(){return(u=O(V.mark((function e(r){var i,u,s;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.reserve.isZero()){e.next=2;break}return e.abrupt("return",new t(0));case 2:return e.next=4,Je(r.address,n);case 4:return i=e.sent,u=ie(r.address),s=i.multipliedBy(r.reserve.toString()).multipliedBy(2),e.abrupt("return",s.multipliedBy(re(o)).dividedBy(new t(a.totalSupply.toString())).dividedBy(re(u)));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)},i=function(e){return u.apply(this,arguments)},e.next=4,Me(r,n);case 4:return a=e.sent,o=ie(r),e.prev=6,e.next=9,i({address:a.token0,reserve:a.reserve0});case 9:return e.abrupt("return",e.sent);case 12:return e.prev=12,e.t0=e.catch(6),e.prev=15,e.next=18,i({address:a.token1,reserve:a.reserve1});case 18:return e.abrupt("return",e.sent);case 21:throw e.prev=21,e.t1=e.catch(15),Error("Unable to fetch price for both tokens of LP "+r);case 25:case"end":return e.stop()}}),e,null,[[6,12],[15,21]])})))).apply(this,arguments)}function qe(e,r){return new t(e.toString()).div(re(36-r))}function He(e,t,r){return Ge.apply(this,arguments)}function Ge(){return(Ge=O(V.mark((function e(t,n,a){var o;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new r.Contract(C.misc.oracle,c.abi,a),e.next=3,o.getUnderlyingPrice(t);case 3:return e.abrupt("return",qe(e.sent,n));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ke(e){return Ve.apply(this,arguments)}function Ve(){return(Ve=O(V.mark((function e(t){var n,a,o;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new r.Contract(C.misc.AURILENS,s.abi,t),a=C.auTokens.map((function(e){return e.address})),o=C.auTokens.map((function(e){return ie(e.underlying)})),e.next=5,n.auTokenUnderlyingPriceAll(a);case 5:return e.abrupt("return",e.sent.map((function(e,t){return{auToken:e.auToken,underlyingPrice:qe(e.underlyingPrice,o[t])}})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Qe(){return Ze.apply(this,arguments)}function Ze(){return(Ze=O(V.mark((function e(){var r,n,a,o,i;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=x.get("https://validators.narwallets.com/metrics_json").then((function(e){return e.data})),n=Ie("near"),e.next=4,Promise.all([r,n]);case 4:return o=(a=e.sent)[1],i=new t(a[0].st_near_price),e.abrupt("return",i.multipliedBy(o));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ze(e){return(e=e.toLowerCase())==C.tokens.AURORA||e==C.tokens.TRI||e==C.tokens.META}function Je(e,t){return $e.apply(this,arguments)}function $e(){return($e=O(V.mark((function e(t,r){var n;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(ee(R.has(t.toLocaleLowerCase()),"Address "+t+" is not whitelisted for price fetching"),!ne(t,C.tokens.stNEAR)){e.next=3;break}return e.abrupt("return",Qe());case 3:if(!ze(t)){e.next=5;break}return e.abrupt("return",Oe(t));case 5:if(void 0===(n=C.auTokens.find((function(e){return ne(e.underlying,t)})))){e.next=10;break}return e.abrupt("return",He(n.address,ie(t),r));case 10:throw Error("Unable to fetch price for "+t);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Xe(e,t){return et.apply(this,arguments)}function et(){return(et=O(V.mark((function e(r,n){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r.toLowerCase()in D)){e.next=4;break}return e.abrupt("return",new t(D[r.toLowerCase()]));case 4:if(!ne(r,C.tokens.PLYWNEAR)){e.next=8;break}return e.abrupt("return",je(r,n));case 8:if(!ne(r,C.tokens.PLY)){e.next=12;break}return e.abrupt("return",tt(n));case 12:if(!ne(r,C.tokens.PULP)){e.next=14;break}return e.abrupt("return",nt(n));case 14:return e.abrupt("return",Je(r,n));case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function tt(e){return rt.apply(this,arguments)}function rt(){return(rt=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",ot(C.tokens.PLYWNEAR,t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function nt(e){return at.apply(this,arguments)}function at(){return(at=O(V.mark((function e(r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new t(0));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ot(e,t){return it.apply(this,arguments)}function it(){return(it=O(V.mark((function e(r,n){var a,o,i;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Me(r,n);case 2:if(!(a=e.sent).reserve1.isZero()){e.next=5;break}return e.abrupt("return",new t(0));case 5:return o=ie(a.token0),i=ie(a.token1),e.next=9,Xe(a.token1,n);case 9:return e.abrupt("return",e.sent.multipliedBy(a.reserve1.toString()).multipliedBy(re(o)).dividedBy(re(i)).dividedBy(a.reserve0.toString()));case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ut(e,t){return st.apply(this,arguments)}function st(){return(st=O(V.mark((function e(r,n){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("0"!=r.rawAmount()){e.next=2;break}return e.abrupt("return",new t(0));case 2:return e.next=4,Xe(r.token.address,n);case 4:return e.abrupt("return",ct(r,e.sent));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ct(e,r){return new t(e.formattedAmount()).multipliedBy(r)}function pt(e,t){return ft.apply(this,arguments)}function ft(){return(ft=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ut(t,r);case 2:return e.abrupt("return",{tokenAmount:t,currencyAmount:{currency:"USD",amount:e.sent.toFixed(10)}});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var lt,dt,ht=function(e){function t(t,n){var a;return(a=e.call(this,n)||this).auToken=new r.Contract(t,p.abi,a._networkConnection.provider),a}M(t,e);var n=t.prototype;return n.queryERC20TransfersOf=function(){var e=O(V.mark((function e(t,r,n){var a,o,i,u=this;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=[this.auToken.filters.Transfer(t,null),this.auToken.filters.Transfer(null,t)],e.next=3,Promise.all(a.map((function(e){return u.auToken.queryFilter(e,r,n)})));case 3:return o=e.sent.flat(),(i=o.map((function(e){return{from:e.args[0],to:e.args[1],amount:e.args[2],blockNumber:e.blockNumber}}))).sort((function(e,t){return e.blockNumber-t.blockNumber})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),n.queryERC20BalanceAt=function(){var e=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.auToken.balanceOf(t,{blockTag:r+1}));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t}(q),wt={__proto__:null,getApi:Se,getPaginatedApi:Ne,getQuery:Z,queryGraphQL:$,assert:ee,formatObject:te,decimalFactor:re,isSameAddress:ne,getCurrentTimestamp:ae,validateAndParseAddress:oe,getDecimal:ie,getSymbol:ue,getUnderlying:se,calcLMRewardApr:ce,getBlockTimestamp:pe,getBlocksTimestampViaRPC:le,getBlocksTimestamp:he,getBlockBeforeTimestamp:me,devLog:ye,fetchPriceFromCoingeckoAPI:Ie,fetchPriceFromCoingecko:Oe,fetchLPPositions:Me,fetchLPPrice:je,fetchPriceFromOracle:He,fetchUnderlyingTokensPrices:Ke,fetchStNEARPrice:Qe,fetchPrice:Xe,fetchPLYPrice:tt,fetchPULPPrice:nt,fetchToken0PriceByLP:ot,fetchValuation:ut,calcValuation:ct,valuateToken:pt,TransferEventQuery:ht},mt=function(e){function t(t){var n;return(n=e.call(this,t)||this).airDrop=new r.Contract(C.misc.AURI_AIRDROP,i.abi,t.provider),n}return M(t,e),t.prototype.getRedeemableReward=function(){var e=O(V.mark((function e(t,n,a){var o;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new ge(n,ie(n)),e.next=3,this.airDrop.getRedeemableReward(r.utils.formatBytes32String(t),n,a);case 3:return e.abrupt("return",new xe(o,e.sent.toString()));case 5:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),t}(q),vt=function(e){function t(){return e.apply(this,arguments)||this}M(t,e);var n=t.prototype;return n.redeemMultiple=function(){var e=O(V.mark((function e(t,n){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ee(t.length==n.length,"campaigns and tokens must have the same length"),e.t0=this.airDrop.connect(this._networkConnection.signer),e.t1=t.map((function(e){return r.utils.formatBytes32String(e)})),e.t2=n,e.next=6,this._networkConnection.signer.getAddress();case 6:return e.t3=e.sent,e.abrupt("return",e.t0.redeem.call(e.t0,e.t1,e.t2,e.t3));case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),n.redeemSingle=function(){var e=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.redeemMultiple([t],[r]));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t}(mt),yt=function(e){function t(){return e.call(this)||this}M(t,e);var r=t.prototype;return r.read=function(e){return new mt(e)},r.readWrite=function(e){return new vt(e)},t}(G);(lt=exports.ComptrollerRewardType||(exports.ComptrollerRewardType={}))[lt.PLY=0]="PLY",lt[lt.AURORA=1]="AURORA",(dt=exports.MarketAction||(exports.MarketAction={}))[dt.Deposit=0]="Deposit",dt[dt.Borrow=1]="Borrow",dt[dt.Withdraw=2]="Withdraw",dt[dt.Repay=3]="Repay",dt[dt.EnableCollateral=4]="EnableCollateral",dt[dt.DisableCollateral=5]="DisableCollateral";var gt=function(e){function n(t,n,i){var u;return(u=e.call(this,t)||this).env=new K(t),u.auToken=ne(i,L)?new r.Contract(n,o.abi,t.provider):new r.Contract(n,a.abi,t.provider),u.underlying=new ge(i,ie(i)),u}M(n,e);var i=n.prototype;return i.getRewardSpeeds=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriLens.getRewardSpeeds(this.env.comptroller.address,this.auToken.address);case 2:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getTotalTokenBorrowed=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=xe,e.t1=this.underlying,e.next=4,this.auToken.totalBorrows();case 4:return e.t2=e.sent.toString(),e.abrupt("return",new e.t0(e.t1,e.t2));case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getTotalTokenDeposited=function(){var e=O(V.mark((function e(){var t,n,a,o=this;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=[]).push(this.getTotalTokenBorrowed().then((function(e){n=e}))),t.push(this.auToken.getCash().then((function(e){a=new xe(o.underlying,e.toString())}))),e.next=5,Promise.all(t);case 5:return e.abrupt("return",new xe(this.underlying,r.BigNumber.from(a.rawAmount()).add(n.rawAmount()).toString()));case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getDepositAPY=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auToken.supplyRatePerTimestamp();case 2:return e.abrupt("return",new t(e.sent.toString()).multipliedBy(31536e3).div(re(18)));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getBorrowAPY=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auToken.borrowRatePerTimestamp();case 2:return e.abrupt("return",new t(e.sent.toString()).multipliedBy(31536e3).div(re(18)));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getCollateralRatio=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.comptroller.markets(this.auToken.address).then((function(e){return new t(e.collateralFactorMantissa.toString()).div(re(18))})));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getBorrowPlyAPY=function(){var e=O(V.mark((function e(){var t,r,n,a,o;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=[]).push(this.getTotalTokenBorrowed().then((function(e){r=e}))),t.push(this.env.comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY,this.auToken.address,!1).then((function(e){n=new xe(be,e.toString())}))),t.push(Xe(C.tokens.PLY,this._networkConnection.provider).then((function(e){a=e}))),t.push(Xe(this.underlying.address,this._networkConnection.provider).then((function(e){o=e}))),e.next=7,Promise.all(t);case 7:return e.abrupt("return",ce(a.multipliedBy(n.formattedAmount()),o.multipliedBy(r.formattedAmount()),31536e3));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getDepositPlyAPY=function(){var e=O(V.mark((function e(){var t,r,n,a,o;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=[]).push(this.getTotalTokenDeposited().then((function(e){r=e}))),t.push(this.env.comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY,this.auToken.address,!0).then((function(e){n=new xe(be,e.toString())}))),t.push(Xe(C.tokens.PLY,this._networkConnection.provider).then((function(e){a=e}))),t.push(Xe(this.underlying.address,this._networkConnection.provider).then((function(e){o=e}))),e.next=7,Promise.all(t);case 7:return e.abrupt("return",ce(a.multipliedBy(n.formattedAmount()),o.multipliedBy(r.formattedAmount()),31536e3));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getDetails=function(){var e=O(V.mark((function e(){var r,n,a,o,i,u,s,c,p,f,l,d,h,w;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=[]).push(this.getTotalTokenDeposited().then((function(e){n=e}))),r.push(this.getTotalTokenBorrowed().then((function(e){a=e}))),r.push(this.getDepositAPY().then((function(e){o=e.toNumber()}))),r.push(this.getBorrowAPY().then((function(e){i=e.toNumber()}))),r.push(this.getCollateralRatio().then((function(e){u=e.toNumber()}))),r.push(this.getRewardSpeeds().then((function(e){p=e}))),r.push(Xe(C.tokens.PLY,this._networkConnection.provider).then((function(e){s=e}))),r.push(Xe(this.underlying.address,this._networkConnection.provider).then((function(e){c=e}))),e.next=11,Promise.all(r);case 11:return f=ce(ct(new xe(be,p.plyRewardBorrowSpeed.toString()),s),c.multipliedBy(a.formattedAmount()),31536e3),l=ce(ct(new xe(be,p.plyRewardSupplySpeed.toString()),s),c.multipliedBy(n.formattedAmount()),31536e3),e.t0=wt,e.next=16,ut(this.getDepositNEARRewardPerWeek(),this._networkConnection.provider);case 16:return e.t1=e.sent,e.t2=c.multipliedBy(n.formattedAmount()),d=e.t0.calcLMRewardApr.call(e.t0,e.t1,e.t2,52),e.t3=wt,e.next=22,ut(this.getBorrowNEARRewardPerWeek(),this._networkConnection.provider);case 22:return e.t4=e.sent,e.t5=c.multipliedBy(a.formattedAmount()),h=e.t3.calcLMRewardApr.call(e.t3,e.t4,e.t5,52),w=ne(this.underlying.address,C.tokens.stNEAR)?ce(new t(5e4),c.multipliedBy(n.formattedAmount()),12):new t(0),e.abrupt("return",{auTokenAddress:this.auToken.address,totalTokenDeposited:n,totalTokenBorrowed:a,depositApy:o,depositPlyApy:l.toNumber(),borrowApy:i,borrowPlyApy:-1*f.toNumber(),collateralRatio:u,depositPlyPerWeek:new xe(be,p.plyRewardSupplySpeed.mul(86400).mul(7).toString()),borrowPlyPerWeek:new xe(be,p.plyRewardBorrowSpeed.mul(86400).mul(7).toString()),depositNEARApy:d.toNumber(),borrowNEARApy:-1*h.toNumber(),depositMETAApy:w.toNumber()});case 27:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.getUserBorrowBalance=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auToken.callStatic.borrowBalanceCurrent(t);case 2:return e.abrupt("return",new xe(this.underlying,e.sent.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),i.getUserDepositBalance=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auToken.callStatic.balanceOfUnderlying(t);case 2:return e.abrupt("return",new xe(this.underlying,e.sent.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),i.getDepositNEARRewardPerWeek=function(){var e=new ge(C.tokens.WNEAR,ie(C.tokens.WNEAR)),t=ae();if(t<=1651845600&&t>1650636e3){var r,n=null!=(r=_[this.underlying.address.toLocaleLowerCase()])?r:"0";return new xe(e,n,!1)}return new xe(e,"0")},i.getBorrowNEARRewardPerWeek=function(){var e=new ge(C.tokens.WNEAR,ie(C.tokens.WNEAR)),t=ae();if(t<=1651845600&&t>1650636e3){var r,n=null!=(r=N[this.underlying.address.toLocaleLowerCase()])?r:"0";return new xe(e,n,!1)}return new xe(e,"0")},n}(q),bt=function(e){function n(t,n,a){var o;return(o=e.call(this,t,n,a)||this)._EthRepayHelper=new r.Contract(C.misc.ETHREPAYHELPER,l.abi,t.provider),o}M(n,e);var a=n.prototype;return a.deposit=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ne(t.token.address,L)){e.next=4;break}return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).mint({value:t.rawAmount()}));case 4:return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).mint(t.rawAmount()));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.borrow=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).borrow(t.rawAmount()));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.withdraw=function(){var e=O(V.mark((function e(r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!new t(r.rawAmount()).lt(0)){e.next=2;break}return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).redeemUnderlying(S));case 2:return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).redeemUnderlying(r.rawAmount()));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.repay=function(){var e=O(V.mark((function e(r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ne(r.token.address,L)){e.next=4;break}return e.abrupt("return",this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({value:r.rawAmount()}));case 4:if(!new t(r.rawAmount()).lt(0)){e.next=8;break}return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).repayBorrow(S));case 8:return e.abrupt("return",this.auToken.connect(this._networkConnection.signer).repayBorrow(r.rawAmount()));case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.enableCollateral=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.disableCollateral=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n}(gt),kt=function(e){function t(t,r){var n;return(n=e.call(this)||this).address=oe(t),n.underlying=oe(r),n}M(t,e);var r=t.prototype;return r.read=function(e){return new gt(e,this.address,this.underlying)},r.readWrite=function(e){return new bt(e,this.address,this.underlying)},t}(G),xt=function(e){function t(t){var n;return(n=e.call(this,t)||this).multicall=new r.Contract(C.misc.MULTICALL,m.abi,t.provider),n}return M(t,e),t.prototype.aggregate=function(){var e=O(V.mark((function e(t){var n,a,o,i,u,s,c,p;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=[],a=0;case 2:if(!(a<t.length)){e.next=11;break}return i=t[a],e.next=6,(o=i.contract.populateTransaction)[i.method].apply(o,i.args);case 6:n.push({target:(u=e.sent).to,callData:u.data});case 8:a++,e.next=2;break;case 11:return e.next=13,this.multicall.callStatic.aggregate(n);case 13:for(s=e.sent,c=[],p=0;p<t.length;p++)c.push(r.ethers.utils.defaultAbiCoder.decode(t[p].returnTypes,s.returnData[p]));return e.abrupt("return",c);case 17:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(q),At=r.BigNumber.from(1e4),Lt=function(e){function n(t){var r;(r=e.call(this,t)||this).env=new K(t);var n=C.tokens.PLY,a=C.tokens.PULP;return r.plyToken=new ge(n,ie(n)),r.pulpToken=new ge(a,ie(a)),r}M(n,e);var a=n.prototype;return a.getPlyBalance=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.ply.balanceOf(t);case 2:return e.abrupt("return",new xe(this.plyToken,e.sent.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getPulpBalance=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.pulp.balanceOf(t);case 2:return e.abrupt("return",new xe(this.pulpToken,e.sent.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getUnclaimedPlyReward=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriLens.callStatic.claimRewards(this.env.comptroller.address,this.env.auriFairLaunch.address,B,{from:t});case 2:return e.abrupt("return",new xe(this.plyToken,e.sent.plyAccrured.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getWeek=function(e){return r.BigNumber.from(e-1651759200).div(604800).toNumber()},a.getLockingDetails=function(){var e=O(V.mark((function e(n){var a,o,i,u,s,c,p,f,l,d,h,w,m;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.getWeek(ae()),(o=[]).push(this.env.auriLens.getPercentLock(this.env.pulp.address,n,a)),o.push(this.env.auriLens.getPercentLock(this.env.pulp.address,n,a+1)),o.push(this.getUnclaimedPlyReward(n)),e.next=7,Promise.all(o);case 7:return u=r.BigNumber.from((i=e.sent)[0]),s=r.BigNumber.from(i[1]),c=i[2],e.next=13,this.env.pulp.calcLockAmount(n,c.rawAmount());case 13:return f=(p=e.sent)[0],l=p[1],d=s.mul(c.rawAmount()).div(At),h=r.BigNumber.from(c.rawAmount()).sub(d),w=At.sub(u).toString(),m=At.sub(s).toString(),e.abrupt("return",{vestingStart:1651759200,currentUnlockPortion:new t(w).dividedBy(100).toNumber(),accruedPly:c,currentPly:new xe(this.plyToken,l.toString()),currentPulp:new xe(this.pulpToken,f.toString()),nextUnlockPortion:new t(m).dividedBy(100).toNumber(),nextPly:new xe(this.plyToken,d.toString()),nextPulp:new xe(this.pulpToken,h.toString())});case 21:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getTimestampToUnlock=function(){var e=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriLens.getWeekToUnlock(this.env.pulp.address,t,100*r);case 2:return e.abrupt("return",1651759200+604800*e.sent.toNumber());case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),a.getNextWeekTimestamp=function(){return 1651759200+604800*(this.getWeek(ae())+1)},a.getUnlockPortionAt=function(){var e=O(V.mark((function e(t,r){var n;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriLens.getPercentLock(this.env.pulp.address,t,this.getWeek(r));case 2:return n=At.sub(e.sent),e.abrupt("return",n.toNumber()/100);case 5:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),n}(q),Ct=function(e){function t(t){return e.call(this,t)||this}M(t,e);var r=t.prototype;return r.redeem=function(){var e=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.pulp.connect(this._networkConnection.signer).redeem(t,r.rawAmount()));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.selfRedeem=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._networkConnection.signer.getAddress();case 2:return e.abrupt("return",this.redeem(e.sent,t));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(Lt),Et=function(e){function t(){return e.call(this)||this}M(t,e);var r=t.prototype;return r.read=function(e){return new Lt(e)},r.readWrite=function(e){return new Ct(e)},t}(G),Rt=function(e){function t(t){var r;return(r=e.call(this,t)||this).env=new K(t),r}M(t,e);var n=t.prototype;return n.getPLYWNEARPoolDetails=function(){var e=O(V.mark((function e(){var t,r,n,a,o,i,u,s,c;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriFairLaunch.getPoolInfo(0).then((function(e){t=e.totalStake,r=e.rewardPerSeconds}));case 2:return n=new xe(ke,t.toString()),e.next=5,ut(n,this._networkConnection.provider);case 5:for(a=e.sent,o=[],i=0;i<r.length;i++)s=new ge(u=T[i],ie(u)),o.push(ut(new xe(s,r[i].toString()),this._networkConnection.provider));return c=[],e.next=11,Promise.all(o);case 11:return e.sent.forEach((function(e,t){var r=T[t],n=ce(e,a,31536e3).toFixed(10);c.push({address:r,apy:n})})),e.abrupt("return",{totalStakedLiquidity:n,APYs:c});case 13:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.stakeBalanceOf=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriFairLaunch.getUserInfo(0,t);case 2:return e.abrupt("return",new xe(ke,e.sent.amount.toString()));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.LpBalanceOf=function(){var e=O(V.mark((function e(t){var n;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new r.Contract(C.tokens.PLYWNEAR,d.abi,this._networkConnection.provider),e.next=3,n.balanceOf(t);case 3:return e.abrupt("return",new xe(ke,e.sent.toString()));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.unclaimedRewardsOf=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriFairLaunch.callStatic.updateAndGetUserInfo(0,t,{from:t});case 2:return e.abrupt("return",e.sent.unclaimedRewards.map((function(e,t){return xe.fromAddressAndAmount(T[t],e.toString())})));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(q),Pt=function(e){function t(){return e.apply(this,arguments)||this}M(t,e);var n=t.prototype;return n.stake=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.env.auriFairLaunch.connect(this._networkConnection.signer).deposit(0,t.rawAmount()));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.unstake=function(){var e=O(V.mark((function e(t){var n,a,o,i;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._networkConnection.signer.getAddress();case 2:return n=e.sent,a=r.BigNumber.from(t.rawAmount()),e.t0=r.BigNumber,e.next=7,this.stakeBalanceOf(n);case 7:return e.t1=e.sent.rawAmount(),o=e.t0.from.call(e.t0,e.t1),i=a.lt(o)?a:o.sub(1),e.abrupt("return",this.env.auriFairLaunch.connect(this._networkConnection.signer).withdraw(0,i));case 11:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(Rt),Tt=function(e){function t(){return e.call(this)||this}M(t,e);var r=t.prototype;return r.read=function(e){return new Rt(e)},r.readWrite=function(e){return new Pt(e)},t}(G),Bt=function(e){function n(t){var r;return(r=e.call(this,t)||this).stakingRead=new Rt(t),r.env=new K(t),r}M(n,e);var a=n.prototype;return a.getUserDetails=function(){var e=O(V.mark((function e(r){var n,a,o,i,u,s,c,p,f,l,d,h,w,m,v,y,g,b,k,x,A,L=this;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=C.auTokens.length,a=[],i=[],u=new t(0),s=[],c=function(){var e=f.value,t={};a.push(t),t.market=e.underlying;var n=new gt(L._networkConnection,e.address,e.underlying);i.push(n.getUserDepositBalance(r).then((function(e){t.depositBalance=e}))),i.push(n.getUserBorrowBalance(r).then((function(e){t.borrowBalance=e}))),i.push(n.getCollateralRatio().then((function(e){t.collateralRatio=e.toNumber()}))),s.push(Xe(n.underlying.address,L._networkConnection.provider).then((function(e){return t.underlyingPrice=e.toString(),e})))},p=j(C.auTokens);!(f=p()).done;)c();return i.push(this.env.comptroller.getAssetsIn(r).then((function(e){o=e}))),e.next=10,Promise.all(i);case 10:return e.next=12,Promise.all(s);case 12:for(l=e.sent,d=[],h=function(){var e=C.auTokens[w];a[w].isCollateral=void 0!==o.find((function(t){return ne(e.address,t)})),d.push(ct(a[w].depositBalance,l[w]))},w=0;w<n;w++)h();return u=d.reduce((function(e,t,r){return a[r].isCollateral?e.plus(t.multipliedBy(a[r].collateralRatio)):e}),new t(0)),e.next=19,this.env.comptroller.getAccountLiquidity(r);case 19:for((m=u.minus(new t(e.sent[0].toString()).div(re(18)))).lt("0.00001")&&(m=new t(0)),v=u.multipliedBy(P),y=m.div(P),g=v.lte(m)?new t(0):v.minus(m),w=0;w<n;w++)k=new gt(this._networkConnection,(b=C.auTokens[w]).address,b.underlying),x=u.minus(y).gt(0)?u.minus(y):new t(0),A=x.div(a[w].collateralRatio).div(l[w]),a[w].maxWithdrawableAmount=a[w].isCollateral&&A.lt(a[w].depositBalance.formattedAmount())?new xe(k.underlying,A.toFixed(24),!1):new xe(k.underlying,a[w].depositBalance.rawAmount());return e.t0=a,e.t1={currency:"USD",amount:v.toFixed(10)},e.next=30,new Lt(this._networkConnection).getLockingDetails(r);case 30:return e.t2=e.sent,e.t3={currency:"USD",amount:g.toFixed(10)},e.abrupt("return",{markets:e.t0,borrowLimit:e.t1,userLockingDetails:e.t2,borrowableAmount:e.t3});case 33:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.getTokenPrice=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Xe(t.address,this._networkConnection.provider);case 2:return e.abrupt("return",{currency:"USD",amount:e.sent.toFixed(10)});case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.calcHypotheticalStats=function(e){var r=e.userMarketDetail,n=e.currentBorrowValuation,a=e.action,o=e.tokenAmount,i=new t(e.currentBorrowLimit.amount),u=new t(n.amount);switch(a){case exports.MarketAction.EnableCollateral:case exports.MarketAction.DisableCollateral:var s=ct(r.depositBalance,new t(r.underlyingPrice)).multipliedBy(r.collateralRatio).multipliedBy(P);i=a==exports.MarketAction.EnableCollateral?i.plus(s):i.minus(s);break;case exports.MarketAction.Deposit:case exports.MarketAction.Withdraw:s=ct(o,new t(r.underlyingPrice)).multipliedBy(r.collateralRatio).multipliedBy(P),i=a==exports.MarketAction.Deposit?i.plus(s):i.minus(s);break;case exports.MarketAction.Borrow:case exports.MarketAction.Repay:var c=ct(o,new t(r.underlyingPrice));u=a==exports.MarketAction.Borrow?u.plus(c):u.minus(c)}return{newBorrowLimit:{amount:i.toFixed(10),currency:"USD"},newBorrowUtilization:i.eq(0)?u.eq(0)?0:9999.99:u.div(i).toNumber()}},a.getPlyCirculatingSupply=function(){var e=O(V.mark((function e(){var t,n,a,o;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new xt(this._networkConnection),n={contract:this.env.ply,method:"balanceOf",returnTypes:["uint256"]},e.next=4,t.aggregate([F({},n,{method:"totalSupply",args:[]}),F({},n,{args:[C.misc.TEAM_MULTISIG]}),F({},n,{args:[C.misc.COMPTROLLER]}),F({},n,{args:[C.misc.AURIFAIRLAUNCH]}),F({},n,{args:[C.misc.PLY_TOKEN_LOCK]})]);case 4:return a=e.sent,o=r.BigNumber.from(0),a.forEach((function(e,t){o=0===t?e[0]:o.sub(e[0])})),e.abrupt("return",new xe(be,o.toString()));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),a.getUtilisation=function(){var e=O(V.mark((function e(r){var n,a,o;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.env.auriInternalLens.getAccountLiquidity(r);case 2:return a=new t((n=e.sent).sumBorrowPlusEffects.toString()),o=new t(n.sumCollateral.toString()),e.abrupt("return",a.dividedBy(o));case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),a.sneakAccounts=function(){var e=O(V.mark((function e(n,a){var o,i,u,s,f,l,d,h,w,m,v,y,g,b,k,x,A,L=this;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.BigNumber.from(10).pow(18),i=new t(.1),u=this.env.getContract(C.misc.oracle,c.abi),s=a.map((function(e){return L.env.getContract(e,p.abi)})),e.next=6,u.getUnderlyingPrices(a);case 6:return f=e.sent,e.next=9,this.env.auriInternalLens.callStatic.getExchangeRates(a);case 9:l=e.sent,d=[],h=j(n);case 12:if((w=h()).done){e.next=33;break}m=w.value,v=[],y=0;case 16:if(!(y<s.length)){e.next=30;break}return e.next=19,s[y].getAccountSnapshot(m);case 19:if(b=(g=e.sent)[0].mul(l[y]).div(o).mul(f[y]).div(o),k=g[1].mul(f[y]).div(o),x=new t(b.toString()).dividedBy(o.toString()),A=new t(k.toString()).dividedBy(o.toString()),!x.lt(i)&&!A.lt(i)){e.next=26;break}return e.abrupt("continue",27);case 26:v.push({token:ue(a[y]),deposit:x,borrow:A});case 27:++y,e.next=16;break;case 30:d.push({address:m,tokens:v});case 31:e.next=12;break;case 33:return e.abrupt("return",d);case 34:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),n}(q),St=function(e){function t(t){var n;return(n=e.call(this,t)||this).referral=new r.Contract(C.misc.REFERRAL,y.abi,t.provider),n}M(t,e);var n=t.prototype;return n.generateReferralCode=function(){for(var e="abcdefghijklmnopqrstuvwxyz",t=e+e.toUpperCase()+"1234567890",r="",n=0;n<10;n++)r+=t[Math.floor(Math.random()*t.length)];return r},n.getUserReferralCode=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.referral.userReferralCode(t);case 2:return e.abrupt("return",r.ethers.utils.parseBytes32String(e.sent));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getReferralCodeUsed=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.referral.referralCodeUsed(t);case 2:return e.abrupt("return",r.ethers.utils.parseBytes32String(e.sent));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getReferralCodeOwner=function(){var e=O(V.mark((function e(t){var n;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.ethers.utils.formatBytes32String(t),e.abrupt("return",this.referral.referralCodeOwner(n));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getReferralsList=function(){var e=O(V.mark((function e(t){var r,n,a,o;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ne("/referral/list",{address:t});case 2:return n=(r=e.sent).items.map((function(e){return e.blockNumber})),e.next=6,he(this._networkConnection.provider,n);case 6:return a=e.sent,o=r.items.map((function(e,t){return{user:e.user,timestamp:a[t]}})),e.abrupt("return",o);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(q),_t=function(e){function t(){return e.apply(this,arguments)||this}M(t,e);var n=t.prototype;return n.registerNewReferralCode=function(){var e=O(V.mark((function e(){var t;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.ethers.utils.formatBytes32String(this.generateReferralCode()),e.abrupt("return",this.referral.connect(this._networkConnection.signer).registerNewUserReferralCode(t));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.useReferralCode=function(){var e=O(V.mark((function e(t){var n;return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.ethers.utils.formatBytes32String(t),e.abrupt("return",this.referral.connect(this._networkConnection.signer).registerReferralCodeUsed(n));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(St),Nt=function(e){function t(){return e.call(this)||this}M(t,e);var r=t.prototype;return r.read=function(e){return new St(e)},r.readWrite=function(e){return new _t(e)},t}(G),Dt=function(e){function t(t){var r;return(r=e.call(this,t)||this).env=new K(t),r._stakingRead=new Rt(t),r._misc=new Bt(t),r}M(t,e);var r=t.prototype;return r.getUserDetails=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.getUserDetails(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.getPLYWNEARPoolDetails=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._stakingRead.getPLYWNEARPoolDetails());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getTokenPrice=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.getTokenPrice(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.stakeBalanceOf=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._stakingRead.stakeBalanceOf(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.LpBalanceOf=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._stakingRead.LpBalanceOf(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.unclaimedRewardsOf=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._stakingRead.unclaimedRewardsOf(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.calcHypotheticalStats=function(e){return this._misc.calcHypotheticalStats({userMarketDetail:e.userMarketDetail,currentBorrowLimit:e.currentBorrowLimit,currentBorrowValuation:e.currentBorrowValuation,action:e.action,tokenAmount:e.tokenAmount})},r.getPlyCirculatingSupply=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.getPlyCirculatingSupply());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getUtilisation=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.getUtilisation(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.sneakAccounts=function(){var e=O(V.mark((function e(t,r){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._misc.sneakAccounts(t,r));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t}(q),It=function(e){function t(){return e.apply(this,arguments)||this}M(t,e);var r=t.prototype;return r.claim=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this.env.comptroller.connect(this._networkConnection.signer),e.next=3,this._networkConnection.signer.getAddress();case 3:return e.t1=e.sent,e.abrupt("return",e.t0["claimReward(uint8,address)"].call(e.t0,0,e.t1));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.claimLpRewards=function(){var e=O(V.mark((function e(){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this.env.auriFairLaunch.connect(this._networkConnection.signer),e.next=3,this._networkConnection.signer.getAddress();case 3:return e.t1=e.sent,e.t2=S,e.abrupt("return",e.t0.harvest.call(e.t0,e.t1,0,e.t2));case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.stake=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Pt(this._networkConnection).stake(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.unstake=function(){var e=O(V.mark((function e(t){return V.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Pt(this._networkConnection).unstake(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(Dt),Ut=function(e){function t(){return e.call(this)||this}M(t,e);var r=t.prototype;return r.read=function(e){return new Dt(e)},r.readWrite=function(e){return new It(e)},t}(G);r.ethers.utils.Logger.setLogLevel(n.Logger.levels.ERROR),t.config({DECIMAL_PLACES:50}),exports.MAINNET_ADDRESSES=g,exports.TESTNET_ADDRESSES=b,exports.AIRDROP_END_TIMESTAMP=1651068e3,exports.AIRDROP_KEEP_THRESHOLD=604800,exports.AIRDROP_START_TIMESTAMP=1649858400,exports.ALL_STAKING_POOLS=B,exports.AURORA_CHAINID=1313161554,exports.Airdrop=yt,exports.AirdropRead=mt,exports.AirdropReadWrite=vt,exports.AuriEnv=K,exports.BORROW_LIMIT_BUFFER=P,exports.BORROW_NEAR_REWARDS_PER_WEEK=N,exports.BlockchainEntity=G,exports.BlockchainEntityRead=q,exports.BlockchainEntityReadWrite=H,exports.DECIMAL_PRECISION=10,exports.DEPOSIT_NEAR_REWARDS_PER_WEEK=_,exports.DEPOSIT_ONLY_TOKENS=E,exports.ETHAddress=L,exports.HARDCODE_PRICE_TOKENS=D,exports.INF=S,exports.MiscRead=Bt,exports.MoneyMarket=kt,exports.MoneyMarketRead=gt,exports.MoneyMarketReadWrite=bt,exports.ONE_DAY=86400,exports.ONE_WEEK=604800,exports.ONE_YEAR=31536e3,exports.PLYToken=be,exports.PLYWNEARToken=ke,exports.PLYWNEAR_POOL_ID=0,exports.PLYWNEAR_REWARD_TOKENS=T,exports.PRICE_WHITELISTED=R,exports.Papermill=Et,exports.PapermillRead=Lt,exports.PapermillReadWrite=Ct,exports.REWARD_CLAIM_START=1651759200,exports.Referral=Nt,exports.ReferralRead=St,exports.ReferralReadWrite=_t,exports.SDK=Ut,exports.SdkRead=Dt,exports.SdkReadWrite=It,exports.Staking=Tt,exports.StakingRead=Rt,exports.StakingReadWrite=Pt,exports.Token=ge,exports.TokenAmount=xe,exports.TransferEventQuery=ht,exports.abis=A,exports.assert=ee,exports.calcLMRewardApr=ce,exports.calcValuation=ct,exports.decimalFactor=re,exports.decimalRecords=I,exports.devLog=ye,exports.dummyAddress="0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE",exports.dummyMarketAddress="0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f",exports.dummyPly=Le,exports.dummyPlyAurora=Ce,exports.dummyToken=Ae,exports.dummyTokenAmount=Ee,exports.dummyTokenAmount2=Pe,exports.dummyTokenAmount3=Te,exports.dummyUserMarketDetails=Be,exports.dummyZeroTokenAmount=Re,exports.fetchLPPositions=Me,exports.fetchLPPrice=je,exports.fetchPLYPrice=tt,exports.fetchPULPPrice=nt,exports.fetchPrice=Xe,exports.fetchPriceFromCoingecko=Oe,exports.fetchPriceFromCoingeckoAPI=Ie,exports.fetchPriceFromOracle=He,exports.fetchStNEARPrice=Qe,exports.fetchToken0PriceByLP=ot,exports.fetchUnderlyingTokensPrices=Ke,exports.fetchValuation=ut,exports.formatObject=te,exports.getApi=Se,exports.getBlockBeforeTimestamp=me,exports.getBlockTimestamp=pe,exports.getBlocksTimestamp=he,exports.getBlocksTimestampViaRPC=le,exports.getCurrentTimestamp=ae,exports.getDecimal=ie,exports.getPaginatedApi=Ne,exports.getQuery=Z,exports.getSymbol=ue,exports.getUnderlying=se,exports.isSameAddress=ne,exports.networkAddresses=C,exports.queryGraphQL=$,exports.symbolRecords=Q,exports.validateAndParseAddress=oe,exports.valuateToken=pt;
|
|
2
2
|
//# sourceMappingURL=sdk.cjs.production.min.js.map
|