Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ekubo/sdk

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ekubo/sdk - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

31

dist/index.d.ts

@@ -165,2 +165,31 @@ declare const MAX_U256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;

export { BasePool, type BasePoolResources, type BasePoolState, type Block, MAX_SQRT_RATIO, MAX_TICK, MAX_TICK_SPACING, MAX_U128, MAX_U256, MIN_SQRT_RATIO, MIN_TICK, type NodeKey, type Quote, type QuoteMeta, type QuoteNode, type QuoteParams, type Tick, type TokenAmount, TwammPool, type TwammPoolState, type TwammResources, type TwammSaleRateDelta, amount0Delta, amount1Delta, calculateNextSqrtRatio, computeStep, msb, nextSqrtRatioFromAmount0, nextSqrtRatioFromAmount1, toSqrtRatio };
interface OracleResources extends BasePoolResources {
snapshotUpdated: boolean;
}
interface OraclePoolState extends BasePoolState {
readonly lastSnapshotTime: bigint;
}
declare class OraclePool implements QuoteNode<OracleResources, OraclePoolState> {
private readonly extension;
private readonly basePool;
private readonly lastSnapshotTime;
constructor({ token0, token1, sqrtRatio, liquidity, tick, sortedTicks, extension, lastSnapshotTime, }: {
token0: bigint;
token1: bigint;
extension: bigint;
sqrtRatio: bigint;
liquidity: bigint;
tick: number;
sortedTicks: Tick[];
lastSnapshotTime: bigint;
});
get key(): NodeKey;
get state(): Readonly<OraclePoolState>;
get sortedTicks(): Tick[];
quote(params: QuoteParams<OraclePoolState>): Quote<OracleResources, OraclePoolState>;
combineResources(resource: OracleResources, additionalResources: OracleResources): OracleResources;
initialResources(): OracleResources;
hasLiquidity(): boolean;
}
export { BasePool, type BasePoolResources, type BasePoolState, type Block, MAX_SQRT_RATIO, MAX_TICK, MAX_TICK_SPACING, MAX_U128, MAX_U256, MIN_SQRT_RATIO, MIN_TICK, type NodeKey, OraclePool, type OraclePoolState, type OracleResources, type Quote, type QuoteMeta, type QuoteNode, type QuoteParams, type Tick, type TokenAmount, TwammPool, type TwammPoolState, type TwammResources, type TwammSaleRateDelta, amount0Delta, amount1Delta, calculateNextSqrtRatio, computeStep, msb, nextSqrtRatioFromAmount0, nextSqrtRatioFromAmount1, toSqrtRatio };

2

dist/index.js

@@ -1,1 +0,1 @@

var V=Object.defineProperty;var i0=Object.getOwnPropertyDescriptor;var o0=Object.getOwnPropertyNames;var r0=Object.prototype.hasOwnProperty;var a0=(n,f)=>{for(var e in f)V(n,e,{get:f[e],enumerable:!0})},s0=(n,f,e,t)=>{if(f&&typeof f=="object"||typeof f=="function")for(let i of o0(f))!r0.call(n,i)&&i!==e&&V(n,i,{get:()=>f[i],enumerable:!(t=i0(f,i))||t.enumerable});return n};var c0=n=>s0(V({},"__esModule",{value:!0}),n);var A0={};a0(A0,{BasePool:()=>I,MAX_SQRT_RATIO:()=>A,MAX_TICK:()=>j,MAX_TICK_SPACING:()=>y,MAX_U128:()=>S,MAX_U256:()=>b,MIN_SQRT_RATIO:()=>R,MIN_TICK:()=>$,TwammPool:()=>B,amount0Delta:()=>_,amount1Delta:()=>w,calculateNextSqrtRatio:()=>X,computeStep:()=>Q,msb:()=>G,nextSqrtRatioFromAmount0:()=>D,nextSqrtRatioFromAmount1:()=>C,toSqrtRatio:()=>v});module.exports=c0(A0);var b=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn,S=0xffffffffffffffffffffffffffffffffn;function _(n,f,e,t){if(e===0n||n===f)return 0n;let[i,a]=n<f?[n,f]:[f,n],o=(e<<128n)*(a-i),s=o/a;if(t&&o%a!==0n&&s++,s>b)throw new Error("AMOUNT0_DELTA_OVERFLOW_U256");let r=s/i;if(t&&r%i!==0n&&r++,r>S)throw new Error("AMOUNT0_DELTA_OVERFLOW_U128");return r}var H=0x100000000000000000000000000000000n;function w(n,f,e,t){if(e===0n||n===f)return 0n;let[i,a]=n<f?[n,f]:[f,n],o=e*(a-i);if(o>b)throw new Error("AMOUNT1_DELTA_OVERFLOW_U256");if(t&&o%H!==0n){let s=o/H+1n;if(s>S)throw new Error("AMOUNT1_DELTA_OVERFLOW_U128");return s}else return o>>128n}var l0=1n<<128n;function G(n){if(n>=l0)throw new Error("x too large");if(n<=0n)throw new Error("x must be positive");let f=0;return n>=0x10000000000000000n&&(n=n>>64n,f+=64),n>=0x100000000n&&(n=n>>32n,f+=32),n>=0x10000n&&(n=n>>16n,f+=16),n>=0x100n&&(n=n>>8n,f+=8),n>=0x10n&&(n=n>>4n,f+=4),n>=0x04n&&(n=n>>2n,f+=2),n>=0x02n&&(f+=1),f}function D(n,f,e){if(e===0n)return n;if(f===0n)throw new Error("NO_LIQUIDITY");let t=f<<128n;if(e<0n){let i=e*-1n*n;if(i>=b)return null;let a=t-i;if(a<0n)return null;let o=t*n,s=o/a+(o%a===0n?0n:1n);return s>b?null:s}else{let a=t/n+e,o=t/a;if(t%a===0n)return o;let r=o+1n;return r>b?null:r}}function C(n,f,e){if(e===0n)return n;if(f===0n)throw new Error("NO_LIQUIDITY");let t=e<<128n,i=t/f,a=t%f;if(e<0n){let o=n+i;return o<0n?null:a===0n?o:o!=0n?o-1n:null}else{let o=n+i;return o>b?null:o}}function q(n,f){return n<0n!==f}function J(n){return{consumedAmount:0n,calculatedAmount:0n,sqrtRatioNext:n,feeAmount:0n}}function Y(n,f){if(f===0n)return n;let e=n<<128n,t=(1n<<128n)-f,a=e/t+(e%t!==0n?1n:0n);if(a>S)throw new Error("AMOUNT_BEFORE_FEE_OVERFLOW");return a}function u0(n,f){let e=n*f,t=2n**128n;return e%t!==0n?e/t+1n:e/t}function Q({sqrtRatio:n,liquidity:f,sqrtRatioLimit:e,amount:t,isToken1:i,fee:a}){if(t===0n||n===e)return J(n);let o=q(t,i);if(e<n===o)throw new Error("computeStep: wrong direction");if(f===0n)return J(e);let s;t<0n?s=t:s=t-u0(t,a);let r;if(i?r=C(n,f,s):r=D(n,f,s),r===null||r>e===o){let[l,u]=i?[w(e,n,f,t>=0n)*(t<0n?-1n:1n),_(e,n,f,t<0n)]:[_(e,n,f,t>=0n)*(t<0n?-1n:1n),w(e,n,f,t<0n)];if(t<0n){let d=Y(u,a);return{consumedAmount:l,calculatedAmount:d,feeAmount:d-u,sqrtRatioNext:e}}else{let d=Y(l,a);return{consumedAmount:d,calculatedAmount:u,feeAmount:d-l,sqrtRatioNext:e}}}if(r===n)return{consumedAmount:t,calculatedAmount:0n,feeAmount:t,sqrtRatioNext:n};let c=i?_(r,n,f,t<0n):w(r,n,f,t<0n);if(t<0n){let l=Y(c,a);return{consumedAmount:t,calculatedAmount:l,sqrtRatioNext:r,feeAmount:l-c}}else return{consumedAmount:t,calculatedAmount:c,sqrtRatioNext:r,feeAmount:t-s}}var $=-88722883,j=88722883,A=6277100250585753475930931601400621808602321654880405518632n,R=18446748437148339061n,y=354892;function v(n){if(n<$||n>j)throw new Error(`Invalid tick: ${n}`);let f=n<0;n=Math.abs(n);let e=0x100000000000000000000000000000000n;return n&1&&(e=0xfffff79c8499329c7cbb2510d893283bn),n&2&&(e=e*0xffffef390978c398134b4ff3764fe410n>>128n),n&4&&(e=e*0xffffde72140b00a354bd3dc828e976c9n>>128n),n&8&&(e=e*0xffffbce42c7be6c998ad6318193c0b18n>>128n),n&16&&(e=e*0xffff79c86a8f6150a32d9778eceef97cn>>128n),n&32&&(e=e*0xfffef3911b7cff24ba1b3dbb5f8f5974n>>128n),n&64&&(e=e*0xfffde72350725cc4ea8feece3b5f13c8n>>128n),n&128&&(e=e*0xfffbce4b06c196e9247ac87695d53c60n>>128n),n&256&&(e=e*0xfff79ca7a4d1bf1ee8556cea23cdbaa5n>>128n),n&512&&(e=e*0xffef3995a5b6a6267530f207142a5764n>>128n),n&1024&&(e=e*0xffde7444b28145508125d10077ba83b8n>>128n),n&2048&&(e=e*0xffbceceeb791747f10df216f2e53ec57n>>128n),n&4096&&(e=e*0xff79eb706b9a64c6431d76e63531e929n>>128n),n&8192&&(e=e*0xfef41d1a5f2ae3a20676bec6f7f9459an>>128n),n&16384&&(e=e*0xfde95287d26d81bea159c37073122c73n>>128n),n&32768&&(e=e*0xfbd701c7cbc4c8a6bb81efd232d1e4e7n>>128n),n&65536&&(e=e*0xf7bf5211c72f5185f372aeb1d48f937en>>128n),n&131072&&(e=e*0xefc2bf59df33ecc28125cf78ec4f167fn>>128n),n&262144&&(e=e*0xe08d35706200796273f0b3a981d90cfdn>>128n),n&524288&&(e=e*0xc4f76b68947482dc198a48a54348c4edn>>128n),n&1048576&&(e=e*0x978bcb9894317807e5fa4498eee7c0fan>>128n),n&2097152&&(e=e*0x59b63684b86e9f486ec54727371ba6can>>128n),n&4194304&&(e=e*0x1f703399d88f6aa83a28b22d4a1f56e3n>>128n),n&8388608&&(e=e*0x3dc5dac7376e20fc8679758d1bcdcfcn>>128n),n&16777216&&(e=e*0xee7e32d61fdb0a5e622b820f681d0n>>128n),n&33554432&&(e=e*0xde2ee4bc381afa7089aa84bb66n>>128n),n&67108864&&(e=e*0xc0d55d4d7152c25fb139n>>128n),n>0&&!f&&(e=b/e),e}var b0=Math.log(1.0000005);function Z(n,f,e){let t=Math.log(Number(f)/Number(n))/b0;return Math.floor(Math.abs(t/(e*251)))}var d0=1623313478486440542208n;function X(n,f,e,t,i,a){let o=f0((t<<128n)/e)<<64n;if(f===0n)return o;let s=f0(t*e)*((1n<<128n)-a)/(1n<<128n),r=n>o,c=U(0x200000000n*i*s,f,r);if(c>d0)return o;let l=n0(c),[u,d]=r?[n-o,!0]:[o-n,!1],g=U(u<<128n,o+n,r),[x,m]=[l-g,l+g],k=d?U(m<<128n,x,r):U(x<<128n,m,r);return o*k>>128n}function U(n,f,e){let t=n/f,i=n%f;return t+(i!==0n&&e?1n:0n)}function n0(n){if(n>=36893488147419103e3){let f=n0(n/2n);return f*f>>128n}else return m0(n)}function m0(n){if(n>=0x20000000000000000n)throw new Error("Invalid input");let f=0x100000000000000000000000000000000n;return(n&0x1n)!=0n&&(f=0xffffffffffffffff0000000000000000n),(n&0x2n)!=0n&&(f=f*0xfffffffffffffffe0000000000000002n>>128n),(n&0x4n)!=0n&&(f=f*0xfffffffffffffffc0000000000000008n>>128n),(n&0x8n)!=0n&&(f=f*0xfffffffffffffff80000000000000020n>>128n),(n&0x10n)!=0n&&(f=f*0xfffffffffffffff00000000000000080n>>128n),(n&0x20n)!=0n&&(f=f*0xffffffffffffffe00000000000000200n>>128n),(n&0x40n)!=0n&&(f=f*0xffffffffffffffc00000000000000800n>>128n),(n&0x80n)!=0n&&(f=f*0xffffffffffffff800000000000002000n>>128n),(n&0x100n)!=0n&&(f=f*0xffffffffffffff000000000000008000n>>128n),(n&0x200n)!=0n&&(f=f*0xfffffffffffffe000000000000020000n>>128n),(n&0x400n)!=0n&&(f=f*0xfffffffffffffc000000000000080000n>>128n),(n&0x800n)!=0n&&(f=f*0xfffffffffffff8000000000000200000n>>128n),(n&0x1000n)!=0n&&(f=f*0xfffffffffffff0000000000000800000n>>128n),(n&0x2000n)!=0n&&(f=f*0xffffffffffffe0000000000002000000n>>128n),(n&0x4000n)!=0n&&(f=f*0xffffffffffffc0000000000008000000n>>128n),(n&0x8000n)!=0n&&(f=f*0xffffffffffff80000000000020000000n>>128n),(n&0x10000n)!=0n&&(f=f*0xffffffffffff00000000000080000000n>>128n),(n&0x20000n)!=0n&&(f=f*0xfffffffffffe00000000000200000000n>>128n),(n&0x40000n)!=0n&&(f=f*0xfffffffffffc00000000000800000000n>>128n),(n&0x80000n)!=0n&&(f=f*0xfffffffffff800000000002000000000n>>128n),(n&0x100000n)!=0n&&(f=f*0xfffffffffff000000000008000000000n>>128n),(n&0x200000n)!=0n&&(f=f*0xffffffffffe000000000020000000000n>>128n),(n&0x400000n)!=0n&&(f=f*0xffffffffffc00000000007ffffffffffn>>128n),(n&0x800000n)!=0n&&(f=f*0xffffffffff80000000001ffffffffffbn>>128n),(n&0x1000000n)!=0n&&(f=f*0xffffffffff00000000007fffffffffd5n>>128n),(n&0x2000000n)!=0n&&(f=f*0xfffffffffe0000000001fffffffffeabn>>128n),(n&0x4000000n)!=0n&&(f=f*0xfffffffffc0000000007fffffffff555n>>128n),(n&0x8000000n)!=0n&&(f=f*0xfffffffff8000000001fffffffffaaabn>>128n),(n&0x10000000n)!=0n&&(f=f*0xfffffffff0000000007ffffffffd5555n>>128n),(n&0x20000000n)!=0n&&(f=f*0xffffffffe000000001ffffffffeaaaabn>>128n),(n&0x40000000n)!=0n&&(f=f*0xffffffffc000000007ffffffff555555n>>128n),(n&0x80000000n)!=0n&&(f=f*0xffffffff800000001ffffffffaaaaaabn>>128n),(n&0x100000000n)!=0n&&(f=f*0xffffffff000000007fffffffd5555555n>>128n),(n&0x200000000n)!=0n&&(f=f*0xfffffffe00000001fffffffeaaaaaaabn>>128n),(n&0x400000000n)!=0n&&(f=f*0xfffffffc00000007fffffff555555560n>>128n),(n&0x800000000n)!=0n&&(f=f*0xfffffff80000001fffffffaaaaaaab55n>>128n),(n&0x1000000000n)!=0n&&(f=f*0xfffffff00000007ffffffd5555556000n>>128n),(n&0x2000000000n)!=0n&&(f=f*0xffffffe0000001ffffffeaaaaaab5555n>>128n),(n&0x4000000000n)!=0n&&(f=f*0xffffffc0000007ffffff555555600000n>>128n),(n&0x8000000000n)!=0n&&(f=f*0xffffff8000001ffffffaaaaaab555555n>>128n),(n&0x10000000000n)!=0n&&(f=f*0xffffff0000007fffffd555555ffffffen>>128n),(n&0x20000000000n)!=0n&&(f=f*0xfffffe000001fffffeaaaaab55555511n>>128n),(n&0x40000000000n)!=0n&&(f=f*0xfffffc000007fffff555555ffffff777n>>128n),(n&0x80000000000n)!=0n&&(f=f*0xfffff800001fffffaaaaab5555544444n>>128n),(n&0x100000000000n)!=0n&&(f=f*0xfffff000007ffffd55555fffffddddden>>128n),(n&0x200000000000n)!=0n&&(f=f*0xffffe00001ffffeaaaab555551111128n>>128n),(n&0x400000000000n)!=0n&&(f=f*0xffffc00007ffff55555fffff77777d28n>>128n),(n&0x800000000000n)!=0n&&(f=f*0xffff80001ffffaaaab5555444445b05bn>>128n),(n&0x1000000000000n)!=0n&&(f=f*0xffff00007fffd5555ffffdddde38e381n>>128n),(n&0x2000000000000n)!=0n&&(f=f*0xfffe0001fffeaaab5555111127d276a7n>>128n),(n&0x4000000000000n)!=0n&&(f=f*0xfffc0007fff5555ffff7777d27cf3cf5n>>128n),(n&0x8000000000000n)!=0n&&(f=f*0xfff8001fffaaab55544445b0596597f9n>>128n),(n&0x10000000000000n)!=0n&&(f=f*0xfff0007ffd555fffddde38e2be2d82d5n>>128n),(n&0x20000000000000n)!=0n&&(f=f*0xffe001ffeaab55511127d21522f2295cn>>128n),(n&0x40000000000000n)!=0n&&(f=f*0xffc007ff555fff777d279e7b87acece0n>>128n),(n&0x80000000000000n)!=0n&&(f=f*0xff801ffaab554445b04105b043e8f48dn>>128n),(n&0x100000000000000n)!=0n&&(f=f*0xff007fd55ffdde38d68f08c257e0ce3fn>>128n),(n&0x200000000000000n)!=0n&&(f=f*0xfe01feab551127cbfe5f89994c44216fn>>128n),(n&0x400000000000000n)!=0n&&(f=f*0xfc07f55ff77d2493e885eeaa756ad523n>>128n),(n&0x800000000000000n)!=0n&&(f=f*0xf81fab5445aebc8a58055fcbbb139ae9n>>128n),(n&0x1000000000000000n)!=0n&&(f=f*0xf07d5fde38151e72f18ff03049ac5d7fn>>128n),(n&0x2000000000000000n)!=0n&&(f=f*0xe1eb51276c110c3c3eb1269f2f5d4afbn>>128n),(n&0x4000000000000000n)!=0n&&(f=f*0xc75f7cf564105743415cbc9d6368f3b9n>>128n),(n&0x8000000000000000n)!=0n&&(f=f*0x9b4597e37cb04ff3d675a35530cdd768n>>128n),(n&0x10000000000000000n)!=0n&&(f=f*0x5e2d58d8b3bcdf1abadec7829054f90en>>128n),n!=0n&&(f=b/f),f}function f0(n){if(n<0n)throw new Error("Square root of negative numbers is not supported.");if(n<2n)return n;let f=n/2n,e=(f+n/f)/2n;for(;f>e;)f=e,e=(f+n/f)/2n;return f}function x0(n,f){let e=0,t=n.length;for(;e<t;){let i=Math.floor((e+t)/2);if(n[i].tick<=f){if(i===n.length-1||n[i+1].tick>f)return i;e=i}else t=i}return-1}var I=class{constructor({token0:f,token1:e,tickSpacing:t,fee:i,sqrtRatio:a,liquidity:o,tick:s,sortedTicks:r}){this.key={token0:f,token1:e,fee:i,tickSpacing:t,extension:0n},this.sortedTicks=r,this.state={sqrtRatio:a,liquidity:o,activeTickIndex:x0(r,s)}}combineResources(f,e){return{initializedTicksCrossed:f.initializedTicksCrossed+e.initializedTicksCrossed,tickSpacingsCrossed:f.tickSpacingsCrossed+e.tickSpacingsCrossed}}initialResources(){return{initializedTicksCrossed:0,tickSpacingsCrossed:0}}quote({tokenAmount:{amount:f,token:e},sqrtRatioLimit:t,overrideState:i}){let a=e===this.key.token1;if(!a&&this.key.token0!==e)throw new Error("Invalid token");let o=i??this.state,s=this.initialResources();if(f===0n)return{isPriceIncreasing:a,consumedAmount:0n,calculatedAmount:0n,executionResources:s,stateAfter:o,feesPaid:0n};let r=q(f,a),{sqrtRatio:c,liquidity:l,activeTickIndex:u}=o;if(t){if(r&&t<c)throw new Error("sqrtRatioLimit cannot be less than sqrtRatio");if(!r&&t>c)throw new Error("sqrtRatioLimit cannot be greater than sqrtRatio");if(t<R)throw new Error("sqrtRatioLimit lt min");if(t>A)throw new Error("sqrtRatioLimit gt max")}else t=r?A:R;let d=0n,g=0n,x=s.initializedTicksCrossed,m=f,k=c;for(;m!==0n&&c!==t;){let p=(r?this.sortedTicks[u+1]:this.sortedTicks[u])??null,h=p?v(p.tick):null,F=h===null?t:h<t===r?h:t,P=Q({fee:this.key.fee,sqrtRatio:c,liquidity:l,isToken1:a,sqrtRatioLimit:F,amount:m});m-=P.consumedAmount,d+=P.calculatedAmount,g+=P.feeAmount,c=P.sqrtRatioNext,p&&c===h&&(u=r?u+1:u-1,x++,l+=r?p.liquidityDelta:-p.liquidityDelta)}return{isPriceIncreasing:r,consumedAmount:f-m,calculatedAmount:d,feesPaid:g,executionResources:{initializedTicksCrossed:x,tickSpacingsCrossed:s.tickSpacingsCrossed+Z(k,c,this.key.tickSpacing)},stateAfter:{sqrtRatio:c,liquidity:l,activeTickIndex:u}}}hasLiquidity(){return this.state.liquidity>0n||this.sortedTicks.length>0}};var e0=88368108,g0=22027144413679976675n,p0=5256790760649093508123362461711849782692726119655358142129n,B=class{get key(){return{...this.basePool.key,extension:this.extension}}get sortedTicks(){return this.basePool.sortedTicks}constructor({token0:f,token1:e,fee:t,extension:i,sqrtRatio:a,liquidity:o,tick:s,token0SaleRate:r,token1SaleRate:c,lastExecutionTime:l,saleRateDeltas:u}){this.extension=i,this.basePool=new I({token0:f,token1:e,fee:t,sqrtRatio:a,liquidity:o,tick:s,tickSpacing:y,sortedTicks:[{tick:-e0,liquidityDelta:o},{tick:e0,liquidityDelta:-o}]}),this.token0SaleRate=r,this.token1SaleRate=c,this.lastExecutionTime=l,this.saleRateDeltas=u}initialResources(){return{...this.basePool.initialResources(),virtualOrderSecondsExecuted:0,virtualOrderDeltaTimesCrossed:0}}combineResources(f,e){return{...this.basePool.combineResources(f,e),virtualOrderDeltaTimesCrossed:f.virtualOrderDeltaTimesCrossed+e.virtualOrderDeltaTimesCrossed,virtualOrderSecondsExecuted:f.virtualOrderSecondsExecuted+e.virtualOrderSecondsExecuted}}quote({tokenAmount:f,sqrtRatioLimit:e,overrideState:t,meta:i}){let{block:{time:a}}=i,o=t??this.state,{sqrtRatio:s,token0SaleRate:r,token1SaleRate:c,lastExecutionTime:l}=o,u=a-l;if(u<0)throw new Error("Last execution time exceeds block time");let d=0,g=this.saleRateDeltas.findIndex(T=>T.time>l),x=t,m=this.basePool.initialResources();for(;l!==a;){let T=this.saleRateDeltas[g],K=T?Math.min(T.time,a):a,z=BigInt(K-l),[E,N]=[r*z>>32n,c*z>>32n];if(E>0n&&N>0n){let M=S0(g0,T0(p0,s));s=X(M,this.basePool.sortedTicks[0].liquidityDelta,r,c,z,this.key.fee);let[L,W]=M<s?[this.basePool.key.token1,N]:[this.basePool.key.token0,E],O=this.basePool.quote({tokenAmount:{amount:W,token:L},sqrtRatioLimit:s,meta:i,overrideState:x});x=O.stateAfter,m=this.basePool.combineResources(m,O.executionResources)}else if(E>0n||N>0n){let[M,L,W]=E!==0n?[E,!1,R]:[N,!0,A],O=this.basePool.quote({tokenAmount:{amount:M,token:L?this.basePool.key.token1:this.basePool.key.token0},sqrtRatioLimit:W,meta:i,overrideState:x});x=O.stateAfter,m=this.basePool.combineResources(m,O.executionResources),s=x.sqrtRatio}K===T?.time&&(r+=T.saleRateDelta0,c+=T.saleRateDelta1,g++,d++),l=K}let{consumedAmount:k,calculatedAmount:p,executionResources:h,stateAfter:F,isPriceIncreasing:P,feesPaid:t0}=this.basePool.quote({tokenAmount:f,sqrtRatioLimit:e,meta:i,overrideState:x});return{isPriceIncreasing:P,consumedAmount:k,calculatedAmount:p,feesPaid:t0,executionResources:{...this.basePool.combineResources(m,h),virtualOrderSecondsExecuted:u,virtualOrderDeltaTimesCrossed:d},stateAfter:{...F,token0SaleRate:r,token1SaleRate:c,lastExecutionTime:a}}}hasLiquidity(){return this.basePool.hasLiquidity()}get state(){return{...this.basePool.state,token0SaleRate:this.token0SaleRate,token1SaleRate:this.token1SaleRate,lastExecutionTime:this.lastExecutionTime}}};function T0(n,f){return n>f?f:n}function S0(n,f){return n>f?n:f}0&&(module.exports={BasePool,MAX_SQRT_RATIO,MAX_TICK,MAX_TICK_SPACING,MAX_U128,MAX_U256,MIN_SQRT_RATIO,MIN_TICK,TwammPool,amount0Delta,amount1Delta,calculateNextSqrtRatio,computeStep,msb,nextSqrtRatioFromAmount0,nextSqrtRatioFromAmount1,toSqrtRatio});
var G=Object.defineProperty;var i0=Object.getOwnPropertyDescriptor;var r0=Object.getOwnPropertyNames;var a0=Object.prototype.hasOwnProperty;var s0=(e,f)=>{for(var n in f)G(e,n,{get:f[n],enumerable:!0})},c0=(e,f,n,t)=>{if(f&&typeof f=="object"||typeof f=="function")for(let o of r0(f))!a0.call(e,o)&&o!==n&&G(e,o,{get:()=>f[o],enumerable:!(t=i0(f,o))||t.enumerable});return e};var l0=e=>c0(G({},"__esModule",{value:!0}),e);var R0={};s0(R0,{BasePool:()=>g,MAX_SQRT_RATIO:()=>R,MAX_TICK:()=>H,MAX_TICK_SPACING:()=>O,MAX_U128:()=>S,MAX_U256:()=>b,MIN_SQRT_RATIO:()=>A,MIN_TICK:()=>j,OraclePool:()=>F,TwammPool:()=>X,amount0Delta:()=>_,amount1Delta:()=>w,calculateNextSqrtRatio:()=>B,computeStep:()=>C,msb:()=>V,nextSqrtRatioFromAmount0:()=>y,nextSqrtRatioFromAmount1:()=>Q,toSqrtRatio:()=>U});module.exports=l0(R0);var b=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn,S=0xffffffffffffffffffffffffffffffffn;function _(e,f,n,t){if(n===0n||e===f)return 0n;let[o,i]=e<f?[e,f]:[f,e],r=(n<<128n)*(i-o),s=r/i;if(t&&r%i!==0n&&s++,s>b)throw new Error("AMOUNT0_DELTA_OVERFLOW_U256");let a=s/o;if(t&&a%o!==0n&&a++,a>S)throw new Error("AMOUNT0_DELTA_OVERFLOW_U128");return a}var J=0x100000000000000000000000000000000n;function w(e,f,n,t){if(n===0n||e===f)return 0n;let[o,i]=e<f?[e,f]:[f,e],r=n*(i-o);if(r>b)throw new Error("AMOUNT1_DELTA_OVERFLOW_U256");if(t&&r%J!==0n){let s=r/J+1n;if(s>S)throw new Error("AMOUNT1_DELTA_OVERFLOW_U128");return s}else return r>>128n}var u0=1n<<128n;function V(e){if(e>=u0)throw new Error("x too large");if(e<=0n)throw new Error("x must be positive");let f=0;return e>=0x10000000000000000n&&(e=e>>64n,f+=64),e>=0x100000000n&&(e=e>>32n,f+=32),e>=0x10000n&&(e=e>>16n,f+=16),e>=0x100n&&(e=e>>8n,f+=8),e>=0x10n&&(e=e>>4n,f+=4),e>=0x04n&&(e=e>>2n,f+=2),e>=0x02n&&(f+=1),f}function y(e,f,n){if(n===0n)return e;if(f===0n)throw new Error("NO_LIQUIDITY");let t=f<<128n;if(n<0n){let o=n*-1n*e;if(o>=b)return null;let i=t-o;if(i<0n)return null;let r=t*e,s=r/i+(r%i===0n?0n:1n);return s>b?null:s}else{let i=t/e+n,r=t/i;if(t%i===0n)return r;let a=r+1n;return a>b?null:a}}function Q(e,f,n){if(n===0n)return e;if(f===0n)throw new Error("NO_LIQUIDITY");let t=n<<128n,o=t/f,i=t%f;if(n<0n){let r=e+o;return r<0n?null:i===0n?r:r!=0n?r-1n:null}else{let r=e+o;return r>b?null:r}}function $(e,f){return e<0n!==f}function Z(e){return{consumedAmount:0n,calculatedAmount:0n,sqrtRatioNext:e,feeAmount:0n}}function Y(e,f){if(f===0n)return e;let n=e<<128n,t=(1n<<128n)-f,i=n/t+(n%t!==0n?1n:0n);if(i>S)throw new Error("AMOUNT_BEFORE_FEE_OVERFLOW");return i}function b0(e,f){let n=e*f,t=2n**128n;return n%t!==0n?n/t+1n:n/t}function C({sqrtRatio:e,liquidity:f,sqrtRatioLimit:n,amount:t,isToken1:o,fee:i}){if(t===0n||e===n)return Z(e);let r=$(t,o);if(n<e===r)throw new Error("computeStep: wrong direction");if(f===0n)return Z(n);let s;t<0n?s=t:s=t-b0(t,i);let a;if(o?a=Q(e,f,s):a=y(e,f,s),a===null||a>n===r){let[l,u]=o?[w(n,e,f,t>=0n)*(t<0n?-1n:1n),_(n,e,f,t<0n)]:[_(n,e,f,t>=0n)*(t<0n?-1n:1n),w(n,e,f,t<0n)];if(t<0n){let d=Y(u,i);return{consumedAmount:l,calculatedAmount:d,feeAmount:d-u,sqrtRatioNext:n}}else{let d=Y(l,i);return{consumedAmount:d,calculatedAmount:u,feeAmount:d-l,sqrtRatioNext:n}}}if(a===e)return{consumedAmount:t,calculatedAmount:0n,feeAmount:t,sqrtRatioNext:e};let c=o?_(a,e,f,t<0n):w(a,e,f,t<0n);if(t<0n){let l=Y(c,i);return{consumedAmount:t,calculatedAmount:l,sqrtRatioNext:a,feeAmount:l-c}}else return{consumedAmount:t,calculatedAmount:c,sqrtRatioNext:a,feeAmount:t-s}}var j=-88722883,H=88722883,R=6277100250585753475930931601400621808602321654880405518632n,A=18446748437148339061n,O=354892;function U(e){if(e<j||e>H)throw new Error(`Invalid tick: ${e}`);let f=e<0;e=Math.abs(e);let n=0x100000000000000000000000000000000n;return e&1&&(n=0xfffff79c8499329c7cbb2510d893283bn),e&2&&(n=n*0xffffef390978c398134b4ff3764fe410n>>128n),e&4&&(n=n*0xffffde72140b00a354bd3dc828e976c9n>>128n),e&8&&(n=n*0xffffbce42c7be6c998ad6318193c0b18n>>128n),e&16&&(n=n*0xffff79c86a8f6150a32d9778eceef97cn>>128n),e&32&&(n=n*0xfffef3911b7cff24ba1b3dbb5f8f5974n>>128n),e&64&&(n=n*0xfffde72350725cc4ea8feece3b5f13c8n>>128n),e&128&&(n=n*0xfffbce4b06c196e9247ac87695d53c60n>>128n),e&256&&(n=n*0xfff79ca7a4d1bf1ee8556cea23cdbaa5n>>128n),e&512&&(n=n*0xffef3995a5b6a6267530f207142a5764n>>128n),e&1024&&(n=n*0xffde7444b28145508125d10077ba83b8n>>128n),e&2048&&(n=n*0xffbceceeb791747f10df216f2e53ec57n>>128n),e&4096&&(n=n*0xff79eb706b9a64c6431d76e63531e929n>>128n),e&8192&&(n=n*0xfef41d1a5f2ae3a20676bec6f7f9459an>>128n),e&16384&&(n=n*0xfde95287d26d81bea159c37073122c73n>>128n),e&32768&&(n=n*0xfbd701c7cbc4c8a6bb81efd232d1e4e7n>>128n),e&65536&&(n=n*0xf7bf5211c72f5185f372aeb1d48f937en>>128n),e&131072&&(n=n*0xefc2bf59df33ecc28125cf78ec4f167fn>>128n),e&262144&&(n=n*0xe08d35706200796273f0b3a981d90cfdn>>128n),e&524288&&(n=n*0xc4f76b68947482dc198a48a54348c4edn>>128n),e&1048576&&(n=n*0x978bcb9894317807e5fa4498eee7c0fan>>128n),e&2097152&&(n=n*0x59b63684b86e9f486ec54727371ba6can>>128n),e&4194304&&(n=n*0x1f703399d88f6aa83a28b22d4a1f56e3n>>128n),e&8388608&&(n=n*0x3dc5dac7376e20fc8679758d1bcdcfcn>>128n),e&16777216&&(n=n*0xee7e32d61fdb0a5e622b820f681d0n>>128n),e&33554432&&(n=n*0xde2ee4bc381afa7089aa84bb66n>>128n),e&67108864&&(n=n*0xc0d55d4d7152c25fb139n>>128n),e>0&&!f&&(n=b/n),n}var d0=Math.log(1.0000005);function f0(e,f,n){let t=Math.log(Number(f)/Number(e))/d0;return Math.floor(Math.abs(t/(n*251)))}var m0=1623313478486440542208n;function B(e,f,n,t,o,i){let r=e0((t<<128n)/n)<<64n;if(f===0n)return r;let s=e0(t*n)*((1n<<128n)-i)/(1n<<128n),a=e>r,c=v(0x200000000n*o*s,f,a);if(c>m0)return r;let l=n0(c),[u,d]=a?[e-r,!0]:[r-e,!1],p=v(u<<128n,r+e,a),[x,m]=[l-p,l+p],I=d?v(m<<128n,x,a):v(x<<128n,m,a);return r*I>>128n}function v(e,f,n){let t=e/f,o=e%f;return t+(o!==0n&&n?1n:0n)}function n0(e){if(e>=36893488147419103e3){let f=n0(e/2n);return f*f>>128n}else return x0(e)}function x0(e){if(e>=0x20000000000000000n)throw new Error("Invalid input");let f=0x100000000000000000000000000000000n;return(e&0x1n)!=0n&&(f=0xffffffffffffffff0000000000000000n),(e&0x2n)!=0n&&(f=f*0xfffffffffffffffe0000000000000002n>>128n),(e&0x4n)!=0n&&(f=f*0xfffffffffffffffc0000000000000008n>>128n),(e&0x8n)!=0n&&(f=f*0xfffffffffffffff80000000000000020n>>128n),(e&0x10n)!=0n&&(f=f*0xfffffffffffffff00000000000000080n>>128n),(e&0x20n)!=0n&&(f=f*0xffffffffffffffe00000000000000200n>>128n),(e&0x40n)!=0n&&(f=f*0xffffffffffffffc00000000000000800n>>128n),(e&0x80n)!=0n&&(f=f*0xffffffffffffff800000000000002000n>>128n),(e&0x100n)!=0n&&(f=f*0xffffffffffffff000000000000008000n>>128n),(e&0x200n)!=0n&&(f=f*0xfffffffffffffe000000000000020000n>>128n),(e&0x400n)!=0n&&(f=f*0xfffffffffffffc000000000000080000n>>128n),(e&0x800n)!=0n&&(f=f*0xfffffffffffff8000000000000200000n>>128n),(e&0x1000n)!=0n&&(f=f*0xfffffffffffff0000000000000800000n>>128n),(e&0x2000n)!=0n&&(f=f*0xffffffffffffe0000000000002000000n>>128n),(e&0x4000n)!=0n&&(f=f*0xffffffffffffc0000000000008000000n>>128n),(e&0x8000n)!=0n&&(f=f*0xffffffffffff80000000000020000000n>>128n),(e&0x10000n)!=0n&&(f=f*0xffffffffffff00000000000080000000n>>128n),(e&0x20000n)!=0n&&(f=f*0xfffffffffffe00000000000200000000n>>128n),(e&0x40000n)!=0n&&(f=f*0xfffffffffffc00000000000800000000n>>128n),(e&0x80000n)!=0n&&(f=f*0xfffffffffff800000000002000000000n>>128n),(e&0x100000n)!=0n&&(f=f*0xfffffffffff000000000008000000000n>>128n),(e&0x200000n)!=0n&&(f=f*0xffffffffffe000000000020000000000n>>128n),(e&0x400000n)!=0n&&(f=f*0xffffffffffc00000000007ffffffffffn>>128n),(e&0x800000n)!=0n&&(f=f*0xffffffffff80000000001ffffffffffbn>>128n),(e&0x1000000n)!=0n&&(f=f*0xffffffffff00000000007fffffffffd5n>>128n),(e&0x2000000n)!=0n&&(f=f*0xfffffffffe0000000001fffffffffeabn>>128n),(e&0x4000000n)!=0n&&(f=f*0xfffffffffc0000000007fffffffff555n>>128n),(e&0x8000000n)!=0n&&(f=f*0xfffffffff8000000001fffffffffaaabn>>128n),(e&0x10000000n)!=0n&&(f=f*0xfffffffff0000000007ffffffffd5555n>>128n),(e&0x20000000n)!=0n&&(f=f*0xffffffffe000000001ffffffffeaaaabn>>128n),(e&0x40000000n)!=0n&&(f=f*0xffffffffc000000007ffffffff555555n>>128n),(e&0x80000000n)!=0n&&(f=f*0xffffffff800000001ffffffffaaaaaabn>>128n),(e&0x100000000n)!=0n&&(f=f*0xffffffff000000007fffffffd5555555n>>128n),(e&0x200000000n)!=0n&&(f=f*0xfffffffe00000001fffffffeaaaaaaabn>>128n),(e&0x400000000n)!=0n&&(f=f*0xfffffffc00000007fffffff555555560n>>128n),(e&0x800000000n)!=0n&&(f=f*0xfffffff80000001fffffffaaaaaaab55n>>128n),(e&0x1000000000n)!=0n&&(f=f*0xfffffff00000007ffffffd5555556000n>>128n),(e&0x2000000000n)!=0n&&(f=f*0xffffffe0000001ffffffeaaaaaab5555n>>128n),(e&0x4000000000n)!=0n&&(f=f*0xffffffc0000007ffffff555555600000n>>128n),(e&0x8000000000n)!=0n&&(f=f*0xffffff8000001ffffffaaaaaab555555n>>128n),(e&0x10000000000n)!=0n&&(f=f*0xffffff0000007fffffd555555ffffffen>>128n),(e&0x20000000000n)!=0n&&(f=f*0xfffffe000001fffffeaaaaab55555511n>>128n),(e&0x40000000000n)!=0n&&(f=f*0xfffffc000007fffff555555ffffff777n>>128n),(e&0x80000000000n)!=0n&&(f=f*0xfffff800001fffffaaaaab5555544444n>>128n),(e&0x100000000000n)!=0n&&(f=f*0xfffff000007ffffd55555fffffddddden>>128n),(e&0x200000000000n)!=0n&&(f=f*0xffffe00001ffffeaaaab555551111128n>>128n),(e&0x400000000000n)!=0n&&(f=f*0xffffc00007ffff55555fffff77777d28n>>128n),(e&0x800000000000n)!=0n&&(f=f*0xffff80001ffffaaaab5555444445b05bn>>128n),(e&0x1000000000000n)!=0n&&(f=f*0xffff00007fffd5555ffffdddde38e381n>>128n),(e&0x2000000000000n)!=0n&&(f=f*0xfffe0001fffeaaab5555111127d276a7n>>128n),(e&0x4000000000000n)!=0n&&(f=f*0xfffc0007fff5555ffff7777d27cf3cf5n>>128n),(e&0x8000000000000n)!=0n&&(f=f*0xfff8001fffaaab55544445b0596597f9n>>128n),(e&0x10000000000000n)!=0n&&(f=f*0xfff0007ffd555fffddde38e2be2d82d5n>>128n),(e&0x20000000000000n)!=0n&&(f=f*0xffe001ffeaab55511127d21522f2295cn>>128n),(e&0x40000000000000n)!=0n&&(f=f*0xffc007ff555fff777d279e7b87acece0n>>128n),(e&0x80000000000000n)!=0n&&(f=f*0xff801ffaab554445b04105b043e8f48dn>>128n),(e&0x100000000000000n)!=0n&&(f=f*0xff007fd55ffdde38d68f08c257e0ce3fn>>128n),(e&0x200000000000000n)!=0n&&(f=f*0xfe01feab551127cbfe5f89994c44216fn>>128n),(e&0x400000000000000n)!=0n&&(f=f*0xfc07f55ff77d2493e885eeaa756ad523n>>128n),(e&0x800000000000000n)!=0n&&(f=f*0xf81fab5445aebc8a58055fcbbb139ae9n>>128n),(e&0x1000000000000000n)!=0n&&(f=f*0xf07d5fde38151e72f18ff03049ac5d7fn>>128n),(e&0x2000000000000000n)!=0n&&(f=f*0xe1eb51276c110c3c3eb1269f2f5d4afbn>>128n),(e&0x4000000000000000n)!=0n&&(f=f*0xc75f7cf564105743415cbc9d6368f3b9n>>128n),(e&0x8000000000000000n)!=0n&&(f=f*0x9b4597e37cb04ff3d675a35530cdd768n>>128n),(e&0x10000000000000000n)!=0n&&(f=f*0x5e2d58d8b3bcdf1abadec7829054f90en>>128n),e!=0n&&(f=b/f),f}function e0(e){if(e<0n)throw new Error("Square root of negative numbers is not supported.");if(e<2n)return e;let f=e/2n,n=(f+e/f)/2n;for(;f>n;)f=n,n=(f+e/f)/2n;return f}function p0(e,f){let n=0,t=e.length;for(;n<t;){let o=Math.floor((n+t)/2);if(e[o].tick<=f){if(o===e.length-1||e[o+1].tick>f)return o;n=o}else t=o}return-1}var g=class{constructor({token0:f,token1:n,tickSpacing:t,fee:o,sqrtRatio:i,liquidity:r,tick:s,sortedTicks:a}){this.key={token0:f,token1:n,fee:o,tickSpacing:t,extension:0n},this.sortedTicks=a,this.state={sqrtRatio:i,liquidity:r,activeTickIndex:p0(a,s)}}combineResources(f,n){return{initializedTicksCrossed:f.initializedTicksCrossed+n.initializedTicksCrossed,tickSpacingsCrossed:f.tickSpacingsCrossed+n.tickSpacingsCrossed}}initialResources(){return{initializedTicksCrossed:0,tickSpacingsCrossed:0}}quote({tokenAmount:{amount:f,token:n},sqrtRatioLimit:t,overrideState:o}){let i=n===this.key.token1;if(!i&&this.key.token0!==n)throw new Error("Invalid token");let r=o??this.state,s=this.initialResources();if(f===0n)return{isPriceIncreasing:i,consumedAmount:0n,calculatedAmount:0n,executionResources:s,stateAfter:r,feesPaid:0n};let a=$(f,i),{sqrtRatio:c,liquidity:l,activeTickIndex:u}=r;if(t){if(a&&t<c)throw new Error("sqrtRatioLimit cannot be less than sqrtRatio");if(!a&&t>c)throw new Error("sqrtRatioLimit cannot be greater than sqrtRatio");if(t<A)throw new Error("sqrtRatioLimit lt min");if(t>R)throw new Error("sqrtRatioLimit gt max")}else t=a?R:A;let d=0n,p=0n,x=s.initializedTicksCrossed,m=f,I=c;for(;m!==0n&&c!==t;){let T=(a?this.sortedTicks[u+1]:this.sortedTicks[u])??null,P=T?U(T.tick):null,K=P===null?t:P<t===a?P:t,k=C({fee:this.key.fee,sqrtRatio:c,liquidity:l,isToken1:i,sqrtRatioLimit:K,amount:m});m-=k.consumedAmount,d+=k.calculatedAmount,p+=k.feeAmount,c=k.sqrtRatioNext,T&&c===P&&(u=a?u+1:u-1,x++,l+=a?T.liquidityDelta:-T.liquidityDelta)}return{isPriceIncreasing:a,consumedAmount:f-m,calculatedAmount:d,feesPaid:p,executionResources:{initializedTicksCrossed:x,tickSpacingsCrossed:s.tickSpacingsCrossed+f0(I,c,this.key.tickSpacing)},stateAfter:{sqrtRatio:c,liquidity:l,activeTickIndex:u}}}hasLiquidity(){return this.state.liquidity>0n||this.sortedTicks.length>0}};var t0=88368108,g0=22027144413679976675n,T0=5256790760649093508123362461711849782692726119655358142129n,X=class{get key(){return{...this.basePool.key,extension:this.extension}}get sortedTicks(){return this.basePool.sortedTicks}constructor({token0:f,token1:n,fee:t,extension:o,sqrtRatio:i,liquidity:r,tick:s,token0SaleRate:a,token1SaleRate:c,lastExecutionTime:l,saleRateDeltas:u}){this.extension=o,this.basePool=new g({token0:f,token1:n,fee:t,sqrtRatio:i,liquidity:r,tick:s,tickSpacing:O,sortedTicks:[{tick:-t0,liquidityDelta:r},{tick:t0,liquidityDelta:-r}]}),this.token0SaleRate=a,this.token1SaleRate=c,this.lastExecutionTime=l,this.saleRateDeltas=u}initialResources(){return{...this.basePool.initialResources(),virtualOrderSecondsExecuted:0,virtualOrderDeltaTimesCrossed:0}}combineResources(f,n){return{...this.basePool.combineResources(f,n),virtualOrderDeltaTimesCrossed:f.virtualOrderDeltaTimesCrossed+n.virtualOrderDeltaTimesCrossed,virtualOrderSecondsExecuted:f.virtualOrderSecondsExecuted+n.virtualOrderSecondsExecuted}}quote({tokenAmount:f,sqrtRatioLimit:n,overrideState:t,meta:o}){let{block:{time:i}}=o,r=t??this.state,{sqrtRatio:s,token0SaleRate:a,token1SaleRate:c,lastExecutionTime:l}=r,u=i-l;if(u<0)throw new Error("Last execution time exceeds block time");let d=0,p=this.saleRateDeltas.findIndex(h=>h.time>l),x=t,m=this.basePool.initialResources();for(;l!==i;){let h=this.saleRateDeltas[p],L=h?Math.min(h.time,i):i,z=BigInt(L-l),[E,M]=[a*z>>32n,c*z>>32n];if(E>0n&&M>0n){let D=S0(g0,h0(T0,s));s=B(D,this.basePool.sortedTicks[0].liquidityDelta,a,c,z,this.key.fee);let[q,W]=D<s?[this.basePool.key.token1,M]:[this.basePool.key.token0,E],N=this.basePool.quote({tokenAmount:{amount:W,token:q},sqrtRatioLimit:s,meta:o,overrideState:x});x=N.stateAfter,m=this.basePool.combineResources(m,N.executionResources)}else if(E>0n||M>0n){let[D,q,W]=E!==0n?[E,!1,A]:[M,!0,R],N=this.basePool.quote({tokenAmount:{amount:D,token:q?this.basePool.key.token1:this.basePool.key.token0},sqrtRatioLimit:W,meta:o,overrideState:x});x=N.stateAfter,m=this.basePool.combineResources(m,N.executionResources),s=x.sqrtRatio}L===h?.time&&(a+=h.saleRateDelta0,c+=h.saleRateDelta1,p++,d++),l=L}let{consumedAmount:I,calculatedAmount:T,executionResources:P,stateAfter:K,isPriceIncreasing:k,feesPaid:o0}=this.basePool.quote({tokenAmount:f,sqrtRatioLimit:n,meta:o,overrideState:x});return{isPriceIncreasing:k,consumedAmount:I,calculatedAmount:T,feesPaid:o0,executionResources:{...this.basePool.combineResources(m,P),virtualOrderSecondsExecuted:u,virtualOrderDeltaTimesCrossed:d},stateAfter:{...K,token0SaleRate:a,token1SaleRate:c,lastExecutionTime:i}}}hasLiquidity(){return this.basePool.hasLiquidity()}get state(){return{...this.basePool.state,token0SaleRate:this.token0SaleRate,token1SaleRate:this.token1SaleRate,lastExecutionTime:this.lastExecutionTime}}};function h0(e,f){return e>f?f:e}function S0(e,f){return e>f?e:f}var F=class{constructor({token0:f,token1:n,sqrtRatio:t,liquidity:o,tick:i,sortedTicks:r,extension:s,lastSnapshotTime:a}){this.basePool=new g({token0:f,token1:n,fee:0n,tickSpacing:O,sortedTicks:r,tick:i,sqrtRatio:t,liquidity:o}),this.extension=s,this.lastSnapshotTime=a}get key(){return{...this.basePool.key,extension:this.extension}}get state(){return{...this.basePool.state,lastSnapshotTime:this.lastSnapshotTime}}get sortedTicks(){return this.basePool.sortedTicks}quote(f){let n=this.basePool.quote(f),t=f.overrideState??this.state,o=BigInt(f.meta.block.time),i=t.lastSnapshotTime<o;return{...n,executionResources:{...n.executionResources,snapshotUpdated:i},stateAfter:{...t,lastSnapshotTime:i?o:t.lastSnapshotTime}}}combineResources(f,n){return{...this.basePool.combineResources(f,n),snapshotUpdated:f.snapshotUpdated||n.snapshotUpdated}}initialResources(){return{...this.basePool.initialResources(),snapshotUpdated:!1}}hasLiquidity(){return this.basePool.hasLiquidity()}};0&&(module.exports={BasePool,MAX_SQRT_RATIO,MAX_TICK,MAX_TICK_SPACING,MAX_U128,MAX_U256,MIN_SQRT_RATIO,MIN_TICK,OraclePool,TwammPool,amount0Delta,amount1Delta,calculateNextSqrtRatio,computeStep,msb,nextSqrtRatioFromAmount0,nextSqrtRatioFromAmount1,toSqrtRatio});
{
"name": "@ekubo/sdk",
"version": "0.0.3",
"version": "0.0.4",
"description": "SDK for working with Ekubo protocol",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc