Comparing version 2.1.0 to 2.1.1-beta.1
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@stacks/transactions"),e=require("clarity-codegen"),n=require("@stacks/network");function r(t){return t}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function i(t,e,n,r,o,i,a){try{var p=t[i](a),u=p.value}catch(t){return void n(t)}p.done?e(u):Promise.resolve(u).then(r,o)}function a(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var a=t.apply(e,n);function p(t){i(a,r,o,p,u,"next",t)}function u(t){i(a,r,o,p,u,"throw",t)}p(void 0)}))}}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(){return u=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},u.apply(null,arguments)}function c(){c=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",p=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function s(t,e,n,r){var i=Object.create((e&&e.prototype instanceof g?e:g).prototype),a=new _(r||[]);return o(i,"_invoke",{value:A(t,n,a)}),i}function y(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var m="suspendedStart",f="suspendedYield",T="executing",d="completed",h={};function g(){}function k(){}function x(){}var b={};l(b,a,(function(){return this}));var v=Object.getPrototypeOf,w=v&&v(v(P([])));w&&w!==n&&r.call(w,a)&&(b=w);var S=x.prototype=g.prototype=Object.create(b);function C(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function n(o,i,a,p){var u=y(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,p)}),(function(t){n("throw",t,a,p)})):e.resolve(l).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,p)}))}p(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function A(e,n,r){var o=m;return function(i,a){if(o===T)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var p=r.delegate;if(p){var u=I(p,r);if(u){if(u===h)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===m)throw o=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=T;var c=y(e,n,r);if("normal"===c.type){if(o=r.done?d:f,c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=d,r.method="throw",r.arg=c.arg)}}}function I(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,I(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=y(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,h;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,h):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,h)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function P(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return k.prototype=x,o(S,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:k,configurable:!0}),k.displayName=l(x,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===k||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,l(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},C(E.prototype),l(E.prototype,p,(function(){return this})),e.AsyncIterator=E,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new E(s(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},C(S),l(S,u,"Generator"),l(S,a,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=P,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(O),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return p.type="throw",p.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],p=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:P(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),h}},e}exports.Currency=void 0,(exports.Currency||(exports.Currency={})).STX=r("token-wstx");var l=e.defineContract(u({},e.defineContract({"amm-pool-v2-01":{"add-to-position":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT},{name:"max-dy",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT,supply:e.uintT})),mode:"public"},"create-pool":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"pool-owner",type:e.principalT},{name:"dx",type:e.uintT},{name:"dy",type:e.uintT}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT,supply:e.uintT})),mode:"public"},pause:{input:[{name:"new-paused",type:e.booleanT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"reduce-position":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"percent",type:e.uintT}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"public"},"set-end-block":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-end-block",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-fee-rate-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"fee-rate-x",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-fee-rate-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"fee-rate-y",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-max-in-ratio":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-max-in-ratio",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-max-out-ratio":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-max-out-ratio",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-oracle-average":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-oracle-average",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-oracle-enabled":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"enabled",type:e.booleanT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-start-block":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-start-block",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-threshold-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-threshold",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-threshold-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-threshold",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"swap-helper":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dy",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.uintT),mode:"public"},"swap-helper-a":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"token-z-trait",type:e.traitT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dz",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.uintT),mode:"public"},"swap-helper-b":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"token-z-trait",type:e.traitT},{name:"token-w-trait",type:e.traitT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dw",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.uintT),mode:"public"},"swap-helper-c":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"token-z-trait",type:e.traitT},{name:"token-w-trait",type:e.traitT},{name:"token-v-trait",type:e.traitT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"factor-w",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dv",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.uintT),mode:"public"},"swap-x-for-y":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dy",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"public"},"swap-y-for-x":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"dy",type:e.uintT},{name:"min-dx",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"public"},"check-pool-status":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"readonly"},"fee-helper":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"fee-helper-a":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"fee-helper-b":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"token-w",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"fee-helper-c":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"token-w",type:e.principalT},{name:"token-v",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"factor-w",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-balances":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.tupleT({"balance-x":e.uintT,"balance-y":e.uintT})),mode:"readonly"},"get-end-block":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-fee-rate-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-fee-rate-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-fee-rebate":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-helper":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-helper-a":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-helper-b":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"token-w",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-helper-c":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"token-w",type:e.principalT},{name:"token-v",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"factor-w",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-invariant":{input:[{name:"balance-x",type:e.uintT},{name:"balance-y",type:e.uintT},{name:"t",type:e.uintT}],output:e.uintT,mode:"readonly"},"get-max-in-ratio":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-max-out-ratio":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-max-ratio-limit":{input:[],output:e.uintT,mode:"readonly"},"get-oracle-average":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-oracle-enabled":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"readonly"},"get-oracle-instant":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-oracle-resilient":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-pool-details":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.tupleT({"balance-x":e.uintT,"balance-y":e.uintT,"end-block":e.uintT,"fee-rate-x":e.uintT,"fee-rate-y":e.uintT,"fee-rebate":e.uintT,"max-in-ratio":e.uintT,"max-out-ratio":e.uintT,"oracle-average":e.uintT,"oracle-enabled":e.booleanT,"oracle-resilient":e.uintT,"pool-id":e.uintT,"pool-owner":e.principalT,"start-block":e.uintT,"threshold-x":e.uintT,"threshold-y":e.uintT,"total-supply":e.uintT})),mode:"readonly"},"get-pool-details-by-id":{input:[{name:"pool-id",type:e.uintT}],output:e.responseSimpleT(e.tupleT({factor:e.uintT,"token-x":e.principalT,"token-y":e.principalT})),mode:"readonly"},"get-pool-exists":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.optionalT(e.tupleT({"balance-x":e.uintT,"balance-y":e.uintT,"end-block":e.uintT,"fee-rate-x":e.uintT,"fee-rate-y":e.uintT,"fee-rebate":e.uintT,"max-in-ratio":e.uintT,"max-out-ratio":e.uintT,"oracle-average":e.uintT,"oracle-enabled":e.booleanT,"oracle-resilient":e.uintT,"pool-id":e.uintT,"pool-owner":e.principalT,"start-block":e.uintT,"threshold-x":e.uintT,"threshold-y":e.uintT,"total-supply":e.uintT})),mode:"readonly"},"get-pool-owner":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.principalT),mode:"readonly"},"get-position-given-burn":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"token-amount",type:e.uintT}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"readonly"},"get-position-given-mint":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"token-amount",type:e.uintT}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"readonly"},"get-price":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-start-block":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-switch-threshold":{input:[],output:e.uintT,mode:"readonly"},"get-threshold-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-threshold-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-token-given-position":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT},{name:"max-dy",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.tupleT({dy:e.uintT,token:e.uintT})),mode:"readonly"},"get-x-given-price":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"price",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-x-given-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dy",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-x-in-given-y-out":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dy",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-y-given-price":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"price",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-y-given-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-y-in-given-x-out":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"is-blocklisted-or-default":{input:[{name:"sender",type:e.principalT}],output:e.booleanT,mode:"readonly"},"is-dao-or-extension":{input:[],output:e.responseSimpleT(e.booleanT),mode:"readonly"},"is-paused":{input:[],output:e.booleanT,mode:"readonly"},paused:{input:e.noneT,output:e.booleanT,mode:"variable"}}}))),s={CONTRACT_DEPLOYER:"SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM",API_HOST:"https://api.alexgo.io",STACKS_API_HOST:"https://api.hiro.so",READONLY_CALL_API_HOST:"https://stacks-node.alexlab.co"};function y(t){return null!=t}function m(t){return t.reduce((function(t,e){return t[e[0]]=e[1],t}),{})}function f(t,e){return e.map((function(e){return e.tokenX===t?{neighbour:e.tokenY,pool:e}:e.tokenY===t?{neighbour:e.tokenX,pool:e}:null})).filter(y)}function T(t,e,n){var r;if(0===n.length)return[];for(var o=((r={})[t]=[],r),i=0;i<4;i++)for(var a,u=Object.keys(o).map((function(t){return t})),c=p(u);!(a=c()).done;)for(var l,s=a.value,y=p(f(s,n));!(l=y()).done;){var m,T,d=l.value;if(d.neighbour===e)return[].concat(null!=(m=o[s])?m:[],[d]);null==o[d.neighbour]&&(o[d.neighbour]=[].concat(null!=(T=o[s])?T:[],[d]))}return[]}var d=function(t,e,n,r){var o=l[t][e].input.map((function(t){return t.type.encode(n[t.name])}));return{contractName:t,functionName:String(e),functionArgs:o,contractAddress:s.CONTRACT_DEPLOYER,postConditions:r}};function h(e,n,r,o,i,a,p){var u=function(t){return p.find((function(e){return e.id===t})).wrapToken.split("::")[0]},c=s.CONTRACT_DEPLOYER+".amm-vault-v2-01",l=T(n,r,a);if(0===l.length)throw new Error("Can't find AMM route");var y,m=(y=p,function(e,n,r,o){void 0===o&&(o=t.FungibleConditionCode.Equal);var i=y.find((function(t){return t.id===n}));if(!i)throw new Error("Token mapping not found");var a=BigInt(Math.pow(10,i.underlyingTokenDecimals)),p=r*BigInt(a)/BigInt(1e8);return n===exports.Currency.STX?t.createSTXPostCondition(e,o,p):t.createFungiblePostCondition(e,o,p,i.underlyingToken)});if(1===l.length)return d("amm-pool-v2-01","swap-helper",{"token-x-trait":u(n),"token-y-trait":u(l[0].neighbour),factor:l[0].pool.factor,dx:o,"min-dy":i},[m(e,n,o),m(c,r,i,t.FungibleConditionCode.GreaterEqual)]);if(2===l.length)return d("amm-pool-v2-01","swap-helper-a",{"token-x-trait":u(n),"token-y-trait":u(l[0].neighbour),"token-z-trait":u(l[1].neighbour),"factor-x":l[0].pool.factor,"factor-y":l[1].pool.factor,dx:o,"min-dz":i},[m(e,n,o),m(c,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,r,i,t.FungibleConditionCode.GreaterEqual)]);if(3===l.length)return d("amm-pool-v2-01","swap-helper-b",{"token-x-trait":u(n),"token-y-trait":u(l[0].neighbour),"token-z-trait":u(l[1].neighbour),"token-w-trait":u(l[2].neighbour),"factor-x":l[0].pool.factor,"factor-y":l[1].pool.factor,"factor-z":l[2].pool.factor,dx:o,"min-dw":i},[m(e,n,o),m(c,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,l[1].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[1].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,r,i,t.FungibleConditionCode.GreaterEqual)]);if(4===l.length)return d("amm-pool-v2-01","swap-helper-c",{"token-x-trait":u(n),"token-y-trait":u(l[0].neighbour),"token-z-trait":u(l[1].neighbour),"token-w-trait":u(l[2].neighbour),"token-v-trait":u(l[3].neighbour),"factor-x":l[0].pool.factor,"factor-y":l[1].pool.factor,"factor-z":l[2].pool.factor,"factor-w":l[3].pool.factor,dx:o,"min-dv":i},[m(e,n,o),m(c,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,l[1].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[1].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,l[2].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[2].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,r,i,t.FungibleConditionCode.GreaterEqual)]);throw new Error("Too many AMM pools in route")}var g=function(){var e=a(c().mark((function e(r){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callReadOnlyFunction(u({},r,{senderAddress:s.CONTRACT_DEPLOYER,network:new n.StacksMainnet({url:s.READONLY_CALL_API_HOST})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function k(t,e,n){return x.apply(this,arguments)}function x(){return(x=a(c().mark((function t(e,n,r){var o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=(o=l[e][n]).input.map((function(t){return t.type.encode(r[t.name])})),t.next=4,g({contractName:e,functionName:String(n),functionArgs:i,contractAddress:s.CONTRACT_DEPLOYER});case 4:return t.abrupt("return",o.output.decode(t.sent));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function b(t,e,n,r){return v.apply(this,arguments)}function v(){return(v=a(c().mark((function t(n,r,o,i){var a;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(a=T(n,r,o)).length){t.next=3;break}throw new Error("No AMM pools in route");case 3:if(1!==a.length){t.next=7;break}return t.next=6,k("amm-pool-v2-01","fee-helper",{"token-x":i(n),"token-y":i(r),factor:a[0].pool.factor}).then(e.unwrapResponse);case 6:case 10:case 14:case 18:return t.abrupt("return",t.sent);case 7:if(2!==a.length){t.next=11;break}return t.next=10,k("amm-pool-v2-01","fee-helper-a",{"token-x":i(n),"token-y":i(a[0].neighbour),"token-z":i(a[1].neighbour),"factor-x":a[0].pool.factor,"factor-y":a[1].pool.factor}).then(e.unwrapResponse);case 11:if(3!==a.length){t.next=15;break}return t.next=14,k("amm-pool-v2-01","fee-helper-b",{"token-x":i(n),"token-y":i(a[0].neighbour),"token-z":i(a[1].neighbour),"token-w":i(a[2].neighbour),"factor-x":a[0].pool.factor,"factor-y":a[1].pool.factor,"factor-z":a[2].pool.factor}).then(e.unwrapResponse);case 15:if(4!==a.length){t.next=19;break}return t.next=18,k("amm-pool-v2-01","fee-helper-c",{"token-x":i(n),"token-y":i(a[0].neighbour),"token-z":i(a[1].neighbour),"token-w":i(a[2].neighbour),"token-v":i(a[3].neighbour),"factor-x":a[0].pool.factor,"factor-y":a[1].pool.factor,"factor-z":a[2].pool.factor,"factor-w":a[3].pool.factor}).then(e.unwrapResponse);case 19:throw new Error("Too many AMM pools in route");case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function w(){return S.apply(this,arguments)}function S(){return(S=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",fetch("https://alex-sdk-api.alexlab.co").then((function(t){if(t.ok)return t.json();throw new Error("Failed to fetch token mappings")})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function C(t){return E.apply(this,arguments)}function E(){return(E=a(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",fetch(s.API_HOST+"/v2/public/token-prices").then((function(t){if(t.ok)return t.json();throw new Error("Failed to fetch token mappings")})).then((function(t){return t.data.map((function(t){var n,r=null==(n=e.find((function(e){return e.underlyingToken.split("::")[0]===t.contract_id})))?void 0:n.id;return null==r?null:{token:r,price:t.last_price_usd}})).filter(y)})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function A(t,e){return I.apply(this,arguments)}function I(){return(I=a(c().mark((function t(e,n){var r;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(s.STACKS_API_HOST+"/extended/v1/address/"+e+"/balances").then((function(t){return t.json()}));case 2:return r=t.sent,t.abrupt("return",m(n.map((function(t){var e;if(t.id===exports.Currency.STX)return[t.id,BigInt(r.stx.balance)*BigInt(100)];var n=null==(e=r.fungible_tokens[t.underlyingToken.split("::")[0]])?void 0:e.balance;return null==n?[t.id,BigInt(0)]:[t.id,BigInt(n)*BigInt(1e8)/BigInt(Math.pow(10,t.underlyingTokenDecimals))]}))));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function L(t,e,n){return O.apply(this,arguments)}function O(){return(O=a(c().mark((function t(e,n,r){var o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((o=T(e,n,r)).length>0)){t.next=3;break}return t.abrupt("return",[e].concat(o.map((function(t){return t.neighbour}))));case 3:throw new Error("Can't find route");case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var _=function(){var t=a(c().mark((function t(n,r,o,i,a){var p;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(p=T(n,r,i)).length){t.next=3;break}throw new Error("No AMM pool found for the given route");case 3:if(1!==p.length){t.next=7;break}return t.next=6,k("amm-pool-v2-01","get-helper",{"token-x":a(n),"token-y":a(p[0].neighbour),dx:o,factor:p[0].pool.factor}).then(e.unwrapResponse);case 6:case 10:case 14:case 18:return t.abrupt("return",t.sent);case 7:if(2!==p.length){t.next=11;break}return t.next=10,k("amm-pool-v2-01","get-helper-a",{"token-x":a(n),"token-y":a(p[0].neighbour),"token-z":a(p[1].neighbour),"factor-x":p[0].pool.factor,"factor-y":p[1].pool.factor,dx:o}).then(e.unwrapResponse);case 11:if(3!==p.length){t.next=15;break}return t.next=14,k("amm-pool-v2-01","get-helper-b",{"token-x":a(n),"token-y":a(p[0].neighbour),"token-z":a(p[1].neighbour),"token-w":a(p[2].neighbour),"factor-x":p[0].pool.factor,"factor-y":p[1].pool.factor,"factor-z":p[2].pool.factor,dx:o}).then(e.unwrapResponse);case 15:if(4!==p.length){t.next=19;break}return t.next=18,k("amm-pool-v2-01","get-helper-c",{"token-x":a(n),"token-y":a(p[0].neighbour),"token-z":a(p[1].neighbour),"token-w":a(p[2].neighbour),"token-v":a(p[3].neighbour),"factor-x":p[0].pool.factor,"factor-y":p[1].pool.factor,"factor-z":p[2].pool.factor,"factor-w":p[3].pool.factor,dx:o}).then(e.unwrapResponse);case 19:throw new Error("Too many AMM pools in route");case 20:case"end":return t.stop()}}),t)})));return function(e,n,r,o,i){return t.apply(this,arguments)}}();exports.AlexSDK=function(){function t(){this.alexSDKData=void 0}var e=t.prototype;return e.getAlexSDKData=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null==this.alexSDKData&&(this.alexSDKData=w()),t.abrupt("return",this.alexSDKData);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getTokenInfos=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAlexSDKData();case 2:return t.abrupt("return",t.sent.tokens);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getTokenMappings=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=m,t.next=3,this.getTokenInfos();case 3:return t.t1=t.sent.map((function(t){return[t.id,t]})),t.abrupt("return",(0,t.t0)(t.t1));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getContractId=function(){var t=a(c().mark((function t(){var e;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getTokenMappings();case 2:return e=t.sent,t.abrupt("return",(function(t){return e[t].wrapToken.split("::")[0]}));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getPools=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAlexSDKData();case 2:return t.abrupt("return",t.sent.pools);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.fetchSwappableCurrency=function(){return this.getTokenInfos()},e.getPrices=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=C,t.next=3,this.getTokenInfos();case 3:return t.t1=t.sent,t.abrupt("return",(0,t.t0)(t.t1));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getFeeRate=function(){var t=a(c().mark((function t(e,n){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=b,t.t1=e,t.t2=n,t.next=5,this.getPools();case 5:return t.t3=t.sent,t.next=8,this.getContractId();case 8:return t.t4=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3,t.t4));case 10:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.getRouter=function(){var t=a(c().mark((function t(e,n){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=L,t.t1=e,t.t2=n,t.next=5,this.getPools();case 5:return t.t3=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3));case 7:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.getAmountTo=function(){var t=a(c().mark((function t(e,n,r){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=_,t.t1=e,t.t2=r,t.t3=n,t.next=6,this.getPools();case 6:return t.t4=t.sent,t.next=9,this.getContractId();case 9:return t.t5=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3,t.t4,t.t5));case 11:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),e.runSwap=function(){var t=a(c().mark((function t(e,n,r,o,i){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=h,t.t1=e,t.t2=n,t.t3=r,t.t4=o,t.t5=i,t.next=8,this.getPools();case 8:return t.t6=t.sent,t.next=11,this.getTokenInfos();case 11:return t.t7=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3,t.t4,t.t5,t.t6,t.t7));case 13:case"end":return t.stop()}}),t,this)})));return function(e,n,r,o,i){return t.apply(this,arguments)}}(),e.getLatestPrices=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPrices();case 2:return t.abrupt("return",m(t.sent.map((function(t){return[t.token,t.price]}))));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getBalances=function(){var t=a(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=A,t.t1=e,t.next=4,this.getTokenInfos();case 4:return t.t2=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2));case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@stacks/transactions"),e=require("clarity-codegen"),n=require("@stacks/network");function r(t){return t}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function i(t,e,n,r,o,i,a){try{var p=t[i](a),u=p.value}catch(t){return void n(t)}p.done?e(u):Promise.resolve(u).then(r,o)}function a(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var a=t.apply(e,n);function p(t){i(a,r,o,p,u,"next",t)}function u(t){i(a,r,o,p,u,"throw",t)}p(void 0)}))}}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(){return u=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},u.apply(null,arguments)}function c(){c=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",p=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function s(t,e,n,r){var i=Object.create((e&&e.prototype instanceof g?e:g).prototype),a=new _(r||[]);return o(i,"_invoke",{value:A(t,n,a)}),i}function y(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var m="suspendedStart",f="suspendedYield",T="executing",d="completed",h={};function g(){}function k(){}function x(){}var b={};l(b,a,(function(){return this}));var v=Object.getPrototypeOf,w=v&&v(v(P([])));w&&w!==n&&r.call(w,a)&&(b=w);var S=x.prototype=g.prototype=Object.create(b);function C(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function n(o,i,a,p){var u=y(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,p)}),(function(t){n("throw",t,a,p)})):e.resolve(l).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,p)}))}p(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function A(e,n,r){var o=m;return function(i,a){if(o===T)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var p=r.delegate;if(p){var u=I(p,r);if(u){if(u===h)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===m)throw o=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=T;var c=y(e,n,r);if("normal"===c.type){if(o=r.done?d:f,c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=d,r.method="throw",r.arg=c.arg)}}}function I(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,I(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=y(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,h;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,h):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,h)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function P(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return k.prototype=x,o(S,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:k,configurable:!0}),k.displayName=l(x,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===k||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,l(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},C(E.prototype),l(E.prototype,p,(function(){return this})),e.AsyncIterator=E,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new E(s(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},C(S),l(S,u,"Generator"),l(S,a,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=P,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(O),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return p.type="throw",p.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],p=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:P(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),h}},e}exports.Currency=void 0,(exports.Currency||(exports.Currency={})).STX=r("token-wstx");var l=e.defineContract(u({},e.defineContract({"amm-pool-v2-01":{"add-to-position":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT},{name:"max-dy",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT,supply:e.uintT})),mode:"public"},"create-pool":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"pool-owner",type:e.principalT},{name:"dx",type:e.uintT},{name:"dy",type:e.uintT}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT,supply:e.uintT})),mode:"public"},pause:{input:[{name:"new-paused",type:e.booleanT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"reduce-position":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"percent",type:e.uintT}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"public"},"set-end-block":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-end-block",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-fee-rate-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"fee-rate-x",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-fee-rate-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"fee-rate-y",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-max-in-ratio":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-max-in-ratio",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-max-out-ratio":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-max-out-ratio",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-oracle-average":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-oracle-average",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-oracle-enabled":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"enabled",type:e.booleanT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-start-block":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-start-block",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-threshold-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-threshold",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"set-threshold-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"new-threshold",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"public"},"swap-helper":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dy",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.uintT),mode:"public"},"swap-helper-a":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"token-z-trait",type:e.traitT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dz",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.uintT),mode:"public"},"swap-helper-b":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"token-z-trait",type:e.traitT},{name:"token-w-trait",type:e.traitT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dw",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.uintT),mode:"public"},"swap-helper-c":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"token-z-trait",type:e.traitT},{name:"token-w-trait",type:e.traitT},{name:"token-v-trait",type:e.traitT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"factor-w",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dv",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.uintT),mode:"public"},"swap-x-for-y":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT},{name:"min-dy",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"public"},"swap-y-for-x":{input:[{name:"token-x-trait",type:e.traitT},{name:"token-y-trait",type:e.traitT},{name:"factor",type:e.uintT},{name:"dy",type:e.uintT},{name:"min-dx",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"public"},"check-pool-status":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"readonly"},"fee-helper":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"fee-helper-a":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"fee-helper-b":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"token-w",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"fee-helper-c":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"token-w",type:e.principalT},{name:"token-v",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"factor-w",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-balances":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.tupleT({"balance-x":e.uintT,"balance-y":e.uintT})),mode:"readonly"},"get-end-block":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-fee-rate-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-fee-rate-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-fee-rebate":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-helper":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-helper-a":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-helper-b":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"token-w",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-helper-c":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"token-z",type:e.principalT},{name:"token-w",type:e.principalT},{name:"token-v",type:e.principalT},{name:"factor-x",type:e.uintT},{name:"factor-y",type:e.uintT},{name:"factor-z",type:e.uintT},{name:"factor-w",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-invariant":{input:[{name:"balance-x",type:e.uintT},{name:"balance-y",type:e.uintT},{name:"t",type:e.uintT}],output:e.uintT,mode:"readonly"},"get-max-in-ratio":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-max-out-ratio":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-max-ratio-limit":{input:[],output:e.uintT,mode:"readonly"},"get-oracle-average":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-oracle-enabled":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.booleanT),mode:"readonly"},"get-oracle-instant":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-oracle-resilient":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-pool-details":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.tupleT({"balance-x":e.uintT,"balance-y":e.uintT,"end-block":e.uintT,"fee-rate-x":e.uintT,"fee-rate-y":e.uintT,"fee-rebate":e.uintT,"max-in-ratio":e.uintT,"max-out-ratio":e.uintT,"oracle-average":e.uintT,"oracle-enabled":e.booleanT,"oracle-resilient":e.uintT,"pool-id":e.uintT,"pool-owner":e.principalT,"start-block":e.uintT,"threshold-x":e.uintT,"threshold-y":e.uintT,"total-supply":e.uintT})),mode:"readonly"},"get-pool-details-by-id":{input:[{name:"pool-id",type:e.uintT}],output:e.responseSimpleT(e.tupleT({factor:e.uintT,"token-x":e.principalT,"token-y":e.principalT})),mode:"readonly"},"get-pool-exists":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.optionalT(e.tupleT({"balance-x":e.uintT,"balance-y":e.uintT,"end-block":e.uintT,"fee-rate-x":e.uintT,"fee-rate-y":e.uintT,"fee-rebate":e.uintT,"max-in-ratio":e.uintT,"max-out-ratio":e.uintT,"oracle-average":e.uintT,"oracle-enabled":e.booleanT,"oracle-resilient":e.uintT,"pool-id":e.uintT,"pool-owner":e.principalT,"start-block":e.uintT,"threshold-x":e.uintT,"threshold-y":e.uintT,"total-supply":e.uintT})),mode:"readonly"},"get-pool-owner":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.principalT),mode:"readonly"},"get-position-given-burn":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"token-amount",type:e.uintT}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"readonly"},"get-position-given-mint":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"token-amount",type:e.uintT}],output:e.responseSimpleT(e.tupleT({dx:e.uintT,dy:e.uintT})),mode:"readonly"},"get-price":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-start-block":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-switch-threshold":{input:[],output:e.uintT,mode:"readonly"},"get-threshold-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-threshold-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-token-given-position":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT},{name:"max-dy",type:e.optionalT(e.uintT)}],output:e.responseSimpleT(e.tupleT({dy:e.uintT,token:e.uintT})),mode:"readonly"},"get-x-given-price":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"price",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-x-given-y":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dy",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-x-in-given-y-out":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dy",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-y-given-price":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"price",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-y-given-x":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"get-y-in-given-x-out":{input:[{name:"token-x",type:e.principalT},{name:"token-y",type:e.principalT},{name:"factor",type:e.uintT},{name:"dx",type:e.uintT}],output:e.responseSimpleT(e.uintT),mode:"readonly"},"is-blocklisted-or-default":{input:[{name:"sender",type:e.principalT}],output:e.booleanT,mode:"readonly"},"is-dao-or-extension":{input:[],output:e.responseSimpleT(e.booleanT),mode:"readonly"},"is-paused":{input:[],output:e.booleanT,mode:"readonly"},paused:{input:e.noneT,output:e.booleanT,mode:"variable"}}}))),s={CONTRACT_DEPLOYER:"SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM",API_HOST:"https://api.alexgo.io",STACKS_API_HOST:"https://api.hiro.so",READONLY_CALL_API_HOST:"https://stacks-node.alexlab.co"};function y(t){return null!=t}function m(t){return t.reduce((function(t,e){return t[e[0]]=e[1],t}),{})}function f(t,e){return e.map((function(e){return e.tokenX===t?{neighbour:e.tokenY,pool:e}:e.tokenY===t?{neighbour:e.tokenX,pool:e}:null})).filter(y)}function T(t,e,n){var r;if(0===n.length)return[];for(var o=((r={})[t]=[],r),i=0;i<4;i++)for(var a,u=Object.keys(o).map((function(t){return t})),c=p(u);!(a=c()).done;)for(var l,s=a.value,y=p(f(s,n));!(l=y()).done;){var m,T,d=l.value;if(d.neighbour===e)return[].concat(null!=(m=o[s])?m:[],[d]);null==o[d.neighbour]&&(o[d.neighbour]=[].concat(null!=(T=o[s])?T:[],[d]))}return[]}var d=function(t,e,n,r){var o=l[t][e].input.map((function(t){return t.type.encode(n[t.name])}));return{contractName:t,functionName:String(e),functionArgs:o,contractAddress:s.CONTRACT_DEPLOYER,postConditions:r}};function h(e,n,r,o,i,a,p){var u=function(t){return p.find((function(e){return e.id===t})).wrapToken.split("::")[0]},c=s.CONTRACT_DEPLOYER+".amm-vault-v2-01",l=T(n,r,a);if(0===l.length)throw new Error("Can't find AMM route");var y,m=(y=p,function(e,n,r,o){void 0===o&&(o=t.FungibleConditionCode.Equal);var i=y.find((function(t){return t.id===n}));if(!i)throw new Error("Token mapping not found");var a=BigInt(Math.pow(10,i.underlyingTokenDecimals)),p=r*BigInt(a)/BigInt(1e8);return n===exports.Currency.STX?t.createSTXPostCondition(e,o,p):(i.isRebaseToken&&(o=t.FungibleConditionCode.GreaterEqual,p=BigInt(0)),t.createFungiblePostCondition(e,o,p,i.underlyingToken))});if(1===l.length)return d("amm-pool-v2-01","swap-helper",{"token-x-trait":u(n),"token-y-trait":u(l[0].neighbour),factor:l[0].pool.factor,dx:o,"min-dy":i},[m(e,n,o),m(c,r,i,t.FungibleConditionCode.GreaterEqual)]);if(2===l.length)return d("amm-pool-v2-01","swap-helper-a",{"token-x-trait":u(n),"token-y-trait":u(l[0].neighbour),"token-z-trait":u(l[1].neighbour),"factor-x":l[0].pool.factor,"factor-y":l[1].pool.factor,dx:o,"min-dz":i},[m(e,n,o),m(c,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,r,i,t.FungibleConditionCode.GreaterEqual)]);if(3===l.length)return d("amm-pool-v2-01","swap-helper-b",{"token-x-trait":u(n),"token-y-trait":u(l[0].neighbour),"token-z-trait":u(l[1].neighbour),"token-w-trait":u(l[2].neighbour),"factor-x":l[0].pool.factor,"factor-y":l[1].pool.factor,"factor-z":l[2].pool.factor,dx:o,"min-dw":i},[m(e,n,o),m(c,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,l[1].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[1].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,r,i,t.FungibleConditionCode.GreaterEqual)]);if(4===l.length)return d("amm-pool-v2-01","swap-helper-c",{"token-x-trait":u(n),"token-y-trait":u(l[0].neighbour),"token-z-trait":u(l[1].neighbour),"token-w-trait":u(l[2].neighbour),"token-v-trait":u(l[3].neighbour),"factor-x":l[0].pool.factor,"factor-y":l[1].pool.factor,"factor-z":l[2].pool.factor,"factor-w":l[3].pool.factor,dx:o,"min-dv":i},[m(e,n,o),m(c,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[0].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,l[1].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[1].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,l[2].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(e,l[2].neighbour,BigInt(0),t.FungibleConditionCode.GreaterEqual),m(c,r,i,t.FungibleConditionCode.GreaterEqual)]);throw new Error("Too many AMM pools in route")}var g=function(){var e=a(c().mark((function e(r){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callReadOnlyFunction(u({},r,{senderAddress:s.CONTRACT_DEPLOYER,network:new n.StacksMainnet({url:s.READONLY_CALL_API_HOST})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function k(t,e,n){return x.apply(this,arguments)}function x(){return(x=a(c().mark((function t(e,n,r){var o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=(o=l[e][n]).input.map((function(t){return t.type.encode(r[t.name])})),t.next=4,g({contractName:e,functionName:String(n),functionArgs:i,contractAddress:s.CONTRACT_DEPLOYER});case 4:return t.abrupt("return",o.output.decode(t.sent));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function b(t,e,n,r){return v.apply(this,arguments)}function v(){return(v=a(c().mark((function t(n,r,o,i){var a;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(a=T(n,r,o)).length){t.next=3;break}throw new Error("No AMM pools in route");case 3:if(1!==a.length){t.next=7;break}return t.next=6,k("amm-pool-v2-01","fee-helper",{"token-x":i(n),"token-y":i(r),factor:a[0].pool.factor}).then(e.unwrapResponse);case 6:case 10:case 14:case 18:return t.abrupt("return",t.sent);case 7:if(2!==a.length){t.next=11;break}return t.next=10,k("amm-pool-v2-01","fee-helper-a",{"token-x":i(n),"token-y":i(a[0].neighbour),"token-z":i(a[1].neighbour),"factor-x":a[0].pool.factor,"factor-y":a[1].pool.factor}).then(e.unwrapResponse);case 11:if(3!==a.length){t.next=15;break}return t.next=14,k("amm-pool-v2-01","fee-helper-b",{"token-x":i(n),"token-y":i(a[0].neighbour),"token-z":i(a[1].neighbour),"token-w":i(a[2].neighbour),"factor-x":a[0].pool.factor,"factor-y":a[1].pool.factor,"factor-z":a[2].pool.factor}).then(e.unwrapResponse);case 15:if(4!==a.length){t.next=19;break}return t.next=18,k("amm-pool-v2-01","fee-helper-c",{"token-x":i(n),"token-y":i(a[0].neighbour),"token-z":i(a[1].neighbour),"token-w":i(a[2].neighbour),"token-v":i(a[3].neighbour),"factor-x":a[0].pool.factor,"factor-y":a[1].pool.factor,"factor-z":a[2].pool.factor,"factor-w":a[3].pool.factor}).then(e.unwrapResponse);case 19:throw new Error("Too many AMM pools in route");case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function w(){return S.apply(this,arguments)}function S(){return(S=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",fetch("https://alex-sdk-api.alexlab.co").then((function(t){if(t.ok)return t.json();throw new Error("Failed to fetch token mappings")})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function C(t){return E.apply(this,arguments)}function E(){return(E=a(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",fetch(s.API_HOST+"/v2/public/token-prices").then((function(t){if(t.ok)return t.json();throw new Error("Failed to fetch token mappings")})).then((function(t){return t.data.map((function(t){var n,r=null==(n=e.find((function(e){return e.underlyingToken.split("::")[0]===t.contract_id})))?void 0:n.id;return null==r?null:{token:r,price:t.last_price_usd}})).filter(y)})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function A(t,e){return I.apply(this,arguments)}function I(){return I=a(c().mark((function r(o,i){var p;return c().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fetch(s.STACKS_API_HOST+"/extended/v1/address/"+o+"/balances").then((function(t){return t.json()}));case 2:return p=r.sent,r.t0=m,r.next=6,Promise.all(i.map(function(){var r=a(c().mark((function r(i){var a,u,l,y,m,f,T;return c().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!i.isRebaseToken){r.next=7;break}return u=i.underlyingToken.split("::")[0].split("."),l=u[0],y=u[1],r.next=4,t.callReadOnlyFunction({senderAddress:o,contractAddress:l,contractName:y,functionName:"get-balance",functionArgs:[e.principalCV(o)],network:new n.StacksMainnet({url:s.READONLY_CALL_API_HOST})});case 4:return m=r.sent,f=e.unwrapResponse(e.responseSimpleT(e.uintT).decode(m)),r.abrupt("return",[i.id,BigInt(f)*BigInt(1e8)/BigInt(Math.pow(10,i.underlyingTokenDecimals))]);case 7:if(i.id!==exports.Currency.STX){r.next=9;break}return r.abrupt("return",[i.id,BigInt(p.stx.balance)*BigInt(100)]);case 9:if(null!=(T=null==(a=p.fungible_tokens[i.underlyingToken.split("::")[0]])?void 0:a.balance)){r.next=12;break}return r.abrupt("return",[i.id,BigInt(0)]);case 12:return r.abrupt("return",[i.id,BigInt(T)*BigInt(1e8)/BigInt(Math.pow(10,i.underlyingTokenDecimals))]);case 13:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}()));case 6:return r.t1=r.sent,r.abrupt("return",(0,r.t0)(r.t1));case 8:case"end":return r.stop()}}),r)}))),I.apply(this,arguments)}function L(t,e,n){return O.apply(this,arguments)}function O(){return(O=a(c().mark((function t(e,n,r){var o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((o=T(e,n,r)).length>0)){t.next=3;break}return t.abrupt("return",[e].concat(o.map((function(t){return t.neighbour}))));case 3:throw new Error("Can't find route");case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var _=function(){var t=a(c().mark((function t(n,r,o,i,a){var p;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(p=T(n,r,i)).length){t.next=3;break}throw new Error("No AMM pool found for the given route");case 3:if(1!==p.length){t.next=7;break}return t.next=6,k("amm-pool-v2-01","get-helper",{"token-x":a(n),"token-y":a(p[0].neighbour),dx:o,factor:p[0].pool.factor}).then(e.unwrapResponse);case 6:case 10:case 14:case 18:return t.abrupt("return",t.sent);case 7:if(2!==p.length){t.next=11;break}return t.next=10,k("amm-pool-v2-01","get-helper-a",{"token-x":a(n),"token-y":a(p[0].neighbour),"token-z":a(p[1].neighbour),"factor-x":p[0].pool.factor,"factor-y":p[1].pool.factor,dx:o}).then(e.unwrapResponse);case 11:if(3!==p.length){t.next=15;break}return t.next=14,k("amm-pool-v2-01","get-helper-b",{"token-x":a(n),"token-y":a(p[0].neighbour),"token-z":a(p[1].neighbour),"token-w":a(p[2].neighbour),"factor-x":p[0].pool.factor,"factor-y":p[1].pool.factor,"factor-z":p[2].pool.factor,dx:o}).then(e.unwrapResponse);case 15:if(4!==p.length){t.next=19;break}return t.next=18,k("amm-pool-v2-01","get-helper-c",{"token-x":a(n),"token-y":a(p[0].neighbour),"token-z":a(p[1].neighbour),"token-w":a(p[2].neighbour),"token-v":a(p[3].neighbour),"factor-x":p[0].pool.factor,"factor-y":p[1].pool.factor,"factor-z":p[2].pool.factor,"factor-w":p[3].pool.factor,dx:o}).then(e.unwrapResponse);case 19:throw new Error("Too many AMM pools in route");case 20:case"end":return t.stop()}}),t)})));return function(e,n,r,o,i){return t.apply(this,arguments)}}();exports.AlexSDK=function(){function t(){this.alexSDKData=void 0}var e=t.prototype;return e.getAlexSDKData=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null==this.alexSDKData&&(this.alexSDKData=w()),t.abrupt("return",this.alexSDKData);case 2:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getTokenInfos=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAlexSDKData();case 2:return t.abrupt("return",t.sent.tokens);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getTokenMappings=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=m,t.next=3,this.getTokenInfos();case 3:return t.t1=t.sent.map((function(t){return[t.id,t]})),t.abrupt("return",(0,t.t0)(t.t1));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getContractId=function(){var t=a(c().mark((function t(){var e;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getTokenMappings();case 2:return e=t.sent,t.abrupt("return",(function(t){return e[t].wrapToken.split("::")[0]}));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getPools=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAlexSDKData();case 2:return t.abrupt("return",t.sent.pools);case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.fetchSwappableCurrency=function(){return this.getTokenInfos()},e.getPrices=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=C,t.next=3,this.getTokenInfos();case 3:return t.t1=t.sent,t.abrupt("return",(0,t.t0)(t.t1));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getFeeRate=function(){var t=a(c().mark((function t(e,n){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=b,t.t1=e,t.t2=n,t.next=5,this.getPools();case 5:return t.t3=t.sent,t.next=8,this.getContractId();case 8:return t.t4=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3,t.t4));case 10:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.getRouter=function(){var t=a(c().mark((function t(e,n){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=L,t.t1=e,t.t2=n,t.next=5,this.getPools();case 5:return t.t3=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3));case 7:case"end":return t.stop()}}),t,this)})));return function(e,n){return t.apply(this,arguments)}}(),e.getAmountTo=function(){var t=a(c().mark((function t(e,n,r){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=_,t.t1=e,t.t2=r,t.t3=n,t.next=6,this.getPools();case 6:return t.t4=t.sent,t.next=9,this.getContractId();case 9:return t.t5=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3,t.t4,t.t5));case 11:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),e.runSwap=function(){var t=a(c().mark((function t(e,n,r,o,i){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=h,t.t1=e,t.t2=n,t.t3=r,t.t4=o,t.t5=i,t.next=8,this.getPools();case 8:return t.t6=t.sent,t.next=11,this.getTokenInfos();case 11:return t.t7=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3,t.t4,t.t5,t.t6,t.t7));case 13:case"end":return t.stop()}}),t,this)})));return function(e,n,r,o,i){return t.apply(this,arguments)}}(),e.getLatestPrices=function(){var t=a(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getPrices();case 2:return t.abrupt("return",m(t.sent.map((function(t){return[t.token,t.price]}))));case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getBalances=function(){var t=a(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=A,t.t1=e,t.next=4,this.getTokenInfos();case 4:return t.t2=t.sent,t.abrupt("return",(0,t.t0)(t.t1,t.t2));case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(); | ||
//# sourceMappingURL=alex-sdk.cjs.production.min.js.map |
export { Currency } from './currency'; | ||
export * from './alexSDK'; | ||
export { TokenInfo } from './types'; |
@@ -10,2 +10,3 @@ import { Currency } from './currency'; | ||
underlyingTokenDecimals: number; | ||
isRebaseToken: boolean; | ||
}; | ||
@@ -12,0 +13,0 @@ export type PoolData = { |
{ | ||
"version": "2.1.0", | ||
"version": "2.1.1-beta.1", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
export { Currency } from './currency'; | ||
export * from './alexSDK'; | ||
export { TokenInfo } from './types'; |
@@ -11,2 +11,3 @@ import { Currency } from './currency'; | ||
underlyingTokenDecimals: number; | ||
isRebaseToken: boolean; | ||
}; | ||
@@ -13,0 +14,0 @@ |
@@ -6,2 +6,10 @@ import { Currency } from '../currency'; | ||
import { AlexSDKResponse, PriceData, TokenInfo } from '../types'; | ||
import { callReadOnlyFunction } from '@stacks/transactions'; | ||
import { StacksMainnet } from '@stacks/network'; | ||
import { | ||
principalCV, | ||
responseSimpleT, | ||
uintT, | ||
unwrapResponse, | ||
} from 'clarity-codegen'; | ||
@@ -51,18 +59,44 @@ export async function getAlexSDKData(): Promise<AlexSDKResponse> { | ||
return fromEntries( | ||
tokenMappings.map((a) => { | ||
if (a.id === Currency.STX) { | ||
return [a.id, BigInt(response.stx.balance) * BigInt(100)]; | ||
} | ||
const fungibleToken = | ||
response.fungible_tokens[a.underlyingToken.split('::')[0]]?.balance; | ||
if (fungibleToken == null) { | ||
return [a.id, BigInt(0)]; | ||
} | ||
return [ | ||
a.id, | ||
(BigInt(fungibleToken) * BigInt(1e8)) / | ||
BigInt(10 ** a.underlyingTokenDecimals), | ||
]; | ||
}) | ||
await Promise.all( | ||
tokenMappings.map(async (a) => { | ||
if (a.isRebaseToken) { | ||
// call readonly functions to get the correct balance | ||
const [contractAddr, contractName] = a.underlyingToken | ||
.split('::')[0] | ||
.split('.'); | ||
const response = await callReadOnlyFunction({ | ||
senderAddress: stxAddress, | ||
contractAddress: contractAddr, | ||
contractName: contractName, | ||
functionName: 'get-balance', | ||
functionArgs: [principalCV(stxAddress)], | ||
network: new StacksMainnet({ | ||
url: configs.READONLY_CALL_API_HOST, | ||
}), | ||
}); | ||
const amount = unwrapResponse( | ||
responseSimpleT(uintT).decode(response) | ||
); | ||
return [ | ||
a.id, | ||
(BigInt(amount) * BigInt(1e8)) / | ||
BigInt(10 ** a.underlyingTokenDecimals), | ||
]; | ||
} | ||
if (a.id === Currency.STX) { | ||
return [a.id, BigInt(response.stx.balance) * BigInt(100)]; | ||
} | ||
const fungibleToken = | ||
response.fungible_tokens[a.underlyingToken.split('::')[0]]?.balance; | ||
if (fungibleToken == null) { | ||
return [a.id, BigInt(0)]; | ||
} | ||
return [ | ||
a.id, | ||
(BigInt(fungibleToken) * BigInt(1e8)) / | ||
BigInt(10 ** a.underlyingTokenDecimals), | ||
]; | ||
}) | ||
) | ||
); | ||
} |
@@ -24,6 +24,12 @@ import { | ||
const scale = BigInt(10 ** mapping.underlyingTokenDecimals); | ||
const nativeAmount = (amount * BigInt(scale)) / BigInt(1e8); | ||
let nativeAmount = (amount * BigInt(scale)) / BigInt(1e8); | ||
if (currency === Currency.STX) { | ||
return createSTXPostCondition(senderAddress, compare, nativeAmount); | ||
} | ||
if (mapping.isRebaseToken) { | ||
// Currently the rebase token's ft-amount is different from actual amount | ||
// We have to fallback to a weak PostCondition for them | ||
compare = FungibleConditionCode.GreaterEqual; | ||
nativeAmount = BigInt(0); | ||
} | ||
return createFungiblePostCondition( | ||
@@ -30,0 +36,0 @@ senderAddress, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
700837
9826
3