whirlpools-client/docs/classes/SwapUtils.html

92 lines
40 KiB
HTML

<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>SwapUtils | @orca-so/whirlpools-sdk</title><meta name="description" content="Documentation for @orca-so/whirlpools-sdk"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@orca-so/whirlpools-sdk</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@orca-so/whirlpools-sdk</a></li><li><a href="SwapUtils.html">SwapUtils</a></li></ul><h1>Class SwapUtils </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">SwapUtils</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section"><h3>Other</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="SwapUtils.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#calculateSwapAmountsFromQuote" class="tsd-kind-icon">calculate<wbr/>Swap<wbr/>Amounts<wbr/>From<wbr/>Quote</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getBatchTickArrays" class="tsd-kind-icon">get<wbr/>Batch<wbr/>Tick<wbr/>Arrays</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getDefaultOtherAmountThreshold" class="tsd-kind-icon">get<wbr/>Default<wbr/>Other<wbr/>Amount<wbr/>Threshold</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getDefaultSqrtPriceLimit" class="tsd-kind-icon">get<wbr/>Default<wbr/>Sqrt<wbr/>Price<wbr/>Limit</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getSwapDirection" class="tsd-kind-icon">get<wbr/>Swap<wbr/>Direction</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getSwapParamsFromQuote" class="tsd-kind-icon">get<wbr/>Swap<wbr/>Params<wbr/>From<wbr/>Quote</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getSwapParamsFromQuoteKeys" class="tsd-kind-icon">get<wbr/>Swap<wbr/>Params<wbr/>From<wbr/>Quote<wbr/>Keys</a></li></ul></section><section class="tsd-index-section"><h3>Whirlpool Utils</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getTickArrayPublicKeys" class="tsd-kind-icon">get<wbr/>Tick<wbr/>Array<wbr/>Public<wbr/>Keys</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getTickArrays" class="tsd-kind-icon">get<wbr/>Tick<wbr/>Arrays</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group tsd-kind-class"><h2>Other</h2><section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link">constructor<a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">new <wbr/>Swap<wbr/>Utils<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="SwapUtils.html" class="tsd-signature-type" data-tsd-kind="Class">SwapUtils</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="SwapUtils.html" class="tsd-signature-type" data-tsd-kind="Class">SwapUtils</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="calculateSwapAmountsFromQuote" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> calculate<wbr/>Swap<wbr/>Amounts<wbr/>From<wbr/>Quote<a href="#calculateSwapAmountsFromQuote" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">calculate<wbr/>Swap<wbr/>Amounts<wbr/>From<wbr/>Quote<span class="tsd-signature-symbol">(</span>amount<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">BN</span>, estAmountIn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">BN</span>, estAmountOut<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">BN</span>, slippageTolerance<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Percentage</span>, amountSpecifiedIsInput<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Pick</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#SwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">SwapInput</a><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">&quot;amount&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;otherAmountThreshold&quot;</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L200">utils/public/swap-utils.ts:200</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Calculate the SwapInput parameters <code>amount</code> &amp; <code>otherAmountThreshold</code> based on the amountIn &amp; amountOut estimates from a quote.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>amount: <span class="tsd-signature-type">BN</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The amount of tokens the user wanted to swap from.</p>
</div></div></li><li><h5>estAmountIn: <span class="tsd-signature-type">BN</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The estimated amount of input tokens expected in a <code>SwapQuote</code></p>
</div></div></li><li><h5>estAmountOut: <span class="tsd-signature-type">BN</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The estimated amount of output tokens expected from a <code>SwapQuote</code></p>
</div></div></li><li><h5>slippageTolerance: <span class="tsd-signature-type">Percentage</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The amount of slippage to adjust for.</p>
</div></div></li><li><h5>amountSpecifiedIsInput: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Specifies the token the parameter <code>amount</code>represents in the swap quote. If true, the amount represents
the input token of the swap.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Pick</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#SwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">SwapInput</a><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">&quot;amount&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;otherAmountThreshold&quot;</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A Partial <code>SwapInput</code> object containing the slippage adjusted &#39;amount&#39; &amp; &#39;otherAmountThreshold&#39; parameters.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getBatchTickArrays" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Batch<wbr/>Tick<wbr/>Arrays<a href="#getBatchTickArrays" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">get<wbr/>Batch<wbr/>Tick<wbr/>Arrays<span class="tsd-signature-symbol">(</span>programId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, fetcher<span class="tsd-signature-symbol">: </span><a href="AccountFetcher.html" class="tsd-signature-type" data-tsd-kind="Class">AccountFetcher</a>, refresh<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span>, tickArrayRequests<span class="tsd-signature-symbol">: </span><a href="../interfaces/TickArrayRequest.html" class="tsd-signature-type" data-tsd-kind="Interface">TickArrayRequest</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#TickArray" class="tsd-signature-type" data-tsd-kind="Type alias">TickArray</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L153">utils/public/swap-utils.ts:153</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetch a batch of tick-arrays for a set of TA requests.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>programId: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The Whirlpool programId which the Whirlpool lives on.</p>
</div></div></li><li><h5>fetcher: <a href="AccountFetcher.html" class="tsd-signature-type" data-tsd-kind="Class">AccountFetcher</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>AccountFetcher object to fetch solana accounts</p>
</div></div></li><li><h5>refresh: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>If true, fetcher would default to fetching the latest accounts</p>
</div></div></li><li><h5>tickArrayRequests: <a href="../interfaces/TickArrayRequest.html" class="tsd-signature-type" data-tsd-kind="Interface">TickArrayRequest</a><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>An array of <a href="../interfaces/TickArrayRequest.html">TickArrayRequest</a> of tick-arrays to request for.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#TickArray" class="tsd-signature-type" data-tsd-kind="Type alias">TickArray</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A array of request indicies mapped to an array of resulting PublicKeys.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getDefaultOtherAmountThreshold" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Default<wbr/>Other<wbr/>Amount<wbr/>Threshold<a href="#getDefaultOtherAmountThreshold" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">get<wbr/>Default<wbr/>Other<wbr/>Amount<wbr/>Threshold<span class="tsd-signature-symbol">(</span>amountSpecifiedIsInput<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">BN</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L52">utils/public/swap-utils.ts:52</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the default values for the otherAmountThreshold parameter in a swap.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>amountSpecifiedIsInput: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The direction of a swap</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">BN</span></h4><div><p>The default values for the otherAmountThreshold parameter in a swap.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getDefaultSqrtPriceLimit" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Default<wbr/>Sqrt<wbr/>Price<wbr/>Limit<a href="#getDefaultSqrtPriceLimit" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">get<wbr/>Default<wbr/>Sqrt<wbr/>Price<wbr/>Limit<span class="tsd-signature-symbol">(</span>aToB<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">BN</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L43">utils/public/swap-utils.ts:43</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the default values for the sqrtPriceLimit parameter in a swap.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>aToB: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The direction of a swap</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">BN</span></h4><div><p>The default values for the sqrtPriceLimit parameter in a swap.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getSwapDirection" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Swap<wbr/>Direction<a href="#getSwapDirection" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">get<wbr/>Swap<wbr/>Direction<span class="tsd-signature-symbol">(</span>pool<span class="tsd-signature-symbol">: </span><a href="../modules.html#WhirlpoolData" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolData</a>, swapTokenMint<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, swapTokenIsInput<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../enums/SwapDirection.html" class="tsd-signature-type" data-tsd-kind="Enumeration">SwapDirection</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L63">utils/public/swap-utils.ts:63</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Given the intended token mint to swap, return the swap direction of a swap for a Whirlpool</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>pool: <a href="../modules.html#WhirlpoolData" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The Whirlpool to evaluate the mint against</p>
</div></div></li><li><h5>swapTokenMint: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The token mint PublicKey the user bases their swap against</p>
</div></div></li><li><h5>swapTokenIsInput: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Whether the swap token is the input token. (similar to amountSpecifiedIsInput from swap Ix)</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../enums/SwapDirection.html" class="tsd-signature-type" data-tsd-kind="Enumeration">SwapDirection</a></h4><div><p>The direction of the swap given the swapTokenMint. undefined if the token mint is not part of the trade pair of the pool.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getSwapParamsFromQuote" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Swap<wbr/>Params<wbr/>From<wbr/>Quote<a href="#getSwapParamsFromQuote" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">get<wbr/>Swap<wbr/>Params<wbr/>From<wbr/>Quote<span class="tsd-signature-symbol">(</span>quote<span class="tsd-signature-symbol">: </span><a href="../modules.html#SwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">SwapInput</a>, ctx<span class="tsd-signature-symbol">: </span><a href="WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</a>, whirlpool<span class="tsd-signature-symbol">: </span><a href="../interfaces/Whirlpool.html" class="tsd-signature-type" data-tsd-kind="Interface">Whirlpool</a>, inputTokenAssociatedAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, outputTokenAssociatedAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, wallet<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#SwapParams" class="tsd-signature-type" data-tsd-kind="Type alias">SwapParams</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L232">utils/public/swap-utils.ts:232</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Convert a quote object and WhirlpoolClient&#39;s <a href="../enums/AccountName.html#Whirlpool">Whirlpool</a> object into a <a href="../modules.html#SwapParams">SwapParams</a> type
to be plugged into <a href="WhirlpoolIx.html#swapIx">WhirlpoolIx.swapIx</a>.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>quote: <a href="../modules.html#SwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">SwapInput</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A <a href="../modules.html#SwapQuote">SwapQuote</a> type generated from <a href="../modules.html#swapQuoteWithParams">swapQuoteWithParams</a></p>
</div></div></li><li><h5>ctx: <a href="WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="WhirlpoolContext.html">WhirlpoolContext</a></p>
</div></div></li><li><h5>whirlpool: <a href="../interfaces/Whirlpool.html" class="tsd-signature-type" data-tsd-kind="Interface">Whirlpool</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A <a href="../enums/AccountName.html#Whirlpool">Whirlpool</a> object from WhirlpoolClient</p>
</div></div></li><li><h5>inputTokenAssociatedAddress: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The public key for the ATA of the input token in the swap</p>
</div></div></li><li><h5>outputTokenAssociatedAddress: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The public key for the ATA of the input token in the swap</p>
</div></div></li><li><h5>wallet: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The token authority for this swap</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules.html#SwapParams" class="tsd-signature-type" data-tsd-kind="Type alias">SwapParams</a></h4><div><p>A converted <a href="../modules.html#SwapParams">SwapParams</a> generated from the input</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getSwapParamsFromQuoteKeys" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Swap<wbr/>Params<wbr/>From<wbr/>Quote<wbr/>Keys<a href="#getSwapParamsFromQuoteKeys" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">get<wbr/>Swap<wbr/>Params<wbr/>From<wbr/>Quote<wbr/>Keys<span class="tsd-signature-symbol">(</span>quote<span class="tsd-signature-symbol">: </span><a href="../modules.html#SwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">SwapInput</a>, ctx<span class="tsd-signature-symbol">: </span><a href="WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</a>, whirlpool<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, tokenVaultA<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, tokenVaultB<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, inputTokenAssociatedAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, outputTokenAssociatedAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, wallet<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#SwapParams" class="tsd-signature-type" data-tsd-kind="Type alias">SwapParams</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L253">utils/public/swap-utils.ts:253</a></li></ul></aside><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>quote: <a href="../modules.html#SwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">SwapInput</a></h5></li><li><h5>ctx: <a href="WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</a></h5></li><li><h5>whirlpool: <span class="tsd-signature-type">PublicKey</span></h5></li><li><h5>tokenVaultA: <span class="tsd-signature-type">PublicKey</span></h5></li><li><h5>tokenVaultB: <span class="tsd-signature-type">PublicKey</span></h5></li><li><h5>inputTokenAssociatedAddress: <span class="tsd-signature-type">Address</span></h5></li><li><h5>outputTokenAssociatedAddress: <span class="tsd-signature-type">Address</span></h5></li><li><h5>wallet: <span class="tsd-signature-type">PublicKey</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules.html#SwapParams" class="tsd-signature-type" data-tsd-kind="Type alias">SwapParams</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group tsd-kind-class"><h2>Whirlpool Utils</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getTickArrayPublicKeys" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Tick<wbr/>Array<wbr/>Public<wbr/>Keys<a href="#getTickArrayPublicKeys" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">get<wbr/>Tick<wbr/>Array<wbr/>Public<wbr/>Keys<span class="tsd-signature-symbol">(</span>tickCurrentIndex<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, tickSpacing<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, aToB<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span>, programId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, whirlpoolAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">[]</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L90">utils/public/swap-utils.ts:90</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Given the current tick-index, returns the dervied PDA and fetched data
for the tick-arrays that this swap may traverse across.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>tickCurrentIndex: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The current tickIndex for the Whirlpool to swap on.</p>
</div></div></li><li><h5>tickSpacing: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The tickSpacing for the Whirlpool.</p>
</div></div></li><li><h5>aToB: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The direction of the trade.</p>
</div></div></li><li><h5>programId: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The Whirlpool programId which the Whirlpool lives on.</p>
</div></div></li><li><h5>whirlpoolAddress: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>PublicKey of the whirlpool to swap on.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">[]</span></h4><div><p>An array of PublicKey[] for the tickArray accounts that this swap may traverse across.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getTickArrays" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Tick<wbr/>Arrays<a href="#getTickArrays" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"><li class="tsd-signature tsd-kind-icon">get<wbr/>Tick<wbr/>Arrays<span class="tsd-signature-symbol">(</span>tickCurrentIndex<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, tickSpacing<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, aToB<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span>, programId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, whirlpoolAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, fetcher<span class="tsd-signature-symbol">: </span><a href="AccountFetcher.html" class="tsd-signature-type" data-tsd-kind="Class">AccountFetcher</a>, refresh<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#TickArray" class="tsd-signature-type" data-tsd-kind="Type alias">TickArray</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/9e0a389/sdk/src/utils/public/swap-utils.ts#L130">utils/public/swap-utils.ts:130</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Given the current tick-index, returns TickArray objects that this swap may traverse across.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>tickCurrentIndex: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The current tickIndex for the Whirlpool to swap on.</p>
</div></div></li><li><h5>tickSpacing: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The tickSpacing for the Whirlpool.</p>
</div></div></li><li><h5>aToB: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The direction of the trade.</p>
</div></div></li><li><h5>programId: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The Whirlpool programId which the Whirlpool lives on.</p>
</div></div></li><li><h5>whirlpoolAddress: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>PublicKey of the whirlpool to swap on.</p>
</div></div></li><li><h5>fetcher: <a href="AccountFetcher.html" class="tsd-signature-type" data-tsd-kind="Class">AccountFetcher</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>AccountFetcher object to fetch solana accounts</p>
</div></div></li><li><h5>refresh: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>If true, fetcher would default to fetching the latest accounts</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#TickArray" class="tsd-signature-type" data-tsd-kind="Type alias">TickArray</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>An array of PublicKey[] for the tickArray accounts that this swap may traverse across.</p>
</div></li></ul></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-class"><a href="SwapUtils.html" class="tsd-kind-icon">Swap<wbr/>Utils</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="SwapUtils.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#calculateSwapAmountsFromQuote" class="tsd-kind-icon">calculate<wbr/>Swap<wbr/>Amounts<wbr/>From<wbr/>Quote</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getBatchTickArrays" class="tsd-kind-icon">get<wbr/>Batch<wbr/>Tick<wbr/>Arrays</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getDefaultOtherAmountThreshold" class="tsd-kind-icon">get<wbr/>Default<wbr/>Other<wbr/>Amount<wbr/>Threshold</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getDefaultSqrtPriceLimit" class="tsd-kind-icon">get<wbr/>Default<wbr/>Sqrt<wbr/>Price<wbr/>Limit</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getSwapDirection" class="tsd-kind-icon">get<wbr/>Swap<wbr/>Direction</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getSwapParamsFromQuote" class="tsd-kind-icon">get<wbr/>Swap<wbr/>Params<wbr/>From<wbr/>Quote</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getSwapParamsFromQuoteKeys" class="tsd-kind-icon">get<wbr/>Swap<wbr/>Params<wbr/>From<wbr/>Quote<wbr/>Keys</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getTickArrayPublicKeys" class="tsd-kind-icon">get<wbr/>Tick<wbr/>Array<wbr/>Public<wbr/>Keys</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="SwapUtils.html#getTickArrays" class="tsd-kind-icon">get<wbr/>Tick<wbr/>Arrays</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>