@galacticcouncil/sdk 0.0.4 → 0.0.5
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/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/errors.d.ts +3 -0
- package/dist/types/pool/lbp/lbpPool.d.ts +5 -1
- package/dist/types/pool/omni/omniMath.d.ts +3 -0
- package/dist/types/pool/omni/omniPolkadotApiClient.d.ts +4 -0
- package/dist/types/pool/omni/omniPool.d.ts +13 -3
- package/dist/types/types.d.ts +0 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Yt=Object.create;var Qe=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty;var Pt=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports),$t=(u,e)=>{for(var n in e)Qe(u,n,{get:e[n],enumerable:!0})},At=(u,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of Jt(e))!Vt.call(u,t)&&t!==n&&Qe(u,t,{get:()=>e[t],enumerable:!(o=zt(e,t))||o.enumerable});return u};var yt=(u,e,n)=>(n=u!=null?Yt(Kt(u)):{},At(e||!u||!u.__esModule?Qe(n,"default",{value:u,enumerable:!0}):n,u)),Zt=u=>At(Qe({},"__esModule",{value:!0}),u);var Lt=Pt((lo,De)=>{var tn={},S,{TextEncoder:nn,TextDecoder:on}=require("util"),V=0,it=null;function at(){return(it===null||it.buffer!==S.memory.buffer)&&(it=new Uint8Array(S.memory.buffer)),it}var lt=new nn("utf-8"),rn=typeof lt.encodeInto=="function"?function(u,e){return lt.encodeInto(u,e)}:function(u,e){let n=lt.encode(u);return e.set(n),{read:u.length,written:n.length}};function j(u,e,n){if(n===void 0){let l=lt.encode(u),b=e(l.length);return at().subarray(b,b+l.length).set(l),V=l.length,b}let o=u.length,t=e(o),i=at(),a=0;for(;a<o;a++){let l=u.charCodeAt(a);if(l>127)break;i[t+a]=l}if(a!==o){a!==0&&(u=u.slice(a)),t=n(t,o,o=a+u.length*3);let l=at().subarray(t+a,t+o);a+=rn(u,l).written}return V=a,t}var st=null;function xe(){return(st===null||st.buffer!==S.memory.buffer)&&(st=new Int32Array(S.memory.buffer)),st}var Mt=new on("utf-8",{ignoreBOM:!0,fatal:!0});Mt.decode();function Je(u,e){return Mt.decode(at().subarray(u,u+e))}De.exports.calculate_pool_trade_fee=function(u,e,n){try{let i=S.__wbindgen_add_to_stack_pointer(-16),a=j(u,S.__wbindgen_malloc,S.__wbindgen_realloc),l=V;S.calculate_pool_trade_fee(i,a,l,e,n);var o=xe()[i/4+0],t=xe()[i/4+1];return Je(o,t)}finally{S.__wbindgen_add_to_stack_pointer(16),S.__wbindgen_free(o,t)}};De.exports.get_spot_price=function(u,e,n,o,t){try{let l=S.__wbindgen_add_to_stack_pointer(-16),b=j(u,S.__wbindgen_malloc,S.__wbindgen_realloc),y=V,B=j(e,S.__wbindgen_malloc,S.__wbindgen_realloc),I=V,E=j(n,S.__wbindgen_malloc,S.__wbindgen_realloc),R=V,k=j(o,S.__wbindgen_malloc,S.__wbindgen_realloc),W=V,H=j(t,S.__wbindgen_malloc,S.__wbindgen_realloc),z=V;S.get_spot_price(l,b,y,B,I,E,R,k,W,H,z);var i=xe()[l/4+0],a=xe()[l/4+1];return Je(i,a)}finally{S.__wbindgen_add_to_stack_pointer(16),S.__wbindgen_free(i,a)}};De.exports.calculate_out_given_in=function(u,e,n,o,t){try{let l=S.__wbindgen_add_to_stack_pointer(-16),b=j(u,S.__wbindgen_malloc,S.__wbindgen_realloc),y=V,B=j(e,S.__wbindgen_malloc,S.__wbindgen_realloc),I=V,E=j(n,S.__wbindgen_malloc,S.__wbindgen_realloc),R=V,k=j(o,S.__wbindgen_malloc,S.__wbindgen_realloc),W=V,H=j(t,S.__wbindgen_malloc,S.__wbindgen_realloc),z=V;S.calculate_out_given_in(l,b,y,B,I,E,R,k,W,H,z);var i=xe()[l/4+0],a=xe()[l/4+1];return Je(i,a)}finally{S.__wbindgen_add_to_stack_pointer(16),S.__wbindgen_free(i,a)}};De.exports.calculate_in_given_out=function(u,e,n,o,t){try{let l=S.__wbindgen_add_to_stack_pointer(-16),b=j(u,S.__wbindgen_malloc,S.__wbindgen_realloc),y=V,B=j(e,S.__wbindgen_malloc,S.__wbindgen_realloc),I=V,E=j(n,S.__wbindgen_malloc,S.__wbindgen_realloc),R=V,k=j(o,S.__wbindgen_malloc,S.__wbindgen_realloc),W=V,H=j(t,S.__wbindgen_malloc,S.__wbindgen_realloc),z=V;S.calculate_in_given_out(l,b,y,B,I,E,R,k,W,H,z);var i=xe()[l/4+0],a=xe()[l/4+1];return Je(i,a)}finally{S.__wbindgen_add_to_stack_pointer(16),S.__wbindgen_free(i,a)}};De.exports.calculate_linear_weights=function(u,e,n,o,t){try{let l=S.__wbindgen_add_to_stack_pointer(-16),b=j(u,S.__wbindgen_malloc,S.__wbindgen_realloc),y=V,B=j(e,S.__wbindgen_malloc,S.__wbindgen_realloc),I=V,E=j(n,S.__wbindgen_malloc,S.__wbindgen_realloc),R=V,k=j(o,S.__wbindgen_malloc,S.__wbindgen_realloc),W=V,H=j(t,S.__wbindgen_malloc,S.__wbindgen_realloc),z=V;S.calculate_linear_weights(l,b,y,B,I,E,R,k,W,H,z);var i=xe()[l/4+0],a=xe()[l/4+1];return Je(i,a)}finally{S.__wbindgen_add_to_stack_pointer(16),S.__wbindgen_free(i,a)}};var sn=require("path").join(__dirname,"hydra_dx_wasm_bg.wasm"),an=require("fs").readFileSync(sn),ln=new WebAssembly.Module(an),cn=new WebAssembly.Instance(ln,tn);S=cn.exports;De.exports.__wasm=S});var qt=Pt((jo,ae)=>{var un={},f,{TextEncoder:_n,TextDecoder:pn}=require("util"),v=0,Nt=new Uint8Array;function pt(){return Nt.byteLength===0&&(Nt=new Uint8Array(f.memory.buffer)),Nt}var dt=new _n("utf-8"),dn=typeof dt.encodeInto=="function"?function(u,e){return dt.encodeInto(u,e)}:function(u,e){let n=dt.encode(u);return e.set(n),{read:u.length,written:n.length}};function F(u,e,n){if(n===void 0){let l=dt.encode(u),b=e(l.length);return pt().subarray(b,b+l.length).set(l),v=l.length,b}let o=u.length,t=e(o),i=pt(),a=0;for(;a<o;a++){let l=u.charCodeAt(a);if(l>127)break;i[t+a]=l}if(a!==o){a!==0&&(u=u.slice(a)),t=n(t,o,o=a+u.length*3);let l=pt().subarray(t+a,t+o);a+=dn(u,l).written}return v=a,t}var vt=new Int32Array;function ne(){return vt.byteLength===0&&(vt=new Int32Array(f.memory.buffer)),vt}var Ct=new pn("utf-8",{ignoreBOM:!0,fatal:!0});Ct.decode();function Ae(u,e){return Ct.decode(pt().subarray(u,u+e))}ae.exports.calculate_shares=function(u,e,n,o){try{let a=f.__wbindgen_add_to_stack_pointer(-16),l=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),b=v,y=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),B=v,I=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),E=v,R=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),k=v;f.calculate_shares(a,l,b,y,B,I,E,R,k);var t=ne()[a/4+0],i=ne()[a/4+1];return Ae(t,i)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(t,i)}};ae.exports.calculate_liquidity_out=function(u,e,n,o,t,i,a){try{let y=f.__wbindgen_add_to_stack_pointer(-16),B=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),I=v,E=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),R=v,k=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),W=v,H=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),z=v,x=F(t,f.__wbindgen_malloc,f.__wbindgen_realloc),oe=v,pe=F(i,f.__wbindgen_malloc,f.__wbindgen_realloc),D=v,G=F(a,f.__wbindgen_malloc,f.__wbindgen_realloc),Q=v;f.calculate_liquidity_out(y,B,I,E,R,k,W,H,z,x,oe,pe,D,G,Q);var l=ne()[y/4+0],b=ne()[y/4+1];return Ae(l,b)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(l,b)}};ae.exports.calculate_liquidity_lrna_out=function(u,e,n,o,t,i,a){try{let y=f.__wbindgen_add_to_stack_pointer(-16),B=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),I=v,E=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),R=v,k=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),W=v,H=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),z=v,x=F(t,f.__wbindgen_malloc,f.__wbindgen_realloc),oe=v,pe=F(i,f.__wbindgen_malloc,f.__wbindgen_realloc),D=v,G=F(a,f.__wbindgen_malloc,f.__wbindgen_realloc),Q=v;f.calculate_liquidity_lrna_out(y,B,I,E,R,k,W,H,z,x,oe,pe,D,G,Q);var l=ne()[y/4+0],b=ne()[y/4+1];return Ae(l,b)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(l,b)}};ae.exports.calculate_out_given_in=function(u,e,n,o,t,i,a,l,b){try{let I=f.__wbindgen_add_to_stack_pointer(-16),E=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),R=v,k=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),W=v,H=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),z=v,x=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),oe=v,pe=F(t,f.__wbindgen_malloc,f.__wbindgen_realloc),D=v,G=F(i,f.__wbindgen_malloc,f.__wbindgen_realloc),Q=v,r=F(a,f.__wbindgen_malloc,f.__wbindgen_realloc),s=v,c=F(l,f.__wbindgen_malloc,f.__wbindgen_realloc),m=v,p=F(b,f.__wbindgen_malloc,f.__wbindgen_realloc),g=v;f.calculate_out_given_in(I,E,R,k,W,H,z,x,oe,pe,D,G,Q,r,s,c,m,p,g);var y=ne()[I/4+0],B=ne()[I/4+1];return Ae(y,B)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(y,B)}};ae.exports.calculate_in_given_out=function(u,e,n,o,t,i,a,l,b){try{let I=f.__wbindgen_add_to_stack_pointer(-16),E=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),R=v,k=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),W=v,H=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),z=v,x=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),oe=v,pe=F(t,f.__wbindgen_malloc,f.__wbindgen_realloc),D=v,G=F(i,f.__wbindgen_malloc,f.__wbindgen_realloc),Q=v,r=F(a,f.__wbindgen_malloc,f.__wbindgen_realloc),s=v,c=F(l,f.__wbindgen_malloc,f.__wbindgen_realloc),m=v,p=F(b,f.__wbindgen_malloc,f.__wbindgen_realloc),g=v;f.calculate_in_given_out(I,E,R,k,W,H,z,x,oe,pe,D,G,Q,r,s,c,m,p,g);var y=ne()[I/4+0],B=ne()[I/4+1];return Ae(y,B)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(y,B)}};ae.exports.calculate_spot_price=function(u,e,n,o){try{let a=f.__wbindgen_add_to_stack_pointer(-16),l=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),b=v,y=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),B=v,I=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),E=v,R=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),k=v;f.calculate_spot_price(a,l,b,y,B,I,E,R,k);var t=ne()[a/4+0],i=ne()[a/4+1];return Ae(t,i)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(t,i)}};ae.exports.calculate_cap_difference=function(u,e,n,o){try{let a=f.__wbindgen_add_to_stack_pointer(-16),l=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),b=v,y=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),B=v,I=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),E=v,R=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),k=v;f.calculate_cap_difference(a,l,b,y,B,I,E,R,k);var t=ne()[a/4+0],i=ne()[a/4+1];return Ae(t,i)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(t,i)}};ae.exports.verify_asset_cap=function(u,e,n,o){let t=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),i=v,a=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),l=v,b=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),y=v,B=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),I=v;return f.verify_asset_cap(t,i,a,l,b,y,B,I)!==0};ae.exports.calculate_liquidity_hub_in=function(u,e,n,o){try{let a=f.__wbindgen_add_to_stack_pointer(-16),l=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),b=v,y=F(e,f.__wbindgen_malloc,f.__wbindgen_realloc),B=v,I=F(n,f.__wbindgen_malloc,f.__wbindgen_realloc),E=v,R=F(o,f.__wbindgen_malloc,f.__wbindgen_realloc),k=v;f.calculate_liquidity_hub_in(a,l,b,y,B,I,E,R,k);var t=ne()[a/4+0],i=ne()[a/4+1];return Ae(t,i)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(t,i)}};ae.exports.is_sell_allowed=function(u){return f.is_sell_allowed(u)!==0};ae.exports.is_buy_allowed=function(u){return f.is_buy_allowed(u)!==0};ae.exports.is_add_liquidity_allowed=function(u){return f.is_add_liquidity_allowed(u)!==0};ae.exports.is_remove_liquidity_allowed=function(u){return f.is_remove_liquidity_allowed(u)!==0};ae.exports.calculate_pool_trade_fee=function(u,e,n){try{let i=f.__wbindgen_add_to_stack_pointer(-16),a=F(u,f.__wbindgen_malloc,f.__wbindgen_realloc),l=v;f.calculate_pool_trade_fee(i,a,l,e,n);var o=ne()[i/4+0],t=ne()[i/4+1];return Ae(o,t)}finally{f.__wbindgen_add_to_stack_pointer(16),f.__wbindgen_free(o,t)}};var gn=require("path").join(__dirname,"hydra_dx_wasm_bg.wasm"),mn=require("fs").readFileSync(gn),fn=new WebAssembly.Module(mn),hn=new WebAssembly.Instance(fn,un);f=hn.exports;ae.exports.__wasm=f});var Ht=Pt((fr,Be)=>{var bn={},T,{TextEncoder:wn,TextDecoder:Pn}=require("util"),Y=0,gt=null;function ft(){return(gt===null||gt.buffer!==T.memory.buffer)&&(gt=new Uint8Array(T.memory.buffer)),gt}var ht=new wn("utf-8"),yn=typeof ht.encodeInto=="function"?function(u,e){return ht.encodeInto(u,e)}:function(u,e){let n=ht.encode(u);return e.set(n),{read:u.length,written:n.length}};function J(u,e,n){if(n===void 0){let l=ht.encode(u),b=e(l.length);return ft().subarray(b,b+l.length).set(l),Y=l.length,b}let o=u.length,t=e(o),i=ft(),a=0;for(;a<o;a++){let l=u.charCodeAt(a);if(l>127)break;i[t+a]=l}if(a!==o){a!==0&&(u=u.slice(a)),t=n(t,o,o=a+u.length*3);let l=ft().subarray(t+a,t+o);a+=yn(u,l).written}return Y=a,t}var mt=null;function le(){return(mt===null||mt.buffer!==T.memory.buffer)&&(mt=new Int32Array(T.memory.buffer)),mt}var Wt=new Pn("utf-8",{ignoreBOM:!0,fatal:!0});Wt.decode();function Me(u,e){return Wt.decode(ft().subarray(u,u+e))}Be.exports.calculate_pool_trade_fee=function(u,e,n){try{let i=T.__wbindgen_add_to_stack_pointer(-16),a=J(u,T.__wbindgen_malloc,T.__wbindgen_realloc),l=Y;T.calculate_pool_trade_fee(i,a,l,e,n);var o=le()[i/4+0],t=le()[i/4+1];return Me(o,t)}finally{T.__wbindgen_add_to_stack_pointer(16),T.__wbindgen_free(o,t)}};Be.exports.get_spot_price=function(u,e,n){try{let i=T.__wbindgen_add_to_stack_pointer(-16),a=J(u,T.__wbindgen_malloc,T.__wbindgen_realloc),l=Y,b=J(e,T.__wbindgen_malloc,T.__wbindgen_realloc),y=Y,B=J(n,T.__wbindgen_malloc,T.__wbindgen_realloc),I=Y;T.get_spot_price(i,a,l,b,y,B,I);var o=le()[i/4+0],t=le()[i/4+1];return Me(o,t)}finally{T.__wbindgen_add_to_stack_pointer(16),T.__wbindgen_free(o,t)}};Be.exports.calculate_out_given_in=function(u,e,n){try{let i=T.__wbindgen_add_to_stack_pointer(-16),a=J(u,T.__wbindgen_malloc,T.__wbindgen_realloc),l=Y,b=J(e,T.__wbindgen_malloc,T.__wbindgen_realloc),y=Y,B=J(n,T.__wbindgen_malloc,T.__wbindgen_realloc),I=Y;T.calculate_out_given_in(i,a,l,b,y,B,I);var o=le()[i/4+0],t=le()[i/4+1];return Me(o,t)}finally{T.__wbindgen_add_to_stack_pointer(16),T.__wbindgen_free(o,t)}};Be.exports.calculate_in_given_out=function(u,e,n){try{let i=T.__wbindgen_add_to_stack_pointer(-16),a=J(u,T.__wbindgen_malloc,T.__wbindgen_realloc),l=Y,b=J(e,T.__wbindgen_malloc,T.__wbindgen_realloc),y=Y,B=J(n,T.__wbindgen_malloc,T.__wbindgen_realloc),I=Y;T.calculate_in_given_out(i,a,l,b,y,B,I);var o=le()[i/4+0],t=le()[i/4+1];return Me(o,t)}finally{T.__wbindgen_add_to_stack_pointer(16),T.__wbindgen_free(o,t)}};Be.exports.calculate_liquidity_in=function(u,e,n){try{let i=T.__wbindgen_add_to_stack_pointer(-16),a=J(u,T.__wbindgen_malloc,T.__wbindgen_realloc),l=Y,b=J(e,T.__wbindgen_malloc,T.__wbindgen_realloc),y=Y,B=J(n,T.__wbindgen_malloc,T.__wbindgen_realloc),I=Y;T.calculate_liquidity_in(i,a,l,b,y,B,I);var o=le()[i/4+0],t=le()[i/4+1];return Me(o,t)}finally{T.__wbindgen_add_to_stack_pointer(16),T.__wbindgen_free(o,t)}};Be.exports.calculate_shares=function(u,e,n){try{let i=T.__wbindgen_add_to_stack_pointer(-16),a=J(u,T.__wbindgen_malloc,T.__wbindgen_realloc),l=Y,b=J(e,T.__wbindgen_malloc,T.__wbindgen_realloc),y=Y,B=J(n,T.__wbindgen_malloc,T.__wbindgen_realloc),I=Y;T.calculate_shares(i,a,l,b,y,B,I);var o=le()[i/4+0],t=le()[i/4+1];return Me(o,t)}finally{T.__wbindgen_add_to_stack_pointer(16),T.__wbindgen_free(o,t)}};Be.exports.calculate_liquidity_out_asset_a=function(u,e,n,o){try{let a=T.__wbindgen_add_to_stack_pointer(-16),l=J(u,T.__wbindgen_malloc,T.__wbindgen_realloc),b=Y,y=J(e,T.__wbindgen_malloc,T.__wbindgen_realloc),B=Y,I=J(n,T.__wbindgen_malloc,T.__wbindgen_realloc),E=Y,R=J(o,T.__wbindgen_malloc,T.__wbindgen_realloc),k=Y;T.calculate_liquidity_out_asset_a(a,l,b,y,B,I,E,R,k);var t=le()[a/4+0],i=le()[a/4+1];return Me(t,i)}finally{T.__wbindgen_add_to_stack_pointer(16),T.__wbindgen_free(t,i)}};Be.exports.calculate_liquidity_out_asset_b=function(u,e,n,o){try{let a=T.__wbindgen_add_to_stack_pointer(-16),l=J(u,T.__wbindgen_malloc,T.__wbindgen_realloc),b=Y,y=J(e,T.__wbindgen_malloc,T.__wbindgen_realloc),B=Y,I=J(n,T.__wbindgen_malloc,T.__wbindgen_realloc),E=Y,R=J(o,T.__wbindgen_malloc,T.__wbindgen_realloc),k=Y;T.calculate_liquidity_out_asset_b(a,l,b,y,B,I,E,R,k);var t=le()[a/4+0],i=le()[a/4+1];return Me(t,i)}finally{T.__wbindgen_add_to_stack_pointer(16),T.__wbindgen_free(t,i)}};var On=require("path").join(__dirname,"hydra_dx_wasm_bg.wasm"),xn=require("fs").readFileSync(On),In=new WebAssembly.Module(xn),Bn=new WebAssembly.Instance(In,bn);T=Bn.exports;Be.exports.__wasm=T});var Tn={};$t(Tn,{BigNumber:()=>We,DECIMAL_PLACES:()=>Rt,DENOMINATOR:()=>Ce,HYDRADX_PARACHAIN_ID:()=>zn,HYDRADX_SS58_PREFIX:()=>Ft,INFINITY:()=>en,LbpMath:()=>he,LbpPool:()=>Ee,ONE:()=>Oe,OmniMath:()=>Fe,OmniPool:()=>Re,PolkadotApiPoolService:()=>_t,PoolConfigNotFound:()=>ve,PoolError:()=>et,PoolFactory:()=>Ue,PoolType:()=>Pe,RUNTIME_DECIMALS:()=>It,Router:()=>Ge,SYSTEM_ASSET_DECIMALS:()=>Yn,SYSTEM_ASSET_ID:()=>tt,TradeRouter:()=>$e,TradeType:()=>xt,XykMath:()=>Te,XykPool:()=>Le,ZERO:()=>se,bnum:()=>L,scale:()=>_e});module.exports=Zt(Tn);var je=class{constructor(e=1/0){this.capacity=e;this.storage=[]}enqueue(e){if(this.size()===this.capacity)throw Error("Queue has reached max capacity, you cannot add more items");this.storage.push(e)}dequeue(){return this.storage.shift()}size(){return this.storage.length}};var Qt=4,Ye=class{isNotVisited(e,n){let o=!0;return n.forEach(t=>{(t[0]===e[0]||t[1]===e[1])&&(o=!1)}),o}findPaths(e,n,o){let t=[],i=new je,a=[];for(a.push([n,""]),i.enqueue(a);i.size()>0;){let l=i.dequeue();if(l==null||l.length>Qt)return t;let b=l[l.length-1];(o===null||b[0]===o)&&t.push(l),e[b[0]].forEach(B=>{if(this.isNotVisited(B,l)){let I=[...l];I.push(B),i.enqueue(I)}})}return t}buildAndPopulateGraph(e,n){let o=e[e.length-1],t=[];for(let i=0;i<=parseInt(o);i++)t.push([]);for(let[i,a,l]of n){let b=parseInt(a),y=parseInt(l);t[b].push([y,i])}return t}};function Ot(u){let e={};for(let n of u){let o=n.tokens.length;for(let t=0;t<o;t++){e[n.tokens[t].id]||(e[n.tokens[t].id]=[]);for(let i=0;i<o;i++){if(t==i)continue;let a=[n.address,n.tokens[t].id,n.tokens[i].id];e[n.tokens[t].id].push(a)}}}return e}var ze=class{getProposals(e,n,o){let t=Ot(o),i=Object.keys(t),a=i.map(B=>t[B]).flat(),l=new Ye,b=l.buildAndPopulateGraph(i,a),y=l.findPaths(b,parseInt(e),n?parseInt(n):null);return this.parsePaths(y)}parsePaths(e){let n=[];for(let o of e){let t=[];for(let i=0;i<o.length;i++){let a=o[i],l=o[i+1];if(l==null)break;t.push(this.toEdge(a,l))}n.push(t)}return n}toEdge(e,n){return[n[1],e[0].toString(),n[0].toString()]}};var Pe=(t=>(t.XYK="XYK",t.LBP="LBP",t.Stable="Stable",t.Omni="Omni",t))(Pe||{}),et=(o=>(o.InsufficientTradingAmount="InsufficientTradingAmount",o.MaxInRatioExceeded="MaxInRatioExceeded",o.MaxOutRatioExceeded="MaxOutRatioExceeded",o))(et||{}),xt=(n=>(n.Buy="Buy",n.Sell="Sell",n))(xt||{});var It=18,tt="0",Yn=12,zn=2034,Ft=63,Ce=1e3;var Vn=require("@polkadot/api-augment"),Se=class{constructor(e){this.api=e}getStorageKey(e,n){return e[0].toHuman()[n]}getStorageEntryArray(e){return e[1].toHuman()}async getPoolTokens(e,n){let o=n.map(async t=>{let i=await this.getAccountBalance(e,t),l=(await this.getAssetMetadata(t)).toHuman();if(tt==t){let b=this.api.registry.chainDecimals[0],y=this.api.registry.chainTokens[0];return{id:t,balance:i,decimals:b,symbol:y}}return{id:t,balance:i,decimals:l.decimals,symbol:l.symbol}});return Promise.all(o)}async syncPoolTokens(e,n){let o=n.map(async t=>{let i=await this.getAccountBalance(e,t.id);return{...t,balance:i}});return Promise.all(o)}async getAssetMetadata(e){return await this.api.query.assetRegistry.assetMetadataMap(e)}async getAccountBalance(e,n){return n===tt?await this.getSystemAccountBalance(e):await this.getTokenAccountBalance(e,n)}async getSystemAccountBalance(e){let{data:{free:n}}=await this.api.query.system.account(e);return n.toString()}async getTokenAccountBalance(e,n){let{free:o}=await this.api.query.tokens.accounts(e,n);return o.toString()}};var nt=class extends Se{constructor(){super(...arguments);this.pools=[];this._poolsLoaded=!1}async getPools(){return this._poolsLoaded?this.pools=await this.syncPools():(this.pools=await this.loadPools(),this._poolsLoaded=!0),this.pools}async loadPools(){let o=(await this.api.query.xyk.poolAssets.entries()).map(async t=>{let i=this.getStorageKey(t,0),a=this.getStorageEntryArray(t),l=await this.getPoolTokens(i,a);return{address:i,type:"XYK",tradeFee:this.getTradeFee(),tokens:l,...this.getPoolLimits()}});return Promise.all(o)}async syncPools(){let n=this.pools.map(async o=>({...o,tokens:await this.syncPoolTokens(o.address,o.tokens)}));return Promise.all(n)}getTradeFee(){return this.api.consts.xyk.getExchangeFee.toJSON()}getPoolLimits(){let n=this.api.consts.xyk.maxInRatio.toJSON(),o=this.api.consts.xyk.maxOutRatio.toJSON(),t=this.api.consts.xyk.minTradingLimit.toJSON();return{maxInRatio:n,maxOutRatio:o,minTradingLimit:t}}};var jt=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Bt=Math.ceil,ye=Math.floor,de="[BigNumber Error] ",kt=de+"Number primitive has more than 15 significant digits: ",be=1e14,M=14,Tt=9007199254740991,St=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ke=1e7,te=1e9;function Et(u){var e,n,o,t=x.prototype={constructor:x,toString:null,valueOf:null},i=new x(1),a=20,l=4,b=-7,y=21,B=-1e7,I=1e7,E=!1,R=1,k=0,W={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function x(r,s){var c,m,p,g,P,_,d,w,h=this;if(!(h instanceof x))return new x(r,s);if(s==null){if(r&&r._isBigNumber===!0){h.s=r.s,!r.c||r.e>I?h.c=h.e=null:r.e<B?h.c=[h.e=0]:(h.e=r.e,h.c=r.c.slice());return}if((_=typeof r=="number")&&r*0==0){if(h.s=1/r<0?(r=-r,-1):1,r===~~r){for(g=0,P=r;P>=10;P/=10,g++);g>I?h.c=h.e=null:(h.e=g,h.c=[r]);return}w=String(r)}else{if(!jt.test(w=String(r)))return o(h,w,_);h.s=w.charCodeAt(0)==45?(w=w.slice(1),-1):1}(g=w.indexOf("."))>-1&&(w=w.replace(".","")),(P=w.search(/e/i))>0?(g<0&&(g=P),g+=+w.slice(P+1),w=w.substring(0,P)):g<0&&(g=w.length)}else{if(K(s,2,H.length,"Base"),s==10&&z)return h=new x(r),G(h,a+h.e+1,l);if(w=String(r),_=typeof r=="number"){if(r*0!=0)return o(h,w,_,s);if(h.s=1/r<0?(w=w.slice(1),-1):1,x.DEBUG&&w.replace(/^0\.0*|\./,"").length>15)throw Error(kt+r)}else h.s=w.charCodeAt(0)===45?(w=w.slice(1),-1):1;for(c=H.slice(0,s),g=P=0,d=w.length;P<d;P++)if(c.indexOf(m=w.charAt(P))<0){if(m=="."){if(P>g){g=d;continue}}else if(!p&&(w==w.toUpperCase()&&(w=w.toLowerCase())||w==w.toLowerCase()&&(w=w.toUpperCase()))){p=!0,P=-1,g=0;continue}return o(h,String(r),_,s)}_=!1,w=n(w,s,10,h.s),(g=w.indexOf("."))>-1?w=w.replace(".",""):g=w.length}for(P=0;w.charCodeAt(P)===48;P++);for(d=w.length;w.charCodeAt(--d)===48;);if(w=w.slice(P,++d)){if(d-=P,_&&x.DEBUG&&d>15&&(r>Tt||r!==ye(r)))throw Error(kt+h.s*r);if((g=g-P-1)>I)h.c=h.e=null;else if(g<B)h.c=[h.e=0];else{if(h.e=g,h.c=[],P=(g+1)%M,g<0&&(P+=M),P<d){for(P&&h.c.push(+w.slice(0,P)),d-=M;P<d;)h.c.push(+w.slice(P,P+=M));P=M-(w=w.slice(P)).length}else P-=d;for(;P--;w+="0");h.c.push(+w)}}else h.c=[h.e=0]}x.clone=Et,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(r){var s,c;if(r!=null)if(typeof r=="object"){if(r.hasOwnProperty(s="DECIMAL_PLACES")&&(c=r[s],K(c,0,te,s),a=c),r.hasOwnProperty(s="ROUNDING_MODE")&&(c=r[s],K(c,0,8,s),l=c),r.hasOwnProperty(s="EXPONENTIAL_AT")&&(c=r[s],c&&c.pop?(K(c[0],-te,0,s),K(c[1],0,te,s),b=c[0],y=c[1]):(K(c,-te,te,s),b=-(y=c<0?-c:c))),r.hasOwnProperty(s="RANGE"))if(c=r[s],c&&c.pop)K(c[0],-te,-1,s),K(c[1],1,te,s),B=c[0],I=c[1];else if(K(c,-te,te,s),c)B=-(I=c<0?-c:c);else throw Error(de+s+" cannot be zero: "+c);if(r.hasOwnProperty(s="CRYPTO"))if(c=r[s],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))E=c;else throw E=!c,Error(de+"crypto unavailable");else E=c;else throw Error(de+s+" not true or false: "+c);if(r.hasOwnProperty(s="MODULO_MODE")&&(c=r[s],K(c,0,9,s),R=c),r.hasOwnProperty(s="POW_PRECISION")&&(c=r[s],K(c,0,te,s),k=c),r.hasOwnProperty(s="FORMAT"))if(c=r[s],typeof c=="object")W=c;else throw Error(de+s+" not an object: "+c);if(r.hasOwnProperty(s="ALPHABET"))if(c=r[s],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))z=c.slice(0,10)=="0123456789",H=c;else throw Error(de+s+" invalid: "+c)}else throw Error(de+"Object expected: "+r);return{DECIMAL_PLACES:a,ROUNDING_MODE:l,EXPONENTIAL_AT:[b,y],RANGE:[B,I],CRYPTO:E,MODULO_MODE:R,POW_PRECISION:k,FORMAT:W,ALPHABET:H}},x.isBigNumber=function(r){if(!r||r._isBigNumber!==!0)return!1;if(!x.DEBUG)return!0;var s,c,m=r.c,p=r.e,g=r.s;e:if({}.toString.call(m)=="[object Array]"){if((g===1||g===-1)&&p>=-te&&p<=te&&p===ye(p)){if(m[0]===0){if(p===0&&m.length===1)return!0;break e}if(s=(p+1)%M,s<1&&(s+=M),String(m[0]).length==s){for(s=0;s<m.length;s++)if(c=m[s],c<0||c>=be||c!==ye(c))break e;if(c!==0)return!0}}}else if(m===null&&p===null&&(g===null||g===1||g===-1))return!0;throw Error(de+"Invalid BigNumber: "+r)},x.maximum=x.max=function(){return pe(arguments,t.lt)},x.minimum=x.min=function(){return pe(arguments,t.gt)},x.random=function(){var r=9007199254740992,s=Math.random()*r&2097151?function(){return ye(Math.random()*r)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var m,p,g,P,_,d=0,w=[],h=new x(i);if(c==null?c=a:K(c,0,te),P=Bt(c/M),E)if(crypto.getRandomValues){for(m=crypto.getRandomValues(new Uint32Array(P*=2));d<P;)_=m[d]*131072+(m[d+1]>>>11),_>=9e15?(p=crypto.getRandomValues(new Uint32Array(2)),m[d]=p[0],m[d+1]=p[1]):(w.push(_%1e14),d+=2);d=P/2}else if(crypto.randomBytes){for(m=crypto.randomBytes(P*=7);d<P;)_=(m[d]&31)*281474976710656+m[d+1]*1099511627776+m[d+2]*4294967296+m[d+3]*16777216+(m[d+4]<<16)+(m[d+5]<<8)+m[d+6],_>=9e15?crypto.randomBytes(7).copy(m,d):(w.push(_%1e14),d+=7);d=P/7}else throw E=!1,Error(de+"crypto unavailable");if(!E)for(;d<P;)_=s(),_<9e15&&(w[d++]=_%1e14);for(P=w[--d],c%=M,P&&c&&(_=St[M-c],w[d]=ye(P/_)*_);w[d]===0;w.pop(),d--);if(d<0)w=[g=0];else{for(g=-1;w[0]===0;w.splice(0,1),g-=M);for(d=1,_=w[0];_>=10;_/=10,d++);d<M&&(g-=M-d)}return h.e=g,h.c=w,h}}(),x.sum=function(){for(var r=1,s=arguments,c=new x(s[0]);r<s.length;)c=c.plus(s[r++]);return c},n=function(){var r="0123456789";function s(c,m,p,g){for(var P,_=[0],d,w=0,h=c.length;w<h;){for(d=_.length;d--;_[d]*=m);for(_[0]+=g.indexOf(c.charAt(w++)),P=0;P<_.length;P++)_[P]>p-1&&(_[P+1]==null&&(_[P+1]=0),_[P+1]+=_[P]/p|0,_[P]%=p)}return _.reverse()}return function(c,m,p,g,P){var _,d,w,h,O,N,A,q,$=c.indexOf("."),ee=a,C=l;for($>=0&&(h=k,k=0,c=c.replace(".",""),q=new x(m),N=q.pow(c.length-$),k=h,q.c=s(Ne(me(N.c),N.e,"0"),10,p,r),q.e=q.c.length),A=s(c,m,p,P?(_=H,r):(_=r,H)),w=h=A.length;A[--h]==0;A.pop());if(!A[0])return _.charAt(0);if($<0?--w:(N.c=A,N.e=w,N.s=g,N=e(N,q,ee,C,p),A=N.c,O=N.r,w=N.e),d=w+ee+1,$=A[d],h=p/2,O=O||d<0||A[d+1]!=null,O=C<4?($!=null||O)&&(C==0||C==(N.s<0?3:2)):$>h||$==h&&(C==4||O||C==6&&A[d-1]&1||C==(N.s<0?8:7)),d<1||!A[0])c=O?Ne(_.charAt(1),-ee,_.charAt(0)):_.charAt(0);else{if(A.length=d,O)for(--p;++A[--d]>p;)A[d]=0,d||(++w,A=[1].concat(A));for(h=A.length;!A[--h];);for($=0,c="";$<=h;c+=_.charAt(A[$++]));c=Ne(c,w,_.charAt(0))}return c}}(),e=function(){function r(m,p,g){var P,_,d,w,h=0,O=m.length,N=p%ke,A=p/ke|0;for(m=m.slice();O--;)d=m[O]%ke,w=m[O]/ke|0,P=A*d+w*N,_=N*d+P%ke*ke+h,h=(_/g|0)+(P/ke|0)+A*w,m[O]=_%g;return h&&(m=[h].concat(m)),m}function s(m,p,g,P){var _,d;if(g!=P)d=g>P?1:-1;else for(_=d=0;_<g;_++)if(m[_]!=p[_]){d=m[_]>p[_]?1:-1;break}return d}function c(m,p,g,P){for(var _=0;g--;)m[g]-=_,_=m[g]<p[g]?1:0,m[g]=_*P+m[g]-p[g];for(;!m[0]&&m.length>1;m.splice(0,1));}return function(m,p,g,P,_){var d,w,h,O,N,A,q,$,ee,C,U,ie,Ze,bt,wt,we,Xe,ge=m.s==p.s?1:-1,ue=m.c,Z=p.c;if(!ue||!ue[0]||!Z||!Z[0])return new x(!m.s||!p.s||(ue?Z&&ue[0]==Z[0]:!Z)?NaN:ue&&ue[0]==0||!Z?ge*0:ge/0);for($=new x(ge),ee=$.c=[],w=m.e-p.e,ge=g+w+1,_||(_=be,w=fe(m.e/M)-fe(p.e/M),ge=ge/M|0),h=0;Z[h]==(ue[h]||0);h++);if(Z[h]>(ue[h]||0)&&w--,ge<0)ee.push(1),O=!0;else{for(bt=ue.length,we=Z.length,h=0,ge+=2,N=ye(_/(Z[0]+1)),N>1&&(Z=r(Z,N,_),ue=r(ue,N,_),we=Z.length,bt=ue.length),Ze=we,C=ue.slice(0,we),U=C.length;U<we;C[U++]=0);Xe=Z.slice(),Xe=[0].concat(Xe),wt=Z[0],Z[1]>=_/2&&wt++;do{if(N=0,d=s(Z,C,we,U),d<0){if(ie=C[0],we!=U&&(ie=ie*_+(C[1]||0)),N=ye(ie/wt),N>1)for(N>=_&&(N=_-1),A=r(Z,N,_),q=A.length,U=C.length;s(A,C,q,U)==1;)N--,c(A,we<q?Xe:Z,q,_),q=A.length,d=1;else N==0&&(d=N=1),A=Z.slice(),q=A.length;if(q<U&&(A=[0].concat(A)),c(C,A,U,_),U=C.length,d==-1)for(;s(Z,C,we,U)<1;)N++,c(C,we<U?Xe:Z,U,_),U=C.length}else d===0&&(N++,C=[0]);ee[h++]=N,C[0]?C[U++]=ue[Ze]||0:(C=[ue[Ze]],U=1)}while((Ze++<bt||C[0]!=null)&&ge--);O=C[0]!=null,ee[0]||ee.splice(0,1)}if(_==be){for(h=1,ge=ee[0];ge>=10;ge/=10,h++);G($,g+($.e=h+w*M-1)+1,P,O)}else $.e=w,$.r=+O;return $}}();function oe(r,s,c,m){var p,g,P,_,d;if(c==null?c=l:K(c,0,8),!r.c)return r.toString();if(p=r.c[0],P=r.e,s==null)d=me(r.c),d=m==1||m==2&&(P<=b||P>=y)?rt(d,P):Ne(d,P,"0");else if(r=G(new x(r),s,c),g=r.e,d=me(r.c),_=d.length,m==1||m==2&&(s<=g||g<=b)){for(;_<s;d+="0",_++);d=rt(d,g)}else if(s-=P,d=Ne(d,g,"0"),g+1>_){if(--s>0)for(d+=".";s--;d+="0");}else if(s+=g-_,s>0)for(g+1==_&&(d+=".");s--;d+="0");return r.s<0&&p?"-"+d:d}function pe(r,s){for(var c,m=1,p=new x(r[0]);m<r.length;m++)if(c=new x(r[m]),c.s)s.call(p,c)&&(p=c);else{p=c;break}return p}function D(r,s,c){for(var m=1,p=s.length;!s[--p];s.pop());for(p=s[0];p>=10;p/=10,m++);return(c=m+c*M-1)>I?r.c=r.e=null:c<B?r.c=[r.e=0]:(r.e=c,r.c=s),r}o=function(){var r=/^(-?)0([xbo])(?=\w[\w.]*$)/i,s=/^([^.]+)\.$/,c=/^\.([^.]+)$/,m=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(g,P,_,d){var w,h=_?P:P.replace(p,"");if(m.test(h))g.s=isNaN(h)?null:h<0?-1:1;else{if(!_&&(h=h.replace(r,function(O,N,A){return w=(A=A.toLowerCase())=="x"?16:A=="b"?2:8,!d||d==w?N:O}),d&&(w=d,h=h.replace(s,"$1").replace(c,"0.$1")),P!=h))return new x(h,w);if(x.DEBUG)throw Error(de+"Not a"+(d?" base "+d:"")+" number: "+P);g.s=null}g.c=g.e=null}}();function G(r,s,c,m){var p,g,P,_,d,w,h,O=r.c,N=St;if(O){e:{for(p=1,_=O[0];_>=10;_/=10,p++);if(g=s-p,g<0)g+=M,P=s,d=O[w=0],h=d/N[p-P-1]%10|0;else if(w=Bt((g+1)/M),w>=O.length)if(m){for(;O.length<=w;O.push(0));d=h=0,p=1,g%=M,P=g-M+1}else break e;else{for(d=_=O[w],p=1;_>=10;_/=10,p++);g%=M,P=g-M+p,h=P<0?0:d/N[p-P-1]%10|0}if(m=m||s<0||O[w+1]!=null||(P<0?d:d%N[p-P-1]),m=c<4?(h||m)&&(c==0||c==(r.s<0?3:2)):h>5||h==5&&(c==4||m||c==6&&(g>0?P>0?d/N[p-P]:0:O[w-1])%10&1||c==(r.s<0?8:7)),s<1||!O[0])return O.length=0,m?(s-=r.e+1,O[0]=N[(M-s%M)%M],r.e=-s||0):O[0]=r.e=0,r;if(g==0?(O.length=w,_=1,w--):(O.length=w+1,_=N[M-g],O[w]=P>0?ye(d/N[p-P]%N[P])*_:0),m)for(;;)if(w==0){for(g=1,P=O[0];P>=10;P/=10,g++);for(P=O[0]+=_,_=1;P>=10;P/=10,_++);g!=_&&(r.e++,O[0]==be&&(O[0]=1));break}else{if(O[w]+=_,O[w]!=be)break;O[w--]=0,_=1}for(g=O.length;O[--g]===0;O.pop());}r.e>I?r.c=r.e=null:r.e<B&&(r.c=[r.e=0])}return r}function Q(r){var s,c=r.e;return c===null?r.toString():(s=me(r.c),s=c<=b||c>=y?rt(s,c):Ne(s,c,"0"),r.s<0?"-"+s:s)}return t.absoluteValue=t.abs=function(){var r=new x(this);return r.s<0&&(r.s=1),r},t.comparedTo=function(r,s){return qe(this,new x(r,s))},t.decimalPlaces=t.dp=function(r,s){var c,m,p,g=this;if(r!=null)return K(r,0,te),s==null?s=l:K(s,0,8),G(new x(g),r+g.e+1,s);if(!(c=g.c))return null;if(m=((p=c.length-1)-fe(this.e/M))*M,p=c[p])for(;p%10==0;p/=10,m--);return m<0&&(m=0),m},t.dividedBy=t.div=function(r,s){return e(this,new x(r,s),a,l)},t.dividedToIntegerBy=t.idiv=function(r,s){return e(this,new x(r,s),0,1)},t.exponentiatedBy=t.pow=function(r,s){var c,m,p,g,P,_,d,w,h,O=this;if(r=new x(r),r.c&&!r.isInteger())throw Error(de+"Exponent not an integer: "+Q(r));if(s!=null&&(s=new x(s)),_=r.e>14,!O.c||!O.c[0]||O.c[0]==1&&!O.e&&O.c.length==1||!r.c||!r.c[0])return h=new x(Math.pow(+Q(O),_?2-ot(r):+Q(r))),s?h.mod(s):h;if(d=r.s<0,s){if(s.c?!s.c[0]:!s.s)return new x(NaN);m=!d&&O.isInteger()&&s.isInteger(),m&&(O=O.mod(s))}else{if(r.e>9&&(O.e>0||O.e<-1||(O.e==0?O.c[0]>1||_&&O.c[1]>=24e7:O.c[0]<8e13||_&&O.c[0]<=9999975e7)))return g=O.s<0&&ot(r)?-0:0,O.e>-1&&(g=1/g),new x(d?1/g:g);k&&(g=Bt(k/M+2))}for(_?(c=new x(.5),d&&(r.s=1),w=ot(r)):(p=Math.abs(+Q(r)),w=p%2),h=new x(i);;){if(w){if(h=h.times(O),!h.c)break;g?h.c.length>g&&(h.c.length=g):m&&(h=h.mod(s))}if(p){if(p=ye(p/2),p===0)break;w=p%2}else if(r=r.times(c),G(r,r.e+1,1),r.e>14)w=ot(r);else{if(p=+Q(r),p===0)break;w=p%2}O=O.times(O),g?O.c&&O.c.length>g&&(O.c.length=g):m&&(O=O.mod(s))}return m?h:(d&&(h=i.div(h)),s?h.mod(s):g?G(h,k,l,P):h)},t.integerValue=function(r){var s=new x(this);return r==null?r=l:K(r,0,8),G(s,s.e+1,r)},t.isEqualTo=t.eq=function(r,s){return qe(this,new x(r,s))===0},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(r,s){return qe(this,new x(r,s))>0},t.isGreaterThanOrEqualTo=t.gte=function(r,s){return(s=qe(this,new x(r,s)))===1||s===0},t.isInteger=function(){return!!this.c&&fe(this.e/M)>this.c.length-2},t.isLessThan=t.lt=function(r,s){return qe(this,new x(r,s))<0},t.isLessThanOrEqualTo=t.lte=function(r,s){return(s=qe(this,new x(r,s)))===-1||s===0},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return this.s>0},t.isZero=function(){return!!this.c&&this.c[0]==0},t.minus=function(r,s){var c,m,p,g,P=this,_=P.s;if(r=new x(r,s),s=r.s,!_||!s)return new x(NaN);if(_!=s)return r.s=-s,P.plus(r);var d=P.e/M,w=r.e/M,h=P.c,O=r.c;if(!d||!w){if(!h||!O)return h?(r.s=-s,r):new x(O?P:NaN);if(!h[0]||!O[0])return O[0]?(r.s=-s,r):new x(h[0]?P:l==3?-0:0)}if(d=fe(d),w=fe(w),h=h.slice(),_=d-w){for((g=_<0)?(_=-_,p=h):(w=d,p=O),p.reverse(),s=_;s--;p.push(0));p.reverse()}else for(m=(g=(_=h.length)<(s=O.length))?_:s,_=s=0;s<m;s++)if(h[s]!=O[s]){g=h[s]<O[s];break}if(g&&(p=h,h=O,O=p,r.s=-r.s),s=(m=O.length)-(c=h.length),s>0)for(;s--;h[c++]=0);for(s=be-1;m>_;){if(h[--m]<O[m]){for(c=m;c&&!h[--c];h[c]=s);--h[c],h[m]+=be}h[m]-=O[m]}for(;h[0]==0;h.splice(0,1),--w);return h[0]?D(r,h,w):(r.s=l==3?-1:1,r.c=[r.e=0],r)},t.modulo=t.mod=function(r,s){var c,m,p=this;return r=new x(r,s),!p.c||!r.s||r.c&&!r.c[0]?new x(NaN):!r.c||p.c&&!p.c[0]?new x(p):(R==9?(m=r.s,r.s=1,c=e(p,r,0,3),r.s=m,c.s*=m):c=e(p,r,0,R),r=p.minus(c.times(r)),!r.c[0]&&R==1&&(r.s=p.s),r)},t.multipliedBy=t.times=function(r,s){var c,m,p,g,P,_,d,w,h,O,N,A,q,$,ee,C=this,U=C.c,ie=(r=new x(r,s)).c;if(!U||!ie||!U[0]||!ie[0])return!C.s||!r.s||U&&!U[0]&&!ie||ie&&!ie[0]&&!U?r.c=r.e=r.s=null:(r.s*=C.s,!U||!ie?r.c=r.e=null:(r.c=[0],r.e=0)),r;for(m=fe(C.e/M)+fe(r.e/M),r.s*=C.s,d=U.length,O=ie.length,d<O&&(q=U,U=ie,ie=q,p=d,d=O,O=p),p=d+O,q=[];p--;q.push(0));for($=be,ee=ke,p=O;--p>=0;){for(c=0,N=ie[p]%ee,A=ie[p]/ee|0,P=d,g=p+P;g>p;)w=U[--P]%ee,h=U[P]/ee|0,_=A*w+h*N,w=N*w+_%ee*ee+q[g]+c,c=(w/$|0)+(_/ee|0)+A*h,q[g--]=w%$;q[g]=c}return c?++m:q.splice(0,1),D(r,q,m)},t.negated=function(){var r=new x(this);return r.s=-r.s||null,r},t.plus=function(r,s){var c,m=this,p=m.s;if(r=new x(r,s),s=r.s,!p||!s)return new x(NaN);if(p!=s)return r.s=-s,m.minus(r);var g=m.e/M,P=r.e/M,_=m.c,d=r.c;if(!g||!P){if(!_||!d)return new x(p/0);if(!_[0]||!d[0])return d[0]?r:new x(_[0]?m:p*0)}if(g=fe(g),P=fe(P),_=_.slice(),p=g-P){for(p>0?(P=g,c=d):(p=-p,c=_),c.reverse();p--;c.push(0));c.reverse()}for(p=_.length,s=d.length,p-s<0&&(c=d,d=_,_=c,s=p),p=0;s;)p=(_[--s]=_[s]+d[s]+p)/be|0,_[s]=be===_[s]?0:_[s]%be;return p&&(_=[p].concat(_),++P),D(r,_,P)},t.precision=t.sd=function(r,s){var c,m,p,g=this;if(r!=null&&r!==!!r)return K(r,1,te),s==null?s=l:K(s,0,8),G(new x(g),r,s);if(!(c=g.c))return null;if(p=c.length-1,m=p*M+1,p=c[p]){for(;p%10==0;p/=10,m--);for(p=c[0];p>=10;p/=10,m++);}return r&&g.e+1>m&&(m=g.e+1),m},t.shiftedBy=function(r){return K(r,-Tt,Tt),this.times("1e"+r)},t.squareRoot=t.sqrt=function(){var r,s,c,m,p,g=this,P=g.c,_=g.s,d=g.e,w=a+4,h=new x("0.5");if(_!==1||!P||!P[0])return new x(!_||_<0&&(!P||P[0])?NaN:P?g:1/0);if(_=Math.sqrt(+Q(g)),_==0||_==1/0?(s=me(P),(s.length+d)%2==0&&(s+="0"),_=Math.sqrt(+s),d=fe((d+1)/2)-(d<0||d%2),_==1/0?s="5e"+d:(s=_.toExponential(),s=s.slice(0,s.indexOf("e")+1)+d),c=new x(s)):c=new x(_+""),c.c[0]){for(d=c.e,_=d+w,_<3&&(_=0);;)if(p=c,c=h.times(p.plus(e(g,p,w,1))),me(p.c).slice(0,_)===(s=me(c.c)).slice(0,_))if(c.e<d&&--_,s=s.slice(_-3,_+1),s=="9999"||!m&&s=="4999"){if(!m&&(G(p,p.e+a+2,0),p.times(p).eq(g))){c=p;break}w+=4,_+=4,m=1}else{(!+s||!+s.slice(1)&&s.charAt(0)=="5")&&(G(c,c.e+a+2,1),r=!c.times(c).eq(g));break}}return G(c,c.e+a+1,l,r)},t.toExponential=function(r,s){return r!=null&&(K(r,0,te),r++),oe(this,r,s,1)},t.toFixed=function(r,s){return r!=null&&(K(r,0,te),r=r+this.e+1),oe(this,r,s)},t.toFormat=function(r,s,c){var m,p=this;if(c==null)r!=null&&s&&typeof s=="object"?(c=s,s=null):r&&typeof r=="object"?(c=r,r=s=null):c=W;else if(typeof c!="object")throw Error(de+"Argument not an object: "+c);if(m=p.toFixed(r,s),p.c){var g,P=m.split("."),_=+c.groupSize,d=+c.secondaryGroupSize,w=c.groupSeparator||"",h=P[0],O=P[1],N=p.s<0,A=N?h.slice(1):h,q=A.length;if(d&&(g=_,_=d,d=g,q-=g),_>0&&q>0){for(g=q%_||_,h=A.substr(0,g);g<q;g+=_)h+=w+A.substr(g,_);d>0&&(h+=w+A.slice(g)),N&&(h="-"+h)}m=O?h+(c.decimalSeparator||"")+((d=+c.fractionGroupSize)?O.replace(new RegExp("\\d{"+d+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):O):h}return(c.prefix||"")+m+(c.suffix||"")},t.toFraction=function(r){var s,c,m,p,g,P,_,d,w,h,O,N,A=this,q=A.c;if(r!=null&&(_=new x(r),!_.isInteger()&&(_.c||_.s!==1)||_.lt(i)))throw Error(de+"Argument "+(_.isInteger()?"out of range: ":"not an integer: ")+Q(_));if(!q)return new x(A);for(s=new x(i),w=c=new x(i),m=d=new x(i),N=me(q),g=s.e=N.length-A.e-1,s.c[0]=St[(P=g%M)<0?M+P:P],r=!r||_.comparedTo(s)>0?g>0?s:w:_,P=I,I=1/0,_=new x(N),d.c[0]=0;h=e(_,s,0,1),p=c.plus(h.times(m)),p.comparedTo(r)!=1;)c=m,m=p,w=d.plus(h.times(p=w)),d=p,s=_.minus(h.times(p=s)),_=p;return p=e(r.minus(c),m,0,1),d=d.plus(p.times(w)),c=c.plus(p.times(m)),d.s=w.s=A.s,g=g*2,O=e(w,m,g,l).minus(A).abs().comparedTo(e(d,c,g,l).minus(A).abs())<1?[w,m]:[d,c],I=P,O},t.toNumber=function(){return+Q(this)},t.toPrecision=function(r,s){return r!=null&&K(r,1,te),oe(this,r,s,2)},t.toString=function(r){var s,c=this,m=c.s,p=c.e;return p===null?m?(s="Infinity",m<0&&(s="-"+s)):s="NaN":(r==null?s=p<=b||p>=y?rt(me(c.c),p):Ne(me(c.c),p,"0"):r===10&&z?(c=G(new x(c),a+p+1,l),s=Ne(me(c.c),c.e,"0")):(K(r,2,H.length,"Base"),s=n(Ne(me(c.c),p,"0"),10,r,m,!0)),m<0&&c.c[0]&&(s="-"+s)),s},t.valueOf=t.toJSON=function(){return Q(this)},t._isBigNumber=!0,t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf,u!=null&&x.set(u),x}function fe(u){var e=u|0;return u>0||u===e?e:e-1}function me(u){for(var e,n,o=1,t=u.length,i=u[0]+"";o<t;){for(e=u[o++]+"",n=M-e.length;n--;e="0"+e);i+=e}for(t=i.length;i.charCodeAt(--t)===48;);return i.slice(0,t+1||1)}function qe(u,e){var n,o,t=u.c,i=e.c,a=u.s,l=e.s,b=u.e,y=e.e;if(!a||!l)return null;if(n=t&&!t[0],o=i&&!i[0],n||o)return n?o?0:-l:a;if(a!=l)return a;if(n=a<0,o=b==y,!t||!i)return o?0:!t^n?1:-1;if(!o)return b>y^n?1:-1;for(l=(b=t.length)<(y=i.length)?b:y,a=0;a<l;a++)if(t[a]!=i[a])return t[a]>i[a]^n?1:-1;return b==y?0:b>y^n?1:-1}function K(u,e,n,o){if(u<e||u>n||u!==ye(u))throw Error(de+(o||"Argument")+(typeof u=="number"?u<e||u>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(u))}function ot(u){var e=u.c.length-1;return fe(u.e/M)==e&&u.c[e]%2!=0}function rt(u,e){return(u.length>1?u.charAt(0)+"."+u.slice(1):u)+(e<0?"e":"e+")+e}function Ne(u,e,n){var o,t;if(e<0){for(t=n+".";++e;t+=n);u=t+u}else if(o=u.length,++e>o){for(t=n,e-=o;--e;t+=n);u+=t}else e<o&&(u=u.slice(0,e)+"."+u.slice(e));return u}var We=Et();var Rt=12;We.config({EXPONENTIAL_AT:[-100,100],ROUNDING_MODE:4,DECIMAL_PLACES:Rt});var se=L(0),Oe=L(1),en=L("Infinity");function _e(u,e){let n=new We(e.toString()),o=new We(10).pow(n);return u.times(o)}function L(u){return new We(u.toString())}var Ie=yt(Lt()),he=class{static getSpotPrice(e,n,o,t,i){return(0,Ie.get_spot_price)(e,n,o,t,i)}static calculateInGivenOut(e,n,o,t,i){return(0,Ie.calculate_in_given_out)(e,n,o,t,i)}static calculateOutGivenIn(e,n,o,t,i){return(0,Ie.calculate_out_given_in)(e,n,o,t,i)}static calculateLinearWeights(e,n,o,t,i){return(0,Ie.calculate_linear_weights)(e,n,o,t,i)}static calculatePoolTradeFee(e,n,o){return(0,Ie.calculate_pool_trade_fee)(e,n,o)}};var ct=class extends Se{constructor(){super(...arguments);this.MAX_FINAL_WEIGHT=_e(L(100),6);this.poolsData=new Map([]);this.pools=[];this._poolsLoaded=!1}async getPools(){return this._poolsLoaded?this.pools=await this.syncPools():(this.pools=await this.loadPools(),this._poolsLoaded=!0),this.pools}async loadPools(){let o=(await this.api.query.lbp.poolData.entries()).map(async t=>{let i=this.getStorageKey(t,0),a=t[1].toJSON(),l=await this.getPoolTokens(i,a.assets),b=await this.getLinearWeight(a),y=L(b),B=this.MAX_FINAL_WEIGHT.minus(L(y)),I=l[0].id;return this.poolsData.set(i,a),{address:i,type:"LBP",tradeFee:a.fee,repayFee:this.getRepayFee(),repayFeeApply:await this.isRepayFeeApplied(I,a),tokens:[{...l[0],weight:y},{...l[1],weight:B}],...this.getPoolLimits()}});return Promise.all(o)}async syncPools(){let n=this.pools.map(async o=>{let t=this.poolsData.get(o.address),i=await this.syncPoolTokens(o.address,o.tokens),a=await this.getLinearWeight(t),l=L(a),b=this.MAX_FINAL_WEIGHT.minus(L(l)),y=i[0].id;return{...o,repayFeeApply:await this.isRepayFeeApplied(y,t),tokens:[{...i[0],weight:l},{...i[1],weight:b}]}});return Promise.all(n)}async getLinearWeight(n){let t=(await this.api.query.parachainSystem.validationData()).toJSON();return he.calculateLinearWeights(n.start.toString(),n.end.toString(),n.initialWeight.toString(),n.finalWeight.toString(),t.relayParentNumber.toString())}async isRepayFeeApplied(n,o){let t=L(o.repayTarget);try{let i=await this.getAccountBalance(n,o.feeCollector);return L(i).isLessThan(t)}catch{return!0}}getRepayFee(){return this.api.consts.lbp.repayFee.toJSON()}getPoolLimits(){let n=this.api.consts.xyk.maxInRatio.toJSON(),o=this.api.consts.xyk.maxOutRatio.toJSON(),t=this.api.consts.xyk.minTradingLimit.toJSON();return{maxInRatio:n,maxOutRatio:o,minTradingLimit:t}}};var Dt=require("@polkadot/util-crypto"),Gt=require("@polkadot/util");var ut=class extends Se{constructor(){super(...arguments);this.pools=[];this._poolLoaded=!1}async getPools(){if(this._poolLoaded){let n=await this.syncPool();this.pools=[n]}else{let n=await this.loadPool();this.pools=[n],this._poolLoaded=!0}return this.pools}async loadPool(){let n=await this.api.query.omnipool.assets.entries(),o=n.map(l=>this.getStorageKey(l,0)),t=this.getPoolId(),a=(await this.getPoolTokens(t,o)).map((l,b)=>{let y=n[b][1].toJSON();return{...l,hubReserves:L(y.hubReserve),shares:L(y.shares)}});return{address:t,type:"Omni",tradeFee:this.getTradeFee(),assetFee:this.getAssetFee(),protocolFee:this.getProtocolFee(),tokens:a,...this.getPoolLimits()}}async syncPool(){let n=await this.api.query.omnipool.assets.entries(),t=(await this.syncPoolTokens(this.pools[0].address,this.pools[0].tokens)).map((i,a)=>{let l=n[a][1].toJSON();return{...i,hubReserves:L(l.hubReserve),shares:L(l.shares)}});return{...this.pools[0],tokens:t}}getTradeFee(){let n=this.getAssetFee(),o=this.getProtocolFee();return[n[0]+o[0],1e3]}getAssetFee(){return[this.api.consts.omnipool.assetFee.toJSON()/1e3,1e3]}getProtocolFee(){return[this.api.consts.omnipool.protocolFee.toJSON()/1e3,1e3]}getPoolId(){return(0,Dt.encodeAddress)((0,Gt.stringToU8a)("modlomnipool".padEnd(32,"\0")),63)}getPoolLimits(){let n=this.api.consts.omnipool.maxInRatio.toJSON(),o=this.api.consts.omnipool.maxOutRatio.toJSON(),t=this.api.consts.omnipool.minimumTradingLimit.toJSON();return{maxInRatio:n,maxOutRatio:o,minTradingLimit:t}}};var _t=class{constructor(e){this.api=e,this.xykClient=new nt(this.api),this.omniClient=new ut(this.api),this.lbpClient=new ct(this.api)}async getPools(e){if(e.length==0)return(await Promise.all([this.xykClient.getPools(),this.omniClient.getPools(),this.lbpClient.getPools()])).flat();let n=[];return e.forEach(t=>{switch(t){case"XYK":n.push(this.xykClient.getPools());break;case"Omni":n.push(this.omniClient.getPools());break;case"LBP":n.push(this.lbpClient.getPools());break}}),(await Promise.all(n)).flat()}isOmnipoolTx(e){return e.length==1&&e[0].poolType=="Omni"}buildBuyTx(e,n,o,t,i){let a;this.isOmnipoolTx(i)?a=this.api.tx.omnipool.buy(n,e,o.toFixed(),t.toFixed()):a=this.api.tx.router.buy(e,n,o.toFixed(),t.toFixed(),i);let l=()=>a;return{hex:a.toHex(),name:"RouterBuy",get:l}}buildSellTx(e,n,o,t,i){let a;this.isOmnipoolTx(i)?a=this.api.tx.omnipool.sell(e,n,o.toFixed(),t.toFixed()):a=this.api.tx.router.sell(e,n,o.toFixed(),t.toFixed(),i);let l=()=>a;return{hex:a.toHex(),name:"RouterSell",get:l}}};var ve=class extends Error{constructor(e,n){super(),this.message=`${e} pool missing ${n}`,this.name="PoolConfigNotFound"}};function re(u,e){return u.shiftedBy(-1*e).toString()}function He(u){return u[0]/u[1]*100}function Ke(u){return u[0]/u[1]}var Ee=class{static fromPool(e){if(!e.repayFee)throw new ve("LBP","repayFee");if(!e.repayFeeApply)throw new ve("LBP","repayFeeApply");return new Ee(e.address,e.tradeFee,e.tokens,e.maxInRatio,e.maxOutRatio,e.minTradingLimit,e.repayFee,e.repayFeeApply)}constructor(e,n,o,t,i,a,l,b){this.type="LBP",this.address=e,this.tradeFee=n,this.tokens=o,this.maxInRatio=t,this.maxOutRatio=i,this.minTradingLimit=a,this.repayFee=l,this.repayFeeApply=b}validPair(e,n){return!0}parsePoolPair(e,n){let o=new Map(this.tokens.map(b=>[b.id,b])),t=o.get(e),i=o.get(n);if(t==null)throw new Error("Pool does not contain tokenIn");if(i==null)throw new Error("Pool does not contain tokenOut");let a=L(t.balance),l=L(i.balance);return{assetIn:e,assetOut:n,decimalsIn:t.decimals,decimalsOut:i.decimals,weightIn:t.weight,weightOut:i.weight,balanceIn:a,balanceOut:l}}validateBuy(e,n){if(this.tokens[0].id===e.assetOut){let t=this.calculateTradeFee(n),i=n.plus(t),a=this.calculateInGivenOut(e,i),l=He(this.repayFeeApply?this.repayFee:this.tradeFee);return{amountIn:a,calculatedIn:a,amountOut:n,feePct:l}}else{let t=this.calculateInGivenOut(e,n);return{amountIn:t,calculatedIn:t,amountOut:n,feePct:0}}}validateSell(e,n){if(this.tokens[0].id===e.assetIn){let t=this.calculateOutGivenIn(e,n);return{amountIn:n,calculatedOut:t,amountOut:t,feePct:0}}else{let t=this.calculateOutGivenIn(e,n),i=this.calculateTradeFee(t),a=t.minus(i),l=He(this.repayFeeApply?this.repayFee:this.tradeFee);return{amountIn:n,calculatedOut:t,amountOut:a,feePct:l}}}calculateInGivenOut(e,n){let o=he.calculateInGivenOut(e.balanceIn.toString(),e.balanceOut.toString(),e.weightIn.toString(),e.weightOut.toString(),n.toFixed(0)),t=L(o);return t.isNegative()?se:t}calculateOutGivenIn(e,n){let o=he.calculateOutGivenIn(e.balanceIn.toString(),e.balanceOut.toString(),e.weightIn.toString(),e.weightOut.toString(),n.toFixed(0)),t=L(o);return t.isNegative()?se:t}spotPriceInGivenOut(e){let n=he.getSpotPrice(e.balanceOut.toString(),e.balanceIn.toString(),e.weightOut.toString(),e.weightIn.toString(),_e(Oe,e.decimalsOut).toString());return L(n)}spotPriceOutGivenIn(e){let n=he.getSpotPrice(e.balanceIn.toString(),e.balanceOut.toString(),e.weightIn.toString(),e.weightOut.toString(),_e(Oe,e.decimalsIn).toString());return L(n)}calculateTradeFee(e){let n=he.calculatePoolTradeFee(e.toString(),this.repayFeeApply?this.repayFee[0]:this.tradeFee[0],this.repayFeeApply?this.repayFee[1]:this.tradeFee[1]);return L(n)}};var X=yt(qt()),Fe=class{static calculateSpotPrice(e,n,o,t){return(0,X.calculate_spot_price)(e,n,o,t)}static calculateInGivenOut(e,n,o,t,i,a,l,b,y){return(0,X.calculate_in_given_out)(e,n,o,t,i,a,l,b,y)}static calculateOutGivenIn(e,n,o,t,i,a,l,b,y){return(0,X.calculate_out_given_in)(e,n,o,t,i,a,l,b,y)}static calculatePoolTradeFee(e,n,o){return(0,X.calculate_pool_trade_fee)(e,n,o)}static calculateShares(e,n,o,t){return(0,X.calculate_shares)(e,n,o,t)}static calculateLiquidityOut(e,n,o,t,i,a,l){return(0,X.calculate_liquidity_out)(e,n,o,t,i,a,l)}static calculateLiquidityLRNAOut(e,n,o,t,i,a,l){return(0,X.calculate_liquidity_lrna_out)(e,n,o,t,i,a,l)}static calculateCapDifference(e,n,o,t){return(0,X.calculate_cap_difference)(e,n,o,t)}static verifyAssetCap(e,n,o,t){return(0,X.verify_asset_cap)(e,n,o,t)}static calculateLimitHubIn(e,n,o,t){return(0,X.calculate_liquidity_hub_in)(e,n,o,t)}static isSellAllowed(e){return(0,X.is_sell_allowed)(e)}static isBuyAllowed(e){return(0,X.is_buy_allowed)(e)}static isAddLiquidityAllowed(e){return(0,X.is_add_liquidity_allowed)(e)}static isRemoveLiquidityAllowed(e){return(0,X.is_remove_liquidity_allowed)(e)}};var Re=class{static fromPool(e){if(!e.assetFee)throw new ve("Omni","assetFee");if(!e.protocolFee)throw new ve("Omni","protocolFee");return new Re(e.address,e.tradeFee,e.tokens,e.maxInRatio,e.maxOutRatio,e.minTradingLimit,e.assetFee,e.protocolFee)}constructor(e,n,o,t,i,a,l,b){this.type="Omni",this.address=e,this.tradeFee=n,this.tokens=o,this.maxInRatio=t,this.maxOutRatio=i,this.minTradingLimit=a,this.assetFee=l,this.protocolFee=b}validPair(e,n){return!0}parsePoolPair(e,n){let o=new Map(this.tokens.map(b=>[b.id,b])),t=o.get(e),i=o.get(n);if(t==null)throw new Error("Pool does not contain tokenIn");if(i==null)throw new Error("Pool does not contain tokenOut");let a=L(t.balance),l=L(i.balance);return{assetIn:e,assetOut:n,hubReservesIn:t.hubReserves,hubReservesOut:i.hubReserves,sharesIn:t.shares,sharesOut:i.shares,decimalsIn:t.decimals,decimalsOut:i.decimals,balanceIn:a,balanceOut:l}}validateBuy(e,n){let o=this.calculateInGivenOut(e,n,!1),t=this.calculateInGivenOut(e,n,!0),i=t.minus(o),a=o===se?se:i.div(o).multipliedBy(100).decimalPlaces(2),l=[];n.isLessThan(this.minTradingLimit)&&l.push("InsufficientTradingAmount");let b=e.balanceOut.div(this.maxOutRatio);n.isGreaterThan(b)&&l.push("MaxOutRatioExceeded");let y=e.balanceIn.div(this.maxInRatio);return t.isGreaterThan(y)&&l.push("MaxInRatioExceeded"),{amountIn:t,calculatedIn:o,amountOut:n,feePct:a.toNumber(),errors:l}}validateSell(e,n){let o=this.calculateOutGivenIn(e,n,!1),t=this.calculateOutGivenIn(e,n,!0),a=o.minus(t).div(o).multipliedBy(100).decimalPlaces(2),l=[];n.isLessThan(this.minTradingLimit)&&l.push("InsufficientTradingAmount");let b=e.balanceIn.div(this.maxInRatio);n.isGreaterThan(b)&&l.push("MaxInRatioExceeded");let y=e.balanceOut.div(this.maxOutRatio);return t.isGreaterThan(y)&&l.push("MaxOutRatioExceeded"),{amountIn:n,calculatedOut:o,amountOut:t,feePct:a.toNumber(),errors:l}}calculateInGivenOut(e,n,o){let t=Fe.calculateInGivenOut(e.balanceIn.toString(),e.hubReservesIn.toString(),e.sharesIn.toString(),e.balanceOut.toString(),e.hubReservesOut.toString(),e.sharesOut.toString(),n.toFixed(0),o?Ke(this.assetFee).toString():se.toString(),o?Ke(this.protocolFee).toString():se.toString()),i=L(t);return i.isNegative()?se:i}calculateOutGivenIn(e,n,o){let t=Fe.calculateOutGivenIn(e.balanceIn.toString(),e.hubReservesIn.toString(),e.sharesIn.toString(),e.balanceOut.toString(),e.hubReservesOut.toString(),e.sharesOut.toString(),n.toFixed(0),o?Ke(this.assetFee).toString():se.toString(),o?Ke(this.protocolFee).toString():se.toString()),i=L(t);return i.isNegative()?se:i}spotPriceInGivenOut(e){let n=Fe.calculateSpotPrice(e.balanceOut.toString(),e.hubReservesOut.toString(),e.balanceIn.toString(),e.hubReservesIn.toString());return L(n).shiftedBy(-1*(18-e.decimalsOut)).decimalPlaces(0,1)}spotPriceOutGivenIn(e){let n=Fe.calculateSpotPrice(e.balanceIn.toString(),e.hubReservesIn.toString(),e.balanceOut.toString(),e.hubReservesOut.toString());return L(n).shiftedBy(-1*(18-e.decimalsIn)).decimalPlaces(0,1)}calculateTradeFee(e){throw new Error("Not supported in OmniPool")}};var ce=yt(Ht()),Te=class{static getSpotPrice(e,n,o){return(0,ce.get_spot_price)(e,n,o)}static calculateInGivenOut(e,n,o){return(0,ce.calculate_in_given_out)(e,n,o)}static calculateOutGivenIn(e,n,o){return(0,ce.calculate_out_given_in)(e,n,o)}static calculatePoolTradeFee(e,n,o){return(0,ce.calculate_pool_trade_fee)(e,n,o)}static calculateLiquidityIn(e,n,o){return(0,ce.calculate_liquidity_in)(e,n,o)}static calculateShares(e,n,o){return(0,ce.calculate_shares)(e,n,o)}static calculateLiquidityOutAssetA(e,n,o,t){return(0,ce.calculate_liquidity_out_asset_a)(e,n,o,t)}static calculateLiquidityOutAssetB(e,n,o,t){return(0,ce.calculate_liquidity_out_asset_b)(e,n,o,t)}};var Le=class{static fromPool(e){return new Le(e.address,e.tradeFee,e.tokens,e.maxInRatio,e.maxOutRatio,e.minTradingLimit)}constructor(e,n,o,t,i,a){this.type="XYK",this.address=e,this.tradeFee=n,this.tokens=o,this.maxInRatio=t,this.maxOutRatio=i,this.minTradingLimit=a}validPair(e,n){return!0}parsePoolPair(e,n){let o=new Map(this.tokens.map(b=>[b.id,b])),t=o.get(e),i=o.get(n);if(t==null)throw new Error("Pool does not contain tokenIn");if(i==null)throw new Error("Pool does not contain tokenOut");let a=L(t.balance),l=L(i.balance);return{assetIn:e,assetOut:n,decimalsIn:t.decimals,decimalsOut:i.decimals,balanceIn:a,balanceOut:l}}validateBuy(e,n){let o=this.calculateInGivenOut(e,n),t=this.calculateTradeFee(o),i=o.plus(t),a=He(this.tradeFee),l=[];n.isLessThan(this.minTradingLimit)&&l.push("InsufficientTradingAmount");let b=e.balanceOut.div(this.maxOutRatio);n.isGreaterThan(b)&&l.push("MaxOutRatioExceeded");let y=e.balanceIn.div(this.maxInRatio);return i.isGreaterThan(y)&&l.push("MaxInRatioExceeded"),{amountIn:i,calculatedIn:o,amountOut:n,feePct:a,errors:l}}validateSell(e,n){let o=this.calculateOutGivenIn(e,n),t=this.calculateTradeFee(o),i=o.minus(t),a=He(this.tradeFee),l=[];n.isLessThan(this.minTradingLimit)&&l.push("InsufficientTradingAmount");let b=e.balanceIn.div(this.maxInRatio);n.isGreaterThan(b)&&l.push("MaxInRatioExceeded");let y=e.balanceOut.div(this.maxOutRatio);return i.isGreaterThan(y)&&l.push("MaxOutRatioExceeded"),{amountIn:n,calculatedOut:o,amountOut:i,feePct:a,errors:l}}calculateInGivenOut(e,n){let o=Te.calculateInGivenOut(e.balanceIn.toString(),e.balanceOut.toString(),n.toFixed(0)),t=L(o);return t.isNegative()?se:t}calculateOutGivenIn(e,n){let o=Te.calculateOutGivenIn(e.balanceIn.toString(),e.balanceOut.toString(),n.toFixed(0)),t=L(o);return t.isNegative()?se:t}spotPriceInGivenOut(e){let n=Te.getSpotPrice(e.balanceOut.toString(),e.balanceIn.toString(),_e(Oe,e.decimalsOut).toString());return L(n)}spotPriceOutGivenIn(e){let n=Te.getSpotPrice(e.balanceIn.toString(),e.balanceOut.toString(),_e(Oe,e.decimalsIn).toString());return L(n)}calculateTradeFee(e){let n=Te.calculatePoolTradeFee(e.toString(),this.tradeFee[0],this.tradeFee[1]);return L(n)}};var Ue=class{static get(e){switch(e.type){case"XYK":return Le.fromPool(e);case"Omni":return Re.fromPool(e);case"LBP":return Ee.fromPool(e);default:throw new Error("Pool type "+e.type+" is not supported yet")}}};var Ge=class{constructor(e,n){this.defaultRouterOptions={includeOnly:[]};this.poolService=e,this.routeSuggester=new ze,this.routerOptions={...this.defaultRouterOptions,...n}}async getPools(){let e=this.routerOptions.includeOnly;return await this.poolService.getPools(e)}async getAllAssets(){let e=await this.getPools();if(e.length===0)throw new Error("No pools configured");let n=await this.getAssets(e);return[...new Map(n).values()]}async getAssetPairs(e){let n=await this.getPools();if(n.length===0)throw new Error("No pools configured");let{assets:o,poolsMap:t}=await this.validateToken(e,n),a=this.getPaths(e,null,t,n).map(l=>l[l.length-1].assetOut);return this.toPoolAssets([...new Set(a)],o)}async getAllPaths(e,n){let o=await this.getPools();if(o.length===0)throw new Error("No pools configured");let{poolsMap:t}=await this.validateTokenPair(e,n,o);return this.getPaths(e,n,t,o)}async getAssets(e){let n=e.map(o=>o.tokens.map(({id:t,symbol:i})=>({id:t,symbol:i}))).flat();return new Map(n.map(o=>[o.id,o]))}getPaths(e,n,o,t){return this.routeSuggester.getProposals(e,n,t).filter(l=>this.validPath(l,o)).map(l=>this.toHops(l,o))}async validateTokenPair(e,n,o){let t=await this.getAssets(o);if(t.get(e)==null)throw new Error(e+" is not supported token");if(t.get(n)==null)throw new Error(n+" is not supported token");let i=this.getPoolMap(o);return{assets:t,poolsMap:i}}async validateToken(e,n){let o=await this.getAssets(n);if(o.get(e)==null)throw new Error(e+" is not supported token");let t=this.getPoolMap(n);return{assets:o,poolsMap:t}}getPoolMap(e){return new Map(e.map(n=>[n.address,Ue.get(n)]))}validPath(e,n){return e.length>0&&e.map(o=>this.validEdge(o,n)).reduce((o,t)=>o&&t)}validEdge([e,n,o],t){return t.get(e)?.validPair(n,o)||!1}toHops(e,n){return e.map(([o,t,i])=>{let a=n.get(o);return{poolId:o,poolType:a?.type,assetIn:t,assetOut:i}})}toPoolAssets(e,n){return e.map(o=>{let t=n.get(o);return{id:o,symbol:t?.symbol}})}};function Ve(u,e,n,o){let t=u.shiftedBy(-1*e).multipliedBy(n),i=o;return t.minus(i).abs().div(t.plus(i).div(2)).multipliedBy(100).decimalPlaces(2)}function Ut(u,e){return Oe.minus(e.div(u)).multipliedBy(100).decimalPlaces(2)}function Xt(u,e){return e.div(u).minus(Oe).multipliedBy(100).decimalPlaces(2)}var $e=class extends Ge{async getBestSpotPrice(e,n){let o=await super.getPools();if(o.length===0)throw new Error("No pools configured");let{poolsMap:t}=await super.validateTokenPair(e,n,o);return super.getPaths(e,n,t,o).map(l=>this.getSpotPrice(l,t)).sort((l,b)=>{let y=l.amount,B=b.amount;return y.isGreaterThan(B)?-1:1})[0]}getSpotPrice(e,n){let o=[];for(let a=0;a<e.length;a++){let l=e[a],b=n.get(l.poolId);if(b==null)throw new Error("Pool does not exit");let y=b.parsePoolPair(l.assetIn,l.assetOut),B=b.spotPriceOutGivenIn(y);o.push({amount:B,decimals:y.decimalsOut})}let t=o.map(a=>a.amount.shiftedBy(-1*a.decimals)).reduce((a,l)=>a.multipliedBy(l)),i=o[o.length-1].decimals;return{amount:_e(t,i).decimalPlaces(0,1),decimals:i}}isDirectTrade(e){return e.length==1}async getBestSell(e,n,o){let t=await super.getPools();if(t.length===0)throw new Error("No pools configured");let{poolsMap:i}=await super.validateTokenPair(e,n,t),b=super.getPaths(e,n,i,t).map(D=>this.toSellSwaps(o,D,i)).sort((D,G)=>{let Q=D[D.length-1].amountOut,r=G[G.length-1].amountOut;return Q.isGreaterThan(r)?-1:1}),y=b.find(D=>D.every(G=>G.errors.length==0))||b[0],B=y[0],I=y[y.length-1],E=this.isDirectTrade(y),R=y.map(D=>D.spotPrice.shiftedBy(-1*D.assetOutDecimals)).reduce((D,G)=>D.multipliedBy(G)),k=_e(R,I.assetOutDecimals).decimalPlaces(0,1),W=Ve(B.amountIn,B.assetInDecimals,k,I.calculatedOut),H=E?I.calculatedOut:this.calculateDelta0Y(B.amountIn,y,i),z=I.amountOut,x=E?I.tradeFeePct:Ut(H,z).toNumber(),oe=H.minus(z),pe=D=>this.poolService.buildSellTx(e,n,B.amountIn,D,y.map(G=>G));return{type:"Sell",amountIn:B.amountIn,amountOut:I.amountOut,spotPrice:k,tradeFee:oe,tradeFeePct:x,priceImpactPct:W.toNumber(),swaps:y,toTx:pe,toHuman(){return{type:"Sell",amountIn:re(B.amountIn,B.assetInDecimals),amountOut:re(I.amountOut,I.assetOutDecimals),spotPrice:re(k,I.assetOutDecimals),tradeFee:re(oe,I.assetOutDecimals),tradeFeePct:x,priceImpactPct:W.toNumber(),swaps:y.map(D=>D.toHuman())}}}}calculateDelta0Y(e,n,o){let t=[];for(let i=0;i<n.length;i++){let a=n[i],l=o.get(a.poolId);if(l==null)throw new Error("Pool does not exit");let b=l.parsePoolPair(a.assetIn,a.assetOut),y;i>0?y=t[i-1]:y=e;let B=l.calculateOutGivenIn(b,y,!1);t.push(B)}return t[t.length-1]}toSellSwaps(e,n,o){let t=[];for(let i=0;i<n.length;i++){let a=n[i],l=o.get(a.poolId);if(l==null)throw new Error("Pool does not exit");let b=l.parsePoolPair(a.assetIn,a.assetOut),y;i>0?y=t[i-1].amountOut:y=_e(L(e),b.decimalsIn).decimalPlaces(0,1);let{amountOut:B,calculatedOut:I,feePct:E,errors:R}=l.validateSell(b,y),k=l.spotPriceOutGivenIn(b),W=Ve(y,b.decimalsIn,k,I);t.push({...a,assetInDecimals:b.decimalsIn,assetOutDecimals:b.decimalsOut,amountIn:y,calculatedOut:I,amountOut:B,spotPrice:k,tradeFeePct:E,priceImpactPct:W.toNumber(),errors:R,toHuman(){return{...a,amountIn:re(y,b.decimalsIn),calculatedOut:re(I,b.decimalsOut),amountOut:re(B,b.decimalsOut),spotPrice:re(k,b.decimalsOut),tradeFeePct:E,priceImpactPct:W.toNumber(),errors:R}}})}return t}async getBestBuy(e,n,o){let t=await super.getPools();if(t.length===0)throw new Error("No pools configured");let{poolsMap:i}=await super.validateTokenPair(e,n,t),b=super.getPaths(e,n,i,t).map(D=>this.toBuySwaps(o,D,i)).sort((D,G)=>{let Q=D[0].amountIn,r=G[0].amountIn;return Q.isGreaterThan(r)?1:-1}),y=b.find(D=>D.every(G=>G.errors.length==0))||b[0],B=y[y.length-1],I=y[0],E=this.isDirectTrade(y),R=y.map(D=>D.spotPrice.shiftedBy(-1*D.assetInDecimals)).reduce((D,G)=>D.multipliedBy(G)),k=_e(R,I.assetInDecimals).decimalPlaces(0,1),W=Ve(B.amountOut,B.assetOutDecimals,k,I.calculatedIn),H=E?I.calculatedIn:this.calculateDelta0X(B.amountOut,y,i),z=I.amountIn,x=E?I.tradeFeePct:Xt(H,z),oe=z.minus(H),pe=D=>this.poolService.buildBuyTx(e,n,B.amountOut,D,y.map(G=>G));return{type:"Buy",amountOut:B.amountOut,amountIn:I.amountIn,spotPrice:k,tradeFee:oe,tradeFeePct:x,priceImpactPct:W.toNumber(),swaps:y,toTx:pe,toHuman(){return{type:"Buy",amountOut:re(B.amountOut,B.assetOutDecimals),amountIn:re(I.amountIn,I.assetInDecimals),spotPrice:re(k,I.assetInDecimals),tradeFee:re(oe,I.assetInDecimals),tradeFeePct:x,priceImpactPct:W.toNumber(),swaps:y.map(D=>D.toHuman())}}}}calculateDelta0X(e,n,o){let t=[];for(let i=n.length-1;i>=0;i--){let a=n[i],l=o.get(a.poolId);if(l==null)throw new Error("Pool does not exit");let b=l.parsePoolPair(a.assetIn,a.assetOut),y;i==n.length-1?y=e:y=t[0];let B=l.calculateInGivenOut(b,y,!1);t.unshift(B)}return t[0]}toBuySwaps(e,n,o){let t=[];for(let i=n.length-1;i>=0;i--){let a=n[i],l=o.get(a.poolId);if(l==null)throw new Error("Pool does not exit");let b=l.parsePoolPair(a.assetIn,a.assetOut),y;i==n.length-1?y=_e(L(e),b.decimalsOut).decimalPlaces(0,1):y=t[0].amountIn;let{amountIn:B,calculatedIn:I,feePct:E,errors:R}=l.validateBuy(b,y),k=l.spotPriceInGivenOut(b),W=Ve(y,b.decimalsOut,k,I);t.unshift({...a,assetInDecimals:b.decimalsIn,assetOutDecimals:b.decimalsOut,amountOut:y,calculatedIn:I,amountIn:B,spotPrice:k,tradeFeePct:E,priceImpactPct:W.toNumber(),errors:R,toHuman(){return{...a,amountOut:re(y,b.decimalsOut),calculatedIn:re(I,b.decimalsIn),amountIn:re(B,b.decimalsIn),spotPrice:re(k,b.decimalsIn),tradeFeePct:E,priceImpactPct:W.toNumber(),errors:R}}})}return t}};0&&(module.exports={BigNumber,DECIMAL_PLACES,DENOMINATOR,HYDRADX_PARACHAIN_ID,HYDRADX_SS58_PREFIX,INFINITY,LbpMath,LbpPool,ONE,OmniMath,OmniPool,PolkadotApiPoolService,PoolConfigNotFound,PoolError,PoolFactory,PoolType,RUNTIME_DECIMALS,Router,SYSTEM_ASSET_DECIMALS,SYSTEM_ASSET_ID,TradeRouter,TradeType,XykMath,XykPool,ZERO,bnum,scale});
|
|
1
|
+
"use strict";var zt=Object.create;var et=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Vt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var Ot=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports),Zt=(u,e)=>{for(var t in e)et(u,t,{get:e[t],enumerable:!0})},Ft=(u,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Jt(e))!$t.call(u,n)&&n!==t&&et(u,n,{get:()=>e[n],enumerable:!(o=Kt(e,n))||o.enumerable});return u};var It=(u,e,t)=>(t=u!=null?zt(Vt(u)):{},Ft(e||!u||!u.__esModule?et(t,"default",{value:u,enumerable:!0}):t,u)),Qt=u=>Ft(et({},"__esModule",{value:!0}),u);var Dt=Ot((co,De)=>{var nn={},N,{TextEncoder:on,TextDecoder:rn}=require("util"),$=0,at=null;function ct(){return(at===null||at.buffer!==N.memory.buffer)&&(at=new Uint8Array(N.memory.buffer)),at}var ut=new on("utf-8"),sn=typeof ut.encodeInto=="function"?function(u,e){return ut.encodeInto(u,e)}:function(u,e){let t=ut.encode(u);return e.set(t),{read:u.length,written:t.length}};function ee(u,e,t){if(t===void 0){let l=ut.encode(u),f=e(l.length);return ct().subarray(f,f+l.length).set(l),$=l.length,f}let o=u.length,n=e(o),i=ct(),a=0;for(;a<o;a++){let l=u.charCodeAt(a);if(l>127)break;i[n+a]=l}if(a!==o){a!==0&&(u=u.slice(a)),n=t(n,o,o=a+u.length*3);let l=ct().subarray(n+a,n+o);a+=sn(u,l).written}return $=a,n}var lt=null;function Se(){return(lt===null||lt.buffer!==N.memory.buffer)&&(lt=new Int32Array(N.memory.buffer)),lt}var Mt=new rn("utf-8",{ignoreBOM:!0,fatal:!0});Mt.decode();function $e(u,e){return Mt.decode(ct().subarray(u,u+e))}De.exports.calculate_pool_trade_fee=function(u,e,t){try{let i=N.__wbindgen_add_to_stack_pointer(-16),a=ee(u,N.__wbindgen_malloc,N.__wbindgen_realloc),l=$;N.calculate_pool_trade_fee(i,a,l,e,t);var o=Se()[i/4+0],n=Se()[i/4+1];return $e(o,n)}finally{N.__wbindgen_add_to_stack_pointer(16),N.__wbindgen_free(o,n)}};De.exports.get_spot_price=function(u,e,t,o,n){try{let l=N.__wbindgen_add_to_stack_pointer(-16),f=ee(u,N.__wbindgen_malloc,N.__wbindgen_realloc),P=$,S=ee(e,N.__wbindgen_malloc,N.__wbindgen_realloc),x=$,k=ee(t,N.__wbindgen_malloc,N.__wbindgen_realloc),R=$,A=ee(o,N.__wbindgen_malloc,N.__wbindgen_realloc),G=$,q=ee(n,N.__wbindgen_malloc,N.__wbindgen_realloc),X=$;N.get_spot_price(l,f,P,S,x,k,R,A,G,q,X);var i=Se()[l/4+0],a=Se()[l/4+1];return $e(i,a)}finally{N.__wbindgen_add_to_stack_pointer(16),N.__wbindgen_free(i,a)}};De.exports.calculate_out_given_in=function(u,e,t,o,n){try{let l=N.__wbindgen_add_to_stack_pointer(-16),f=ee(u,N.__wbindgen_malloc,N.__wbindgen_realloc),P=$,S=ee(e,N.__wbindgen_malloc,N.__wbindgen_realloc),x=$,k=ee(t,N.__wbindgen_malloc,N.__wbindgen_realloc),R=$,A=ee(o,N.__wbindgen_malloc,N.__wbindgen_realloc),G=$,q=ee(n,N.__wbindgen_malloc,N.__wbindgen_realloc),X=$;N.calculate_out_given_in(l,f,P,S,x,k,R,A,G,q,X);var i=Se()[l/4+0],a=Se()[l/4+1];return $e(i,a)}finally{N.__wbindgen_add_to_stack_pointer(16),N.__wbindgen_free(i,a)}};De.exports.calculate_in_given_out=function(u,e,t,o,n){try{let l=N.__wbindgen_add_to_stack_pointer(-16),f=ee(u,N.__wbindgen_malloc,N.__wbindgen_realloc),P=$,S=ee(e,N.__wbindgen_malloc,N.__wbindgen_realloc),x=$,k=ee(t,N.__wbindgen_malloc,N.__wbindgen_realloc),R=$,A=ee(o,N.__wbindgen_malloc,N.__wbindgen_realloc),G=$,q=ee(n,N.__wbindgen_malloc,N.__wbindgen_realloc),X=$;N.calculate_in_given_out(l,f,P,S,x,k,R,A,G,q,X);var i=Se()[l/4+0],a=Se()[l/4+1];return $e(i,a)}finally{N.__wbindgen_add_to_stack_pointer(16),N.__wbindgen_free(i,a)}};De.exports.calculate_linear_weights=function(u,e,t,o,n){try{let l=N.__wbindgen_add_to_stack_pointer(-16),f=ee(u,N.__wbindgen_malloc,N.__wbindgen_realloc),P=$,S=ee(e,N.__wbindgen_malloc,N.__wbindgen_realloc),x=$,k=ee(t,N.__wbindgen_malloc,N.__wbindgen_realloc),R=$,A=ee(o,N.__wbindgen_malloc,N.__wbindgen_realloc),G=$,q=ee(n,N.__wbindgen_malloc,N.__wbindgen_realloc),X=$;N.calculate_linear_weights(l,f,P,S,x,k,R,A,G,q,X);var i=Se()[l/4+0],a=Se()[l/4+1];return $e(i,a)}finally{N.__wbindgen_add_to_stack_pointer(16),N.__wbindgen_free(i,a)}};var an=require("path").join(__dirname,"hydra_dx_wasm_bg.wasm"),ln=require("fs").readFileSync(an),cn=new WebAssembly.Module(ln),un=new WebAssembly.Instance(cn,nn);N=un.exports;De.exports.__wasm=N});var Wt=Ot((er,ne)=>{var _n={},_,{TextEncoder:dn,TextDecoder:gn}=require("util"),v=0,Nt=new Uint8Array;function pt(){return Nt.byteLength===0&&(Nt=new Uint8Array(_.memory.buffer)),Nt}var mt=new dn("utf-8"),pn=typeof mt.encodeInto=="function"?function(u,e){return mt.encodeInto(u,e)}:function(u,e){let t=mt.encode(u);return e.set(t),{read:u.length,written:t.length}};function T(u,e,t){if(t===void 0){let l=mt.encode(u),f=e(l.length);return pt().subarray(f,f+l.length).set(l),v=l.length,f}let o=u.length,n=e(o),i=pt(),a=0;for(;a<o;a++){let l=u.charCodeAt(a);if(l>127)break;i[n+a]=l}if(a!==o){a!==0&&(u=u.slice(a)),n=t(n,o,o=a+u.length*3);let l=pt().subarray(n+a,n+o);a+=pn(u,l).written}return v=a,n}var At=new Int32Array;function z(){return At.byteLength===0&&(At=new Int32Array(_.memory.buffer)),At}var qt=new gn("utf-8",{ignoreBOM:!0,fatal:!0});qt.decode();function pe(u,e){return qt.decode(pt().subarray(u,u+e))}ne.exports.calculate_pool_trade_fee=function(u,e,t){try{let i=_.__wbindgen_add_to_stack_pointer(-16),a=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),l=v;_.calculate_pool_trade_fee(i,a,l,e,t);var o=z()[i/4+0],n=z()[i/4+1];return pe(o,n)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(o,n)}};ne.exports.calculate_shares=function(u,e,t,o){try{let a=_.__wbindgen_add_to_stack_pointer(-16),l=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),f=v,P=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),S=v,x=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),k=v,R=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),A=v;_.calculate_shares(a,l,f,P,S,x,k,R,A);var n=z()[a/4+0],i=z()[a/4+1];return pe(n,i)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(n,i)}};ne.exports.calculate_liquidity_out=function(u,e,t,o,n,i,a){try{let P=_.__wbindgen_add_to_stack_pointer(-16),S=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),x=v,k=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),R=v,A=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),G=v,q=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),X=v,I=T(n,_.__wbindgen_malloc,_.__wbindgen_realloc),oe=v,ae=T(i,_.__wbindgen_malloc,_.__wbindgen_realloc),D=v,C=T(a,_.__wbindgen_malloc,_.__wbindgen_realloc),j=v;_.calculate_liquidity_out(P,S,x,k,R,A,G,q,X,I,oe,ae,D,C,j);var l=z()[P/4+0],f=z()[P/4+1];return pe(l,f)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(l,f)}};ne.exports.calculate_liquidity_lrna_out=function(u,e,t,o,n,i,a){try{let P=_.__wbindgen_add_to_stack_pointer(-16),S=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),x=v,k=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),R=v,A=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),G=v,q=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),X=v,I=T(n,_.__wbindgen_malloc,_.__wbindgen_realloc),oe=v,ae=T(i,_.__wbindgen_malloc,_.__wbindgen_realloc),D=v,C=T(a,_.__wbindgen_malloc,_.__wbindgen_realloc),j=v;_.calculate_liquidity_lrna_out(P,S,x,k,R,A,G,q,X,I,oe,ae,D,C,j);var l=z()[P/4+0],f=z()[P/4+1];return pe(l,f)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(l,f)}};ne.exports.calculate_out_given_in=function(u,e,t,o,n,i,a,l,f){try{let x=_.__wbindgen_add_to_stack_pointer(-16),k=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),R=v,A=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),G=v,q=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),X=v,I=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),oe=v,ae=T(n,_.__wbindgen_malloc,_.__wbindgen_realloc),D=v,C=T(i,_.__wbindgen_malloc,_.__wbindgen_realloc),j=v,r=T(a,_.__wbindgen_malloc,_.__wbindgen_realloc),s=v,c=T(l,_.__wbindgen_malloc,_.__wbindgen_realloc),h=v,g=T(f,_.__wbindgen_malloc,_.__wbindgen_realloc),m=v;_.calculate_out_given_in(x,k,R,A,G,q,X,I,oe,ae,D,C,j,r,s,c,h,g,m);var P=z()[x/4+0],S=z()[x/4+1];return pe(P,S)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(P,S)}};ne.exports.calculate_out_given_lrna_in=function(u,e,t,o,n){try{let l=_.__wbindgen_add_to_stack_pointer(-16),f=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),P=v,S=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),x=v,k=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),R=v,A=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),G=v,q=T(n,_.__wbindgen_malloc,_.__wbindgen_realloc),X=v;_.calculate_out_given_lrna_in(l,f,P,S,x,k,R,A,G,q,X);var i=z()[l/4+0],a=z()[l/4+1];return pe(i,a)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(i,a)}};ne.exports.calculate_in_given_out=function(u,e,t,o,n,i,a,l,f){try{let x=_.__wbindgen_add_to_stack_pointer(-16),k=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),R=v,A=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),G=v,q=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),X=v,I=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),oe=v,ae=T(n,_.__wbindgen_malloc,_.__wbindgen_realloc),D=v,C=T(i,_.__wbindgen_malloc,_.__wbindgen_realloc),j=v,r=T(a,_.__wbindgen_malloc,_.__wbindgen_realloc),s=v,c=T(l,_.__wbindgen_malloc,_.__wbindgen_realloc),h=v,g=T(f,_.__wbindgen_malloc,_.__wbindgen_realloc),m=v;_.calculate_in_given_out(x,k,R,A,G,q,X,I,oe,ae,D,C,j,r,s,c,h,g,m);var P=z()[x/4+0],S=z()[x/4+1];return pe(P,S)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(P,S)}};ne.exports.calculate_lrna_in_given_out=function(u,e,t,o,n){try{let l=_.__wbindgen_add_to_stack_pointer(-16),f=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),P=v,S=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),x=v,k=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),R=v,A=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),G=v,q=T(n,_.__wbindgen_malloc,_.__wbindgen_realloc),X=v;_.calculate_lrna_in_given_out(l,f,P,S,x,k,R,A,G,q,X);var i=z()[l/4+0],a=z()[l/4+1];return pe(i,a)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(i,a)}};ne.exports.calculate_spot_price=function(u,e,t,o){try{let a=_.__wbindgen_add_to_stack_pointer(-16),l=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),f=v,P=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),S=v,x=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),k=v,R=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),A=v;_.calculate_spot_price(a,l,f,P,S,x,k,R,A);var n=z()[a/4+0],i=z()[a/4+1];return pe(n,i)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(n,i)}};ne.exports.calculate_lrna_spot_price=function(u,e){try{let n=_.__wbindgen_add_to_stack_pointer(-16),i=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),a=v,l=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),f=v;_.calculate_lrna_spot_price(n,i,a,l,f);var t=z()[n/4+0],o=z()[n/4+1];return pe(t,o)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(t,o)}};ne.exports.calculate_cap_difference=function(u,e,t,o){try{let a=_.__wbindgen_add_to_stack_pointer(-16),l=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),f=v,P=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),S=v,x=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),k=v,R=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),A=v;_.calculate_cap_difference(a,l,f,P,S,x,k,R,A);var n=z()[a/4+0],i=z()[a/4+1];return pe(n,i)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(n,i)}};ne.exports.verify_asset_cap=function(u,e,t,o){let n=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),i=v,a=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),l=v,f=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),P=v,S=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),x=v;return _.verify_asset_cap(n,i,a,l,f,P,S,x)!==0};ne.exports.calculate_tvl_cap_difference=function(u,e,t,o,n,i){try{let f=_.__wbindgen_add_to_stack_pointer(-16),P=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),S=v,x=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),k=v,R=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),A=v,G=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),q=v,X=T(n,_.__wbindgen_malloc,_.__wbindgen_realloc),I=v,oe=T(i,_.__wbindgen_malloc,_.__wbindgen_realloc),ae=v;_.calculate_tvl_cap_difference(f,P,S,x,k,R,A,G,q,X,I,oe,ae);var a=z()[f/4+0],l=z()[f/4+1];return pe(a,l)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(a,l)}};ne.exports.calculate_liquidity_hub_in=function(u,e,t,o){try{let a=_.__wbindgen_add_to_stack_pointer(-16),l=T(u,_.__wbindgen_malloc,_.__wbindgen_realloc),f=v,P=T(e,_.__wbindgen_malloc,_.__wbindgen_realloc),S=v,x=T(t,_.__wbindgen_malloc,_.__wbindgen_realloc),k=v,R=T(o,_.__wbindgen_malloc,_.__wbindgen_realloc),A=v;_.calculate_liquidity_hub_in(a,l,f,P,S,x,k,R,A);var n=z()[a/4+0],i=z()[a/4+1];return pe(n,i)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_free(n,i)}};ne.exports.is_sell_allowed=function(u){return _.is_sell_allowed(u)!==0};ne.exports.is_buy_allowed=function(u){return _.is_buy_allowed(u)!==0};ne.exports.is_add_liquidity_allowed=function(u){return _.is_add_liquidity_allowed(u)!==0};ne.exports.is_remove_liquidity_allowed=function(u){return _.is_remove_liquidity_allowed(u)!==0};var mn=require("path").join(__dirname,"hydra_dx_wasm_bg.wasm"),fn=require("fs").readFileSync(mn),hn=new WebAssembly.Module(fn),bn=new WebAssembly.Instance(hn,_n);_=bn.exports;ne.exports.__wasm=_});var Ut=Ot((hr,ve)=>{var wn={},B,{TextEncoder:Pn,TextDecoder:yn}=require("util"),K=0,ft=null;function bt(){return(ft===null||ft.buffer!==B.memory.buffer)&&(ft=new Uint8Array(B.memory.buffer)),ft}var wt=new Pn("utf-8"),On=typeof wt.encodeInto=="function"?function(u,e){return wt.encodeInto(u,e)}:function(u,e){let t=wt.encode(u);return e.set(t),{read:u.length,written:t.length}};function J(u,e,t){if(t===void 0){let l=wt.encode(u),f=e(l.length);return bt().subarray(f,f+l.length).set(l),K=l.length,f}let o=u.length,n=e(o),i=bt(),a=0;for(;a<o;a++){let l=u.charCodeAt(a);if(l>127)break;i[n+a]=l}if(a!==o){a!==0&&(u=u.slice(a)),n=t(n,o,o=a+u.length*3);let l=bt().subarray(n+a,n+o);a+=On(u,l).written}return K=a,n}var ht=null;function ce(){return(ht===null||ht.buffer!==B.memory.buffer)&&(ht=new Int32Array(B.memory.buffer)),ht}var Ht=new yn("utf-8",{ignoreBOM:!0,fatal:!0});Ht.decode();function Le(u,e){return Ht.decode(bt().subarray(u,u+e))}ve.exports.calculate_pool_trade_fee=function(u,e,t){try{let i=B.__wbindgen_add_to_stack_pointer(-16),a=J(u,B.__wbindgen_malloc,B.__wbindgen_realloc),l=K;B.calculate_pool_trade_fee(i,a,l,e,t);var o=ce()[i/4+0],n=ce()[i/4+1];return Le(o,n)}finally{B.__wbindgen_add_to_stack_pointer(16),B.__wbindgen_free(o,n)}};ve.exports.get_spot_price=function(u,e,t){try{let i=B.__wbindgen_add_to_stack_pointer(-16),a=J(u,B.__wbindgen_malloc,B.__wbindgen_realloc),l=K,f=J(e,B.__wbindgen_malloc,B.__wbindgen_realloc),P=K,S=J(t,B.__wbindgen_malloc,B.__wbindgen_realloc),x=K;B.get_spot_price(i,a,l,f,P,S,x);var o=ce()[i/4+0],n=ce()[i/4+1];return Le(o,n)}finally{B.__wbindgen_add_to_stack_pointer(16),B.__wbindgen_free(o,n)}};ve.exports.calculate_out_given_in=function(u,e,t){try{let i=B.__wbindgen_add_to_stack_pointer(-16),a=J(u,B.__wbindgen_malloc,B.__wbindgen_realloc),l=K,f=J(e,B.__wbindgen_malloc,B.__wbindgen_realloc),P=K,S=J(t,B.__wbindgen_malloc,B.__wbindgen_realloc),x=K;B.calculate_out_given_in(i,a,l,f,P,S,x);var o=ce()[i/4+0],n=ce()[i/4+1];return Le(o,n)}finally{B.__wbindgen_add_to_stack_pointer(16),B.__wbindgen_free(o,n)}};ve.exports.calculate_in_given_out=function(u,e,t){try{let i=B.__wbindgen_add_to_stack_pointer(-16),a=J(u,B.__wbindgen_malloc,B.__wbindgen_realloc),l=K,f=J(e,B.__wbindgen_malloc,B.__wbindgen_realloc),P=K,S=J(t,B.__wbindgen_malloc,B.__wbindgen_realloc),x=K;B.calculate_in_given_out(i,a,l,f,P,S,x);var o=ce()[i/4+0],n=ce()[i/4+1];return Le(o,n)}finally{B.__wbindgen_add_to_stack_pointer(16),B.__wbindgen_free(o,n)}};ve.exports.calculate_liquidity_in=function(u,e,t){try{let i=B.__wbindgen_add_to_stack_pointer(-16),a=J(u,B.__wbindgen_malloc,B.__wbindgen_realloc),l=K,f=J(e,B.__wbindgen_malloc,B.__wbindgen_realloc),P=K,S=J(t,B.__wbindgen_malloc,B.__wbindgen_realloc),x=K;B.calculate_liquidity_in(i,a,l,f,P,S,x);var o=ce()[i/4+0],n=ce()[i/4+1];return Le(o,n)}finally{B.__wbindgen_add_to_stack_pointer(16),B.__wbindgen_free(o,n)}};ve.exports.calculate_shares=function(u,e,t){try{let i=B.__wbindgen_add_to_stack_pointer(-16),a=J(u,B.__wbindgen_malloc,B.__wbindgen_realloc),l=K,f=J(e,B.__wbindgen_malloc,B.__wbindgen_realloc),P=K,S=J(t,B.__wbindgen_malloc,B.__wbindgen_realloc),x=K;B.calculate_shares(i,a,l,f,P,S,x);var o=ce()[i/4+0],n=ce()[i/4+1];return Le(o,n)}finally{B.__wbindgen_add_to_stack_pointer(16),B.__wbindgen_free(o,n)}};ve.exports.calculate_liquidity_out_asset_a=function(u,e,t,o){try{let a=B.__wbindgen_add_to_stack_pointer(-16),l=J(u,B.__wbindgen_malloc,B.__wbindgen_realloc),f=K,P=J(e,B.__wbindgen_malloc,B.__wbindgen_realloc),S=K,x=J(t,B.__wbindgen_malloc,B.__wbindgen_realloc),k=K,R=J(o,B.__wbindgen_malloc,B.__wbindgen_realloc),A=K;B.calculate_liquidity_out_asset_a(a,l,f,P,S,x,k,R,A);var n=ce()[a/4+0],i=ce()[a/4+1];return Le(n,i)}finally{B.__wbindgen_add_to_stack_pointer(16),B.__wbindgen_free(n,i)}};ve.exports.calculate_liquidity_out_asset_b=function(u,e,t,o){try{let a=B.__wbindgen_add_to_stack_pointer(-16),l=J(u,B.__wbindgen_malloc,B.__wbindgen_realloc),f=K,P=J(e,B.__wbindgen_malloc,B.__wbindgen_realloc),S=K,x=J(t,B.__wbindgen_malloc,B.__wbindgen_realloc),k=K,R=J(o,B.__wbindgen_malloc,B.__wbindgen_realloc),A=K;B.calculate_liquidity_out_asset_b(a,l,f,P,S,x,k,R,A);var n=ce()[a/4+0],i=ce()[a/4+1];return Le(n,i)}finally{B.__wbindgen_add_to_stack_pointer(16),B.__wbindgen_free(n,i)}};var In=require("path").join(__dirname,"hydra_dx_wasm_bg.wasm"),xn=require("fs").readFileSync(In),Sn=new WebAssembly.Module(xn),Bn=new WebAssembly.Instance(Sn,wn);B=Bn.exports;ve.exports.__wasm=B});var vn={};Zt(vn,{BigNumber:()=>He,DECIMAL_PLACES:()=>Lt,DENOMINATOR:()=>qe,HYDRADX_PARACHAIN_ID:()=>Kn,HYDRADX_SS58_PREFIX:()=>kt,INFINITY:()=>tn,LbpMath:()=>we,LbpPool:()=>Ee,ONE:()=>xe,OmniMath:()=>me,OmniPool:()=>Re,PolkadotApiPoolService:()=>gt,PoolConfigNotFound:()=>Fe,PoolError:()=>nt,PoolFactory:()=>Ye,PoolType:()=>Oe,RUNTIME_DECIMALS:()=>Ve,RouteNotFound:()=>Ue,Router:()=>Ce,SYSTEM_ASSET_DECIMALS:()=>zn,SYSTEM_ASSET_ID:()=>ot,TradeRouter:()=>Qe,TradeType:()=>St,XykMath:()=>Te,XykPool:()=>Me,ZERO:()=>te,bnum:()=>L,scale:()=>de});module.exports=Qt(vn);var tt=class{constructor(e=1/0){this.capacity=e;this.storage=[]}enqueue(e){if(this.size()===this.capacity)throw Error("Queue has reached max capacity, you cannot add more items");this.storage.push(e)}dequeue(){return this.storage.shift()}size(){return this.storage.length}};var jt=4,Ke=class{isNotVisited(e,t){let o=!0;return t.forEach(n=>{(n[0]===e[0]||n[1]===e[1])&&(o=!1)}),o}findPaths(e,t,o){let n=[],i=new tt,a=[];for(a.push([t,""]),i.enqueue(a);i.size()>0;){let l=i.dequeue();if(l==null||l.length>jt)return n;let f=l[l.length-1];(o===null||f[0]===o)&&n.push(l),e[f[0]].forEach(S=>{if(this.isNotVisited(S,l)){let x=[...l];x.push(S),i.enqueue(x)}})}return n}buildAndPopulateGraph(e,t){let o=e[e.length-1],n=[];for(let i=0;i<=parseInt(o);i++)n.push([]);for(let[i,a,l]of t){let f=parseInt(a),P=parseInt(l);n[f].push([P,i])}return n}};function xt(u){let e={};for(let t of u){let o=t.tokens.length;for(let n=0;n<o;n++){e[t.tokens[n].id]||(e[t.tokens[n].id]=[]);for(let i=0;i<o;i++){if(n==i)continue;let a=[t.address,t.tokens[n].id,t.tokens[i].id];e[t.tokens[n].id].push(a)}}}return e}var Je=class{getProposals(e,t,o){let n=xt(o),i=Object.keys(n),a=i.map(S=>n[S]).flat(),l=new Ke,f=l.buildAndPopulateGraph(i,a),P=l.findPaths(f,parseInt(e),t?parseInt(t):null);return this.parsePaths(P)}parsePaths(e){let t=[];for(let o of e){let n=[];for(let i=0;i<o.length;i++){let a=o[i],l=o[i+1];if(l==null)break;n.push(this.toEdge(a,l))}t.push(n)}return t}toEdge(e,t){return[t[1],e[0].toString(),t[0].toString()]}};var Oe=(n=>(n.XYK="XYK",n.LBP="LBP",n.Stable="Stable",n.Omni="Omni",n))(Oe||{}),nt=(o=>(o.InsufficientTradingAmount="InsufficientTradingAmount",o.MaxInRatioExceeded="MaxInRatioExceeded",o.MaxOutRatioExceeded="MaxOutRatioExceeded",o))(nt||{}),St=(t=>(t.Buy="Buy",t.Sell="Sell",t))(St||{});var Ve=18,ot="0",zn=12,Kn=2034,kt=63,qe=1e3;var $n=require("@polkadot/api-augment"),Ne=class{constructor(e){this.api=e}getStorageKey(e,t){return e[0].toHuman()[t]}getStorageEntryArray(e){return e[1].toHuman()}async getPoolTokens(e,t){let o=t.map(async n=>{let i=await this.getAccountBalance(e,n),l=(await this.getAssetMetadata(n)).toHuman();if(ot==n){let f=this.api.registry.chainDecimals[0],P=this.api.registry.chainTokens[0];return{id:n,balance:i,decimals:f,symbol:P}}return{id:n,balance:i,decimals:l.decimals,symbol:l.symbol}});return Promise.all(o)}async syncPoolTokens(e,t){let o=t.map(async n=>{let i=await this.getAccountBalance(e,n.id);return{...n,balance:i}});return Promise.all(o)}async getAssetMetadata(e){return await this.api.query.assetRegistry.assetMetadataMap(e)}async getAccountBalance(e,t){return t===ot?await this.getSystemAccountBalance(e):await this.getTokenAccountBalance(e,t)}async getSystemAccountBalance(e){let{data:{free:t}}=await this.api.query.system.account(e);return t.toString()}async getTokenAccountBalance(e,t){let{free:o}=await this.api.query.tokens.accounts(e,t);return o.toString()}};var rt=class extends Ne{constructor(){super(...arguments);this.pools=[];this._poolsLoaded=!1}async getPools(){return this._poolsLoaded?this.pools=await this.syncPools():(this.pools=await this.loadPools(),this._poolsLoaded=!0),this.pools}async loadPools(){let o=(await this.api.query.xyk.poolAssets.entries()).map(async n=>{let i=this.getStorageKey(n,0),a=this.getStorageEntryArray(n),l=await this.getPoolTokens(i,a);return{address:i,type:"XYK",tradeFee:this.getTradeFee(),tokens:l,...this.getPoolLimits()}});return Promise.all(o)}async syncPools(){let t=this.pools.map(async o=>({...o,tokens:await this.syncPoolTokens(o.address,o.tokens)}));return Promise.all(t)}getTradeFee(){return this.api.consts.xyk.getExchangeFee.toJSON()}getPoolLimits(){let t=this.api.consts.xyk.maxInRatio.toJSON(),o=this.api.consts.xyk.maxOutRatio.toJSON(),n=this.api.consts.xyk.minTradingLimit.toJSON();return{maxInRatio:t,maxOutRatio:o,minTradingLimit:n}}};var en=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Bt=Math.ceil,Ie=Math.floor,ge="[BigNumber Error] ",Et=ge+"Number primitive has more than 15 significant digits: ",Pe=1e14,M=14,vt=9007199254740991,Tt=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ke=1e7,ie=1e9;function Rt(u){var e,t,o,n=I.prototype={constructor:I,toString:null,valueOf:null},i=new I(1),a=20,l=4,f=-7,P=21,S=-1e7,x=1e7,k=!1,R=1,A=0,G={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},q="0123456789abcdefghijklmnopqrstuvwxyz",X=!0;function I(r,s){var c,h,g,m,y,d,p,w,b=this;if(!(b instanceof I))return new I(r,s);if(s==null){if(r&&r._isBigNumber===!0){b.s=r.s,!r.c||r.e>x?b.c=b.e=null:r.e<S?b.c=[b.e=0]:(b.e=r.e,b.c=r.c.slice());return}if((d=typeof r=="number")&&r*0==0){if(b.s=1/r<0?(r=-r,-1):1,r===~~r){for(m=0,y=r;y>=10;y/=10,m++);m>x?b.c=b.e=null:(b.e=m,b.c=[r]);return}w=String(r)}else{if(!en.test(w=String(r)))return o(b,w,d);b.s=w.charCodeAt(0)==45?(w=w.slice(1),-1):1}(m=w.indexOf("."))>-1&&(w=w.replace(".","")),(y=w.search(/e/i))>0?(m<0&&(m=y),m+=+w.slice(y+1),w=w.substring(0,y)):m<0&&(m=w.length)}else{if(V(s,2,q.length,"Base"),s==10&&X)return b=new I(r),C(b,a+b.e+1,l);if(w=String(r),d=typeof r=="number"){if(r*0!=0)return o(b,w,d,s);if(b.s=1/r<0?(w=w.slice(1),-1):1,I.DEBUG&&w.replace(/^0\.0*|\./,"").length>15)throw Error(Et+r)}else b.s=w.charCodeAt(0)===45?(w=w.slice(1),-1):1;for(c=q.slice(0,s),m=y=0,p=w.length;y<p;y++)if(c.indexOf(h=w.charAt(y))<0){if(h=="."){if(y>m){m=p;continue}}else if(!g&&(w==w.toUpperCase()&&(w=w.toLowerCase())||w==w.toLowerCase()&&(w=w.toUpperCase()))){g=!0,y=-1,m=0;continue}return o(b,String(r),d,s)}d=!1,w=t(w,s,10,b.s),(m=w.indexOf("."))>-1?w=w.replace(".",""):m=w.length}for(y=0;w.charCodeAt(y)===48;y++);for(p=w.length;w.charCodeAt(--p)===48;);if(w=w.slice(y,++p)){if(p-=y,d&&I.DEBUG&&p>15&&(r>vt||r!==Ie(r)))throw Error(Et+b.s*r);if((m=m-y-1)>x)b.c=b.e=null;else if(m<S)b.c=[b.e=0];else{if(b.e=m,b.c=[],y=(m+1)%M,m<0&&(y+=M),y<p){for(y&&b.c.push(+w.slice(0,y)),p-=M;y<p;)b.c.push(+w.slice(y,y+=M));y=M-(w=w.slice(y)).length}else y-=p;for(;y--;w+="0");b.c.push(+w)}}else b.c=[b.e=0]}I.clone=Rt,I.ROUND_UP=0,I.ROUND_DOWN=1,I.ROUND_CEIL=2,I.ROUND_FLOOR=3,I.ROUND_HALF_UP=4,I.ROUND_HALF_DOWN=5,I.ROUND_HALF_EVEN=6,I.ROUND_HALF_CEIL=7,I.ROUND_HALF_FLOOR=8,I.EUCLID=9,I.config=I.set=function(r){var s,c;if(r!=null)if(typeof r=="object"){if(r.hasOwnProperty(s="DECIMAL_PLACES")&&(c=r[s],V(c,0,ie,s),a=c),r.hasOwnProperty(s="ROUNDING_MODE")&&(c=r[s],V(c,0,8,s),l=c),r.hasOwnProperty(s="EXPONENTIAL_AT")&&(c=r[s],c&&c.pop?(V(c[0],-ie,0,s),V(c[1],0,ie,s),f=c[0],P=c[1]):(V(c,-ie,ie,s),f=-(P=c<0?-c:c))),r.hasOwnProperty(s="RANGE"))if(c=r[s],c&&c.pop)V(c[0],-ie,-1,s),V(c[1],1,ie,s),S=c[0],x=c[1];else if(V(c,-ie,ie,s),c)S=-(x=c<0?-c:c);else throw Error(ge+s+" cannot be zero: "+c);if(r.hasOwnProperty(s="CRYPTO"))if(c=r[s],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))k=c;else throw k=!c,Error(ge+"crypto unavailable");else k=c;else throw Error(ge+s+" not true or false: "+c);if(r.hasOwnProperty(s="MODULO_MODE")&&(c=r[s],V(c,0,9,s),R=c),r.hasOwnProperty(s="POW_PRECISION")&&(c=r[s],V(c,0,ie,s),A=c),r.hasOwnProperty(s="FORMAT"))if(c=r[s],typeof c=="object")G=c;else throw Error(ge+s+" not an object: "+c);if(r.hasOwnProperty(s="ALPHABET"))if(c=r[s],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))X=c.slice(0,10)=="0123456789",q=c;else throw Error(ge+s+" invalid: "+c)}else throw Error(ge+"Object expected: "+r);return{DECIMAL_PLACES:a,ROUNDING_MODE:l,EXPONENTIAL_AT:[f,P],RANGE:[S,x],CRYPTO:k,MODULO_MODE:R,POW_PRECISION:A,FORMAT:G,ALPHABET:q}},I.isBigNumber=function(r){if(!r||r._isBigNumber!==!0)return!1;if(!I.DEBUG)return!0;var s,c,h=r.c,g=r.e,m=r.s;e:if({}.toString.call(h)=="[object Array]"){if((m===1||m===-1)&&g>=-ie&&g<=ie&&g===Ie(g)){if(h[0]===0){if(g===0&&h.length===1)return!0;break e}if(s=(g+1)%M,s<1&&(s+=M),String(h[0]).length==s){for(s=0;s<h.length;s++)if(c=h[s],c<0||c>=Pe||c!==Ie(c))break e;if(c!==0)return!0}}}else if(h===null&&g===null&&(m===null||m===1||m===-1))return!0;throw Error(ge+"Invalid BigNumber: "+r)},I.maximum=I.max=function(){return ae(arguments,n.lt)},I.minimum=I.min=function(){return ae(arguments,n.gt)},I.random=function(){var r=9007199254740992,s=Math.random()*r&2097151?function(){return Ie(Math.random()*r)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var h,g,m,y,d,p=0,w=[],b=new I(i);if(c==null?c=a:V(c,0,ie),y=Bt(c/M),k)if(crypto.getRandomValues){for(h=crypto.getRandomValues(new Uint32Array(y*=2));p<y;)d=h[p]*131072+(h[p+1]>>>11),d>=9e15?(g=crypto.getRandomValues(new Uint32Array(2)),h[p]=g[0],h[p+1]=g[1]):(w.push(d%1e14),p+=2);p=y/2}else if(crypto.randomBytes){for(h=crypto.randomBytes(y*=7);p<y;)d=(h[p]&31)*281474976710656+h[p+1]*1099511627776+h[p+2]*4294967296+h[p+3]*16777216+(h[p+4]<<16)+(h[p+5]<<8)+h[p+6],d>=9e15?crypto.randomBytes(7).copy(h,p):(w.push(d%1e14),p+=7);p=y/7}else throw k=!1,Error(ge+"crypto unavailable");if(!k)for(;p<y;)d=s(),d<9e15&&(w[p++]=d%1e14);for(y=w[--p],c%=M,y&&c&&(d=Tt[M-c],w[p]=Ie(y/d)*d);w[p]===0;w.pop(),p--);if(p<0)w=[m=0];else{for(m=-1;w[0]===0;w.splice(0,1),m-=M);for(p=1,d=w[0];d>=10;d/=10,p++);p<M&&(m-=M-p)}return b.e=m,b.c=w,b}}(),I.sum=function(){for(var r=1,s=arguments,c=new I(s[0]);r<s.length;)c=c.plus(s[r++]);return c},t=function(){var r="0123456789";function s(c,h,g,m){for(var y,d=[0],p,w=0,b=c.length;w<b;){for(p=d.length;p--;d[p]*=h);for(d[0]+=m.indexOf(c.charAt(w++)),y=0;y<d.length;y++)d[y]>g-1&&(d[y+1]==null&&(d[y+1]=0),d[y+1]+=d[y]/g|0,d[y]%=g)}return d.reverse()}return function(c,h,g,m,y){var d,p,w,b,O,F,E,U,Z=c.indexOf("."),re=a,H=l;for(Z>=0&&(b=A,A=0,c=c.replace(".",""),U=new I(h),F=U.pow(c.length-Z),A=b,U.c=s(Ae(he(F.c),F.e,"0"),10,g,r),U.e=U.c.length),E=s(c,h,g,y?(d=q,r):(d=r,q)),w=b=E.length;E[--b]==0;E.pop());if(!E[0])return d.charAt(0);if(Z<0?--w:(F.c=E,F.e=w,F.s=m,F=e(F,U,re,H,g),E=F.c,O=F.r,w=F.e),p=w+re+1,Z=E[p],b=g/2,O=O||p<0||E[p+1]!=null,O=H<4?(Z!=null||O)&&(H==0||H==(F.s<0?3:2)):Z>b||Z==b&&(H==4||O||H==6&&E[p-1]&1||H==(F.s<0?8:7)),p<1||!E[0])c=O?Ae(d.charAt(1),-re,d.charAt(0)):d.charAt(0);else{if(E.length=p,O)for(--g;++E[--p]>g;)E[p]=0,p||(++w,E=[1].concat(E));for(b=E.length;!E[--b];);for(Z=0,c="";Z<=b;c+=d.charAt(E[Z++]));c=Ae(c,w,d.charAt(0))}return c}}(),e=function(){function r(h,g,m){var y,d,p,w,b=0,O=h.length,F=g%ke,E=g/ke|0;for(h=h.slice();O--;)p=h[O]%ke,w=h[O]/ke|0,y=E*p+w*F,d=F*p+y%ke*ke+b,b=(d/m|0)+(y/ke|0)+E*w,h[O]=d%m;return b&&(h=[b].concat(h)),h}function s(h,g,m,y){var d,p;if(m!=y)p=m>y?1:-1;else for(d=p=0;d<m;d++)if(h[d]!=g[d]){p=h[d]>g[d]?1:-1;break}return p}function c(h,g,m,y){for(var d=0;m--;)h[m]-=d,d=h[m]<g[m]?1:0,h[m]=d*y+h[m]-g[m];for(;!h[0]&&h.length>1;h.splice(0,1));}return function(h,g,m,y,d){var p,w,b,O,F,E,U,Z,re,H,Y,le,je,Pt,yt,ye,ze,fe=h.s==g.s?1:-1,_e=h.c,Q=g.c;if(!_e||!_e[0]||!Q||!Q[0])return new I(!h.s||!g.s||(_e?Q&&_e[0]==Q[0]:!Q)?NaN:_e&&_e[0]==0||!Q?fe*0:fe/0);for(Z=new I(fe),re=Z.c=[],w=h.e-g.e,fe=m+w+1,d||(d=Pe,w=be(h.e/M)-be(g.e/M),fe=fe/M|0),b=0;Q[b]==(_e[b]||0);b++);if(Q[b]>(_e[b]||0)&&w--,fe<0)re.push(1),O=!0;else{for(Pt=_e.length,ye=Q.length,b=0,fe+=2,F=Ie(d/(Q[0]+1)),F>1&&(Q=r(Q,F,d),_e=r(_e,F,d),ye=Q.length,Pt=_e.length),je=ye,H=_e.slice(0,ye),Y=H.length;Y<ye;H[Y++]=0);ze=Q.slice(),ze=[0].concat(ze),yt=Q[0],Q[1]>=d/2&&yt++;do{if(F=0,p=s(Q,H,ye,Y),p<0){if(le=H[0],ye!=Y&&(le=le*d+(H[1]||0)),F=Ie(le/yt),F>1)for(F>=d&&(F=d-1),E=r(Q,F,d),U=E.length,Y=H.length;s(E,H,U,Y)==1;)F--,c(E,ye<U?ze:Q,U,d),U=E.length,p=1;else F==0&&(p=F=1),E=Q.slice(),U=E.length;if(U<Y&&(E=[0].concat(E)),c(H,E,Y,d),Y=H.length,p==-1)for(;s(Q,H,ye,Y)<1;)F++,c(H,ye<Y?ze:Q,Y,d),Y=H.length}else p===0&&(F++,H=[0]);re[b++]=F,H[0]?H[Y++]=_e[je]||0:(H=[_e[je]],Y=1)}while((je++<Pt||H[0]!=null)&&fe--);O=H[0]!=null,re[0]||re.splice(0,1)}if(d==Pe){for(b=1,fe=re[0];fe>=10;fe/=10,b++);C(Z,m+(Z.e=b+w*M-1)+1,y,O)}else Z.e=w,Z.r=+O;return Z}}();function oe(r,s,c,h){var g,m,y,d,p;if(c==null?c=l:V(c,0,8),!r.c)return r.toString();if(g=r.c[0],y=r.e,s==null)p=he(r.c),p=h==1||h==2&&(y<=f||y>=P)?st(p,y):Ae(p,y,"0");else if(r=C(new I(r),s,c),m=r.e,p=he(r.c),d=p.length,h==1||h==2&&(s<=m||m<=f)){for(;d<s;p+="0",d++);p=st(p,m)}else if(s-=y,p=Ae(p,m,"0"),m+1>d){if(--s>0)for(p+=".";s--;p+="0");}else if(s+=m-d,s>0)for(m+1==d&&(p+=".");s--;p+="0");return r.s<0&&g?"-"+p:p}function ae(r,s){for(var c,h=1,g=new I(r[0]);h<r.length;h++)if(c=new I(r[h]),c.s)s.call(g,c)&&(g=c);else{g=c;break}return g}function D(r,s,c){for(var h=1,g=s.length;!s[--g];s.pop());for(g=s[0];g>=10;g/=10,h++);return(c=h+c*M-1)>x?r.c=r.e=null:c<S?r.c=[r.e=0]:(r.e=c,r.c=s),r}o=function(){var r=/^(-?)0([xbo])(?=\w[\w.]*$)/i,s=/^([^.]+)\.$/,c=/^\.([^.]+)$/,h=/^-?(Infinity|NaN)$/,g=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(m,y,d,p){var w,b=d?y:y.replace(g,"");if(h.test(b))m.s=isNaN(b)?null:b<0?-1:1;else{if(!d&&(b=b.replace(r,function(O,F,E){return w=(E=E.toLowerCase())=="x"?16:E=="b"?2:8,!p||p==w?F:O}),p&&(w=p,b=b.replace(s,"$1").replace(c,"0.$1")),y!=b))return new I(b,w);if(I.DEBUG)throw Error(ge+"Not a"+(p?" base "+p:"")+" number: "+y);m.s=null}m.c=m.e=null}}();function C(r,s,c,h){var g,m,y,d,p,w,b,O=r.c,F=Tt;if(O){e:{for(g=1,d=O[0];d>=10;d/=10,g++);if(m=s-g,m<0)m+=M,y=s,p=O[w=0],b=p/F[g-y-1]%10|0;else if(w=Bt((m+1)/M),w>=O.length)if(h){for(;O.length<=w;O.push(0));p=b=0,g=1,m%=M,y=m-M+1}else break e;else{for(p=d=O[w],g=1;d>=10;d/=10,g++);m%=M,y=m-M+g,b=y<0?0:p/F[g-y-1]%10|0}if(h=h||s<0||O[w+1]!=null||(y<0?p:p%F[g-y-1]),h=c<4?(b||h)&&(c==0||c==(r.s<0?3:2)):b>5||b==5&&(c==4||h||c==6&&(m>0?y>0?p/F[g-y]:0:O[w-1])%10&1||c==(r.s<0?8:7)),s<1||!O[0])return O.length=0,h?(s-=r.e+1,O[0]=F[(M-s%M)%M],r.e=-s||0):O[0]=r.e=0,r;if(m==0?(O.length=w,d=1,w--):(O.length=w+1,d=F[M-m],O[w]=y>0?Ie(p/F[g-y]%F[y])*d:0),h)for(;;)if(w==0){for(m=1,y=O[0];y>=10;y/=10,m++);for(y=O[0]+=d,d=1;y>=10;y/=10,d++);m!=d&&(r.e++,O[0]==Pe&&(O[0]=1));break}else{if(O[w]+=d,O[w]!=Pe)break;O[w--]=0,d=1}for(m=O.length;O[--m]===0;O.pop());}r.e>x?r.c=r.e=null:r.e<S&&(r.c=[r.e=0])}return r}function j(r){var s,c=r.e;return c===null?r.toString():(s=he(r.c),s=c<=f||c>=P?st(s,c):Ae(s,c,"0"),r.s<0?"-"+s:s)}return n.absoluteValue=n.abs=function(){var r=new I(this);return r.s<0&&(r.s=1),r},n.comparedTo=function(r,s){return We(this,new I(r,s))},n.decimalPlaces=n.dp=function(r,s){var c,h,g,m=this;if(r!=null)return V(r,0,ie),s==null?s=l:V(s,0,8),C(new I(m),r+m.e+1,s);if(!(c=m.c))return null;if(h=((g=c.length-1)-be(this.e/M))*M,g=c[g])for(;g%10==0;g/=10,h--);return h<0&&(h=0),h},n.dividedBy=n.div=function(r,s){return e(this,new I(r,s),a,l)},n.dividedToIntegerBy=n.idiv=function(r,s){return e(this,new I(r,s),0,1)},n.exponentiatedBy=n.pow=function(r,s){var c,h,g,m,y,d,p,w,b,O=this;if(r=new I(r),r.c&&!r.isInteger())throw Error(ge+"Exponent not an integer: "+j(r));if(s!=null&&(s=new I(s)),d=r.e>14,!O.c||!O.c[0]||O.c[0]==1&&!O.e&&O.c.length==1||!r.c||!r.c[0])return b=new I(Math.pow(+j(O),d?2-it(r):+j(r))),s?b.mod(s):b;if(p=r.s<0,s){if(s.c?!s.c[0]:!s.s)return new I(NaN);h=!p&&O.isInteger()&&s.isInteger(),h&&(O=O.mod(s))}else{if(r.e>9&&(O.e>0||O.e<-1||(O.e==0?O.c[0]>1||d&&O.c[1]>=24e7:O.c[0]<8e13||d&&O.c[0]<=9999975e7)))return m=O.s<0&&it(r)?-0:0,O.e>-1&&(m=1/m),new I(p?1/m:m);A&&(m=Bt(A/M+2))}for(d?(c=new I(.5),p&&(r.s=1),w=it(r)):(g=Math.abs(+j(r)),w=g%2),b=new I(i);;){if(w){if(b=b.times(O),!b.c)break;m?b.c.length>m&&(b.c.length=m):h&&(b=b.mod(s))}if(g){if(g=Ie(g/2),g===0)break;w=g%2}else if(r=r.times(c),C(r,r.e+1,1),r.e>14)w=it(r);else{if(g=+j(r),g===0)break;w=g%2}O=O.times(O),m?O.c&&O.c.length>m&&(O.c.length=m):h&&(O=O.mod(s))}return h?b:(p&&(b=i.div(b)),s?b.mod(s):m?C(b,A,l,y):b)},n.integerValue=function(r){var s=new I(this);return r==null?r=l:V(r,0,8),C(s,s.e+1,r)},n.isEqualTo=n.eq=function(r,s){return We(this,new I(r,s))===0},n.isFinite=function(){return!!this.c},n.isGreaterThan=n.gt=function(r,s){return We(this,new I(r,s))>0},n.isGreaterThanOrEqualTo=n.gte=function(r,s){return(s=We(this,new I(r,s)))===1||s===0},n.isInteger=function(){return!!this.c&&be(this.e/M)>this.c.length-2},n.isLessThan=n.lt=function(r,s){return We(this,new I(r,s))<0},n.isLessThanOrEqualTo=n.lte=function(r,s){return(s=We(this,new I(r,s)))===-1||s===0},n.isNaN=function(){return!this.s},n.isNegative=function(){return this.s<0},n.isPositive=function(){return this.s>0},n.isZero=function(){return!!this.c&&this.c[0]==0},n.minus=function(r,s){var c,h,g,m,y=this,d=y.s;if(r=new I(r,s),s=r.s,!d||!s)return new I(NaN);if(d!=s)return r.s=-s,y.plus(r);var p=y.e/M,w=r.e/M,b=y.c,O=r.c;if(!p||!w){if(!b||!O)return b?(r.s=-s,r):new I(O?y:NaN);if(!b[0]||!O[0])return O[0]?(r.s=-s,r):new I(b[0]?y:l==3?-0:0)}if(p=be(p),w=be(w),b=b.slice(),d=p-w){for((m=d<0)?(d=-d,g=b):(w=p,g=O),g.reverse(),s=d;s--;g.push(0));g.reverse()}else for(h=(m=(d=b.length)<(s=O.length))?d:s,d=s=0;s<h;s++)if(b[s]!=O[s]){m=b[s]<O[s];break}if(m&&(g=b,b=O,O=g,r.s=-r.s),s=(h=O.length)-(c=b.length),s>0)for(;s--;b[c++]=0);for(s=Pe-1;h>d;){if(b[--h]<O[h]){for(c=h;c&&!b[--c];b[c]=s);--b[c],b[h]+=Pe}b[h]-=O[h]}for(;b[0]==0;b.splice(0,1),--w);return b[0]?D(r,b,w):(r.s=l==3?-1:1,r.c=[r.e=0],r)},n.modulo=n.mod=function(r,s){var c,h,g=this;return r=new I(r,s),!g.c||!r.s||r.c&&!r.c[0]?new I(NaN):!r.c||g.c&&!g.c[0]?new I(g):(R==9?(h=r.s,r.s=1,c=e(g,r,0,3),r.s=h,c.s*=h):c=e(g,r,0,R),r=g.minus(c.times(r)),!r.c[0]&&R==1&&(r.s=g.s),r)},n.multipliedBy=n.times=function(r,s){var c,h,g,m,y,d,p,w,b,O,F,E,U,Z,re,H=this,Y=H.c,le=(r=new I(r,s)).c;if(!Y||!le||!Y[0]||!le[0])return!H.s||!r.s||Y&&!Y[0]&&!le||le&&!le[0]&&!Y?r.c=r.e=r.s=null:(r.s*=H.s,!Y||!le?r.c=r.e=null:(r.c=[0],r.e=0)),r;for(h=be(H.e/M)+be(r.e/M),r.s*=H.s,p=Y.length,O=le.length,p<O&&(U=Y,Y=le,le=U,g=p,p=O,O=g),g=p+O,U=[];g--;U.push(0));for(Z=Pe,re=ke,g=O;--g>=0;){for(c=0,F=le[g]%re,E=le[g]/re|0,y=p,m=g+y;m>g;)w=Y[--y]%re,b=Y[y]/re|0,d=E*w+b*F,w=F*w+d%re*re+U[m]+c,c=(w/Z|0)+(d/re|0)+E*b,U[m--]=w%Z;U[m]=c}return c?++h:U.splice(0,1),D(r,U,h)},n.negated=function(){var r=new I(this);return r.s=-r.s||null,r},n.plus=function(r,s){var c,h=this,g=h.s;if(r=new I(r,s),s=r.s,!g||!s)return new I(NaN);if(g!=s)return r.s=-s,h.minus(r);var m=h.e/M,y=r.e/M,d=h.c,p=r.c;if(!m||!y){if(!d||!p)return new I(g/0);if(!d[0]||!p[0])return p[0]?r:new I(d[0]?h:g*0)}if(m=be(m),y=be(y),d=d.slice(),g=m-y){for(g>0?(y=m,c=p):(g=-g,c=d),c.reverse();g--;c.push(0));c.reverse()}for(g=d.length,s=p.length,g-s<0&&(c=p,p=d,d=c,s=g),g=0;s;)g=(d[--s]=d[s]+p[s]+g)/Pe|0,d[s]=Pe===d[s]?0:d[s]%Pe;return g&&(d=[g].concat(d),++y),D(r,d,y)},n.precision=n.sd=function(r,s){var c,h,g,m=this;if(r!=null&&r!==!!r)return V(r,1,ie),s==null?s=l:V(s,0,8),C(new I(m),r,s);if(!(c=m.c))return null;if(g=c.length-1,h=g*M+1,g=c[g]){for(;g%10==0;g/=10,h--);for(g=c[0];g>=10;g/=10,h++);}return r&&m.e+1>h&&(h=m.e+1),h},n.shiftedBy=function(r){return V(r,-vt,vt),this.times("1e"+r)},n.squareRoot=n.sqrt=function(){var r,s,c,h,g,m=this,y=m.c,d=m.s,p=m.e,w=a+4,b=new I("0.5");if(d!==1||!y||!y[0])return new I(!d||d<0&&(!y||y[0])?NaN:y?m:1/0);if(d=Math.sqrt(+j(m)),d==0||d==1/0?(s=he(y),(s.length+p)%2==0&&(s+="0"),d=Math.sqrt(+s),p=be((p+1)/2)-(p<0||p%2),d==1/0?s="5e"+p:(s=d.toExponential(),s=s.slice(0,s.indexOf("e")+1)+p),c=new I(s)):c=new I(d+""),c.c[0]){for(p=c.e,d=p+w,d<3&&(d=0);;)if(g=c,c=b.times(g.plus(e(m,g,w,1))),he(g.c).slice(0,d)===(s=he(c.c)).slice(0,d))if(c.e<p&&--d,s=s.slice(d-3,d+1),s=="9999"||!h&&s=="4999"){if(!h&&(C(g,g.e+a+2,0),g.times(g).eq(m))){c=g;break}w+=4,d+=4,h=1}else{(!+s||!+s.slice(1)&&s.charAt(0)=="5")&&(C(c,c.e+a+2,1),r=!c.times(c).eq(m));break}}return C(c,c.e+a+1,l,r)},n.toExponential=function(r,s){return r!=null&&(V(r,0,ie),r++),oe(this,r,s,1)},n.toFixed=function(r,s){return r!=null&&(V(r,0,ie),r=r+this.e+1),oe(this,r,s)},n.toFormat=function(r,s,c){var h,g=this;if(c==null)r!=null&&s&&typeof s=="object"?(c=s,s=null):r&&typeof r=="object"?(c=r,r=s=null):c=G;else if(typeof c!="object")throw Error(ge+"Argument not an object: "+c);if(h=g.toFixed(r,s),g.c){var m,y=h.split("."),d=+c.groupSize,p=+c.secondaryGroupSize,w=c.groupSeparator||"",b=y[0],O=y[1],F=g.s<0,E=F?b.slice(1):b,U=E.length;if(p&&(m=d,d=p,p=m,U-=m),d>0&&U>0){for(m=U%d||d,b=E.substr(0,m);m<U;m+=d)b+=w+E.substr(m,d);p>0&&(b+=w+E.slice(m)),F&&(b="-"+b)}h=O?b+(c.decimalSeparator||"")+((p=+c.fractionGroupSize)?O.replace(new RegExp("\\d{"+p+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):O):b}return(c.prefix||"")+h+(c.suffix||"")},n.toFraction=function(r){var s,c,h,g,m,y,d,p,w,b,O,F,E=this,U=E.c;if(r!=null&&(d=new I(r),!d.isInteger()&&(d.c||d.s!==1)||d.lt(i)))throw Error(ge+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+j(d));if(!U)return new I(E);for(s=new I(i),w=c=new I(i),h=p=new I(i),F=he(U),m=s.e=F.length-E.e-1,s.c[0]=Tt[(y=m%M)<0?M+y:y],r=!r||d.comparedTo(s)>0?m>0?s:w:d,y=x,x=1/0,d=new I(F),p.c[0]=0;b=e(d,s,0,1),g=c.plus(b.times(h)),g.comparedTo(r)!=1;)c=h,h=g,w=p.plus(b.times(g=w)),p=g,s=d.minus(b.times(g=s)),d=g;return g=e(r.minus(c),h,0,1),p=p.plus(g.times(w)),c=c.plus(g.times(h)),p.s=w.s=E.s,m=m*2,O=e(w,h,m,l).minus(E).abs().comparedTo(e(p,c,m,l).minus(E).abs())<1?[w,h]:[p,c],x=y,O},n.toNumber=function(){return+j(this)},n.toPrecision=function(r,s){return r!=null&&V(r,1,ie),oe(this,r,s,2)},n.toString=function(r){var s,c=this,h=c.s,g=c.e;return g===null?h?(s="Infinity",h<0&&(s="-"+s)):s="NaN":(r==null?s=g<=f||g>=P?st(he(c.c),g):Ae(he(c.c),g,"0"):r===10&&X?(c=C(new I(c),a+g+1,l),s=Ae(he(c.c),c.e,"0")):(V(r,2,q.length,"Base"),s=t(Ae(he(c.c),g,"0"),10,r,h,!0)),h<0&&c.c[0]&&(s="-"+s)),s},n.valueOf=n.toJSON=function(){return j(this)},n._isBigNumber=!0,n[Symbol.toStringTag]="BigNumber",n[Symbol.for("nodejs.util.inspect.custom")]=n.valueOf,u!=null&&I.set(u),I}function be(u){var e=u|0;return u>0||u===e?e:e-1}function he(u){for(var e,t,o=1,n=u.length,i=u[0]+"";o<n;){for(e=u[o++]+"",t=M-e.length;t--;e="0"+e);i+=e}for(n=i.length;i.charCodeAt(--n)===48;);return i.slice(0,n+1||1)}function We(u,e){var t,o,n=u.c,i=e.c,a=u.s,l=e.s,f=u.e,P=e.e;if(!a||!l)return null;if(t=n&&!n[0],o=i&&!i[0],t||o)return t?o?0:-l:a;if(a!=l)return a;if(t=a<0,o=f==P,!n||!i)return o?0:!n^t?1:-1;if(!o)return f>P^t?1:-1;for(l=(f=n.length)<(P=i.length)?f:P,a=0;a<l;a++)if(n[a]!=i[a])return n[a]>i[a]^t?1:-1;return f==P?0:f>P^t?1:-1}function V(u,e,t,o){if(u<e||u>t||u!==Ie(u))throw Error(ge+(o||"Argument")+(typeof u=="number"?u<e||u>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(u))}function it(u){var e=u.c.length-1;return be(u.e/M)==e&&u.c[e]%2!=0}function st(u,e){return(u.length>1?u.charAt(0)+"."+u.slice(1):u)+(e<0?"e":"e+")+e}function Ae(u,e,t){var o,n;if(e<0){for(n=t+".";++e;n+=t);u=n+u}else if(o=u.length,++e>o){for(n=t,e-=o;--e;n+=t);u+=n}else e<o&&(u=u.slice(0,e)+"."+u.slice(e));return u}var He=Rt();var Lt=12;He.config({EXPONENTIAL_AT:[-100,100],ROUNDING_MODE:4,DECIMAL_PLACES:Lt});var te=L(0),xe=L(1),tn=L("Infinity");function de(u,e){let t=new He(e.toString()),o=new He(10).pow(t);return u.times(o)}function L(u){return new He(u.toString())}var Be=It(Dt()),we=class{static getSpotPrice(e,t,o,n,i){return(0,Be.get_spot_price)(e,t,o,n,i)}static calculateInGivenOut(e,t,o,n,i){return(0,Be.calculate_in_given_out)(e,t,o,n,i)}static calculateOutGivenIn(e,t,o,n,i){return(0,Be.calculate_out_given_in)(e,t,o,n,i)}static calculateLinearWeights(e,t,o,n,i){return(0,Be.calculate_linear_weights)(e,t,o,n,i)}static calculatePoolTradeFee(e,t,o){return(0,Be.calculate_pool_trade_fee)(e,t,o)}};var _t=class extends Ne{constructor(){super(...arguments);this.MAX_FINAL_WEIGHT=de(L(100),6);this.poolsData=new Map([]);this.pools=[];this._poolsLoaded=!1}async getPools(){return this._poolsLoaded?this.pools=await this.syncPools():(this.pools=await this.loadPools(),this._poolsLoaded=!0),this.pools}async loadPools(){let o=(await this.api.query.lbp.poolData.entries()).map(async n=>{let i=this.getStorageKey(n,0),a=n[1].toJSON(),l=await this.getPoolTokens(i,a.assets),f=await this.getLinearWeight(a),P=L(f),S=this.MAX_FINAL_WEIGHT.minus(L(P)),x=l[0].id;return this.poolsData.set(i,a),{address:i,type:"LBP",tradeFee:a.fee,repayFee:this.getRepayFee(),repayFeeApply:await this.isRepayFeeApplied(x,a),tokens:[{...l[0],weight:P},{...l[1],weight:S}],...this.getPoolLimits()}});return Promise.all(o)}async syncPools(){let t=this.pools.map(async o=>{let n=this.poolsData.get(o.address),i=await this.syncPoolTokens(o.address,o.tokens),a=await this.getLinearWeight(n),l=L(a),f=this.MAX_FINAL_WEIGHT.minus(L(l)),P=i[0].id;return{...o,repayFeeApply:await this.isRepayFeeApplied(P,n),tokens:[{...i[0],weight:l},{...i[1],weight:f}]}});return Promise.all(t)}async getLinearWeight(t){let n=(await this.api.query.parachainSystem.validationData()).toJSON();return we.calculateLinearWeights(t.start.toString(),t.end.toString(),t.initialWeight.toString(),t.finalWeight.toString(),n.relayParentNumber.toString())}async isRepayFeeApplied(t,o){let n=L(o.repayTarget);try{let i=await this.getAccountBalance(t,o.feeCollector);return L(i).isLessThan(n)}catch{return!0}}getRepayFee(){return this.api.consts.lbp.repayFee.toJSON()}getPoolLimits(){let t=this.api.consts.xyk.maxInRatio.toJSON(),o=this.api.consts.xyk.maxOutRatio.toJSON(),n=this.api.consts.xyk.minTradingLimit.toJSON();return{maxInRatio:t,maxOutRatio:o,minTradingLimit:n}}};var Gt=require("@polkadot/util-crypto"),Ct=require("@polkadot/util");var dt=class extends Ne{constructor(t){super(t);this.pools=[];this._poolLoaded=!1;this.hubAssetId=this.api.consts.omnipool.hubAssetId.toString()}async getPools(){if(this._poolLoaded){let t=await this.syncPool();this.pools=[t]}else{let t=await this.loadPool();this.pools=[t],this._poolLoaded=!0}return this.pools}async loadPool(){let t=await this.api.query.omnipool.assets.entries(),o=t.map(l=>this.getStorageKey(l,0)).concat(this.hubAssetId),n=this.getPoolId(),i=await this.getPoolTokens(n,o),a=this.getPoolTokenState(t,i);return{address:n,type:"Omni",tradeFee:this.getTradeFee(),assetFee:this.getAssetFee(),protocolFee:this.getProtocolFee(),hubAssetId:this.hubAssetId,tokens:a,...this.getPoolLimits()}}async syncPool(){let t=await this.api.query.omnipool.assets.entries(),o=await this.syncPoolTokens(this.pools[0].address,this.pools[0].tokens),n=this.getPoolTokenState(t,o);return{...this.pools[0],tokens:n}}getPoolTokenState(t,o){return o.map((n,i)=>{if(this.hubAssetId===n.id)return n;let a=t[i][1].toJSON();return{...n,hubReserves:L(a.hubReserve),shares:L(a.shares)}})}getTradeFee(){let t=this.getAssetFee(),o=this.getProtocolFee();return[t[0]+o[0],1e3]}getAssetFee(){return[this.api.consts.omnipool.assetFee.toJSON()/1e3,1e3]}getProtocolFee(){return[this.api.consts.omnipool.protocolFee.toJSON()/1e3,1e3]}getPoolId(){return(0,Gt.encodeAddress)((0,Ct.stringToU8a)("modlomnipool".padEnd(32,"\0")),63)}getPoolLimits(){let t=this.api.consts.omnipool.maxInRatio.toJSON(),o=this.api.consts.omnipool.maxOutRatio.toJSON(),n=this.api.consts.omnipool.minimumTradingLimit.toJSON();return{maxInRatio:t,maxOutRatio:o,minTradingLimit:n}}};var gt=class{constructor(e){this.api=e,this.xykClient=new rt(this.api),this.omniClient=new dt(this.api),this.lbpClient=new _t(this.api)}async getPools(e){if(e.length==0)return(await Promise.all([this.xykClient.getPools(),this.omniClient.getPools(),this.lbpClient.getPools()])).flat();let t=[];return e.forEach(n=>{switch(n){case"XYK":t.push(this.xykClient.getPools());break;case"Omni":t.push(this.omniClient.getPools());break;case"LBP":t.push(this.lbpClient.getPools());break}}),(await Promise.all(t)).flat()}isOmnipoolTx(e){return e.length==1&&e[0].poolType=="Omni"}buildBuyTx(e,t,o,n,i){let a;this.isOmnipoolTx(i)?a=this.api.tx.omnipool.buy(t,e,o.toFixed(),n.toFixed()):a=this.api.tx.router.buy(e,t,o.toFixed(),n.toFixed(),i);let l=()=>a;return{hex:a.toHex(),name:"RouterBuy",get:l}}buildSellTx(e,t,o,n,i){let a;this.isOmnipoolTx(i)?a=this.api.tx.omnipool.sell(e,t,o.toFixed(),n.toFixed()):a=this.api.tx.router.sell(e,t,o.toFixed(),n.toFixed(),i);let l=()=>a;return{hex:a.toHex(),name:"RouterSell",get:l}}};var Fe=class extends Error{constructor(e,t){super(),this.message=`${e} pool missing ${t}`,this.name="PoolConfigNotFound"}},Ue=class extends Error{constructor(e,t){super(),this.message=`Route from ${e} to ${t} not found in pool configuration`,this.name="RouteNotFound"}};function se(u,e){return u.shiftedBy(-1*e).toString()}function Xe(u){return u[0]/u[1]*100}function Ge(u){return u[0]/u[1]}var Ee=class{static fromPool(e){if(!e.repayFee)throw new Fe("LBP","repayFee");if(!e.repayFeeApply)throw new Fe("LBP","repayFeeApply");return new Ee(e.address,e.tradeFee,e.tokens,e.maxInRatio,e.maxOutRatio,e.minTradingLimit,e.repayFee,e.repayFeeApply)}constructor(e,t,o,n,i,a,l,f){this.type="LBP",this.address=e,this.tradeFee=t,this.tokens=o,this.maxInRatio=n,this.maxOutRatio=i,this.minTradingLimit=a,this.repayFee=l,this.repayFeeApply=f}validPair(e,t){return!0}parsePoolPair(e,t){let o=new Map(this.tokens.map(f=>[f.id,f])),n=o.get(e),i=o.get(t);if(n==null)throw new Error("Pool does not contain tokenIn");if(i==null)throw new Error("Pool does not contain tokenOut");let a=L(n.balance),l=L(i.balance);return{assetIn:e,assetOut:t,decimalsIn:n.decimals,decimalsOut:i.decimals,weightIn:n.weight,weightOut:i.weight,balanceIn:a,balanceOut:l}}validateBuy(e,t){if(this.tokens[0].id===e.assetOut){let n=this.calculateTradeFee(t),i=t.plus(n),a=this.calculateInGivenOut(e,i),l=Xe(this.repayFeeApply?this.repayFee:this.tradeFee);return{amountIn:a,calculatedIn:a,amountOut:t,feePct:l}}else{let n=this.calculateInGivenOut(e,t);return{amountIn:n,calculatedIn:n,amountOut:t,feePct:0}}}validateSell(e,t){if(this.tokens[0].id===e.assetIn){let n=this.calculateOutGivenIn(e,t);return{amountIn:t,calculatedOut:n,amountOut:n,feePct:0}}else{let n=this.calculateOutGivenIn(e,t),i=this.calculateTradeFee(n),a=n.minus(i),l=Xe(this.repayFeeApply?this.repayFee:this.tradeFee);return{amountIn:t,calculatedOut:n,amountOut:a,feePct:l}}}calculateInGivenOut(e,t){let o=we.calculateInGivenOut(e.balanceIn.toString(),e.balanceOut.toString(),e.weightIn.toString(),e.weightOut.toString(),t.toFixed(0)),n=L(o);return n.isNegative()?te:n}calculateOutGivenIn(e,t){let o=we.calculateOutGivenIn(e.balanceIn.toString(),e.balanceOut.toString(),e.weightIn.toString(),e.weightOut.toString(),t.toFixed(0)),n=L(o);return n.isNegative()?te:n}spotPriceInGivenOut(e){let t=we.getSpotPrice(e.balanceOut.toString(),e.balanceIn.toString(),e.weightOut.toString(),e.weightIn.toString(),de(xe,e.decimalsOut).toString());return L(t)}spotPriceOutGivenIn(e){let t=we.getSpotPrice(e.balanceIn.toString(),e.balanceOut.toString(),e.weightIn.toString(),e.weightOut.toString(),de(xe,e.decimalsIn).toString());return L(t)}calculateTradeFee(e){let t=we.calculatePoolTradeFee(e.toString(),this.repayFeeApply?this.repayFee[0]:this.tradeFee[0],this.repayFeeApply?this.repayFee[1]:this.tradeFee[1]);return L(t)}};var W=It(Wt()),me=class{static calculateSpotPrice(e,t,o,n){return(0,W.calculate_spot_price)(e,t,o,n)}static calculateLrnaSpotPrice(e,t){return(0,W.calculate_lrna_spot_price)(e,t)}static calculateInGivenOut(e,t,o,n,i,a,l,f,P){return(0,W.calculate_in_given_out)(e,t,o,n,i,a,l,f,P)}static calculateLrnaInGivenOut(e,t,o,n,i){return(0,W.calculate_lrna_in_given_out)(e,t,o,n,i)}static calculateOutGivenIn(e,t,o,n,i,a,l,f,P){return(0,W.calculate_out_given_in)(e,t,o,n,i,a,l,f,P)}static calculateOutGivenLrnaIn(e,t,o,n,i){return(0,W.calculate_out_given_lrna_in)(e,t,o,n,i)}static calculatePoolTradeFee(e,t,o){return(0,W.calculate_pool_trade_fee)(e,t,o)}static calculateShares(e,t,o,n){return(0,W.calculate_shares)(e,t,o,n)}static calculateLiquidityOut(e,t,o,n,i,a,l){return(0,W.calculate_liquidity_out)(e,t,o,n,i,a,l)}static calculateLiquidityLRNAOut(e,t,o,n,i,a,l){return(0,W.calculate_liquidity_lrna_out)(e,t,o,n,i,a,l)}static calculateCapDifference(e,t,o,n){return(0,W.calculate_cap_difference)(e,t,o,n)}static verifyAssetCap(e,t,o,n){return(0,W.verify_asset_cap)(e,t,o,n)}static calculateLimitHubIn(e,t,o,n){return(0,W.calculate_liquidity_hub_in)(e,t,o,n)}static isSellAllowed(e){return(0,W.is_sell_allowed)(e)}static isBuyAllowed(e){return(0,W.is_buy_allowed)(e)}static isAddLiquidityAllowed(e){return(0,W.is_add_liquidity_allowed)(e)}static isRemoveLiquidityAllowed(e){return(0,W.is_remove_liquidity_allowed)(e)}};var Re=class{static fromPool(e){if(!e.assetFee)throw new Fe("Omni","assetFee");if(!e.protocolFee)throw new Fe("Omni","protocolFee");return new Re(e.address,e.tradeFee,e.tokens,e.maxInRatio,e.maxOutRatio,e.minTradingLimit,e.assetFee,e.protocolFee,e.hubAssetId)}constructor(e,t,o,n,i,a,l,f,P){this.type="Omni",this.address=e,this.tradeFee=t,this.tokens=o,this.maxInRatio=n,this.maxOutRatio=i,this.minTradingLimit=a,this.assetFee=l,this.protocolFee=f,this.hubAssetId=P}validPair(e,t){return this.hubAssetId!=t}parsePoolPair(e,t){let o=new Map(this.tokens.map(f=>[f.id,f])),n=o.get(e),i=o.get(t);if(n==null)throw new Error("Pool does not contain tokenIn");if(i==null)throw new Error("Pool does not contain tokenOut");let a=L(n.balance),l=L(i.balance);return{assetIn:e,assetOut:t,hubReservesIn:n.hubReserves,hubReservesOut:i.hubReserves,sharesIn:n.shares,sharesOut:i.shares,decimalsIn:n.decimals,decimalsOut:i.decimals,balanceIn:a,balanceOut:l}}validateBuy(e,t){let o=this.calculateInGivenOut(e,t,!1),n=this.calculateInGivenOut(e,t,!0),i=n.minus(o),a=o===te?te:i.div(o).multipliedBy(100).decimalPlaces(2),l=[];t.isLessThan(this.minTradingLimit)&&l.push("InsufficientTradingAmount");let f=e.balanceOut.div(this.maxOutRatio);t.isGreaterThan(f)&&l.push("MaxOutRatioExceeded");let P=e.balanceIn.div(this.maxInRatio);return n.isGreaterThan(P)&&l.push("MaxInRatioExceeded"),{amountIn:n,calculatedIn:o,amountOut:t,feePct:a.toNumber(),errors:l}}validateSell(e,t){let o=this.calculateOutGivenIn(e,t,!1),n=this.calculateOutGivenIn(e,t,!0),a=o.minus(n).div(o).multipliedBy(100).decimalPlaces(2),l=[];t.isLessThan(this.minTradingLimit)&&l.push("InsufficientTradingAmount");let f=e.balanceIn.div(this.maxInRatio);t.isGreaterThan(f)&&l.push("MaxInRatioExceeded");let P=e.balanceOut.div(this.maxOutRatio);return n.isGreaterThan(P)&&l.push("MaxOutRatioExceeded"),{amountIn:t,calculatedOut:o,amountOut:n,feePct:a.toNumber(),errors:l}}calculateInGivenOut(e,t,o){if(e.assetIn==this.hubAssetId)return this.calculateLrnaInGivenOut(e,t,o);let n=me.calculateInGivenOut(e.balanceIn.toString(),e.hubReservesIn.toString(),e.sharesIn.toString(),e.balanceOut.toString(),e.hubReservesOut.toString(),e.sharesOut.toString(),t.toFixed(0),o?Ge(this.assetFee).toString():te.toString(),o?Ge(this.protocolFee).toString():te.toString()),i=L(n);return i.isNegative()?te:i}calculateLrnaInGivenOut(e,t,o){let n=me.calculateLrnaInGivenOut(e.balanceOut.toString(),e.hubReservesOut.toString(),e.sharesOut.toString(),t.toFixed(0),o?Ge(this.assetFee).toString():te.toString()),i=L(n);return i.isNegative()?te:i}calculateOutGivenIn(e,t,o){if(e.assetIn==this.hubAssetId)return this.calculateOutGivenLrnaIn(e,t,o);let n=me.calculateOutGivenIn(e.balanceIn.toString(),e.hubReservesIn.toString(),e.sharesIn.toString(),e.balanceOut.toString(),e.hubReservesOut.toString(),e.sharesOut.toString(),t.toFixed(0),o?Ge(this.assetFee).toString():te.toString(),o?Ge(this.protocolFee).toString():te.toString()),i=L(n);return i.isNegative()?te:i}calculateOutGivenLrnaIn(e,t,o){let n=me.calculateOutGivenLrnaIn(e.balanceOut.toString(),e.hubReservesOut.toString(),e.sharesOut.toString(),t.toFixed(0),o?Ge(this.assetFee).toString():te.toString()),i=L(n);return i.isNegative()?te:i}spotPriceInGivenOut(e){if(e.assetIn==this.hubAssetId)return this.spotPriceLrnaInGivenOut(e);let t=me.calculateSpotPrice(e.balanceOut.toString(),e.hubReservesOut.toString(),e.balanceIn.toString(),e.hubReservesIn.toString());return L(t).shiftedBy(-1*(18-e.decimalsOut)).decimalPlaces(0,1)}spotPriceLrnaInGivenOut(e){let t=me.calculateLrnaSpotPrice(e.hubReservesOut.toString(),e.balanceOut.toString());return L(t).shiftedBy(-1*(18-e.decimalsOut)).decimalPlaces(0,1)}spotPriceOutGivenIn(e){if(e.assetIn==this.hubAssetId)return this.spotPriceOutGivenLrnaIn(e);let t=me.calculateSpotPrice(e.balanceIn.toString(),e.hubReservesIn.toString(),e.balanceOut.toString(),e.hubReservesOut.toString());return L(t).shiftedBy(-1*(18-e.decimalsIn)).decimalPlaces(0,1)}spotPriceOutGivenLrnaIn(e){let t=me.calculateLrnaSpotPrice(e.balanceOut.toString(),e.hubReservesOut.toString());return L(t).shiftedBy(-1*(18-e.decimalsIn)).decimalPlaces(0,1)}calculateTradeFee(e){throw new Error("Not supported in OmniPool")}};var ue=It(Ut()),Te=class{static getSpotPrice(e,t,o){return(0,ue.get_spot_price)(e,t,o)}static calculateInGivenOut(e,t,o){return(0,ue.calculate_in_given_out)(e,t,o)}static calculateOutGivenIn(e,t,o){return(0,ue.calculate_out_given_in)(e,t,o)}static calculatePoolTradeFee(e,t,o){return(0,ue.calculate_pool_trade_fee)(e,t,o)}static calculateLiquidityIn(e,t,o){return(0,ue.calculate_liquidity_in)(e,t,o)}static calculateShares(e,t,o){return(0,ue.calculate_shares)(e,t,o)}static calculateLiquidityOutAssetA(e,t,o,n){return(0,ue.calculate_liquidity_out_asset_a)(e,t,o,n)}static calculateLiquidityOutAssetB(e,t,o,n){return(0,ue.calculate_liquidity_out_asset_b)(e,t,o,n)}};var Me=class{static fromPool(e){return new Me(e.address,e.tradeFee,e.tokens,e.maxInRatio,e.maxOutRatio,e.minTradingLimit)}constructor(e,t,o,n,i,a){this.type="XYK",this.address=e,this.tradeFee=t,this.tokens=o,this.maxInRatio=n,this.maxOutRatio=i,this.minTradingLimit=a}validPair(e,t){return!0}parsePoolPair(e,t){let o=new Map(this.tokens.map(f=>[f.id,f])),n=o.get(e),i=o.get(t);if(n==null)throw new Error("Pool does not contain tokenIn");if(i==null)throw new Error("Pool does not contain tokenOut");let a=L(n.balance),l=L(i.balance);return{assetIn:e,assetOut:t,decimalsIn:n.decimals,decimalsOut:i.decimals,balanceIn:a,balanceOut:l}}validateBuy(e,t){let o=this.calculateInGivenOut(e,t),n=this.calculateTradeFee(o),i=o.plus(n),a=Xe(this.tradeFee),l=[];t.isLessThan(this.minTradingLimit)&&l.push("InsufficientTradingAmount");let f=e.balanceOut.div(this.maxOutRatio);t.isGreaterThan(f)&&l.push("MaxOutRatioExceeded");let P=e.balanceIn.div(this.maxInRatio);return i.isGreaterThan(P)&&l.push("MaxInRatioExceeded"),{amountIn:i,calculatedIn:o,amountOut:t,feePct:a,errors:l}}validateSell(e,t){let o=this.calculateOutGivenIn(e,t),n=this.calculateTradeFee(o),i=o.minus(n),a=Xe(this.tradeFee),l=[];t.isLessThan(this.minTradingLimit)&&l.push("InsufficientTradingAmount");let f=e.balanceIn.div(this.maxInRatio);t.isGreaterThan(f)&&l.push("MaxInRatioExceeded");let P=e.balanceOut.div(this.maxOutRatio);return i.isGreaterThan(P)&&l.push("MaxOutRatioExceeded"),{amountIn:t,calculatedOut:o,amountOut:i,feePct:a,errors:l}}calculateInGivenOut(e,t){let o=Te.calculateInGivenOut(e.balanceIn.toString(),e.balanceOut.toString(),t.toFixed(0)),n=L(o);return n.isNegative()?te:n}calculateOutGivenIn(e,t){let o=Te.calculateOutGivenIn(e.balanceIn.toString(),e.balanceOut.toString(),t.toFixed(0)),n=L(o);return n.isNegative()?te:n}spotPriceInGivenOut(e){let t=Te.getSpotPrice(e.balanceOut.toString(),e.balanceIn.toString(),de(xe,e.decimalsOut).toString());return L(t)}spotPriceOutGivenIn(e){let t=Te.getSpotPrice(e.balanceIn.toString(),e.balanceOut.toString(),de(xe,e.decimalsIn).toString());return L(t)}calculateTradeFee(e){let t=Te.calculatePoolTradeFee(e.toString(),this.tradeFee[0],this.tradeFee[1]);return L(t)}};var Ye=class{static get(e){switch(e.type){case"XYK":return Me.fromPool(e);case"Omni":return Re.fromPool(e);case"LBP":return Ee.fromPool(e);default:throw new Error("Pool type "+e.type+" is not supported yet")}}};var Ce=class{constructor(e,t){this.defaultRouterOptions={includeOnly:[]};this.poolService=e,this.routeSuggester=new Je,this.routerOptions={...this.defaultRouterOptions,...t}}async getPools(){let e=this.routerOptions.includeOnly;return await this.poolService.getPools(e)}async getAllAssets(){let e=await this.getPools();if(e.length===0)throw new Error("No pools configured");let t=await this.getAssets(e);return[...new Map(t).values()]}async getAssetPairs(e){let t=await this.getPools();if(t.length===0)throw new Error("No pools configured");let{assets:o,poolsMap:n}=await this.validateToken(e,t),a=this.getPaths(e,null,n,t).map(l=>l[l.length-1].assetOut);return this.toPoolAssets([...new Set(a)],o)}async getAllPaths(e,t){let o=await this.getPools();if(o.length===0)throw new Error("No pools configured");let{poolsMap:n}=await this.validateTokenPair(e,t,o);return this.getPaths(e,t,n,o)}async getAssets(e){let t=e.map(o=>o.tokens.map(({id:n,symbol:i})=>({id:n,symbol:i}))).flat();return new Map(t.map(o=>[o.id,o]))}getPaths(e,t,o,n){return this.routeSuggester.getProposals(e,t,n).filter(l=>this.validPath(l,o)).map(l=>this.toHops(l,o))}async validateTokenPair(e,t,o){let n=await this.getAssets(o);if(n.get(e)==null)throw new Error(e+" is not supported token");if(n.get(t)==null)throw new Error(t+" is not supported token");let i=this.getPoolMap(o);return{assets:n,poolsMap:i}}async validateToken(e,t){let o=await this.getAssets(t);if(o.get(e)==null)throw new Error(e+" is not supported token");let n=this.getPoolMap(t);return{assets:o,poolsMap:n}}getPoolMap(e){return new Map(e.map(t=>[t.address,Ye.get(t)]))}validPath(e,t){return e.length>0&&e.map(o=>this.validEdge(o,t)).reduce((o,n)=>o&&n)}validEdge([e,t,o],n){return n.get(e)?.validPair(t,o)||!1}toHops(e,t){return e.map(([o,n,i])=>{let a=t.get(o);return{poolId:o,poolType:a?.type,assetIn:n,assetOut:i}})}toPoolAssets(e,t){return e.map(o=>{let n=t.get(o);return{id:o,symbol:n?.symbol}})}};function Ze(u,e,t,o){let n=u.shiftedBy(-1*e).multipliedBy(t),i=o;return n.minus(i).abs().div(n.plus(i).div(2)).multipliedBy(100).decimalPlaces(2)}function Xt(u,e){return xe.minus(e.div(u)).multipliedBy(100).decimalPlaces(2)}function Yt(u,e){return e.div(u).minus(xe).multipliedBy(100).decimalPlaces(2)}var Qe=class extends Ce{async getBestSpotPrice(e,t){let o=await super.getPools();if(o.length===0)throw new Error("No pools configured");let{poolsMap:n}=await super.validateTokenPair(e,t,o);return super.getPaths(e,t,n,o).map(l=>this.getSpotPrice(l,n)).sort((l,f)=>{let P=l.amount,S=f.amount;return P.isGreaterThan(S)?-1:1})[0]}getSpotPrice(e,t){let o=[];for(let a=0;a<e.length;a++){let l=e[a],f=t.get(l.poolId);if(f==null)throw new Error("Pool does not exit");let P=f.parsePoolPair(l.assetIn,l.assetOut),S=f.spotPriceOutGivenIn(P);o.push({amount:S,decimals:P.decimalsOut})}let n=o.map(a=>a.amount.shiftedBy(-1*a.decimals)).reduce((a,l)=>a.multipliedBy(l)),i=o[o.length-1].decimals;return{amount:de(n,i).decimalPlaces(0,1),decimals:i}}isDirectTrade(e){return e.length==1}async getBestSell(e,t,o){let n=await super.getPools();if(n.length===0)throw new Error("No pools configured");let{poolsMap:i}=await super.validateTokenPair(e,t,n),a=super.getPaths(e,t,i,n);if(a.length===0)throw new Ue(e,t);let f=a.map(D=>this.toSellSwaps(o,D,i)).sort((D,C)=>{let j=D[D.length-1].amountOut,r=C[C.length-1].amountOut;return j.isGreaterThan(r)?-1:1}),P=f.find(D=>D.every(C=>C.errors.length==0))||f[0],S=P[0],x=P[P.length-1],k=this.isDirectTrade(P),R=P.map(D=>D.spotPrice.shiftedBy(-1*D.assetOutDecimals)).reduce((D,C)=>D.multipliedBy(C)),A=de(R,x.assetOutDecimals).decimalPlaces(0,1),G=Ze(S.amountIn,S.assetInDecimals,A,x.calculatedOut),q=k?x.calculatedOut:this.calculateDelta0Y(S.amountIn,P,i),X=x.amountOut,I=k?x.tradeFeePct:Xt(q,X).toNumber(),oe=q.minus(X),ae=D=>this.poolService.buildSellTx(e,t,S.amountIn,D,P.map(C=>C));return{type:"Sell",amountIn:S.amountIn,amountOut:x.amountOut,spotPrice:A,tradeFee:oe,tradeFeePct:I,priceImpactPct:G.toNumber(),swaps:P,toTx:ae,toHuman(){return{type:"Sell",amountIn:se(S.amountIn,S.assetInDecimals),amountOut:se(x.amountOut,x.assetOutDecimals),spotPrice:se(A,x.assetOutDecimals),tradeFee:se(oe,x.assetOutDecimals),tradeFeePct:I,priceImpactPct:G.toNumber(),swaps:P.map(D=>D.toHuman())}}}}calculateDelta0Y(e,t,o){let n=[];for(let i=0;i<t.length;i++){let a=t[i],l=o.get(a.poolId);if(l==null)throw new Error("Pool does not exit");let f=l.parsePoolPair(a.assetIn,a.assetOut),P;i>0?P=n[i-1]:P=e;let S=l.calculateOutGivenIn(f,P,!1);n.push(S)}return n[n.length-1]}toSellSwaps(e,t,o){let n=[];for(let i=0;i<t.length;i++){let a=t[i],l=o.get(a.poolId);if(l==null)throw new Error("Pool does not exit");let f=l.parsePoolPair(a.assetIn,a.assetOut),P;i>0?P=n[i-1].amountOut:P=de(L(e),f.decimalsIn).decimalPlaces(0,1);let{amountOut:S,calculatedOut:x,feePct:k,errors:R}=l.validateSell(f,P),A=l.spotPriceOutGivenIn(f),G=Ze(P,f.decimalsIn,A,x);n.push({...a,assetInDecimals:f.decimalsIn,assetOutDecimals:f.decimalsOut,amountIn:P,calculatedOut:x,amountOut:S,spotPrice:A,tradeFeePct:k,priceImpactPct:G.toNumber(),errors:R,toHuman(){return{...a,amountIn:se(P,f.decimalsIn),calculatedOut:se(x,f.decimalsOut),amountOut:se(S,f.decimalsOut),spotPrice:se(A,f.decimalsOut),tradeFeePct:k,priceImpactPct:G.toNumber(),errors:R}}})}return n}async getBestBuy(e,t,o){let n=await super.getPools();if(n.length===0)throw new Error("No pools configured");let{poolsMap:i}=await super.validateTokenPair(e,t,n),a=super.getPaths(e,t,i,n);if(a.length===0)throw new Ue(e,t);let f=a.map(D=>this.toBuySwaps(o,D,i)).sort((D,C)=>{let j=D[0].amountIn,r=C[0].amountIn;return j.isGreaterThan(r)?1:-1}),P=f.find(D=>D.every(C=>C.errors.length==0))||f[0],S=P[P.length-1],x=P[0],k=this.isDirectTrade(P),R=P.map(D=>D.spotPrice.shiftedBy(-1*D.assetInDecimals)).reduce((D,C)=>D.multipliedBy(C)),A=de(R,x.assetInDecimals).decimalPlaces(0,1),G=Ze(S.amountOut,S.assetOutDecimals,A,x.calculatedIn),q=k?x.calculatedIn:this.calculateDelta0X(S.amountOut,P,i),X=x.amountIn,I=k?x.tradeFeePct:Yt(q,X),oe=X.minus(q),ae=D=>this.poolService.buildBuyTx(e,t,S.amountOut,D,P.map(C=>C));return{type:"Buy",amountOut:S.amountOut,amountIn:x.amountIn,spotPrice:A,tradeFee:oe,tradeFeePct:I,priceImpactPct:G.toNumber(),swaps:P,toTx:ae,toHuman(){return{type:"Buy",amountOut:se(S.amountOut,S.assetOutDecimals),amountIn:se(x.amountIn,x.assetInDecimals),spotPrice:se(A,x.assetInDecimals),tradeFee:se(oe,x.assetInDecimals),tradeFeePct:I,priceImpactPct:G.toNumber(),swaps:P.map(D=>D.toHuman())}}}}calculateDelta0X(e,t,o){let n=[];for(let i=t.length-1;i>=0;i--){let a=t[i],l=o.get(a.poolId);if(l==null)throw new Error("Pool does not exit");let f=l.parsePoolPair(a.assetIn,a.assetOut),P;i==t.length-1?P=e:P=n[0];let S=l.calculateInGivenOut(f,P,!1);n.unshift(S)}return n[0]}toBuySwaps(e,t,o){let n=[];for(let i=t.length-1;i>=0;i--){let a=t[i],l=o.get(a.poolId);if(l==null)throw new Error("Pool does not exit");let f=l.parsePoolPair(a.assetIn,a.assetOut),P;i==t.length-1?P=de(L(e),f.decimalsOut).decimalPlaces(0,1):P=n[0].amountIn;let{amountIn:S,calculatedIn:x,feePct:k,errors:R}=l.validateBuy(f,P),A=l.spotPriceInGivenOut(f),G=Ze(P,f.decimalsOut,A,x);n.unshift({...a,assetInDecimals:f.decimalsIn,assetOutDecimals:f.decimalsOut,amountOut:P,calculatedIn:x,amountIn:S,spotPrice:A,tradeFeePct:k,priceImpactPct:G.toNumber(),errors:R,toHuman(){return{...a,amountOut:se(P,f.decimalsOut),calculatedIn:se(x,f.decimalsIn),amountIn:se(S,f.decimalsIn),spotPrice:se(A,f.decimalsIn),tradeFeePct:k,priceImpactPct:G.toNumber(),errors:R}}})}return n}};0&&(module.exports={BigNumber,DECIMAL_PLACES,DENOMINATOR,HYDRADX_PARACHAIN_ID,HYDRADX_SS58_PREFIX,INFINITY,LbpMath,LbpPool,ONE,OmniMath,OmniPool,PolkadotApiPoolService,PoolConfigNotFound,PoolError,PoolFactory,PoolType,RUNTIME_DECIMALS,RouteNotFound,Router,SYSTEM_ASSET_DECIMALS,SYSTEM_ASSET_ID,TradeRouter,TradeType,XykMath,XykPool,ZERO,bnum,scale});
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export declare type WeightedPoolPair = PoolPair & {
|
|
|
7
7
|
export declare type WeightedPoolToken = PoolToken & {
|
|
8
8
|
weight: BigNumber;
|
|
9
9
|
};
|
|
10
|
+
export declare type LbpPoolBase = PoolBase & {
|
|
11
|
+
repayFee: PoolFee;
|
|
12
|
+
repayFeeApply: boolean;
|
|
13
|
+
};
|
|
10
14
|
export declare class LbpPool implements Pool {
|
|
11
15
|
type: PoolType;
|
|
12
16
|
address: string;
|
|
@@ -17,7 +21,7 @@ export declare class LbpPool implements Pool {
|
|
|
17
21
|
minTradingLimit: number;
|
|
18
22
|
repayFee: PoolFee;
|
|
19
23
|
repayFeeApply: boolean;
|
|
20
|
-
static fromPool(pool:
|
|
24
|
+
static fromPool(pool: LbpPoolBase): LbpPool;
|
|
21
25
|
constructor(address: string, swapFee: PoolFee, tokens: WeightedPoolToken[], maxInRation: number, maxOutRatio: number, minTradeLimit: number, repayFee: PoolFee, repayFeeApply: boolean);
|
|
22
26
|
validPair(_tokenIn: string, _tokenOut: string): boolean;
|
|
23
27
|
parsePoolPair(tokenIn: string, tokenOut: string): WeightedPoolPair;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export declare class OmniMath {
|
|
2
2
|
static calculateSpotPrice(assetInBalance: string, assetInHubReserve: string, assetOutBalance: string, assetOutHubReserve: string): string;
|
|
3
|
+
static calculateLrnaSpotPrice(assetBalance: string, assetHubReserve: string): string;
|
|
3
4
|
static calculateInGivenOut(assetInBalance: string, assetInHubReserve: string, assetInShares: string, assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountOut: string, assetFee: string, protocolFee: string): string;
|
|
5
|
+
static calculateLrnaInGivenOut(assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountOut: string, assetFee: string): string;
|
|
4
6
|
static calculateOutGivenIn(assetInBalance: string, assetInHubReserve: string, assetInShares: string, assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountIn: string, assetFee: string, protocolFee: string): string;
|
|
7
|
+
static calculateOutGivenLrnaIn(assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountOut: string, assetFee: string): string;
|
|
5
8
|
static calculatePoolTradeFee(amount: string, feeNumerator: number, feeDenominator: number): string;
|
|
6
9
|
static calculateShares(assetReserve: string, assetHubReserve: string, assetShares: string, amountIn: string): string;
|
|
7
10
|
static calculateLiquidityOut(assetReserve: string, assetHubReserve: string, assetShares: string, positionAmount: string, positionShares: string, positionPrice: string, sharesToRemove: string): string;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { ApiPromise } from '@polkadot/api';
|
|
1
2
|
import { PolkadotApiClient } from '../../client';
|
|
2
3
|
import { PoolBase, PoolFee, PoolLimits } from '../../types';
|
|
3
4
|
export declare class OmniPolkadotApiClient extends PolkadotApiClient {
|
|
4
5
|
private pools;
|
|
5
6
|
private _poolLoaded;
|
|
7
|
+
private hubAssetId;
|
|
8
|
+
constructor(api: ApiPromise);
|
|
6
9
|
getPools(): Promise<PoolBase[]>;
|
|
7
10
|
loadPool(): Promise<PoolBase>;
|
|
8
11
|
syncPool(): Promise<PoolBase>;
|
|
12
|
+
private getPoolTokenState;
|
|
9
13
|
getTradeFee(): PoolFee;
|
|
10
14
|
getAssetFee(): PoolFee;
|
|
11
15
|
getProtocolFee(): PoolFee;
|
|
@@ -10,6 +10,11 @@ export declare type OmniPoolToken = PoolToken & {
|
|
|
10
10
|
hubReserves: BigNumber;
|
|
11
11
|
shares: BigNumber;
|
|
12
12
|
};
|
|
13
|
+
export declare type OmniPoolBase = PoolBase & {
|
|
14
|
+
assetFee: PoolFee;
|
|
15
|
+
protocolFee: PoolFee;
|
|
16
|
+
hubAssetId: string;
|
|
17
|
+
};
|
|
13
18
|
export declare class OmniPool implements Pool {
|
|
14
19
|
type: PoolType;
|
|
15
20
|
address: string;
|
|
@@ -20,15 +25,20 @@ export declare class OmniPool implements Pool {
|
|
|
20
25
|
minTradingLimit: number;
|
|
21
26
|
assetFee: PoolFee;
|
|
22
27
|
protocolFee: PoolFee;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
hubAssetId: string;
|
|
29
|
+
static fromPool(pool: OmniPoolBase): OmniPool;
|
|
30
|
+
constructor(address: string, swapFee: PoolFee, tokens: OmniPoolToken[], maxInRation: number, maxOutRatio: number, minTradeLimit: number, assetFee: PoolFee, protocolFee: PoolFee, hubAssetId: string);
|
|
31
|
+
validPair(_tokenIn: string, tokenOut: string): boolean;
|
|
26
32
|
parsePoolPair(tokenIn: string, tokenOut: string): OmniPoolPair;
|
|
27
33
|
validateBuy(poolPair: OmniPoolPair, amountOut: BigNumber): BuyTransfer;
|
|
28
34
|
validateSell(poolPair: OmniPoolPair, amountIn: BigNumber): SellTransfer;
|
|
29
35
|
calculateInGivenOut(poolPair: OmniPoolPair, amountOut: BigNumber, applyFee: boolean): BigNumber;
|
|
36
|
+
calculateLrnaInGivenOut(poolPair: OmniPoolPair, amountOut: BigNumber, applyFee: boolean): BigNumber;
|
|
30
37
|
calculateOutGivenIn(poolPair: OmniPoolPair, amountIn: BigNumber, applyFee: boolean): BigNumber;
|
|
38
|
+
calculateOutGivenLrnaIn(poolPair: OmniPoolPair, amountIn: BigNumber, applyFee: boolean): BigNumber;
|
|
31
39
|
spotPriceInGivenOut(poolPair: OmniPoolPair): BigNumber;
|
|
40
|
+
spotPriceLrnaInGivenOut(poolPair: OmniPoolPair): BigNumber;
|
|
32
41
|
spotPriceOutGivenIn(poolPair: OmniPoolPair): BigNumber;
|
|
42
|
+
spotPriceOutGivenLrnaIn(poolPair: OmniPoolPair): BigNumber;
|
|
33
43
|
calculateTradeFee(amount: BigNumber): BigNumber;
|
|
34
44
|
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -30,10 +30,6 @@ export declare type PoolBase = {
|
|
|
30
30
|
maxInRatio: number;
|
|
31
31
|
maxOutRatio: number;
|
|
32
32
|
minTradingLimit: number;
|
|
33
|
-
repayFee?: PoolFee;
|
|
34
|
-
repayFeeApply?: boolean;
|
|
35
|
-
assetFee?: PoolFee;
|
|
36
|
-
protocolFee?: PoolFee;
|
|
37
33
|
};
|
|
38
34
|
export declare type PoolLimits = Pick<PoolBase, 'maxInRatio' | 'maxOutRatio' | 'minTradingLimit'>;
|
|
39
35
|
export declare type PoolFee = [numerator: number, denominator: number];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacticcouncil/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Galactic SDK",
|
|
6
6
|
"author": "Pavol Noha <palo@hydradx.io>",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"typescript": "^4.7.4"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@galacticcouncil/math-lbp": "^0.0.
|
|
30
|
-
"@galacticcouncil/math-omnipool": "^0.0.
|
|
31
|
-
"@galacticcouncil/math-xyk": "^0.0.
|
|
29
|
+
"@galacticcouncil/math-lbp": "^0.0.7",
|
|
30
|
+
"@galacticcouncil/math-omnipool": "^0.0.7",
|
|
31
|
+
"@galacticcouncil/math-xyk": "^0.0.7",
|
|
32
32
|
"bignumber.js": "^9.1.0",
|
|
33
33
|
"lodash.clonedeep": "^4.5.0"
|
|
34
34
|
},
|