make usable as client-only lib

- drop instruction bodies
- upgrade to anchor v0.29
- upgrade to solana v1.17
- upgrade borsh to v0.10
- drop mpl-token dependency
This commit is contained in:
Christian Kamm 2024-04-08 16:11:19 +02:00
parent 3da6b8937f
commit 3e7c62e054
254 changed files with 945 additions and 53491 deletions

1303
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.

View File

@ -1,43 +0,0 @@
:root {
--light-hl-0: #001080;
--dark-hl-0: #9CDCFE;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #A31515;
--dark-hl-2: #CE9178;
--light-code-background: #F5F5F5;
--dark-code-background: #1E1E1E;
}
@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--code-background: var(--light-code-background);
} }
@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--code-background: var(--dark-code-background);
} }
body.light {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--code-background: var(--light-code-background);
}
body.dark {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--code-background: var(--dark-code-background);
}
.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
pre, code { background: var(--code-background); }

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,15 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>PoolGraphBuilder | @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="PoolGraphBuilder.html">PoolGraphBuilder</a></li></ul><h1>Class PoolGraphBuilder </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>A builder class for creating a <a href="../modules.html#PoolGraph">PoolGraph</a></p>
</div><div><p>Note: we use an adjacency list as a representation of our pool graph,
since we assume that most token pairings don&#39;t exist as pools</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">PoolGraphBuilder</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>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="PoolGraphBuilder.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PoolGraphBuilder.html#buildPoolGraph" class="tsd-kind-icon">build<wbr/>Pool<wbr/>Graph</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PoolGraphBuilder.html#buildPoolGraphWithFetch" class="tsd-kind-icon">build<wbr/>Pool<wbr/>Graph<wbr/>With<wbr/>Fetch</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</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/>Pool<wbr/>Graph<wbr/>Builder<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="PoolGraphBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">PoolGraphBuilder</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="PoolGraphBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">PoolGraphBuilder</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="buildPoolGraph" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> build<wbr/>Pool<wbr/>Graph<a href="#buildPoolGraph" 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">build<wbr/>Pool<wbr/>Graph<span class="tsd-signature-symbol">(</span>poolTokenPairs<span class="tsd-signature-symbol">: </span><a href="../interfaces/PoolTokenPair.html" class="tsd-signature-type" data-tsd-kind="Interface">PoolTokenPair</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#PoolGraph" class="tsd-signature-type" data-tsd-kind="Type alias">PoolGraph</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/3dc98d0/sdk/src/utils/graphs/public/pool-graph-builder.ts#L46">utils/graphs/public/pool-graph-builder.ts:46</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Build a <a href="../modules.html#PoolGraph">PoolGraph</a> from a list of pools in the format of <a href="../interfaces/PoolTokenPair.html">PoolTokenPair</a></p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>poolTokenPairs: <a href="../interfaces/PoolTokenPair.html" class="tsd-signature-type" data-tsd-kind="Interface">PoolTokenPair</a><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>a list of <a href="../interfaces/PoolTokenPair.html">PoolTokenPair</a> to generate this pool graph</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules.html#PoolGraph" class="tsd-signature-type" data-tsd-kind="Type alias">PoolGraph</a></h4><div><p>A <a href="../modules.html#PoolGraph">PoolGraph</a> with the provided pools</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="buildPoolGraphWithFetch" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> build<wbr/>Pool<wbr/>Graph<wbr/>With<wbr/>Fetch<a href="#buildPoolGraphWithFetch" 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">build<wbr/>Pool<wbr/>Graph<wbr/>With<wbr/>Fetch<span class="tsd-signature-symbol">(</span>pools<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span>, fetcher<span class="tsd-signature-symbol">: </span><a href="../interfaces/WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a><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#PoolGraph" class="tsd-signature-type" data-tsd-kind="Type alias">PoolGraph</a><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/3dc98d0/sdk/src/utils/graphs/public/pool-graph-builder.ts#L20">utils/graphs/public/pool-graph-builder.ts:20</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetch data and build a <a href="../modules.html#PoolGraph">PoolGraph</a> from a list of pools addresses</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>pools: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>a list of pool addresses to generate this pool graph</p>
</div></div></li><li><h5>fetcher: <a href="../interfaces/WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a></h5></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#PoolGraph" class="tsd-signature-type" data-tsd-kind="Type alias">PoolGraph</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A <a href="../modules.html#PoolGraph">PoolGraph</a> with the provided pools</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="PoolGraphBuilder.html" class="tsd-kind-icon">Pool<wbr/>Graph<wbr/>Builder</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="PoolGraphBuilder.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PoolGraphBuilder.html#buildPoolGraph" class="tsd-kind-icon">build<wbr/>Pool<wbr/>Graph</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PoolGraphBuilder.html#buildPoolGraphWithFetch" class="tsd-kind-icon">build<wbr/>Pool<wbr/>Graph<wbr/>With<wbr/>Fetch</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>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,52 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>PositionBundleUtil | @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="PositionBundleUtil.html">PositionBundleUtil</a></li></ul><h1>Class PositionBundleUtil </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>A collection of utility functions when interacting with a PositionBundle.</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">PositionBundleUtil</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>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#checkBundleIndexInBounds" class="tsd-kind-icon">check<wbr/>Bundle<wbr/>Index<wbr/>In<wbr/>Bounds</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#convertBitmapToArray" class="tsd-kind-icon">convert<wbr/>Bitmap<wbr/>To<wbr/>Array</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#findUnoccupiedBundleIndex" class="tsd-kind-icon">find<wbr/>Unoccupied<wbr/>Bundle<wbr/>Index</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#getOccupiedBundleIndexes" class="tsd-kind-icon">get<wbr/>Occupied<wbr/>Bundle<wbr/>Indexes</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#getUnoccupiedBundleIndexes" class="tsd-kind-icon">get<wbr/>Unoccupied<wbr/>Bundle<wbr/>Indexes</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#isEmpty" class="tsd-kind-icon">is<wbr/>Empty</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#isFull" class="tsd-kind-icon">is<wbr/>Full</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#isOccupied" class="tsd-kind-icon">is<wbr/>Occupied</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#isUnoccupied" class="tsd-kind-icon">is<wbr/>Unoccupied</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="checkBundleIndexInBounds" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> check<wbr/>Bundle<wbr/>Index<wbr/>In<wbr/>Bounds<a href="#checkBundleIndexInBounds" 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">check<wbr/>Bundle<wbr/>Index<wbr/>In<wbr/>Bounds<span class="tsd-signature-symbol">(</span>bundleIndex<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L17">utils/public/position-bundle-util.ts:17</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Check if the bundle index is in the correct range.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>bundleIndex: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The bundle index to be checked</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><div><p>true if bundle index is in the correct range</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="convertBitmapToArray" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> convert<wbr/>Bitmap<wbr/>To<wbr/>Array<a href="#convertBitmapToArray" 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">convert<wbr/>Bitmap<wbr/>To<wbr/>Array<span class="tsd-signature-symbol">(</span>positionBundle<span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L116">utils/public/position-bundle-util.ts:116</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Convert position bitmap to the array of boolean which represent if Bundled Position is open.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionBundle: <a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The position bundle whose bitmap will be converted</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">[]</span></h4><div><p>The array of boolean representing if Bundled Position is open</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="findUnoccupiedBundleIndex" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> find<wbr/>Unoccupied<wbr/>Bundle<wbr/>Index<a href="#findUnoccupiedBundleIndex" 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">find<wbr/>Unoccupied<wbr/>Bundle<wbr/>Index<span class="tsd-signature-symbol">(</span>positionBundle<span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L105">utils/public/position-bundle-util.ts:105</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the first unoccupied bundle index in the position bundle.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionBundle: <a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The position bundle to be checked</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span></h4><div><p>The first unoccupied bundle index, null if the position bundle is full</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getOccupiedBundleIndexes" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Occupied<wbr/>Bundle<wbr/>Indexes<a href="#getOccupiedBundleIndexes" 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/>Occupied<wbr/>Bundle<wbr/>Indexes<span class="tsd-signature-symbol">(</span>positionBundle<span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L73">utils/public/position-bundle-util.ts:73</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get all bundle indexes where the corresponding Bundled Position is open.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionBundle: <a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The position bundle to be checked</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h4><div><p>The array of bundle index where the corresponding Bundled Position is open</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getUnoccupiedBundleIndexes" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Unoccupied<wbr/>Bundle<wbr/>Indexes<a href="#getUnoccupiedBundleIndexes" 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/>Unoccupied<wbr/>Bundle<wbr/>Indexes<span class="tsd-signature-symbol">(</span>positionBundle<span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L89">utils/public/position-bundle-util.ts:89</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get all bundle indexes where the corresponding Bundled Position is not open.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionBundle: <a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The position bundle to be checked</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h4><div><p>The array of bundle index where the corresponding Bundled Position is not open</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="isEmpty" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> is<wbr/>Empty<a href="#isEmpty" 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">is<wbr/>Empty<span class="tsd-signature-symbol">(</span>positionBundle<span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L62">utils/public/position-bundle-util.ts:62</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Check if all bundle index is unoccupied.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionBundle: <a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The position bundle to be checked</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><div><p>true if all bundle index is unoccupied</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="isFull" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> is<wbr/>Full<a href="#isFull" 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">is<wbr/>Full<span class="tsd-signature-symbol">(</span>positionBundle<span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L51">utils/public/position-bundle-util.ts:51</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Check if all bundle index is occupied.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionBundle: <a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The position bundle to be checked</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><div><p>true if all bundle index is occupied</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="isOccupied" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> is<wbr/>Occupied<a href="#isOccupied" 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">is<wbr/>Occupied<span class="tsd-signature-symbol">(</span>positionBundle<span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a>, bundleIndex<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L28">utils/public/position-bundle-util.ts:28</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Check if the Bundled Position corresponding to the bundle index has been opened.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionBundle: <a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The position bundle to be checked</p>
</div></div></li><li><h5>bundleIndex: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The bundle index to be checked</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><div><p>true if Bundled Position has been opened</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="isUnoccupied" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> is<wbr/>Unoccupied<a href="#isUnoccupied" 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">is<wbr/>Unoccupied<span class="tsd-signature-symbol">(</span>positionBundle<span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a>, bundleIndex<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</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/3dc98d0/sdk/src/utils/public/position-bundle-util.ts#L41">utils/public/position-bundle-util.ts:41</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Check if the Bundled Position corresponding to the bundle index has not been opened.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionBundle: <a href="../modules.html#PositionBundleData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionBundleData</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The position bundle to be checked</p>
</div></div></li><li><h5>bundleIndex: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The bundle index to be checked</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><div><p>true if Bundled Position has not been opened</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="PositionBundleUtil.html" class="tsd-kind-icon">Position<wbr/>Bundle<wbr/>Util</a><ul><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#checkBundleIndexInBounds" class="tsd-kind-icon">check<wbr/>Bundle<wbr/>Index<wbr/>In<wbr/>Bounds</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#convertBitmapToArray" class="tsd-kind-icon">convert<wbr/>Bitmap<wbr/>To<wbr/>Array</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#findUnoccupiedBundleIndex" class="tsd-kind-icon">find<wbr/>Unoccupied<wbr/>Bundle<wbr/>Index</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#getOccupiedBundleIndexes" class="tsd-kind-icon">get<wbr/>Occupied<wbr/>Bundle<wbr/>Indexes</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#getUnoccupiedBundleIndexes" class="tsd-kind-icon">get<wbr/>Unoccupied<wbr/>Bundle<wbr/>Indexes</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#isEmpty" class="tsd-kind-icon">is<wbr/>Empty</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#isFull" class="tsd-kind-icon">is<wbr/>Full</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#isOccupied" class="tsd-kind-icon">is<wbr/>Occupied</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PositionBundleUtil.html#isUnoccupied" class="tsd-kind-icon">is<wbr/>Unoccupied</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>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,35 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>PriceModuleUtils | @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="PriceModuleUtils.html">PriceModuleUtils</a></li></ul><h1>Class PriceModuleUtils </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>A list of utility functions for the price module.</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">PriceModuleUtils</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>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="PriceModuleUtils.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PriceModuleUtils.html#fetchDecimalsForMints" class="tsd-kind-icon">fetch<wbr/>Decimals<wbr/>For<wbr/>Mints</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PriceModuleUtils.html#fetchPoolDataFromMints" class="tsd-kind-icon">fetch<wbr/>Pool<wbr/>Data<wbr/>From<wbr/>Mints</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PriceModuleUtils.html#fetchTickArraysForPools" class="tsd-kind-icon">fetch<wbr/>Tick<wbr/>Arrays<wbr/>For<wbr/>Pools</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</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/>Price<wbr/>Module<wbr/>Utils<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="PriceModuleUtils.html" class="tsd-signature-type" data-tsd-kind="Class">PriceModuleUtils</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="PriceModuleUtils.html" class="tsd-signature-type" data-tsd-kind="Class">PriceModuleUtils</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="fetchDecimalsForMints" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> fetch<wbr/>Decimals<wbr/>For<wbr/>Mints<a href="#fetchDecimalsForMints" 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">fetch<wbr/>Decimals<wbr/>For<wbr/>Mints<span class="tsd-signature-symbol">(</span>fetcher<span class="tsd-signature-symbol">: </span><a href="../interfaces/WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a>, mints<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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#DecimalsMap" class="tsd-signature-type" data-tsd-kind="Type alias">DecimalsMap</a><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/3dc98d0/sdk/src/prices/price-module.ts#L336">prices/price-module.ts:336</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetch the decimals to token mapping for the given mints.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fetcher: <a href="../interfaces/WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="../interfaces/WhirlpoolAccountFetcherInterface.html">WhirlpoolAccountFetcherInterface</a></p>
</div></div></li><li><h5>mints: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The mints to fetch decimals for.</p>
</div></div></li><li><h5>opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span><span class="tsd-signature-symbol"> = IGNORE_CACHE</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an <a href="../modules.html#WhirlpoolAccountFetchOptions">WhirlpoolAccountFetchOptions</a> object to define fetch and cache options when accessing on-chain 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#DecimalsMap" class="tsd-signature-type" data-tsd-kind="Type alias">DecimalsMap</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A <a href="../modules.html#DecimalsMap">DecimalsMap</a> of mint addresses to decimals.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="fetchPoolDataFromMints" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> fetch<wbr/>Pool<wbr/>Data<wbr/>From<wbr/>Mints<a href="#fetchPoolDataFromMints" 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">fetch<wbr/>Pool<wbr/>Data<wbr/>From<wbr/>Mints<span class="tsd-signature-symbol">(</span>fetcher<span class="tsd-signature-symbol">: </span><a href="../interfaces/WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a>, mints<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span>, config<span class="tsd-signature-symbol">?: </span><a href="../modules.html#GetPricesConfig" class="tsd-signature-type" data-tsd-kind="Type alias">GetPricesConfig</a>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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#PoolMap" class="tsd-signature-type" data-tsd-kind="Type alias">PoolMap</a><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/3dc98d0/sdk/src/prices/price-module.ts#L240">prices/price-module.ts:240</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetch pool data for the given mints by deriving the PDA from all combinations of mints &amp; tick-arrays.
Note that this method can be slow.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fetcher: <a href="../interfaces/WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="../interfaces/WhirlpoolAccountFetcherInterface.html">WhirlpoolAccountFetcherInterface</a></p>
</div></div></li><li><h5>mints: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The mints to fetch pool data for.</p>
</div></div></li><li><h5>config: <a href="../modules.html#GetPricesConfig" class="tsd-signature-type" data-tsd-kind="Type alias">GetPricesConfig</a><span class="tsd-signature-symbol"> = defaultGetPricesConfig</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The configuration for the price calculation.</p>
</div></div></li><li><h5>opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span><span class="tsd-signature-symbol"> = IGNORE_CACHE</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an <a href="../modules.html#WhirlpoolAccountFetchOptions">WhirlpoolAccountFetchOptions</a> object to define fetch and cache options when accessing on-chain 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#PoolMap" class="tsd-signature-type" data-tsd-kind="Type alias">PoolMap</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A <a href="../modules.html#PoolMap">PoolMap</a> of pool addresses to pool data.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="fetchTickArraysForPools" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> fetch<wbr/>Tick<wbr/>Arrays<wbr/>For<wbr/>Pools<a href="#fetchTickArraysForPools" 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">fetch<wbr/>Tick<wbr/>Arrays<wbr/>For<wbr/>Pools<span class="tsd-signature-symbol">(</span>fetcher<span class="tsd-signature-symbol">: </span><a href="../interfaces/WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a>, pools<span class="tsd-signature-symbol">: </span><a href="../modules.html#PoolMap" class="tsd-signature-type" data-tsd-kind="Type alias">PoolMap</a>, config<span class="tsd-signature-symbol">?: </span><a href="../modules.html#GetPricesConfig" class="tsd-signature-type" data-tsd-kind="Type alias">GetPricesConfig</a>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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#TickArrayMap" class="tsd-signature-type" data-tsd-kind="Type alias">TickArrayMap</a><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/3dc98d0/sdk/src/prices/price-module.ts#L281">prices/price-module.ts:281</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetch tick-array data for the given pools</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fetcher: <a href="../interfaces/WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="../interfaces/WhirlpoolAccountFetcherInterface.html">WhirlpoolAccountFetcherInterface</a></p>
</div></div></li><li><h5>pools: <a href="../modules.html#PoolMap" class="tsd-signature-type" data-tsd-kind="Type alias">PoolMap</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The pools to fetch tick-array data for.</p>
</div></div></li><li><h5>config: <a href="../modules.html#GetPricesConfig" class="tsd-signature-type" data-tsd-kind="Type alias">GetPricesConfig</a><span class="tsd-signature-symbol"> = defaultGetPricesConfig</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The configuration for the price calculation.</p>
</div></div></li><li><h5>opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span><span class="tsd-signature-symbol"> = IGNORE_CACHE</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an <a href="../modules.html#WhirlpoolAccountFetchOptions">WhirlpoolAccountFetchOptions</a> object to define fetch and cache options when accessing on-chain 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#TickArrayMap" class="tsd-signature-type" data-tsd-kind="Type alias">TickArrayMap</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A <a href="../modules.html#TickArrayMap">TickArrayMap</a> of tick-array addresses to tick-array data.</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="PriceModuleUtils.html" class="tsd-kind-icon">Price<wbr/>Module<wbr/>Utils</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="PriceModuleUtils.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PriceModuleUtils.html#fetchDecimalsForMints" class="tsd-kind-icon">fetch<wbr/>Decimals<wbr/>For<wbr/>Mints</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PriceModuleUtils.html#fetchPoolDataFromMints" class="tsd-kind-icon">fetch<wbr/>Pool<wbr/>Data<wbr/>From<wbr/>Mints</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="PriceModuleUtils.html#fetchTickArraysForPools" class="tsd-kind-icon">fetch<wbr/>Tick<wbr/>Arrays<wbr/>For<wbr/>Pools</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>

View File

@ -1,32 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>RouterUtils | @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="RouterUtils.html">RouterUtils</a></li></ul><h1>Class RouterUtils </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>A selection of utility functions for the <a href="../interfaces/WhirlpoolRouter.html">WhirlpoolRouter</a>.</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">RouterUtils</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>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="RouterUtils.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#getDefaultRouteOptions" class="tsd-kind-icon">get<wbr/>Default<wbr/>Route<wbr/>Options</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#getDefaultSelectOptions" class="tsd-kind-icon">get<wbr/>Default<wbr/>Select<wbr/>Options</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#getPriceImpactForRoute" class="tsd-kind-icon">get<wbr/>Price<wbr/>Impact<wbr/>For<wbr/>Route</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#getTouchedTickArraysFromRoute" class="tsd-kind-icon">get<wbr/>Touched<wbr/>Tick<wbr/>Arrays<wbr/>From<wbr/>Route</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#selectFirstExecutableRoute" class="tsd-kind-icon">select<wbr/>First<wbr/>Executable<wbr/>Route</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</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/>Router<wbr/>Utils<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="RouterUtils.html" class="tsd-signature-type" data-tsd-kind="Class">RouterUtils</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="RouterUtils.html" class="tsd-signature-type" data-tsd-kind="Class">RouterUtils</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getDefaultRouteOptions" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Default<wbr/>Route<wbr/>Options<a href="#getDefaultRouteOptions" 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/>Route<wbr/>Options<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#RoutingOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RoutingOptions</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/3dc98d0/sdk/src/router/public/router-utils.ts#L220">router/public/router-utils.ts:220</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the default options for generating trade routes.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#RoutingOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RoutingOptions</a></h4><div><p>Default options for generating trade routes.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getDefaultSelectOptions" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Default<wbr/>Select<wbr/>Options<a href="#getDefaultSelectOptions" 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/>Select<wbr/>Options<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#RouteSelectOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RouteSelectOptions</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/3dc98d0/sdk/src/router/public/router-utils.ts#L233">router/public/router-utils.ts:233</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the default options for selecting a route from a list of generated routes.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#RouteSelectOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RouteSelectOptions</a></h4><div><p>Default options for selecting a a route from a list of generated routes.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getPriceImpactForRoute" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Price<wbr/>Impact<wbr/>For<wbr/>Route<a href="#getPriceImpactForRoute" 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/>Price<wbr/>Impact<wbr/>For<wbr/>Route<span class="tsd-signature-symbol">(</span>trade<span class="tsd-signature-symbol">: </span><a href="../modules.html#Trade" class="tsd-signature-type" data-tsd-kind="Type alias">Trade</a>, route<span class="tsd-signature-symbol">: </span><a href="../modules.html#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Decimal</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/3dc98d0/sdk/src/router/public/router-utils.ts#L149">router/public/router-utils.ts:149</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Calculate the price impact for a route.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>trade: <a href="../modules.html#Trade" class="tsd-signature-type" data-tsd-kind="Type alias">Trade</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The trade the user used to derive the route.</p>
</div></div></li><li><h5>route: <a href="../modules.html#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The route to calculate the price impact for.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Decimal</span></h4><div><p>A Decimal object representing the percentage value of the price impact (ex. 3.01%)</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="getTouchedTickArraysFromRoute" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Touched<wbr/>Tick<wbr/>Arrays<wbr/>From<wbr/>Route<a href="#getTouchedTickArraysFromRoute" 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/>Touched<wbr/>Tick<wbr/>Arrays<wbr/>From<wbr/>Route<span class="tsd-signature-symbol">(</span>route<span class="tsd-signature-symbol">: </span><a href="../modules.html#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a><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/3dc98d0/sdk/src/router/public/router-utils.ts#L202">router/public/router-utils.ts:202</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the tick arrays addresses that are touched by a route.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>route: <a href="../modules.html#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The route to get the tick arrays from.</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>The tick arrays addresses that are touched by the route.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="selectFirstExecutableRoute" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> select<wbr/>First<wbr/>Executable<wbr/>Route<a href="#selectFirstExecutableRoute" 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">select<wbr/>First<wbr/>Executable<wbr/>Route<span class="tsd-signature-symbol">(</span>ctx<span class="tsd-signature-symbol">: </span><a href="WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</a>, orderedRoutes<span class="tsd-signature-symbol">: </span><a href="../modules.html#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a><span class="tsd-signature-symbol">[]</span>, opts<span class="tsd-signature-symbol">: </span><a href="../modules.html#RouteSelectOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RouteSelectOptions</a><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><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="../modules.html#ExecutableRoute" class="tsd-signature-type" data-tsd-kind="Type alias">ExecutableRoute</a><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/3dc98d0/sdk/src/router/public/router-utils.ts#L63">router/public/router-utils.ts:63</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Selects the best executable route from a list of routes using the current execution environment.
The wallet support type, available ATA accounts, existance of lookup tables all effect the transaction size
and eligibility of a route.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><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>The <a href="WhirlpoolContext.html">WhirlpoolContext</a> that represents the current execution environment</p>
</div></div></li><li><h5>orderedRoutes: <a href="../modules.html#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A list of routes to select from, ordered by the best routes (trade amount wise) first.</p>
</div></div></li><li><h5>opts: <a href="../modules.html#RouteSelectOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RouteSelectOptions</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="../modules.html#RouteSelectOptions">RouteSelectOptions</a> to configure the selection of the best route.</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><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="../modules.html#ExecutableRoute" class="tsd-signature-type" data-tsd-kind="Type alias">ExecutableRoute</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>The best <a href="../modules.html#ExecutableRoute">ExecutableRoute</a> that can be used to execute a swap. If no executable route is found, null is returned.</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="RouterUtils.html" class="tsd-kind-icon">Router<wbr/>Utils</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="RouterUtils.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#getDefaultRouteOptions" class="tsd-kind-icon">get<wbr/>Default<wbr/>Route<wbr/>Options</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#getDefaultSelectOptions" class="tsd-kind-icon">get<wbr/>Default<wbr/>Select<wbr/>Options</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#getPriceImpactForRoute" class="tsd-kind-icon">get<wbr/>Price<wbr/>Impact<wbr/>For<wbr/>Route</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#getTouchedTickArraysFromRoute" class="tsd-kind-icon">get<wbr/>Touched<wbr/>Tick<wbr/>Arrays<wbr/>From<wbr/>Route</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="RouterUtils.html#selectFirstExecutableRoute" class="tsd-kind-icon">select<wbr/>First<wbr/>Executable<wbr/>Route</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>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,17 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>WhirlpoolRouterBuilder | @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="WhirlpoolRouterBuilder.html">WhirlpoolRouterBuilder</a></li></ul><h1>Class WhirlpoolRouterBuilder </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>Builder to build instances of the <a href="../interfaces/WhirlpoolRouter.html">WhirlpoolRouter</a></p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">WhirlpoolRouterBuilder</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>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="WhirlpoolRouterBuilder.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="WhirlpoolRouterBuilder.html#buildWithPoolGraph" class="tsd-kind-icon">build<wbr/>With<wbr/>Pool<wbr/>Graph</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="WhirlpoolRouterBuilder.html#buildWithPools" class="tsd-kind-icon">build<wbr/>With<wbr/>Pools</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</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/>Whirlpool<wbr/>Router<wbr/>Builder<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="WhirlpoolRouterBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolRouterBuilder</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="WhirlpoolRouterBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolRouterBuilder</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="buildWithPoolGraph" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> build<wbr/>With<wbr/>Pool<wbr/>Graph<a href="#buildWithPoolGraph" 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">build<wbr/>With<wbr/>Pool<wbr/>Graph<span class="tsd-signature-symbol">(</span>ctx<span class="tsd-signature-symbol">: </span><a href="WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</a>, graph<span class="tsd-signature-symbol">: </span><a href="../modules.html#PoolGraph" class="tsd-signature-type" data-tsd-kind="Type alias">PoolGraph</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/WhirlpoolRouter.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolRouter</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/3dc98d0/sdk/src/router/public/router-builder.ts#L19">router/public/router-builder.ts:19</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Builds a <a href="../interfaces/WhirlpoolRouter.html">WhirlpoolRouter</a> with a prebuilt <a href="../modules.html#PoolGraph">PoolGraph</a></p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><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 <a href="WhirlpoolContext.html">WhirlpoolContext</a> for the current execution environment</p>
</div></div></li><li><h5>graph: <a href="../modules.html#PoolGraph" class="tsd-signature-type" data-tsd-kind="Type alias">PoolGraph</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A <a href="../modules.html#PoolGraph">PoolGraph</a> that represents the connections between all pools.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../interfaces/WhirlpoolRouter.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolRouter</a></h4><div><p>A <a href="../interfaces/WhirlpoolRouter.html">WhirlpoolRouter</a> that can be used to find routes and execute swaps</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"><a id="buildWithPools" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> build<wbr/>With<wbr/>Pools<a href="#buildWithPools" 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">build<wbr/>With<wbr/>Pools<span class="tsd-signature-symbol">(</span>ctx<span class="tsd-signature-symbol">: </span><a href="WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</a>, pools<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><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="../interfaces/WhirlpoolRouter.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolRouter</a><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/3dc98d0/sdk/src/router/public/router-builder.ts#L29">router/public/router-builder.ts:29</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetch and builds a <a href="../interfaces/WhirlpoolRouter.html">WhirlpoolRouter</a> with a list of pool addresses.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><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 <a href="WhirlpoolContext.html">WhirlpoolContext</a> for the current execution environment</p>
</div></div></li><li><h5>pools: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A list of {@link Address}es that the router will find routes through.</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="../interfaces/WhirlpoolRouter.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolRouter</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A <a href="../interfaces/WhirlpoolRouter.html">WhirlpoolRouter</a> that can be used to find routes and execute swaps</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="WhirlpoolRouterBuilder.html" class="tsd-kind-icon">Whirlpool<wbr/>Router<wbr/>Builder</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="WhirlpoolRouterBuilder.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="WhirlpoolRouterBuilder.html#buildWithPoolGraph" class="tsd-kind-icon">build<wbr/>With<wbr/>Pool<wbr/>Graph</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="WhirlpoolRouterBuilder.html#buildWithPools" class="tsd-kind-icon">build<wbr/>With<wbr/>Pools</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>

File diff suppressed because one or more lines are too long

View File

@ -1,3 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>SwapDirection | @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="SwapDirection.html">SwapDirection</a></li></ul><h1>Enumeration SwapDirection </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>An enum for the direction of a swap.</p>
</div></div></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>Enumeration Members</h3><ul class="tsd-index-list"><li class="tsd-kind-enum-member tsd-parent-kind-enum"><a href="SwapDirection.html#AtoB" class="tsd-kind-icon">AtoB</a></li><li class="tsd-kind-enum-member tsd-parent-kind-enum"><a href="SwapDirection.html#BtoA" class="tsd-kind-icon">BtoA</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Enumeration Members</h2><section class="tsd-panel tsd-member tsd-kind-enum-member tsd-parent-kind-enum"><a id="AtoB" class="tsd-anchor"></a><h3 class="tsd-anchor-link">AtoB<a href="#AtoB" 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><div class="tsd-signature tsd-kind-icon">AtoB<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;aToB&quot;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/3dc98d0/sdk/src/utils/public/types.ts#L6">utils/public/types.ts:6</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-kind-enum-member tsd-parent-kind-enum"><a id="BtoA" class="tsd-anchor"></a><h3 class="tsd-anchor-link">BtoA<a href="#BtoA" 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><div class="tsd-signature tsd-kind-icon">BtoA<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;bToA&quot;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/3dc98d0/sdk/src/utils/public/types.ts#L7">utils/public/types.ts:7</a></li></ul></aside></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-enum"><a href="SwapDirection.html" class="tsd-kind-icon">Swap<wbr/>Direction</a><ul><li class="tsd-kind-enum-member tsd-parent-kind-enum"><a href="SwapDirection.html#AtoB" class="tsd-kind-icon">AtoB</a></li><li class="tsd-kind-enum-member tsd-parent-kind-enum"><a href="SwapDirection.html#BtoA" class="tsd-kind-icon">BtoA</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>

View File

@ -1,3 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>TokenType | @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="TokenType.html">TokenType</a></li></ul><h1>Enumeration TokenType </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>An enum for the token type in a Whirlpool.</p>
</div></div></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>Enumeration Members</h3><ul class="tsd-index-list"><li class="tsd-kind-enum-member tsd-parent-kind-enum"><a href="TokenType.html#TokenA" class="tsd-kind-icon">TokenA</a></li><li class="tsd-kind-enum-member tsd-parent-kind-enum"><a href="TokenType.html#TokenB" class="tsd-kind-icon">TokenB</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Enumeration Members</h2><section class="tsd-panel tsd-member tsd-kind-enum-member tsd-parent-kind-enum"><a id="TokenA" class="tsd-anchor"></a><h3 class="tsd-anchor-link">TokenA<a href="#TokenA" 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><div class="tsd-signature tsd-kind-icon">TokenA<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">1</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/3dc98d0/sdk/src/utils/public/types.ts#L15">utils/public/types.ts:15</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-kind-enum-member tsd-parent-kind-enum"><a id="TokenB" class="tsd-anchor"></a><h3 class="tsd-anchor-link">TokenB<a href="#TokenB" 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><div class="tsd-signature tsd-kind-icon">TokenB<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">2</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/orca-so/whirlpools/blob/3dc98d0/sdk/src/utils/public/types.ts#L16">utils/public/types.ts:16</a></li></ul></aside></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-enum"><a href="TokenType.html" class="tsd-kind-icon">Token<wbr/>Type</a><ul><li class="tsd-kind-enum-member tsd-parent-kind-enum"><a href="TokenType.html#TokenA" class="tsd-kind-icon">TokenA</a></li><li class="tsd-kind-enum-member tsd-parent-kind-enum"><a href="TokenType.html#TokenB" class="tsd-kind-icon">TokenB</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>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,84 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Position | @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="Position.html">Position</a></li></ul><h1>Interface Position </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>Helper class to interact with a Position account and build complex transactions.</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">Position</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>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#collectFees" class="tsd-kind-icon">collect<wbr/>Fees</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#collectRewards" class="tsd-kind-icon">collect<wbr/>Rewards</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#decreaseLiquidity" class="tsd-kind-icon">decrease<wbr/>Liquidity</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getAddress" class="tsd-kind-icon">get<wbr/>Address</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getData" class="tsd-kind-icon">get<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getLowerTickData" class="tsd-kind-icon">get<wbr/>Lower<wbr/>Tick<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getUpperTickData" class="tsd-kind-icon">get<wbr/>Upper<wbr/>Tick<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getWhirlpoolData" class="tsd-kind-icon">get<wbr/>Whirlpool<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#increaseLiquidity" class="tsd-kind-icon">increase<wbr/>Liquidity</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#refreshData" class="tsd-kind-icon">refresh<wbr/>Data</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="collectFees" class="tsd-anchor"></a><h3 class="tsd-anchor-link">collect<wbr/>Fees<a href="#collectFees" 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-interface"><li class="tsd-signature tsd-kind-icon">collect<wbr/>Fees<span class="tsd-signature-symbol">(</span>updateFeesAndRewards<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span>, ownerTokenAccountMap<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span>, destinationWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, positionWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, ataPayer<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L391">whirlpool-client.ts:391</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Collect fees from this position</p>
</div><div><p>If <code>positionWallet</code> is provided, the wallet owners have to sign this transaction.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> updateFeesAndRewards: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>if true, add instructions to refresh the accumulated fees and rewards data (default to true unless you know that the collect fees quote and on-chain data match for the &quot;feeOwedA&quot; and &quot;feeOwedB&quot; fields in the Position account)</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> ownerTokenAccountMap: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A record that maps a given mint to the owner&#39;s token account for that mint (if an entry doesn&#39;t exist, it will be automatically resolved)</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> destinationWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to deposit tokens into when withdrawing from the position. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> positionWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> ataPayer: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>wallet that will fund the creation of the new associated token accounts</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an options object to define fetch and cache options when accessing on-chain 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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>the transaction that will collect fees from the position</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="collectRewards" class="tsd-anchor"></a><h3 class="tsd-anchor-link">collect<wbr/>Rewards<a href="#collectRewards" 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-interface"><li class="tsd-signature tsd-kind-icon">collect<wbr/>Rewards<span class="tsd-signature-symbol">(</span>rewardsToCollect<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span>, updateFeesAndRewards<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span>, ownerTokenAccountMap<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span>, destinationWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, positionWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, ataPayer<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L414">whirlpool-client.ts:414</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Collect rewards from this position</p>
</div><div><p>If <code>positionWallet</code> is provided, the wallet owners have to sign this transaction.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> rewardsToCollect: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>reward mints to collect (omitting this parameter means all rewards will be collected)</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> updateFeesAndRewards: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>if true, add instructions to refresh the accumulated fees and rewards data (default to true unless you know that the collect fees quote and on-chain data match for the &quot;feeOwedA&quot; and &quot;feeOwedB&quot; fields in the Position account)</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> ownerTokenAccountMap: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A record that maps a given mint to the owner&#39;s token account for that mint (if an entry doesn&#39;t exist, it will be automatically resolved)</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> destinationWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to deposit tokens into when withdrawing from the position. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> positionWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> ataPayer: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>wallet that will fund the creation of the new associated token accounts</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an options object to define fetch and cache options when accessing on-chain 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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>the transaction that will collect fees from the position</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="decreaseLiquidity" class="tsd-anchor"></a><h3 class="tsd-anchor-link">decrease<wbr/>Liquidity<a href="#decreaseLiquidity" 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-interface"><li class="tsd-signature tsd-kind-icon">decrease<wbr/>Liquidity<span class="tsd-signature-symbol">(</span>liquidityInput<span class="tsd-signature-symbol">: </span><a href="../modules.html#DecreaseLiquidityInput" class="tsd-signature-type" data-tsd-kind="Type alias">DecreaseLiquidityInput</a>, resolveATA<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span>, destinationWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, positionWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, ataPayer<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</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><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L370">whirlpool-client.ts:370</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Withdraw liquidity from this position.</p>
</div><div><p>If <code>positionWallet</code> is provided, the wallet owners have to sign this transaction.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>liquidityInput: <a href="../modules.html#DecreaseLiquidityInput" class="tsd-signature-type" data-tsd-kind="Type alias">DecreaseLiquidityInput</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>input that defines the desired liquidity amount and minimum tokens willing to be to withdrawn from the position.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> resolveATA: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>if true, add instructions to create associated token accounts for tokenA,B for the destinationWallet if necessary. (RPC call required)</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> destinationWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to deposit tokens into when withdrawing from the position. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> positionWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> ataPayer: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>wallet that will fund the creation of the new associated token 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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>the transaction that will deposit the tokens into the position when executed.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getAddress" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Address<a href="#getAddress" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Address<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</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/3dc98d0/sdk/src/whirlpool-client.ts#L306">whirlpool-client.ts:306</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Return the address for this Whirlpool instance.</p>
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">PublicKey</span></h4><div><p>the PublicKey for this Whirlpool instance.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getData" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Data<a href="#getData" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Data<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#PositionData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionData</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/3dc98d0/sdk/src/whirlpool-client.ts#L312">whirlpool-client.ts:312</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Return the most recently fetched Position account data.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#PositionData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionData</a></h4><div><p>most recently fetched PositionData for this address.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getLowerTickData" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Lower<wbr/>Tick<wbr/>Data<a href="#getLowerTickData" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Lower<wbr/>Tick<wbr/>Data<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#TickData" class="tsd-signature-type" data-tsd-kind="Type alias">TickData</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/3dc98d0/sdk/src/whirlpool-client.ts#L324">whirlpool-client.ts:324</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Return the most recently fetched TickData account data for this position&#39;s lower tick.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#TickData" class="tsd-signature-type" data-tsd-kind="Type alias">TickData</a></h4><div><p>most recently fetched TickData for this position&#39;s lower tick.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getUpperTickData" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Upper<wbr/>Tick<wbr/>Data<a href="#getUpperTickData" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Upper<wbr/>Tick<wbr/>Data<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#TickData" class="tsd-signature-type" data-tsd-kind="Type alias">TickData</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/3dc98d0/sdk/src/whirlpool-client.ts#L330">whirlpool-client.ts:330</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Return the most recently fetched TickData account data for this position&#39;s upper tick.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#TickData" class="tsd-signature-type" data-tsd-kind="Type alias">TickData</a></h4><div><p>most recently fetched TickData for this position&#39;s upper tick.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getWhirlpoolData" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Whirlpool<wbr/>Data<a href="#getWhirlpoolData" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Whirlpool<wbr/>Data<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#WhirlpoolData" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolData</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/3dc98d0/sdk/src/whirlpool-client.ts#L318">whirlpool-client.ts:318</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Return the most recently fetched Whirlpool account data for this position.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#WhirlpoolData" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolData</a></h4><div><p>most recently fetched WhirlpoolData for this position.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="increaseLiquidity" class="tsd-anchor"></a><h3 class="tsd-anchor-link">increase<wbr/>Liquidity<a href="#increaseLiquidity" 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-interface"><li class="tsd-signature tsd-kind-icon">increase<wbr/>Liquidity<span class="tsd-signature-symbol">(</span>liquidityInput<span class="tsd-signature-symbol">: </span><a href="../modules.html#IncreaseLiquidityInput" class="tsd-signature-type" data-tsd-kind="Type alias">IncreaseLiquidityInput</a>, resolveATA<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span>, wallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, positionWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, ataPayer<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</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><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L350">whirlpool-client.ts:350</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Deposit additional tokens into this postiion.
The wallet must contain the position token and the necessary token A &amp; B to complete the deposit.
If <code>positionWallet</code> and <code>wallet</code> is provided, the wallet owners have to sign this transaction.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>liquidityInput: <a href="../modules.html#IncreaseLiquidityInput" class="tsd-signature-type" data-tsd-kind="Type alias">IncreaseLiquidityInput</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>input that defines the desired liquidity amount and maximum tokens willing to be to deposited.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> resolveATA: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>if true, add instructions to create associated token accounts for tokenA,B for the destinationWallet if necessary. (RPC call required)</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> wallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>to withdraw tokens to deposit into the position. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> positionWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> ataPayer: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>wallet that will fund the creation of the new associated token 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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>the transaction that will deposit the tokens into the position when executed.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="refreshData" class="tsd-anchor"></a><h3 class="tsd-anchor-link">refresh<wbr/>Data<a href="#refreshData" 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-interface"><li class="tsd-signature tsd-kind-icon">refresh<wbr/>Data<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#PositionData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionData</a><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/3dc98d0/sdk/src/whirlpool-client.ts#L336">whirlpool-client.ts:336</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetch and return the most recently fetched Position account data.</p>
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#PositionData" class="tsd-signature-type" data-tsd-kind="Type alias">PositionData</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>the most up to date PositionData for this address.</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-interface"><a href="Position.html" class="tsd-kind-icon">Position</a><ul><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#collectFees" class="tsd-kind-icon">collect<wbr/>Fees</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#collectRewards" class="tsd-kind-icon">collect<wbr/>Rewards</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#decreaseLiquidity" class="tsd-kind-icon">decrease<wbr/>Liquidity</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getAddress" class="tsd-kind-icon">get<wbr/>Address</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getData" class="tsd-kind-icon">get<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getLowerTickData" class="tsd-kind-icon">get<wbr/>Lower<wbr/>Tick<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getUpperTickData" class="tsd-kind-icon">get<wbr/>Upper<wbr/>Tick<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#getWhirlpoolData" class="tsd-kind-icon">get<wbr/>Whirlpool<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#increaseLiquidity" class="tsd-kind-icon">increase<wbr/>Liquidity</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Position.html#refreshData" class="tsd-kind-icon">refresh<wbr/>Data</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>

File diff suppressed because one or more lines are too long

View File

@ -1,103 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Whirlpool | @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="Whirlpool.html">Whirlpool</a></li></ul><h1>Interface Whirlpool </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>Helper class to interact with a Whirlpool account and build complex transactions.</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">Whirlpool</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>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#closePosition" class="tsd-kind-icon">close<wbr/>Position</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getAddress" class="tsd-kind-icon">get<wbr/>Address</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getData" class="tsd-kind-icon">get<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getRewardInfos" class="tsd-kind-icon">get<wbr/>Reward<wbr/>Infos</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getTokenAInfo" class="tsd-kind-icon">get<wbr/>TokenAInfo</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getTokenBInfo" class="tsd-kind-icon">get<wbr/>TokenBInfo</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getTokenVaultAInfo" class="tsd-kind-icon">get<wbr/>Token<wbr/>VaultAInfo</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getTokenVaultBInfo" class="tsd-kind-icon">get<wbr/>Token<wbr/>VaultBInfo</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#initTickArrayForTicks" class="tsd-kind-icon">init<wbr/>Tick<wbr/>Array<wbr/>For<wbr/>Ticks</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#openPosition" class="tsd-kind-icon">open<wbr/>Position</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#openPositionWithMetadata" class="tsd-kind-icon">open<wbr/>Position<wbr/>With<wbr/>Metadata</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#refreshData" class="tsd-kind-icon">refresh<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#swap" class="tsd-kind-icon">swap</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#swapWithDevFees" class="tsd-kind-icon">swap<wbr/>With<wbr/>Dev<wbr/>Fees</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="closePosition" class="tsd-anchor"></a><h3 class="tsd-anchor-link">close<wbr/>Position<a href="#closePosition" 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-interface"><li class="tsd-signature tsd-kind-icon">close<wbr/>Position<span class="tsd-signature-symbol">(</span>positionAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, slippageTolerance<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Percentage</span>, destinationWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, positionWallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, payer<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</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><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L263">whirlpool-client.ts:263</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Withdraw all tokens from a position, close the account and burn the position token.</p>
</div><div><p>Users have to collect all fees and rewards from this position prior to closing the account.</p>
<p>If <code>positionWallet</code>, <code>payer</code> is provided, the wallet owner has to sign this transaction.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionAddress: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The address of the position account.</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 the caller is willing to accept when withdrawing liquidity.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> destinationWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The wallet that the tokens withdrawn and rent lamports will be sent to. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> positionWallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The wallet that houses the position token that corresponds to this position address. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> payer: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet that will fund the cost needed to initialize the token ATA accounts. If null, the WhirlpoolContext wallet is used.</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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getAddress" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Address<a href="#getAddress" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Address<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</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/3dc98d0/sdk/src/whirlpool-client.ts#L142">whirlpool-client.ts:142</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Return the address for this Whirlpool instance.</p>
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">PublicKey</span></h4><div><p>the PublicKey for this Whirlpool instance.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getData" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Data<a href="#getData" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Data<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#WhirlpoolData" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolData</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/3dc98d0/sdk/src/whirlpool-client.ts#L148">whirlpool-client.ts:148</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Return the most recently fetched Whirlpool account data.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#WhirlpoolData" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolData</a></h4><div><p>most recently fetched WhirlpoolData for this address.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getRewardInfos" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Reward<wbr/>Infos<a href="#getRewardInfos" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Reward<wbr/>Infos<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#WhirlpoolRewardInfo" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolRewardInfo</a><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/3dc98d0/sdk/src/whirlpool-client.ts#L184">whirlpool-client.ts:184</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the WhirlpoolRewardInfos for this pool.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#WhirlpoolRewardInfo" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolRewardInfo</a><span class="tsd-signature-symbol">[]</span></h4><div><p>Array of 3 WhirlpoolRewardInfos. However, not all of them may be initialized. Use the initialized field on WhirlpoolRewardInfo to check if the reward is active.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getTokenAInfo" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>TokenAInfo<a href="#getTokenAInfo" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>TokenAInfo<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#TokenInfo" class="tsd-signature-type" data-tsd-kind="Type alias">TokenInfo</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/3dc98d0/sdk/src/whirlpool-client.ts#L160">whirlpool-client.ts:160</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the TokenInfo for token A of this pool.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#TokenInfo" class="tsd-signature-type" data-tsd-kind="Type alias">TokenInfo</a></h4><div><p>TokenInfo for token A</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getTokenBInfo" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>TokenBInfo<a href="#getTokenBInfo" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>TokenBInfo<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules.html#TokenInfo" class="tsd-signature-type" data-tsd-kind="Type alias">TokenInfo</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/3dc98d0/sdk/src/whirlpool-client.ts#L166">whirlpool-client.ts:166</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the TokenInfo for token B of this pool.</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../modules.html#TokenInfo" class="tsd-signature-type" data-tsd-kind="Type alias">TokenInfo</a></h4><div><p>TokenInfo for token B</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getTokenVaultAInfo" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Token<wbr/>VaultAInfo<a href="#getTokenVaultAInfo" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Token<wbr/>VaultAInfo<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Account</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/3dc98d0/sdk/src/whirlpool-client.ts#L172">whirlpool-client.ts:172</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the TokenAccountInfo for token vault A of this pool.</p>
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Account</span></h4><div><p>TokenAccountInfo for token vault A</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getTokenVaultBInfo" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Token<wbr/>VaultBInfo<a href="#getTokenVaultBInfo" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Token<wbr/>VaultBInfo<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Account</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/3dc98d0/sdk/src/whirlpool-client.ts#L178">whirlpool-client.ts:178</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get the TokenAccountInfo for token vault B of this pool.</p>
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Account</span></h4><div><p>TokenAccountInfo for token vault B</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="initTickArrayForTicks" class="tsd-anchor"></a><h3 class="tsd-anchor-link">init<wbr/>Tick<wbr/>Array<wbr/>For<wbr/>Ticks<a href="#initTickArrayForTicks" 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-interface"><li class="tsd-signature tsd-kind-icon">init<wbr/>Tick<wbr/>Array<wbr/>For<wbr/>Ticks<span class="tsd-signature-symbol">(</span>ticks<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span>, funder<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L196">whirlpool-client.ts:196</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Initialize a set of tick-arrays that encompasses the provided ticks.</p>
</div><div><p>If <code>funder</code> is provided, the funder wallet has to sign this transaction.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>ticks: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A group of ticks that define the desired tick-arrays to initialize. If the tick&#39;s array has been initialized, it will be ignored.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> funder: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet that will fund the cost needed to initialize the position. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an <a href="../modules.html#WhirlpoolAccountFetchOptions">WhirlpoolAccountFetchOptions</a> object to define fetch and cache options when accessing on-chain 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><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>a transaction that will initialize the defined tick-arrays if executed. Return null if all of the tick&#39;s arrays are initialized.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="openPosition" class="tsd-anchor"></a><h3 class="tsd-anchor-link">open<wbr/>Position<a href="#openPosition" 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-interface"><li class="tsd-signature tsd-kind-icon">open<wbr/>Position<span class="tsd-signature-symbol">(</span>tickLower<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, tickUpper<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, liquidityInput<span class="tsd-signature-symbol">: </span><a href="../modules.html#IncreaseLiquidityInput" class="tsd-signature-type" data-tsd-kind="Type alias">IncreaseLiquidityInput</a>, wallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, funder<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, positionMint<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">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-symbol">{ </span>positionMint<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">; </span>tx<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L217">whirlpool-client.ts:217</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Open and fund a position on this Whirlpool.</p>
</div><div><p>User has to ensure the TickArray for tickLower and tickUpper has been initialized prior to calling this function.</p>
<p>If <code>wallet</code> or <code>funder</code> is provided, those wallets have to sign this transaction.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>tickLower: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the tick index for the lower bound of this position</p>
</div></div></li><li><h5>tickUpper: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the tick index for the upper bound of this position</p>
</div></div></li><li><h5>liquidityInput: <a href="../modules.html#IncreaseLiquidityInput" class="tsd-signature-type" data-tsd-kind="Type alias">IncreaseLiquidityInput</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an InputLiquidityInput type to define the desired liquidity amount to deposit</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> wallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to withdraw tokens to deposit into the position and house the position token. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> funder: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet that will fund the cost needed to initialize the position. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> positionMint: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the mint address of the position token to be created. If null, a new mint address will be created.</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><span class="tsd-signature-symbol">{ </span>positionMint<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">; </span>tx<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p><code>positionMint</code> - the position to be created. <code>tx</code> - The transaction containing the instructions to perform the operation on chain.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="openPositionWithMetadata" class="tsd-anchor"></a><h3 class="tsd-anchor-link">open<wbr/>Position<wbr/>With<wbr/>Metadata<a href="#openPositionWithMetadata" 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-interface"><li class="tsd-signature tsd-kind-icon">open<wbr/>Position<wbr/>With<wbr/>Metadata<span class="tsd-signature-symbol">(</span>tickLower<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, tickUpper<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, liquidityInput<span class="tsd-signature-symbol">: </span><a href="../modules.html#IncreaseLiquidityInput" class="tsd-signature-type" data-tsd-kind="Type alias">IncreaseLiquidityInput</a>, wallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, funder<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Address</span>, positionMint<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">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-symbol">{ </span>positionMint<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">; </span>tx<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L241">whirlpool-client.ts:241</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Open and fund a position with meta-data on this Whirlpool.</p>
</div><div><p>User has to ensure the TickArray for tickLower and tickUpper has been initialized prior to calling this function.</p>
<p>If <code>wallet</code> or <code>funder</code> is provided, the wallet owners have to sign this transaction.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>tickLower: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the tick index for the lower bound of this position</p>
</div></div></li><li><h5>tickUpper: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the tick index for the upper bound of this position</p>
</div></div></li><li><h5>liquidityInput: <a href="../modules.html#IncreaseLiquidityInput" class="tsd-signature-type" data-tsd-kind="Type alias">IncreaseLiquidityInput</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>input that defines the desired liquidity amount and maximum tokens willing to be to deposited.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> wallet: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet to withdraw tokens to deposit into the position and house the position token. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> funder: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the wallet that will fund the cost needed to initialize the position. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> positionMint: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the mint address of the position token to be created. If null, a new mint address will be created.</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><span class="tsd-signature-symbol">{ </span>positionMint<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">; </span>tx<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p><code>positionMint</code> - the position to be created. <code>tx</code> - The transaction containing the instructions to perform the operation on chain.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="refreshData" class="tsd-anchor"></a><h3 class="tsd-anchor-link">refresh<wbr/>Data<a href="#refreshData" 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-interface"><li class="tsd-signature tsd-kind-icon">refresh<wbr/>Data<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#WhirlpoolData" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolData</a><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/3dc98d0/sdk/src/whirlpool-client.ts#L154">whirlpool-client.ts:154</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetch and return the most recently fetched Whirlpool account data.</p>
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#WhirlpoolData" class="tsd-signature-type" data-tsd-kind="Type alias">WhirlpoolData</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>the most up to date WhirlpoolData for this address.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="swap" class="tsd-anchor"></a><h3 class="tsd-anchor-link">swap<a href="#swap" 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-interface"><li class="tsd-signature tsd-kind-icon">swap<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><a href="../modules.html#SwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">SwapInput</a>, 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><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L278">whirlpool-client.ts:278</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Perform a swap between tokenA and tokenB on this pool.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <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 quote on the desired tokenIn and tokenOut for this swap. Use <a href="../modules.html#swapQuoteWithParams">swapQuoteWithParams</a> or other swap quote functions to generate this object.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> wallet: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The wallet that tokens will be withdrawn and deposit into. If null, the WhirlpoolContext wallet is used.</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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>a transaction that will perform the swap once executed.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="swapWithDevFees" class="tsd-anchor"></a><h3 class="tsd-anchor-link">swap<wbr/>With<wbr/>Dev<wbr/>Fees<a href="#swapWithDevFees" 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-interface"><li class="tsd-signature tsd-kind-icon">swap<wbr/>With<wbr/>Dev<wbr/>Fees<span class="tsd-signature-symbol">(</span>input<span class="tsd-signature-symbol">: </span><a href="../modules.html#DevFeeSwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">DevFeeSwapInput</a>, devFeeWallet<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span>, wallet<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">PublicKey</span>, payer<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">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L289">whirlpool-client.ts:289</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Collect a developer fee and perform a swap between tokenA and tokenB on this pool.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>input: <a href="../modules.html#DevFeeSwapInput" class="tsd-signature-type" data-tsd-kind="Type alias">DevFeeSwapInput</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A quote on the desired tokenIn and tokenOut for this swap. Use <a href="../modules.html#swapQuoteByInputTokenWithDevFees">swapQuoteByInputTokenWithDevFees</a> to generate this object.</p>
</div></div></li><li><h5>devFeeWallet: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The wallet that developer fees will be deposited into.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> wallet: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The wallet that swap tokens will be withdrawn and deposit into. If null, the WhirlpoolContext wallet is used.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> payer: <span class="tsd-signature-type">PublicKey</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The wallet that will fund the cost needed to initialize the dev wallet token ATA accounts. If null, the WhirlpoolContext wallet is used.</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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>a transaction that will perform the swap once executed.</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-interface"><a href="Whirlpool.html" class="tsd-kind-icon">Whirlpool</a><ul><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#closePosition" class="tsd-kind-icon">close<wbr/>Position</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getAddress" class="tsd-kind-icon">get<wbr/>Address</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getData" class="tsd-kind-icon">get<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getRewardInfos" class="tsd-kind-icon">get<wbr/>Reward<wbr/>Infos</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getTokenAInfo" class="tsd-kind-icon">get<wbr/>TokenAInfo</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getTokenBInfo" class="tsd-kind-icon">get<wbr/>TokenBInfo</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getTokenVaultAInfo" class="tsd-kind-icon">get<wbr/>Token<wbr/>VaultAInfo</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#getTokenVaultBInfo" class="tsd-kind-icon">get<wbr/>Token<wbr/>VaultBInfo</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#initTickArrayForTicks" class="tsd-kind-icon">init<wbr/>Tick<wbr/>Array<wbr/>For<wbr/>Ticks</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#openPosition" class="tsd-kind-icon">open<wbr/>Position</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#openPositionWithMetadata" class="tsd-kind-icon">open<wbr/>Position<wbr/>With<wbr/>Metadata</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#refreshData" class="tsd-kind-icon">refresh<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#swap" class="tsd-kind-icon">swap</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="Whirlpool.html#swapWithDevFees" class="tsd-kind-icon">swap<wbr/>With<wbr/>Dev<wbr/>Fees</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>

File diff suppressed because one or more lines are too long

View File

@ -1,65 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>WhirlpoolClient | @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="WhirlpoolClient.html">WhirlpoolClient</a></li></ul><h1>Interface WhirlpoolClient </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>Helper class to help interact with Whirlpool Accounts with a simpler interface.</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">WhirlpoolClient</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>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#collectFeesAndRewardsForPositions" class="tsd-kind-icon">collect<wbr/>Fees<wbr/>And<wbr/>Rewards<wbr/>For<wbr/>Positions</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#collectProtocolFeesForPools" class="tsd-kind-icon">collect<wbr/>Protocol<wbr/>Fees<wbr/>For<wbr/>Pools</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#createPool" class="tsd-kind-icon">create<wbr/>Pool</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getContext" class="tsd-kind-icon">get<wbr/>Context</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getFetcher" class="tsd-kind-icon">get<wbr/>Fetcher</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getPool" class="tsd-kind-icon">get<wbr/>Pool</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getPools" class="tsd-kind-icon">get<wbr/>Pools</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getPosition" class="tsd-kind-icon">get<wbr/>Position</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getPositions" class="tsd-kind-icon">get<wbr/>Positions</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getRouter" class="tsd-kind-icon">get<wbr/>Router</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="collectFeesAndRewardsForPositions" class="tsd-anchor"></a><h3 class="tsd-anchor-link">collect<wbr/>Fees<wbr/>And<wbr/>Rewards<wbr/>For<wbr/>Positions<a href="#collectFeesAndRewardsForPositions" 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-interface"><li class="tsd-signature tsd-kind-icon">collect<wbr/>Fees<wbr/>And<wbr/>Rewards<wbr/>For<wbr/>Positions<span class="tsd-signature-symbol">(</span>positionAddresses<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L89">whirlpool-client.ts:89</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Collect all fees and rewards from a list of positions.</p>
</div><dl class="tsd-comment-tags"><dt>experimental</dt><dd></dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionAddresses: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an options object to define fetch and cache options when accessing on-chain 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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A set of transaction-builders to resolve ATA for affliated tokens, collect fee &amp; rewards for all positions.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="collectProtocolFeesForPools" class="tsd-anchor"></a><h3 class="tsd-anchor-link">collect<wbr/>Protocol<wbr/>Fees<wbr/>For<wbr/>Pools<a href="#collectProtocolFeesForPools" 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-interface"><li class="tsd-signature tsd-kind-icon">collect<wbr/>Protocol<wbr/>Fees<wbr/>For<wbr/>Pools<span class="tsd-signature-symbol">(</span>poolAddresses<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><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><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L119">whirlpool-client.ts:119</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Collect protocol fees from a list of pools</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>poolAddresses: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the addresses of the Whirlpool accounts to collect protocol fees from</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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A transaction builder to resolve ATA for tokenA and tokenB if needed, and collect protocol fees for all pools</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="createPool" class="tsd-anchor"></a><h3 class="tsd-anchor-link">create<wbr/>Pool<a href="#createPool" 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-interface"><li class="tsd-signature tsd-kind-icon">create<wbr/>Pool<span class="tsd-signature-symbol">(</span>whirlpoolsConfig<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, tokenMintA<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, tokenMintB<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, tickSpacing<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, initialTick<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, funder<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</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><span class="tsd-signature-symbol">{ </span>poolKey<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">; </span>tx<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/whirlpool-client.ts#L105">whirlpool-client.ts:105</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Create a Whirlpool account for a group of token A, token B and tick spacing</p>
</div><dl class="tsd-comment-tags"><dt>throws</dt><dd><p>error when the tokens are not in the canonical byte-based ordering. To resolve this, invert the token order and the initialTick (see <code>TickUtil.invertTick()</code>, <code>PriceMath.invertSqrtPriceX64()</code>, or <code>PriceMath.invertPrice()</code>).</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>whirlpoolsConfig: <span class="tsd-signature-type">Address</span></h5></li><li><h5>tokenMintA: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the address of the token A</p>
</div></div></li><li><h5>tokenMintB: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the address of the token B</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 space between two ticks in the tick array</p>
</div></div></li><li><h5>initialTick: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the initial tick that the pool is set to (derived from initial price)</p>
</div></div></li><li><h5>funder: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the account to debit SOL from to fund the creation of the account(s)</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><span class="tsd-signature-symbol">{ </span>poolKey<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PublicKey</span><span class="tsd-signature-symbol">; </span>tx<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p><code>poolKey</code>: The public key of the newly created whirlpool account. <code>tx</code>: The transaction containing instructions for the on-chain operations.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getContext" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Context<a href="#getContext" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Context<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../classes/WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</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/3dc98d0/sdk/src/whirlpool-client.ts#L31">whirlpool-client.ts:31</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get this client&#39;s WhirlpoolContext object</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="../classes/WhirlpoolContext.html" class="tsd-signature-type" data-tsd-kind="Class">WhirlpoolContext</a></h4><div><p>a WhirlpoolContext object</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getFetcher" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Fetcher<a href="#getFetcher" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Fetcher<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</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/3dc98d0/sdk/src/whirlpool-client.ts#L37">whirlpool-client.ts:37</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get an WhirlpoolAccountCacheInterface to fetch and cache Whirlpool accounts</p>
</div></div><h4 class="tsd-returns-title">Returns <a href="WhirlpoolAccountFetcherInterface.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolAccountFetcherInterface</a></h4><div><p>an WhirlpoolAccountCacheInterface instance</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getPool" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Pool<a href="#getPool" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Pool<span class="tsd-signature-symbol">(</span>poolAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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="Whirlpool.html" class="tsd-signature-type" data-tsd-kind="Interface">Whirlpool</a><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/3dc98d0/sdk/src/whirlpool-client.ts#L52">whirlpool-client.ts:52</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get a Whirlpool object to interact with the Whirlpool account at the given address.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>poolAddress: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the address of the Whirlpool account</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an options object to define fetch and cache options when accessing on-chain 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="Whirlpool.html" class="tsd-signature-type" data-tsd-kind="Interface">Whirlpool</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>a Whirlpool object to interact with</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getPools" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Pools<a href="#getPools" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Pools<span class="tsd-signature-symbol">(</span>poolAddresses<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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="Whirlpool.html" class="tsd-signature-type" data-tsd-kind="Interface">Whirlpool</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/3dc98d0/sdk/src/whirlpool-client.ts#L60">whirlpool-client.ts:60</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get a list of Whirlpool objects matching the provided list of addresses.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>poolAddresses: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the addresses of the Whirlpool accounts</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an options object to define fetch and cache options when accessing on-chain 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="Whirlpool.html" class="tsd-signature-type" data-tsd-kind="Interface">Whirlpool</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>a list of Whirlpool objects to interact with</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getPosition" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Position<a href="#getPosition" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Position<span class="tsd-signature-symbol">(</span>positionAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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="Position.html" class="tsd-signature-type" data-tsd-kind="Interface">Position</a><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/3dc98d0/sdk/src/whirlpool-client.ts#L69">whirlpool-client.ts:69</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get a Position object to interact with the Position account at the given address.</p>
</div><dl class="tsd-comment-tags"><dt>throws</dt><dd><p>error when address does not return a Position account.</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionAddress: <span class="tsd-signature-type">Address</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the address of the Position account</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an options object to define fetch and cache options when accessing on-chain 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="Position.html" class="tsd-signature-type" data-tsd-kind="Interface">Position</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>a Position object to interact with.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getPositions" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Positions<a href="#getPositions" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Positions<span class="tsd-signature-symbol">(</span>positionAddresses<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Position.html" class="tsd-signature-type" data-tsd-kind="Interface">Position</a><span class="tsd-signature-symbol">&gt;</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/3dc98d0/sdk/src/whirlpool-client.ts#L77">whirlpool-client.ts:77</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get a list of Position objects to interact with the Position account at the given addresses.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>positionAddresses: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an options object to define fetch and cache options when accessing on-chain 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><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Position.html" class="tsd-signature-type" data-tsd-kind="Interface">Position</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>a Record object between account address and Position. If an address is not a Position account, it will be null.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getRouter" class="tsd-anchor"></a><h3 class="tsd-anchor-link">get<wbr/>Router<a href="#getRouter" 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-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Router<span class="tsd-signature-symbol">(</span>poolAddresses<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Address</span><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="WhirlpoolRouter.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolRouter</a><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/3dc98d0/sdk/src/whirlpool-client.ts#L44">whirlpool-client.ts:44</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Get a WhirlpoolRouter to help generate the best prices when transacting across a set of pools.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>poolAddresses: <span class="tsd-signature-type">Address</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>the addresses of the Whirlpool account addresses to route through</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="WhirlpoolRouter.html" class="tsd-signature-type" data-tsd-kind="Interface">WhirlpoolRouter</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>a <a href="WhirlpoolRouter.html">WhirlpoolRouter</a> instance</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-interface"><a href="WhirlpoolClient.html" class="tsd-kind-icon">Whirlpool<wbr/>Client</a><ul><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#collectFeesAndRewardsForPositions" class="tsd-kind-icon">collect<wbr/>Fees<wbr/>And<wbr/>Rewards<wbr/>For<wbr/>Positions</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#collectProtocolFeesForPools" class="tsd-kind-icon">collect<wbr/>Protocol<wbr/>Fees<wbr/>For<wbr/>Pools</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#createPool" class="tsd-kind-icon">create<wbr/>Pool</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getContext" class="tsd-kind-icon">get<wbr/>Context</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getFetcher" class="tsd-kind-icon">get<wbr/>Fetcher</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getPool" class="tsd-kind-icon">get<wbr/>Pool</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getPools" class="tsd-kind-icon">get<wbr/>Pools</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getPosition" class="tsd-kind-icon">get<wbr/>Position</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getPositions" class="tsd-kind-icon">get<wbr/>Positions</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolClient.html#getRouter" class="tsd-kind-icon">get<wbr/>Router</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>

View File

@ -1,40 +0,0 @@
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>WhirlpoolRouter | @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="WhirlpoolRouter.html">WhirlpoolRouter</a></li></ul><h1>Interface WhirlpoolRouter </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>Convienience class to find routes through a set of Whirlpools and execute a swap across them.
The router only supports up to 2-hop trades between pools and does not support arbitrage trades
between the same token.</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">WhirlpoolRouter</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>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolRouter.html#findAllRoutes" class="tsd-kind-icon">find<wbr/>All<wbr/>Routes</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolRouter.html#findBestRoute" class="tsd-kind-icon">find<wbr/>Best<wbr/>Route</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolRouter.html#swap" class="tsd-kind-icon">swap</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="findAllRoutes" class="tsd-anchor"></a><h3 class="tsd-anchor-link">find<wbr/>All<wbr/>Routes<a href="#findAllRoutes" 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-interface"><li class="tsd-signature tsd-kind-icon">find<wbr/>All<wbr/>Routes<span class="tsd-signature-symbol">(</span>trade<span class="tsd-signature-symbol">: </span><a href="../modules.html#Trade" class="tsd-signature-type" data-tsd-kind="Type alias">Trade</a>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#RoutingOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RoutingOptions</a><span class="tsd-signature-symbol">&gt;</span>, fetchOpts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</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/3dc98d0/sdk/src/router/public/index.ts#L152">router/public/index.ts:152</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Finds all possible routes for a trade, ordered by the best other token amount you would get from a trade.
Use <a href="../classes/RouterUtils.html#selectFirstExecutableRoute">RouterUtils.selectFirstExecutableRoute</a> to find the best executable route.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>trade: <a href="../modules.html#Trade" class="tsd-signature-type" data-tsd-kind="Type alias">Trade</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The trade to find routes for.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#RoutingOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RoutingOptions</a><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an <a href="../modules.html#WhirlpoolAccountFetchOptions">WhirlpoolAccountFetchOptions</a> object to define fetch and cache options when accessing on-chain accounts</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> fetchOpts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="../modules.html#WhirlpoolAccountFetchOptions">WhirlpoolAccountFetchOptions</a> to configure the fetching of on-chain data.</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#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A list of <a href="../modules.html#TradeRoute">TradeRoute</a> that can be used to execute a swap, ordered by the best other token amount.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="findBestRoute" class="tsd-anchor"></a><h3 class="tsd-anchor-link">find<wbr/>Best<wbr/>Route<a href="#findBestRoute" 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-interface"><li class="tsd-signature tsd-kind-icon">find<wbr/>Best<wbr/>Route<span class="tsd-signature-symbol">(</span>trade<span class="tsd-signature-symbol">: </span><a href="../modules.html#Trade" class="tsd-signature-type" data-tsd-kind="Type alias">Trade</a>, opts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#RoutingOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RoutingOptions</a><span class="tsd-signature-symbol">&gt;</span>, selectionOpts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#RouteSelectOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RouteSelectOptions</a><span class="tsd-signature-symbol">&gt;</span>, fetchOpts<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">SimpleAccountFetchOptions</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><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="../modules.html#ExecutableRoute" class="tsd-signature-type" data-tsd-kind="Type alias">ExecutableRoute</a><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/3dc98d0/sdk/src/router/public/index.ts#L175">router/public/index.ts:175</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Finds all possible routes for a trade and select the best route that is executable
under the current execution environment.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>trade: <a href="../modules.html#Trade" class="tsd-signature-type" data-tsd-kind="Type alias">Trade</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The trade to find routes for.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#RoutingOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RoutingOptions</a><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>an <a href="../modules.html#WhirlpoolAccountFetchOptions">WhirlpoolAccountFetchOptions</a> object to define fetch and cache options when accessing on-chain accounts</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> selectionOpts: <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol">&lt;</span><a href="../modules.html#RouteSelectOptions" class="tsd-signature-type" data-tsd-kind="Type alias">RouteSelectOptions</a><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="../modules.html#RouteSelectOptions">RouteSelectOptions</a> to configure the selection of the best route. Missing options
will be filled with default values from {@link RouterUtils.getDefaultRouteSelectOptions}.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> fetchOpts: <span class="tsd-signature-type">SimpleAccountFetchOptions</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p><a href="../modules.html#WhirlpoolAccountFetchOptions">WhirlpoolAccountFetchOptions</a> to configure the fetching of on-chain data.</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><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="../modules.html#ExecutableRoute" class="tsd-signature-type" data-tsd-kind="Type alias">ExecutableRoute</a><span class="tsd-signature-symbol">&gt;</span></h4><div><p>The best <a href="../modules.html#ExecutableRoute">ExecutableRoute</a> that can be used to execute a swap. If no executable route is found, null is returned.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="swap" class="tsd-anchor"></a><h3 class="tsd-anchor-link">swap<a href="#swap" 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-interface"><li class="tsd-signature tsd-kind-icon">swap<span class="tsd-signature-symbol">(</span>trade<span class="tsd-signature-symbol">: </span><a href="../modules.html#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a>, slippage<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Percentage</span>, resolvedAtas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="../modules.html#AtaAccountInfo" class="tsd-signature-type" data-tsd-kind="Type alias">AtaAccountInfo</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><span class="tsd-signature-type">TransactionBuilder</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/3dc98d0/sdk/src/router/public/index.ts#L194">router/public/index.ts:194</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Construct a {@link TransactionBuilder} to help execute a trade route.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>trade: <a href="../modules.html#TradeRoute" class="tsd-signature-type" data-tsd-kind="Type alias">TradeRoute</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The trade route to execute.</p>
</div></div></li><li><h5>slippage: <span class="tsd-signature-type">Percentage</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The slippage tolerance for the trade.</p>
</div></div></li><li><h5>resolvedAtas: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="../modules.html#AtaAccountInfo" class="tsd-signature-type" data-tsd-kind="Type alias">AtaAccountInfo</a><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The ATA accounts that the executing wallet owns / needed by the execution.
If not provided, the router will attempt to resolve them.</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><span class="tsd-signature-type">TransactionBuilder</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A {@link TransactionBuilder}that can be used to execute the trade.
If provvided from <a href="../modules.html#ExecutableRoute">ExecutableRoute</a>, plug the {@link AddressLookupTableAccount}s
into builder to lower the transaction size.</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-interface"><a href="WhirlpoolRouter.html" class="tsd-kind-icon">Whirlpool<wbr/>Router</a><ul><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolRouter.html#findAllRoutes" class="tsd-kind-icon">find<wbr/>All<wbr/>Routes</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolRouter.html#findBestRoute" class="tsd-kind-icon">find<wbr/>Best<wbr/>Route</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WhirlpoolRouter.html#swap" class="tsd-kind-icon">swap</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>

File diff suppressed because one or more lines are too long

View File

@ -1,12 +0,0 @@
// Migrations are an early feature. Currently, they're nothing more than this
// single deploy script that's invoked from the CLI, injecting a provider
// configured from the workspace's Anchor.toml.
const anchor = require("@project-serum/anchor");
module.exports = async function (provider) {
// Configure client to use the provider.
anchor.setProvider(provider);
// Add your deploy script here.
}

View File

@ -1,11 +0,0 @@
{
"name": "orca-whirlpools",
"private": true,
"workspaces": [
"sdk",
"scripts"
],
"scripts": {
"idl": "anchor build -i $INIT_CWD/sdk/src/artifacts -t $INIT_CWD/sdk/src/artifacts"
}
}

View File

@ -1,5 +1,5 @@
[package]
name = "whirlpool"
name = "whirlpool-client"
version = "0.2.0"
description = "Created with Anchor"
edition = "2018"
@ -15,14 +15,14 @@ cpi = ["no-entrypoint"]
default = []
[dependencies]
anchor-lang = "0.26"
anchor-spl = "0.26"
anchor-lang = "0.29"
anchor-spl = "0.29"
spl-token = {version = "3.3", features = ["no-entrypoint"]}
solana-program = "1.14.12"
solana-program = "~1.17.0"
thiserror = "1.0"
uint = {version = "0.9.1", default-features = false}
borsh = "0.9.1"
mpl-token-metadata = { version = "1.7", features = ["no-entrypoint"] }
borsh = "0.10.3"
bytemuck = { version = "1.7.2" }
[dev-dependencies]
proptest = "1.0"

View File

@ -46,33 +46,3 @@ pub struct InitializePool<'info> {
pub system_program: Program<'info, System>,
pub rent: Sysvar<'info, Rent>,
}
pub fn handler(
ctx: Context<InitializePool>,
_bumps: WhirlpoolBumps,
tick_spacing: u16,
initial_sqrt_price: u128,
) -> Result<()> {
let token_mint_a = ctx.accounts.token_mint_a.key();
let token_mint_b = ctx.accounts.token_mint_b.key();
let whirlpool = &mut ctx.accounts.whirlpool;
let whirlpools_config = &ctx.accounts.whirlpools_config;
let default_fee_rate = ctx.accounts.fee_tier.default_fee_rate;
// ignore the bump passed and use one Anchor derived
let bump = *ctx.bumps.get("whirlpool").unwrap();
Ok(whirlpool.initialize(
whirlpools_config,
bump,
tick_spacing,
initial_sqrt_price,
default_fee_rate,
token_mint_a,
ctx.accounts.token_vault_a.key(),
token_mint_b,
ctx.accounts.token_vault_b.key(),
)?)
}

View File

@ -41,23 +41,3 @@ pub struct InitializePositionBundle<'info> {
pub associated_token_program: Program<'info, AssociatedToken>,
}
pub fn handler(ctx: Context<InitializePositionBundle>) -> Result<()> {
let position_bundle_mint = &ctx.accounts.position_bundle_mint;
let position_bundle = &mut ctx.accounts.position_bundle;
position_bundle.initialize(position_bundle_mint.key())?;
let bump = *ctx.bumps.get("position_bundle").unwrap();
mint_position_bundle_token_and_remove_authority(
&ctx.accounts.position_bundle,
position_bundle_mint,
&ctx.accounts.position_bundle_token_account,
&ctx.accounts.token_program,
&[
b"position_bundle".as_ref(),
position_bundle_mint.key().as_ref(),
&[bump],
],
)
}

View File

@ -3,7 +3,7 @@ use anchor_spl::associated_token::AssociatedToken;
use anchor_spl::token::{self, Mint, Token, TokenAccount};
use crate::constants::nft::whirlpool_nft_update_auth::ID as WPB_NFT_UPDATE_AUTH;
use crate::{state::*, util::mint_position_bundle_token_with_metadata_and_remove_authority};
use crate::{state::*};
#[derive(Accounts)]
pub struct InitializePositionBundleWithMetadata<'info> {
@ -51,33 +51,6 @@ pub struct InitializePositionBundleWithMetadata<'info> {
pub associated_token_program: Program<'info, AssociatedToken>,
/// CHECK: checked via account constraints
#[account(address = mpl_token_metadata::ID)]
pub metadata_program: UncheckedAccount<'info>,
}
pub fn handler(ctx: Context<InitializePositionBundleWithMetadata>) -> Result<()> {
let position_bundle_mint = &ctx.accounts.position_bundle_mint;
let position_bundle = &mut ctx.accounts.position_bundle;
position_bundle.initialize(position_bundle_mint.key())?;
let bump = *ctx.bumps.get("position_bundle").unwrap();
mint_position_bundle_token_with_metadata_and_remove_authority(
&ctx.accounts.funder,
&ctx.accounts.position_bundle,
position_bundle_mint,
&ctx.accounts.position_bundle_token_account,
&ctx.accounts.position_bundle_metadata,
&ctx.accounts.metadata_update_auth,
&ctx.accounts.metadata_program,
&ctx.accounts.token_program,
&ctx.accounts.system_program,
&ctx.accounts.rent,
&[
b"position_bundle".as_ref(),
position_bundle_mint.key().as_ref(),
&[bump],
],
)
}

View File

@ -5,7 +5,6 @@ use anchor_spl::token::{self, Mint, Token, TokenAccount};
use crate::{state::*, util::mint_position_token_and_remove_authority};
#[derive(Accounts)]
#[instruction(bumps: OpenPositionBumps)]
pub struct OpenPosition<'info> {
#[account(mut)]
pub funder: Signer<'info>,
@ -44,30 +43,3 @@ pub struct OpenPosition<'info> {
pub associated_token_program: Program<'info, AssociatedToken>,
}
/*
Opens a new Whirlpool Position.
*/
pub fn handler(
ctx: Context<OpenPosition>,
_bumps: OpenPositionBumps,
tick_lower_index: i32,
tick_upper_index: i32,
) -> Result<()> {
let whirlpool = &ctx.accounts.whirlpool;
let position_mint = &ctx.accounts.position_mint;
let position = &mut ctx.accounts.position;
position.open_position(
whirlpool,
position_mint.key(),
tick_lower_index,
tick_upper_index,
)?;
mint_position_token_and_remove_authority(
whirlpool,
position_mint,
&ctx.accounts.position_token_account,
&ctx.accounts.token_program,
)
}

View File

@ -2,12 +2,11 @@ use anchor_lang::prelude::*;
use anchor_spl::associated_token::AssociatedToken;
use anchor_spl::token::{self, Mint, Token, TokenAccount};
use crate::{state::*, util::mint_position_token_with_metadata_and_remove_authority};
use crate::{state::*};
use crate::constants::nft::whirlpool_nft_update_auth::ID as WP_NFT_UPDATE_AUTH;
#[derive(Accounts)]
#[instruction(bumps: OpenPositionWithMetadataBumps)]
pub struct OpenPositionWithMetadata<'info> {
#[account(mut)]
pub funder: Signer<'info>,
@ -51,7 +50,6 @@ pub struct OpenPositionWithMetadata<'info> {
pub associated_token_program: Program<'info, AssociatedToken>,
/// CHECK: checked via account constraints
#[account(address = mpl_token_metadata::ID)]
pub metadata_program: UncheckedAccount<'info>,
/// CHECK: checked via account constraints
@ -59,36 +57,3 @@ pub struct OpenPositionWithMetadata<'info> {
pub metadata_update_auth: UncheckedAccount<'info>,
}
/*
Opens a new Whirlpool Position with Metadata account.
*/
pub fn handler(
ctx: Context<OpenPositionWithMetadata>,
_bumps: OpenPositionWithMetadataBumps,
tick_lower_index: i32,
tick_upper_index: i32,
) -> Result<()> {
let whirlpool = &ctx.accounts.whirlpool;
let position_mint = &ctx.accounts.position_mint;
let position = &mut ctx.accounts.position;
position.open_position(
whirlpool,
position_mint.key(),
tick_lower_index,
tick_upper_index,
)?;
mint_position_token_with_metadata_and_remove_authority(
whirlpool,
position_mint,
&ctx.accounts.position_token_account,
&ctx.accounts.position_metadata_account,
&ctx.accounts.metadata_update_auth,
&ctx.accounts.funder,
&ctx.accounts.metadata_program,
&ctx.accounts.token_program,
&ctx.accounts.system_program,
&ctx.accounts.rent,
)
}

View File

@ -6,10 +6,10 @@ declare_id!("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc");
#[doc(hidden)]
pub mod constants;
#[doc(hidden)]
pub mod errors;
#[doc(hidden)]
pub mod instructions;
#[doc(hidden)]
pub mod errors;
#[doc(hidden)]
pub mod manager;
#[doc(hidden)]
pub mod math;
@ -40,13 +40,7 @@ pub mod whirlpool {
reward_emissions_super_authority: Pubkey,
default_protocol_fee_rate: u16,
) -> Result<()> {
return instructions::initialize_config::handler(
ctx,
fee_authority,
collect_protocol_fees_authority,
reward_emissions_super_authority,
default_protocol_fee_rate,
);
Ok(())
}
/// Initializes a Whirlpool account.
@ -67,12 +61,7 @@ pub mod whirlpool {
tick_spacing: u16,
initial_sqrt_price: u128,
) -> Result<()> {
return instructions::initialize_pool::handler(
ctx,
bumps,
tick_spacing,
initial_sqrt_price,
);
Ok(())
}
/// Initializes a tick_array account to represent a tick-range in a Whirlpool.
@ -88,7 +77,7 @@ pub mod whirlpool {
ctx: Context<InitializeTickArray>,
start_tick_index: i32,
) -> Result<()> {
return instructions::initialize_tick_array::handler(ctx, start_tick_index);
Ok(())
}
/// Initializes a fee_tier account usable by Whirlpools in a WhirlpoolConfig space.
@ -108,7 +97,7 @@ pub mod whirlpool {
tick_spacing: u16,
default_fee_rate: u16,
) -> Result<()> {
return instructions::initialize_fee_tier::handler(ctx, tick_spacing, default_fee_rate);
Ok(())
}
/// Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards.
@ -125,7 +114,7 @@ pub mod whirlpool {
/// index in this pool, or exceeds NUM_REWARDS, or
/// all reward slots for this pool has been initialized.
pub fn initialize_reward(ctx: Context<InitializeReward>, reward_index: u8) -> Result<()> {
return instructions::initialize_reward::handler(ctx, reward_index);
Ok(())
}
/// Set the reward emissions for a reward in a Whirlpool.
@ -150,11 +139,7 @@ pub mod whirlpool {
reward_index: u8,
emissions_per_second_x64: u128,
) -> Result<()> {
return instructions::set_reward_emissions::handler(
ctx,
reward_index,
emissions_per_second_x64,
);
Ok(())
}
/// Open a position in a Whirlpool. A unique token will be minted to represent the position
@ -173,12 +158,7 @@ pub mod whirlpool {
tick_lower_index: i32,
tick_upper_index: i32,
) -> Result<()> {
return instructions::open_position::handler(
ctx,
bumps,
tick_lower_index,
tick_upper_index,
);
Ok(())
}
/// Open a position in a Whirlpool. A unique token will be minted to represent the position
@ -198,12 +178,7 @@ pub mod whirlpool {
tick_lower_index: i32,
tick_upper_index: i32,
) -> Result<()> {
return instructions::open_position_with_metadata::handler(
ctx,
bumps,
tick_lower_index,
tick_upper_index,
);
Ok(())
}
/// Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.
@ -226,12 +201,7 @@ pub mod whirlpool {
token_max_a: u64,
token_max_b: u64,
) -> Result<()> {
return instructions::increase_liquidity::handler(
ctx,
liquidity_amount,
token_max_a,
token_max_b,
);
Ok(())
}
/// Withdraw liquidity from a position in the Whirlpool. This call also updates the position's accrued fees and rewards.
@ -254,12 +224,7 @@ pub mod whirlpool {
token_min_a: u64,
token_min_b: u64,
) -> Result<()> {
return instructions::decrease_liquidity::handler(
ctx,
liquidity_amount,
token_min_a,
token_min_b,
);
Ok(())
}
/// Update the accrued fees and rewards for a position.
@ -268,7 +233,7 @@ pub mod whirlpool {
/// - `TickNotFound` - Provided tick array account does not contain the tick for this position.
/// - `LiquidityZero` - Position has zero liquidity and therefore already has the most updated fees and reward values.
pub fn update_fees_and_rewards(ctx: Context<UpdateFeesAndRewards>) -> Result<()> {
return instructions::update_fees_and_rewards::handler(ctx);
Ok(())
}
/// Collect fees accrued for this position.
@ -276,7 +241,7 @@ pub mod whirlpool {
/// ### Authority
/// - `position_authority` - authority that owns the token corresponding to this desired position.
pub fn collect_fees(ctx: Context<CollectFees>) -> Result<()> {
return instructions::collect_fees::handler(ctx);
Ok(())
}
/// Collect rewards accrued for this position.
@ -284,7 +249,7 @@ pub mod whirlpool {
/// ### Authority
/// - `position_authority` - authority that owns the token corresponding to this desired position.
pub fn collect_reward(ctx: Context<CollectReward>, reward_index: u8) -> Result<()> {
return instructions::collect_reward::handler(ctx, reward_index);
Ok(())
}
/// Collect the protocol fees accrued in this Whirlpool
@ -292,7 +257,7 @@ pub mod whirlpool {
/// ### Authority
/// - `collect_protocol_fees_authority` - assigned authority in the WhirlpoolConfig that can collect protocol fees
pub fn collect_protocol_fees(ctx: Context<CollectProtocolFees>) -> Result<()> {
return instructions::collect_protocol_fees::handler(ctx);
Ok(())
}
/// Perform a swap in this Whirlpool
@ -324,14 +289,7 @@ pub mod whirlpool {
amount_specified_is_input: bool,
a_to_b: bool,
) -> Result<()> {
return instructions::swap::handler(
ctx,
amount,
other_amount_threshold,
sqrt_price_limit,
amount_specified_is_input,
a_to_b,
);
Ok(())
}
/// Close a position in a Whirlpool. Burns the position token in the owner's wallet.
@ -342,7 +300,7 @@ pub mod whirlpool {
/// #### Special Errors
/// - `ClosePositionNotEmpty` - The provided position account is not empty.
pub fn close_position(ctx: Context<ClosePosition>) -> Result<()> {
return instructions::close_position::handler(ctx);
Ok(())
}
/// Set the default_fee_rate for a FeeTier
@ -361,7 +319,7 @@ pub mod whirlpool {
ctx: Context<SetDefaultFeeRate>,
default_fee_rate: u16,
) -> Result<()> {
return instructions::set_default_fee_rate::handler(ctx, default_fee_rate);
Ok(())
}
/// Sets the default protocol fee rate for a WhirlpoolConfig
@ -380,10 +338,7 @@ pub mod whirlpool {
ctx: Context<SetDefaultProtocolFeeRate>,
default_protocol_fee_rate: u16,
) -> Result<()> {
return instructions::set_default_protocol_fee_rate::handler(
ctx,
default_protocol_fee_rate,
);
Ok(())
}
/// Sets the fee rate for a Whirlpool.
@ -399,7 +354,7 @@ pub mod whirlpool {
/// #### Special Errors
/// - `FeeRateMaxExceeded` - If the provided fee_rate exceeds MAX_FEE_RATE.
pub fn set_fee_rate(ctx: Context<SetFeeRate>, fee_rate: u16) -> Result<()> {
return instructions::set_fee_rate::handler(ctx, fee_rate);
Ok(())
}
/// Sets the protocol fee rate for a Whirlpool.
@ -418,7 +373,7 @@ pub mod whirlpool {
ctx: Context<SetProtocolFeeRate>,
protocol_fee_rate: u16,
) -> Result<()> {
return instructions::set_protocol_fee_rate::handler(ctx, protocol_fee_rate);
Ok(())
}
/// Sets the fee authority for a WhirlpoolConfig.
@ -429,7 +384,7 @@ pub mod whirlpool {
/// ### Authority
/// - "fee_authority" - Set authority that can modify pool fees in the WhirlpoolConfig
pub fn set_fee_authority(ctx: Context<SetFeeAuthority>) -> Result<()> {
return instructions::set_fee_authority::handler(ctx);
Ok(())
}
/// Sets the fee authority to collect protocol fees for a WhirlpoolConfig.
@ -440,7 +395,7 @@ pub mod whirlpool {
pub fn set_collect_protocol_fees_authority(
ctx: Context<SetCollectProtocolFeesAuthority>,
) -> Result<()> {
return instructions::set_collect_protocol_fees_authority::handler(ctx);
Ok(())
}
/// Set the whirlpool reward authority at the provided `reward_index`.
@ -454,7 +409,7 @@ pub mod whirlpool {
/// index in this pool, or exceeds NUM_REWARDS, or
/// all reward slots for this pool has been initialized.
pub fn set_reward_authority(ctx: Context<SetRewardAuthority>, reward_index: u8) -> Result<()> {
return instructions::set_reward_authority::handler(ctx, reward_index);
Ok(())
}
/// Set the whirlpool reward authority at the provided `reward_index`.
@ -471,7 +426,7 @@ pub mod whirlpool {
ctx: Context<SetRewardAuthorityBySuperAuthority>,
reward_index: u8,
) -> Result<()> {
return instructions::set_reward_authority_by_super_authority::handler(ctx, reward_index);
Ok(())
}
/// Set the whirlpool reward super authority for a WhirlpoolConfig
@ -483,7 +438,7 @@ pub mod whirlpool {
pub fn set_reward_emissions_super_authority(
ctx: Context<SetRewardEmissionsSuperAuthority>,
) -> Result<()> {
return instructions::set_reward_emissions_super_authority::handler(ctx);
Ok(())
}
/// Perform a two-hop swap in this Whirlpool
@ -521,22 +476,13 @@ pub mod whirlpool {
sqrt_price_limit_one: u128,
sqrt_price_limit_two: u128,
) -> Result<()> {
return instructions::two_hop_swap::handler(
ctx,
amount,
other_amount_threshold,
amount_specified_is_input,
a_to_b_one,
a_to_b_two,
sqrt_price_limit_one,
sqrt_price_limit_two,
);
Ok(())
}
/// Initializes a PositionBundle account that bundles several positions.
/// A unique token will be minted to represent the position bundle in the users wallet.
pub fn initialize_position_bundle(ctx: Context<InitializePositionBundle>) -> Result<()> {
return instructions::initialize_position_bundle::handler(ctx);
Ok(())
}
/// Initializes a PositionBundle account that bundles several positions.
@ -545,7 +491,7 @@ pub mod whirlpool {
pub fn initialize_position_bundle_with_metadata(
ctx: Context<InitializePositionBundleWithMetadata>,
) -> Result<()> {
return instructions::initialize_position_bundle_with_metadata::handler(ctx);
Ok(())
}
/// Delete a PositionBundle account. Burns the position bundle token in the owner's wallet.
@ -556,7 +502,7 @@ pub mod whirlpool {
/// ### Special Errors
/// - `PositionBundleNotDeletable` - The provided position bundle has open positions.
pub fn delete_position_bundle(ctx: Context<DeletePositionBundle>) -> Result<()> {
return instructions::delete_position_bundle::handler(ctx);
Ok(())
}
/// Open a bundled position in a Whirlpool. No new tokens are issued
@ -581,12 +527,7 @@ pub mod whirlpool {
tick_lower_index: i32,
tick_upper_index: i32,
) -> Result<()> {
return instructions::open_bundled_position::handler(
ctx,
bundle_index,
tick_lower_index,
tick_upper_index,
);
Ok(())
}
/// Close a bundled position in a Whirlpool.
@ -604,6 +545,6 @@ pub mod whirlpool {
ctx: Context<CloseBundledPosition>,
bundle_index: u16,
) -> Result<()> {
return instructions::close_bundled_position::handler(ctx, bundle_index);
Ok(())
}
}

View File

@ -22,7 +22,7 @@
use borsh::{BorshDeserialize, BorshSerialize};
use std::borrow::BorrowMut;
use std::convert::TryInto;
use std::io::{Error, ErrorKind, Write};
use std::io::{Error, ErrorKind, Write, Read};
use std::mem::size_of;
use uint::construct_uint;
@ -44,15 +44,10 @@ macro_rules! impl_borsh_deserialize_for_bn {
($type: ident) => {
impl BorshDeserialize for $type {
#[inline]
fn deserialize(buf: &mut &[u8]) -> std::io::Result<Self> {
if buf.len() < size_of::<$type>() {
return Err(Error::new(
ErrorKind::InvalidInput,
"Unexpected length of input",
));
}
let res = $type::from_le_bytes(buf[..size_of::<$type>()].try_into().unwrap());
*buf = &buf[size_of::<$type>()..];
fn deserialize_reader<R: Read>(reader: &mut R) -> std::io::Result<Self> {
let mut buffer = [0u8; size_of::<$type>()];
reader.read_exact(&mut buffer)?;
let res = $type::from_le_bytes(buffer.try_into().unwrap());
Ok(res)
}
}

View File

@ -13,7 +13,7 @@ pub const MIN_TICK_INDEX: i32 = -443636;
pub const TICK_ARRAY_SIZE: i32 = 88;
pub const TICK_ARRAY_SIZE_USIZE: usize = 88;
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(Default, Debug, PartialEq)]
pub struct Tick {
@ -138,7 +138,7 @@ impl TickUpdate {
}
}
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct TickArray {
pub start_tick_index: i32,

View File

@ -1,7 +1,6 @@
use crate::state::{PositionBundle, Whirlpool};
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Mint, Token, TokenAccount, Transfer};
use mpl_token_metadata::instruction::create_metadata_accounts_v3;
use solana_program::program::invoke_signed;
use spl_token::instruction::{burn_checked, close_account, mint_to, set_authority, AuthorityType};
@ -113,60 +112,6 @@ pub fn mint_position_token_and_remove_authority<'info>(
remove_position_token_mint_authority(whirlpool, position_mint, token_program)
}
pub fn mint_position_token_with_metadata_and_remove_authority<'info>(
whirlpool: &Account<'info, Whirlpool>,
position_mint: &Account<'info, Mint>,
position_token_account: &Account<'info, TokenAccount>,
position_metadata_account: &UncheckedAccount<'info>,
metadata_update_auth: &UncheckedAccount<'info>,
funder: &Signer<'info>,
metadata_program: &UncheckedAccount<'info>,
token_program: &Program<'info, Token>,
system_program: &Program<'info, System>,
rent: &Sysvar<'info, Rent>,
) -> Result<()> {
mint_position_token(
whirlpool,
position_mint,
position_token_account,
token_program,
)?;
let metadata_mint_auth_account = whirlpool;
invoke_signed(
&create_metadata_accounts_v3(
metadata_program.key(),
position_metadata_account.key(),
position_mint.key(),
metadata_mint_auth_account.key(),
funder.key(),
metadata_update_auth.key(),
WP_METADATA_NAME.to_string(),
WP_METADATA_SYMBOL.to_string(),
WP_METADATA_URI.to_string(),
None,
0,
false,
true,
None,
None,
None,
),
&[
position_metadata_account.to_account_info(),
position_mint.to_account_info(),
metadata_mint_auth_account.to_account_info(),
metadata_update_auth.to_account_info(),
funder.to_account_info(),
metadata_program.to_account_info(),
system_program.to_account_info(),
rent.to_account_info(),
],
&[&metadata_mint_auth_account.seeds()],
)?;
remove_position_token_mint_authority(whirlpool, position_mint, token_program)
}
fn mint_position_token<'info>(
whirlpool: &Account<'info, Whirlpool>,
@ -240,77 +185,6 @@ pub fn mint_position_bundle_token_and_remove_authority<'info>(
)
}
pub fn mint_position_bundle_token_with_metadata_and_remove_authority<'info>(
funder: &Signer<'info>,
position_bundle: &Account<'info, PositionBundle>,
position_bundle_mint: &Account<'info, Mint>,
position_bundle_token_account: &Account<'info, TokenAccount>,
position_bundle_metadata: &UncheckedAccount<'info>,
metadata_update_auth: &UncheckedAccount<'info>,
metadata_program: &UncheckedAccount<'info>,
token_program: &Program<'info, Token>,
system_program: &Program<'info, System>,
rent: &Sysvar<'info, Rent>,
position_bundle_seeds: &[&[u8]],
) -> Result<()> {
mint_position_bundle_token(
position_bundle,
position_bundle_mint,
position_bundle_token_account,
token_program,
position_bundle_seeds,
)?;
// Create Metadata
// Orca Position Bundle xxxx...yyyy
// xxxx and yyyy are the first and last 4 chars of mint address
let mint_address = position_bundle_mint.key().to_string();
let mut nft_name = String::from(WPB_METADATA_NAME_PREFIX);
nft_name += " ";
nft_name += &mint_address[0..4];
nft_name += "...";
nft_name += &mint_address[mint_address.len() - 4..];
invoke_signed(
&create_metadata_accounts_v3(
metadata_program.key(),
position_bundle_metadata.key(),
position_bundle_mint.key(),
position_bundle.key(),
funder.key(),
metadata_update_auth.key(),
nft_name,
WPB_METADATA_SYMBOL.to_string(),
WPB_METADATA_URI.to_string(),
None,
0,
false,
true,
None,
None,
None,
),
&[
position_bundle.to_account_info(),
position_bundle_metadata.to_account_info(),
position_bundle_mint.to_account_info(),
metadata_update_auth.to_account_info(),
funder.to_account_info(),
metadata_program.to_account_info(),
system_program.to_account_info(),
rent.to_account_info(),
],
&[position_bundle_seeds],
)?;
remove_position_bundle_token_mint_authority(
position_bundle,
position_bundle_mint,
token_program,
position_bundle_seeds,
)
}
fn mint_position_bundle_token<'info>(
position_bundle: &Account<'info, PositionBundle>,
position_bundle_mint: &Account<'info, Mint>,

View File

@ -1,53 +0,0 @@
import * as anchor from "@project-serum/anchor";
import { readFile } from "mz/fs";
import Decimal from "decimal.js";
import { Keypair } from "@solana/web3.js";
const toBuffer = (arr: Buffer | Uint8Array | Array<number>): Buffer => {
if (arr instanceof Buffer) {
return arr;
} else if (arr instanceof Uint8Array) {
return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
} else {
return Buffer.from(arr);
}
};
async function getKeyPair(keyPath: string): Promise<Keypair> {
const buffer = await readFile(keyPath);
let data = JSON.parse(buffer.toString());
return Keypair.fromSecretKey(toBuffer(data));
}
async function run() {
// https://api.mainnet-beta.solana.com
const wallet = new anchor.Wallet(
await getKeyPair("/Users/ottocheung/dev/solana/pub.json")
);
const connection = new anchor.web3.Connection(
"https://api.mainnet-beta.solana.com"
);
const provider = new anchor.AnchorProvider(
connection,
wallet,
anchor.AnchorProvider.defaultOptions()
);
const sizeInBytes = [
1024, 5000, 10000, 50000, 1000000, 3000000, 5000000, 10000000,
];
const solPrice = 160;
sizeInBytes.forEach(async (size) => {
const result = await provider.connection.getMinimumBalanceForRentExemption(
size
);
const sol = new Decimal(result).mul(0.000000001);
console.log(
`size - ${size} lamports - ${result} SOL- ${sol} price - ${sol.mul(
solPrice
)}`
);
});
}
run();

View File

@ -1,15 +0,0 @@
import Decimal from "decimal.js";
Decimal.set({ precision: 40, rounding: 4 });
const x64 = new Decimal(2).pow(64);
const number = new Decimal(1).mul(x64);
console.log(`number - ${number}`);
const exp = new Decimal(1.0001).sqrt().pow(1).mul(x64);
console.log(`exp - ${exp.toFixed(0, 1)}`);
const log = new Decimal(18445821805675392311)
.div(x64)
.log(new Decimal(1.0001).sqrt());
console.log(`log - ${log.toString()}`);

View File

@ -1,68 +0,0 @@
import Decimal from "decimal.js";
Decimal.set({ precision: 40, rounding: 4 });
/**
* This script is to generate the magic numbers & unit tests needed for the exponent function
* in Whirlpools.
*
* Explanation on what magic numbers are:
* https://www.notion.so/orcaso/Fixed-Point-Arithmetic-in-Whirlpools-63f9817a852b4029a6eb15dc755c7baf#5df2cfe5d62b4b0aa7e58f5f381c2d55
*/
const x32 = new Decimal(2).pow(32);
const x64 = new Decimal(2).pow(64);
const x128 = new Decimal(2).pow(128);
const b = new Decimal("1.0001");
// Qm.n = Q32.64
const n = 64;
console.log(
`Printing bit constants for whirlpool exponent of base ${b.toDecimalPlaces(
4
)}`
);
console.log(``);
console.log(`1.0001 x64 const - ${b.mul(x64).toFixed(0, 1)}`);
console.log(``);
console.log(`With a maximum tick of +/-443636, we'll need 19 bit constants:`);
for (let j = 0; j <= 18; j++) {
const power = new Decimal(2).pow(j - 1);
const sqrtBPower = b.pow(power);
const iSqrtBPower = new Decimal(1).div(sqrtBPower).mul(x64);
console.log(`${iSqrtBPower.toFixed(0, 1)}`);
}
const genUnitTestCases = (cases: number[]) => {
console.log(`tick | positive index result | negative index result`);
for (const tick of cases) {
const jsResult = new Decimal(b)
.pow(tick)
.sqrt()
.mul(new Decimal(2).pow(n))
.toFixed(0, 1);
const njsResult = new Decimal(b)
.pow(-tick)
.sqrt()
.mul(new Decimal(2).pow(n))
.toFixed(0, 1);
console.log(tick + " - " + jsResult + " , " + njsResult);
}
};
let bitGroup = [
0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384,
32768, 65536, 131072, 262144, 524288,
];
let randGroup = [2493, 23750, 395, 129, 39502, 395730, 245847, 120821].sort(
(n1, n2) => n1 - n2
);
console.log(" ");
console.log("Printing unit test cases for binary fraction bit cases:");
genUnitTestCases(bitGroup);
console.log(" ");
console.log("Printing unit test cases for random values:");
genUnitTestCases(randGroup);

View File

@ -1,17 +0,0 @@
import Decimal from "decimal.js";
Decimal.set({ toExpPos: 100, toExpNeg: -100, precision: 100 })
const b = new Decimal(1.0001);
const targetBitShift = 64;
const resolution = Decimal.pow(2, targetBitShift);
const results = [];
for (let j = 0; j < 19; j++) {
// Calculate target price
const index = Decimal.pow(2, j);
console.log("index", index);
const rawPrice = b.pow(index.div(2));
const targetPrice = rawPrice.mul(Decimal.pow(2, 96)).floor();
console.log("targetPrice", targetPrice);
}

View File

@ -1,15 +0,0 @@
{
"name": "scripts",
"version": "1.0.0",
"dependencies": {
"@project-serum/anchor": "~0.25.0",
"@solana/spl-token": "^0.1.8"
},
"devDependencies": {
"@types/mocha": "^9.0.0",
"@types/mz": "^2.7.3",
"chai": "^4.3.4",
"mocha": "^9.0.3",
"mz": "^2.7.0"
}
}

View File

@ -1,20 +0,0 @@
{
"compilerOptions": {
"composite": true,
"target": "es6",
"module": "commonjs",
"allowJs": false,
"declaration": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"references": [
{
"path": "../sdk/src"
}
]
}

View File

@ -1,11 +0,0 @@
{
"name": "Orca Whirlpool Position",
"symbol": "OWP",
"description": "Orca Whirlpool Position",
"image": "data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 581.4 581.4' width='120px' height='120px'%3e%3cdefs%3e%3cstyle%3e.cls-1%7bfill:%23ffd15c;%7d%3c/style%3e%3c/defs%3e%3cg id='Layer_3' data-name='Layer 3'%3e%3cpath class='cls-1' d='M523.54,249.16a233.55,233.55,0,0,0-6.7-41.53,222.48,222.48,0,0,0-35.59-75.46,219.47,219.47,0,0,0-27.72-31.06A222.1,222.1,0,0,0,420.62,76,236.75,236.75,0,0,0,384,57.44a260.8,260.8,0,0,0-38.87-12.08,304.15,304.15,0,0,0-80-6.79,4,4,0,0,0,0,8c27.6,1.25,53.31,5.45,76.45,12.49a246,246,0,0,1,35.68,13.78,225.16,225.16,0,0,1,32.68,19.26,209.66,209.66,0,0,1,28.49,24.51,197.65,197.65,0,0,1,40.51,62A199.88,199.88,0,0,1,489.64,214a205.08,205.08,0,0,1,4.22,36.61,218.73,218.73,0,0,1-2.25,36.81A194,194,0,0,1,468.46,356a178.27,178.27,0,0,1-20.76,29.22,167.18,167.18,0,0,1-26.15,24.12,177.22,177.22,0,0,1-64.3,29.73,208.44,208.44,0,0,1-35.61,5.42c-6.45.43-12.39.61-18.26.53-1,0-1.89,0-2.79-.05l-1.47,0-1.34-.07c-.95,0-1.9-.09-2.92-.17-2.93-.2-5.91-.57-8.39-.9a125,125,0,0,1-61.23-26.55,122.38,122.38,0,0,1-38.44-53.58,106.39,106.39,0,0,1-6.14-31.94c-.13-3-.06-5.92,0-8.19s.26-4.91.6-8.2a106.41,106.41,0,0,1,3-16,96.59,96.59,0,0,1,13-28.91A92.54,92.54,0,0,1,219,247.72a102.29,102.29,0,0,1,28.35-14.82,120.85,120.85,0,0,1,32.37-6.14c2.39-.15,5.12-.22,8.35-.22a43.55,43.55,0,0,1,6.33.5,27.2,27.2,0,0,1,9.92,3.39,18.74,18.74,0,0,1,6.23,6,19.74,19.74,0,0,1,2.91,8.37,20.74,20.74,0,0,1-.92,9,19.24,19.24,0,0,1-1.81,3.88,17.87,17.87,0,0,1-2.62,3.24,18.58,18.58,0,0,1-7.5,4.38,27.88,27.88,0,0,1-5.14,1.14l-.72.08c-.24,0-.48.06-.71.07l-1.57.11-4.53.1a91.91,91.91,0,0,0-13.33,1.32A79.66,79.66,0,0,0,261,271.79a68.1,68.1,0,0,0-25.36,16.26,64.19,64.19,0,0,0-15.72,26.82,66.54,66.54,0,0,0,10.52,58.55,68.6,68.6,0,0,0,22.74,19.51,78.85,78.85,0,0,0,26.66,8.55,94.71,94.71,0,0,0,13,.94h1.6l1.39,0c1,0,1.93,0,2.84-.07,1.87-.05,3.79-.14,5.69-.26a167.14,167.14,0,0,0,45-9A148.35,148.35,0,0,0,390.39,371,140,140,0,0,0,441.5,293.6,155.89,155.89,0,0,0,446,247.79a162,162,0,0,0-8.29-44.93,152.92,152.92,0,0,0-21-40.87,155.5,155.5,0,0,0-32-32.74A167,167,0,0,0,301.71,96.4a185.25,185.25,0,0,0-22.24-1.11c-7.17.09-14.4.49-21.51,1.2a239.16,239.16,0,0,0-42.29,8.1,225.88,225.88,0,0,0-76.51,38.84,211.35,211.35,0,0,0-55.49,65.3,219.75,219.75,0,0,0-25.05,81.15A247.29,247.29,0,0,0,57.84,332a234.14,234.14,0,0,0,6.66,41.54A221.33,221.33,0,0,0,100.17,449,217.9,217.9,0,0,0,128,480,220.46,220.46,0,0,0,160.85,505a244.85,244.85,0,0,0,75.4,30.85,295.93,295.93,0,0,0,66,7.27q7,0,14.07-.31a4,4,0,0,0,0-8c-27.43-1.23-53.14-5.48-76.39-12.62-6.29-1.94-12.4-4.05-18.14-6.27-5.94-2.32-11.84-4.9-17.54-7.66A223.72,223.72,0,0,1,171.58,489a200.79,200.79,0,0,1-51.82-53.66,194.09,194.09,0,0,1-28.09-68.13,206.75,206.75,0,0,1-4.18-36.61,218.06,218.06,0,0,1,2.28-36.77,185.5,185.5,0,0,1,23.84-68.1,178.87,178.87,0,0,1,48-52.74,189,189,0,0,1,64.53-30.34,198.5,198.5,0,0,1,35.38-5.81c5.93-.44,12-.62,17.91-.53a141.29,141.29,0,0,1,17.22,1.33c23.12,3.11,44.43,12,61.64,25.75a111.63,111.63,0,0,1,37,53.48,116.89,116.89,0,0,1,5.49,32.61A110.59,110.59,0,0,1,397.11,282,96.37,96.37,0,0,1,384,310.82a93.81,93.81,0,0,1-21.79,22.79,103.63,103.63,0,0,1-28.39,14.88,120,120,0,0,1-32.31,6.19c-1.4.08-2.8.13-4.23.16-.61,0-1.21,0-1.82,0h-2.27a48.07,48.07,0,0,1-6.6-.5A31.48,31.48,0,0,1,275.78,351a20.8,20.8,0,0,1-7-6,19,19,0,0,1-3.41-7.94,18.61,18.61,0,0,1,.46-8.53,16.47,16.47,0,0,1,4.08-6.92,20.27,20.27,0,0,1,7.66-4.76,31.63,31.63,0,0,1,5.38-1.43,45.37,45.37,0,0,1,6.31-.6l5.28-.11h.18l3.31-.23c.85-.06,1.7-.16,2.55-.26l.95-.11a76.87,76.87,0,0,0,14-3.15A65.75,65.75,0,0,0,351.41,283,67.38,67.38,0,0,0,358,269.07,68.91,68.91,0,0,0,361,239.13a67.56,67.56,0,0,0-10.24-28.54,66,66,0,0,0-22-21.15A74.29,74.29,0,0,0,301.6,180a92,92,0,0,0-13.36-1c-4.5,0-8,.13-11.37.36a167.85,167.85,0,0,0-45,8.94,147.55,147.55,0,0,0-41.19,22,139.57,139.57,0,0,0-51,77.56,152.89,152.89,0,0,0-3.93,22.9c-.39,4.39-.61,8-.67,11.48-.09,4.46,0,8.13.16,11.54a151.39,151.39,0,0,0,9.4,45.25,159.53,159.53,0,0,0,21.92,40.09,169,169,0,0,0,70.93,54.75,166.11,166.11,0,0,0,43.7,11.25c4.51.48,8,.75,11.18.88,1.44.08,2.87.11,4.25.14l1.37,0h1.71c1.32,0,2.67,0,3.87,0,6.76-.09,13.92-.49,21.29-1.18a248.58,248.58,0,0,0,42.22-7.6,220.77,220.77,0,0,0,40.43-15.29,208.26,208.26,0,0,0,36.61-23.25,205.59,205.59,0,0,0,54.56-66.34,225.76,225.76,0,0,0,24.06-81.22A248.76,248.76,0,0,0,523.54,249.16Z'/%3e%3c/g%3e%3c/svg%3e",
"external_url": "https://www.orca.so/whirlpools/",
"collection": {
"name": "Orca Whirlpool Position",
"family": "Orca Whirlpool Position"
}
}

1
sdk/.gitignore vendored
View File

@ -1 +0,0 @@
.npmrc

View File

@ -1,2 +0,0 @@
# Ignore artifacts:
src/artifacts

View File

@ -1,3 +0,0 @@
{
"printWidth": 100
}

View File

@ -1,36 +0,0 @@
# Whirlpools
Whirpools is an open-source concentrated liquidity AMM contract on the Solana blockchain.
The Whirlpools Typescript SDK (`@orca-so/whirlpools-sdk`) allows for easy interaction with a deployed Whirlpools program.
The contract has been audited by Kudelski and Neodyme.
# Whirlpool SDK
Use the SDK to interact with a deployed Whirlpools program via Typescript.
## Installation
In your package, run:
```
yarn add `@orca-so/whirlpools-sdk`
yarn add "@coral-xyz/anchor"
yarn add "decimal.js"
```
## Usage
Read instructions on how to use the SDK on the [Orca Developer Portal](https://orca-so.gitbook.io/orca-developer-portal/orca/welcome).
## Tests
To run tests for the SDK, setup your anchor environment and run:
```
anchor test
```
# License
[Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)

View File

@ -1,20 +0,0 @@
module.exports = {
"roots": [
"<rootDir>/src",
"<rootDir>/tests/sdk",
"<rootDir>/tests/integration"
],
"testMatch": [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
globals: {
"ts-jest": {
tsconfig: "./tests/tsconfig.json"
}
},
testTimeout: 30 * 1000
}

View File

@ -1,76 +0,0 @@
{
"name": "@orca-so/whirlpools-sdk",
"version": "0.12.5",
"description": "Typescript SDK to interact with Orca's Whirlpool program.",
"license": "Apache-2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"peerDependencies": {
"@coral-xyz/anchor": "~0.27.0",
"@orca-so/common-sdk": "^0.5.2",
"@solana/spl-token": "^0.3.8",
"@solana/web3.js": "^1.75.0",
"decimal.js": "^10.3.1"
},
"dependencies": {
"tiny-invariant": "^1.3.1"
},
"devDependencies": {
"@coral-xyz/anchor": "^0.27.0",
"@metaplex-foundation/mpl-token-metadata": "2.12.0",
"@orca-so/common-sdk": "^0.5.3",
"@solana/spl-token": "^0.3.11",
"@solana/web3.js": "^1.88.0",
"@types/bn.js": "~5.1.5",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.8",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"chai": "^5.0.0",
"decimal.js": "^10.4.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"mocha": "^10.2.0",
"prettier": "^3.1.1",
"process": "^0.11.10",
"rimraf": "^5.0.5",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.2",
"typedoc": "~0.25.7",
"typescript": "^5.3.3"
},
"scripts": {
"build": "rimraf dist && tsc -p src",
"clean": "rimraf dist",
"watch": "tsc -w -p src",
"prepublishOnly": "yarn build",
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"test": "anchor test",
"docs": "npx typedoc --options typedoc.json"
},
"lint-staged": {
"*.{ts,md}": "yarn run prettier-format"
},
"files": [
".yalc",
"/dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/orca-so/whirlpools.git"
},
"keywords": [
"orca_so",
"orca",
"solana",
"typescript",
"sdk",
"crypto",
"dex"
],
"author": "team@orca.so",
"bugs": {
"url": "https://github.com/orca-so/whirlpools/issues"
},
"homepage": "https://www.orca.so"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,134 +0,0 @@
import { AnchorProvider, Idl, Program } from "@coral-xyz/anchor";
import {
BuildOptions,
LookupTableFetcher,
TransactionBuilderOptions,
Wallet,
WrappedSolAccountCreateMethod,
} from "@orca-so/common-sdk";
import { Commitment, Connection, PublicKey, SendOptions } from "@solana/web3.js";
import { Whirlpool } from "./artifacts/whirlpool";
import WhirlpoolIDL from "./artifacts/whirlpool.json";
import { WhirlpoolAccountFetcherInterface, buildDefaultAccountFetcher } from "./network/public/";
import { contextOptionsToBuilderOptions } from "./utils/txn-utils";
/**
* Default settings used when interacting with transactions.
* @category Core
*/
export type WhirlpoolContextOpts = {
userDefaultBuildOptions?: Partial<BuildOptions>;
userDefaultSendOptions?: Partial<SendOptions>;
userDefaultConfirmCommitment?: Commitment;
accountResolverOptions?: AccountResolverOptions;
};
/**
* Default settings used when resolving token accounts.
* @category Core
*/
export type AccountResolverOptions = {
createWrappedSolAccountMethod: WrappedSolAccountCreateMethod;
allowPDAOwnerAddress: boolean;
};
const DEFAULT_ACCOUNT_RESOLVER_OPTS: AccountResolverOptions = {
createWrappedSolAccountMethod: "keypair",
allowPDAOwnerAddress: false,
};
/**
* Context for storing environment classes and objects for usage throughout the SDK
* @category Core
*/
export class WhirlpoolContext {
readonly connection: Connection;
readonly wallet: Wallet;
readonly program: Program<Whirlpool>;
readonly provider: AnchorProvider;
readonly fetcher: WhirlpoolAccountFetcherInterface;
readonly lookupTableFetcher: LookupTableFetcher | undefined;
readonly opts: WhirlpoolContextOpts;
readonly txBuilderOpts: TransactionBuilderOptions | undefined;
readonly accountResolverOpts: AccountResolverOptions;
public static from(
connection: Connection,
wallet: Wallet,
programId: PublicKey,
fetcher: WhirlpoolAccountFetcherInterface = buildDefaultAccountFetcher(connection),
lookupTableFetcher?: LookupTableFetcher,
opts: WhirlpoolContextOpts = {}
): WhirlpoolContext {
const anchorProvider = new AnchorProvider(connection, wallet, {
commitment: opts.userDefaultConfirmCommitment || "confirmed",
preflightCommitment: opts.userDefaultConfirmCommitment || "confirmed",
});
const program = new Program(WhirlpoolIDL as Idl, programId, anchorProvider);
return new WhirlpoolContext(
anchorProvider,
anchorProvider.wallet,
program,
fetcher,
lookupTableFetcher,
opts
);
}
public static fromWorkspace(
provider: AnchorProvider,
program: Program,
fetcher: WhirlpoolAccountFetcherInterface = buildDefaultAccountFetcher(provider.connection),
lookupTableFetcher?: LookupTableFetcher,
opts: WhirlpoolContextOpts = {}
) {
return new WhirlpoolContext(
provider,
provider.wallet,
program,
fetcher,
lookupTableFetcher,
opts
);
}
public static withProvider(
provider: AnchorProvider,
programId: PublicKey,
fetcher: WhirlpoolAccountFetcherInterface = buildDefaultAccountFetcher(provider.connection),
lookupTableFetcher?: LookupTableFetcher,
opts: WhirlpoolContextOpts = {}
): WhirlpoolContext {
const program = new Program(WhirlpoolIDL as Idl, programId, provider);
return new WhirlpoolContext(
provider,
provider.wallet,
program,
fetcher,
lookupTableFetcher,
opts
);
}
public constructor(
provider: AnchorProvider,
wallet: Wallet,
program: Program,
fetcher: WhirlpoolAccountFetcherInterface,
lookupTableFetcher?: LookupTableFetcher,
opts: WhirlpoolContextOpts = {}
) {
this.connection = provider.connection;
this.wallet = wallet;
// It's a hack but it works on Anchor workspace *shrug*
this.program = program as unknown as Program<Whirlpool>;
this.provider = provider;
this.fetcher = fetcher;
this.lookupTableFetcher = lookupTableFetcher;
this.opts = opts;
this.txBuilderOpts = contextOptionsToBuilderOptions(this.opts);
this.accountResolverOpts = opts.accountResolverOptions ?? DEFAULT_ACCOUNT_RESOLVER_OPTS;
}
// TODO: Add another factory method to build from on-chain IDL
}

View File

@ -1,51 +0,0 @@
export enum MathErrorCode {
MultiplicationOverflow = `MultiplicationOverflow`,
MulDivOverflow = `MulDivOverflow`,
MultiplicationShiftRightOverflow = `MultiplicationShiftRightOverflow`,
DivideByZero = `DivideByZero`,
}
export enum TokenErrorCode {
TokenMaxExceeded = `TokenMaxExceeded`,
TokenMinSubceeded = `TokenMinSubceeded`,
}
export enum SwapErrorCode {
InvalidDevFeePercentage = `InvalidDevFeePercentage`,
InvalidSqrtPriceLimitDirection = `InvalidSqrtPriceLimitDirection`,
SqrtPriceOutOfBounds = `SqrtPriceOutOfBounds`,
ZeroTradableAmount = `ZeroTradableAmount`,
AmountOutBelowMinimum = `AmountOutBelowMinimum`,
AmountInAboveMaximum = `AmountInAboveMaximum`,
TickArrayCrossingAboveMax = `TickArrayCrossingAboveMax`,
TickArrayIndexNotInitialized = `TickArrayIndexNotInitialized`,
TickArraySequenceInvalid = `TickArraySequenceInvalid`,
}
export enum RouteQueryErrorCode {
RouteDoesNotExist = "RouteDoesNotExist",
TradeAmountTooHigh = "TradeAmountTooHigh",
ZeroInputAmount = "ZeroInputAmount",
General = "General",
}
export type WhirlpoolsErrorCode =
| TokenErrorCode
| SwapErrorCode
| MathErrorCode
| RouteQueryErrorCode;
export class WhirlpoolsError extends Error {
message: string;
errorCode?: WhirlpoolsErrorCode;
constructor(message: string, errorCode?: WhirlpoolsErrorCode, stack?: string) {
super(message);
this.message = message;
this.errorCode = errorCode;
this.stack = stack;
}
public static isWhirlpoolsErrorCode(e: any, code: WhirlpoolsErrorCode): boolean {
return e instanceof WhirlpoolsError && e.errorCode === code;
}
}

View File

@ -1,530 +0,0 @@
import { Address } from "@coral-xyz/anchor";
import {
AddressUtil,
Instruction,
TokenUtil,
TransactionBuilder,
ZERO,
resolveOrCreateATAs,
} from "@orca-so/common-sdk";
import { NATIVE_MINT, getAssociatedTokenAddressSync } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import invariant from "tiny-invariant";
import { WhirlpoolContext } from "../context";
import {
DecreaseLiquidityInput,
IncreaseLiquidityInput,
collectFeesIx,
collectRewardIx,
decreaseLiquidityIx,
increaseLiquidityIx,
updateFeesAndRewardsIx,
} from "../instructions";
import {
IGNORE_CACHE,
PREFER_CACHE,
WhirlpoolAccountFetchOptions,
} from "../network/public/fetcher";
import { PositionData, TickArrayData, TickData, WhirlpoolData } from "../types/public";
import { getTickArrayDataForPosition } from "../utils/builder/position-builder-util";
import { PDAUtil, PoolUtil, TickArrayUtil, TickUtil } from "../utils/public";
import {
TokenMintTypes,
getTokenMintsFromWhirlpools,
resolveAtaForMints,
} from "../utils/whirlpool-ata-utils";
import { Position } from "../whirlpool-client";
export class PositionImpl implements Position {
private data: PositionData;
private whirlpoolData: WhirlpoolData;
private lowerTickArrayData: TickArrayData;
private upperTickArrayData: TickArrayData;
constructor(
readonly ctx: WhirlpoolContext,
readonly address: PublicKey,
data: PositionData,
whirlpoolData: WhirlpoolData,
lowerTickArrayData: TickArrayData,
upperTickArrayData: TickArrayData
) {
this.data = data;
this.whirlpoolData = whirlpoolData;
this.lowerTickArrayData = lowerTickArrayData;
this.upperTickArrayData = upperTickArrayData;
}
getAddress(): PublicKey {
return this.address;
}
getData(): PositionData {
return this.data;
}
getWhirlpoolData(): WhirlpoolData {
return this.whirlpoolData;
}
getLowerTickData(): TickData {
return TickArrayUtil.getTickFromArray(
this.lowerTickArrayData,
this.data.tickLowerIndex,
this.whirlpoolData.tickSpacing
);
}
getUpperTickData(): TickData {
return TickArrayUtil.getTickFromArray(
this.upperTickArrayData,
this.data.tickUpperIndex,
this.whirlpoolData.tickSpacing
);
}
async refreshData() {
await this.refresh();
return this.data;
}
async increaseLiquidity(
liquidityInput: IncreaseLiquidityInput,
resolveATA = true,
sourceWallet?: Address,
positionWallet?: Address,
ataPayer?: Address
) {
const sourceWalletKey = sourceWallet
? AddressUtil.toPubKey(sourceWallet)
: this.ctx.wallet.publicKey;
const positionWalletKey = positionWallet
? AddressUtil.toPubKey(positionWallet)
: this.ctx.wallet.publicKey;
const ataPayerKey = ataPayer ? AddressUtil.toPubKey(ataPayer) : this.ctx.wallet.publicKey;
const whirlpool = await this.ctx.fetcher.getPool(this.data.whirlpool, IGNORE_CACHE);
if (!whirlpool) {
throw new Error("Unable to fetch whirlpool for this position.");
}
const txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
let tokenOwnerAccountA: PublicKey;
let tokenOwnerAccountB: PublicKey;
if (resolveATA) {
const [ataA, ataB] = await resolveOrCreateATAs(
this.ctx.connection,
sourceWalletKey,
[
{ tokenMint: whirlpool.tokenMintA, wrappedSolAmountIn: liquidityInput.tokenMaxA },
{ tokenMint: whirlpool.tokenMintB, wrappedSolAmountIn: liquidityInput.tokenMaxB },
],
() => this.ctx.fetcher.getAccountRentExempt(),
ataPayerKey,
undefined, // use default
this.ctx.accountResolverOpts.allowPDAOwnerAddress,
this.ctx.accountResolverOpts.createWrappedSolAccountMethod
);
const { address: ataAddrA, ...tokenOwnerAccountAIx } = ataA!;
const { address: ataAddrB, ...tokenOwnerAccountBIx } = ataB!;
tokenOwnerAccountA = ataAddrA;
tokenOwnerAccountB = ataAddrB;
txBuilder.addInstruction(tokenOwnerAccountAIx);
txBuilder.addInstruction(tokenOwnerAccountBIx);
} else {
tokenOwnerAccountA = getAssociatedTokenAddressSync(
whirlpool.tokenMintA,
sourceWalletKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
tokenOwnerAccountB = getAssociatedTokenAddressSync(
whirlpool.tokenMintB,
sourceWalletKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
}
const positionTokenAccount = getAssociatedTokenAddressSync(
this.data.positionMint,
positionWalletKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
const increaseIx = increaseLiquidityIx(this.ctx.program, {
...liquidityInput,
whirlpool: this.data.whirlpool,
position: this.address,
positionTokenAccount,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA: whirlpool.tokenVaultA,
tokenVaultB: whirlpool.tokenVaultB,
tickArrayLower: PDAUtil.getTickArray(
this.ctx.program.programId,
this.data.whirlpool,
TickUtil.getStartTickIndex(this.data.tickLowerIndex, whirlpool.tickSpacing)
).publicKey,
tickArrayUpper: PDAUtil.getTickArray(
this.ctx.program.programId,
this.data.whirlpool,
TickUtil.getStartTickIndex(this.data.tickUpperIndex, whirlpool.tickSpacing)
).publicKey,
positionAuthority: positionWalletKey,
});
txBuilder.addInstruction(increaseIx);
return txBuilder;
}
async decreaseLiquidity(
liquidityInput: DecreaseLiquidityInput,
resolveATA = true,
sourceWallet?: Address,
positionWallet?: Address,
ataPayer?: Address
) {
const sourceWalletKey = sourceWallet
? AddressUtil.toPubKey(sourceWallet)
: this.ctx.wallet.publicKey;
const positionWalletKey = positionWallet
? AddressUtil.toPubKey(positionWallet)
: this.ctx.wallet.publicKey;
const ataPayerKey = ataPayer ? AddressUtil.toPubKey(ataPayer) : this.ctx.wallet.publicKey;
const whirlpool = await this.ctx.fetcher.getPool(this.data.whirlpool, IGNORE_CACHE);
if (!whirlpool) {
throw new Error("Unable to fetch whirlpool for this position.");
}
const txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
let tokenOwnerAccountA: PublicKey;
let tokenOwnerAccountB: PublicKey;
if (resolveATA) {
const [ataA, ataB] = await resolveOrCreateATAs(
this.ctx.connection,
sourceWalletKey,
[{ tokenMint: whirlpool.tokenMintA }, { tokenMint: whirlpool.tokenMintB }],
() => this.ctx.fetcher.getAccountRentExempt(),
ataPayerKey,
undefined, // use default
this.ctx.accountResolverOpts.allowPDAOwnerAddress,
this.ctx.accountResolverOpts.createWrappedSolAccountMethod
);
const { address: ataAddrA, ...tokenOwnerAccountAIx } = ataA!;
const { address: ataAddrB, ...tokenOwnerAccountBIx } = ataB!;
tokenOwnerAccountA = ataAddrA;
tokenOwnerAccountB = ataAddrB;
txBuilder.addInstruction(tokenOwnerAccountAIx);
txBuilder.addInstruction(tokenOwnerAccountBIx);
} else {
tokenOwnerAccountA = getAssociatedTokenAddressSync(
whirlpool.tokenMintA,
sourceWalletKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
tokenOwnerAccountB = getAssociatedTokenAddressSync(
whirlpool.tokenMintB,
sourceWalletKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
}
const decreaseIx = decreaseLiquidityIx(this.ctx.program, {
...liquidityInput,
whirlpool: this.data.whirlpool,
position: this.address,
positionTokenAccount: getAssociatedTokenAddressSync(
this.data.positionMint,
positionWalletKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
),
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA: whirlpool.tokenVaultA,
tokenVaultB: whirlpool.tokenVaultB,
tickArrayLower: PDAUtil.getTickArray(
this.ctx.program.programId,
this.data.whirlpool,
TickUtil.getStartTickIndex(this.data.tickLowerIndex, whirlpool.tickSpacing)
).publicKey,
tickArrayUpper: PDAUtil.getTickArray(
this.ctx.program.programId,
this.data.whirlpool,
TickUtil.getStartTickIndex(this.data.tickUpperIndex, whirlpool.tickSpacing)
).publicKey,
positionAuthority: positionWalletKey,
});
txBuilder.addInstruction(decreaseIx);
return txBuilder;
}
async collectFees(
updateFeesAndRewards: boolean = true,
ownerTokenAccountMap?: Partial<Record<string, Address>>,
destinationWallet?: Address,
positionWallet?: Address,
ataPayer?: Address,
opts: WhirlpoolAccountFetchOptions = PREFER_CACHE
): Promise<TransactionBuilder> {
const [destinationWalletKey, positionWalletKey, ataPayerKey] = AddressUtil.toPubKeys([
destinationWallet ?? this.ctx.wallet.publicKey,
positionWallet ?? this.ctx.wallet.publicKey,
ataPayer ?? this.ctx.wallet.publicKey,
]);
const whirlpool = await this.ctx.fetcher.getPool(this.data.whirlpool, opts);
if (!whirlpool) {
throw new Error(
`Unable to fetch whirlpool (${this.data.whirlpool}) for this position (${this.address}).`
);
}
let txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
const accountExemption = await this.ctx.fetcher.getAccountRentExempt();
let ataMap = { ...ownerTokenAccountMap };
if (!ownerTokenAccountMap) {
const affliatedMints = getTokenMintsFromWhirlpools([whirlpool], TokenMintTypes.POOL_ONLY);
const { ataTokenAddresses: affliatedTokenAtaMap, resolveAtaIxs } = await resolveAtaForMints(
this.ctx,
{
mints: affliatedMints.mintMap,
accountExemption,
receiver: destinationWalletKey,
payer: ataPayerKey,
}
);
txBuilder.addInstructions(resolveAtaIxs);
if (affliatedMints.hasNativeMint) {
let { address: wSOLAta, ...resolveWSolIx } =
TokenUtil.createWrappedNativeAccountInstruction(
destinationWalletKey,
ZERO,
accountExemption,
ataPayerKey,
destinationWalletKey,
this.ctx.accountResolverOpts.createWrappedSolAccountMethod
);
affliatedTokenAtaMap[NATIVE_MINT.toBase58()] = wSOLAta;
txBuilder.addInstruction(resolveWSolIx);
}
ataMap = { ...affliatedTokenAtaMap };
}
const tokenOwnerAccountA = ataMap[whirlpool.tokenMintA.toBase58()];
invariant(
!!tokenOwnerAccountA,
`No owner token account provided for wallet ${destinationWalletKey.toBase58()} for token A ${whirlpool.tokenMintA.toBase58()} `
);
const tokenOwnerAccountB = ataMap[whirlpool.tokenMintB.toBase58()];
invariant(
!!tokenOwnerAccountB,
`No owner token account provided for wallet ${destinationWalletKey.toBase58()} for token B ${whirlpool.tokenMintB.toBase58()} `
);
const positionTokenAccount = getAssociatedTokenAddressSync(
this.data.positionMint,
positionWalletKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
if (updateFeesAndRewards && !this.data.liquidity.isZero()) {
const updateIx = await this.updateFeesAndRewards();
txBuilder.addInstruction(updateIx);
}
const ix = collectFeesIx(this.ctx.program, {
whirlpool: this.data.whirlpool,
position: this.address,
positionTokenAccount,
tokenOwnerAccountA: AddressUtil.toPubKey(tokenOwnerAccountA),
tokenOwnerAccountB: AddressUtil.toPubKey(tokenOwnerAccountB),
tokenVaultA: whirlpool.tokenVaultA,
tokenVaultB: whirlpool.tokenVaultB,
positionAuthority: positionWalletKey,
});
txBuilder.addInstruction(ix);
return txBuilder;
}
async collectRewards(
rewardsToCollect?: Address[],
updateFeesAndRewards: boolean = true,
ownerTokenAccountMap?: Partial<Record<string, Address>>,
destinationWallet?: Address,
positionWallet?: Address,
ataPayer?: Address,
opts: WhirlpoolAccountFetchOptions = IGNORE_CACHE
): Promise<TransactionBuilder> {
const [destinationWalletKey, positionWalletKey, ataPayerKey] = AddressUtil.toPubKeys([
destinationWallet ?? this.ctx.wallet.publicKey,
positionWallet ?? this.ctx.wallet.publicKey,
ataPayer ?? this.ctx.wallet.publicKey,
]);
const whirlpool = await this.ctx.fetcher.getPool(this.data.whirlpool, opts);
if (!whirlpool) {
throw new Error(
`Unable to fetch whirlpool(${this.data.whirlpool}) for this position(${this.address}).`
);
}
const initializedRewards = whirlpool.rewardInfos.filter((info) =>
PoolUtil.isRewardInitialized(info)
);
const txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
const accountExemption = await this.ctx.fetcher.getAccountRentExempt();
let ataMap = { ...ownerTokenAccountMap };
if (!ownerTokenAccountMap) {
const rewardMints = getTokenMintsFromWhirlpools([whirlpool], TokenMintTypes.REWARD_ONLY);
const { ataTokenAddresses: affliatedTokenAtaMap, resolveAtaIxs } = await resolveAtaForMints(
this.ctx,
{
mints: rewardMints.mintMap,
accountExemption,
receiver: destinationWalletKey,
payer: ataPayerKey,
}
);
if (rewardMints.hasNativeMint) {
let { address: wSOLAta, ...resolveWSolIx } =
TokenUtil.createWrappedNativeAccountInstruction(
destinationWalletKey,
ZERO,
accountExemption,
ataPayerKey,
destinationWalletKey,
this.ctx.accountResolverOpts.createWrappedSolAccountMethod
);
affliatedTokenAtaMap[NATIVE_MINT.toBase58()] = wSOLAta;
txBuilder.addInstruction(resolveWSolIx);
}
txBuilder.addInstructions(resolveAtaIxs);
ataMap = { ...affliatedTokenAtaMap };
}
const positionTokenAccount = getAssociatedTokenAddressSync(
this.data.positionMint,
positionWalletKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
if (updateFeesAndRewards && !this.data.liquidity.isZero()) {
const updateIx = await this.updateFeesAndRewards();
txBuilder.addInstruction(updateIx);
}
initializedRewards.forEach((info, index) => {
if (
rewardsToCollect &&
!rewardsToCollect.some((r) => r.toString() === info.mint.toBase58())
) {
// If rewardsToCollect is specified and this reward is not in it,
// don't include collectIX for that in TX
return;
}
const rewardOwnerAccount = ataMap[info.mint.toBase58()];
invariant(
!!rewardOwnerAccount,
`No owner token account provided for wallet ${destinationWalletKey.toBase58()} for reward ${index} token ${info.mint.toBase58()} `
);
const ix = collectRewardIx(this.ctx.program, {
whirlpool: this.data.whirlpool,
position: this.address,
positionTokenAccount,
rewardIndex: index,
rewardOwnerAccount: AddressUtil.toPubKey(rewardOwnerAccount),
rewardVault: info.vault,
positionAuthority: positionWalletKey,
});
txBuilder.addInstruction(ix);
});
return txBuilder;
}
private async refresh() {
const positionAccount = await this.ctx.fetcher.getPosition(this.address, IGNORE_CACHE);
if (!!positionAccount) {
this.data = positionAccount;
}
const whirlpoolAccount = await this.ctx.fetcher.getPool(this.data.whirlpool, IGNORE_CACHE);
if (!!whirlpoolAccount) {
this.whirlpoolData = whirlpoolAccount;
}
const [lowerTickArray, upperTickArray] = await getTickArrayDataForPosition(
this.ctx,
this.data,
this.whirlpoolData,
IGNORE_CACHE
);
if (lowerTickArray) {
this.lowerTickArrayData = lowerTickArray;
}
if (upperTickArray) {
this.upperTickArrayData = upperTickArray;
}
}
private async updateFeesAndRewards(): Promise<Instruction> {
const whirlpool = await this.ctx.fetcher.getPool(this.data.whirlpool);
if (!whirlpool) {
throw new Error(
`Unable to fetch whirlpool(${this.data.whirlpool}) for this position(${this.address}).`
);
}
const [tickArrayLowerPda, tickArrayUpperPda] = [
this.data.tickLowerIndex,
this.data.tickUpperIndex,
].map((tickIndex) =>
PDAUtil.getTickArrayFromTickIndex(
tickIndex,
whirlpool.tickSpacing,
this.data.whirlpool,
this.ctx.program.programId
)
);
const updateIx = updateFeesAndRewardsIx(this.ctx.program, {
whirlpool: this.data.whirlpool,
position: this.address,
tickArrayLower: tickArrayLowerPda.publicKey,
tickArrayUpper: tickArrayUpperPda.publicKey,
});
return updateIx;
}
}

View File

@ -1,80 +0,0 @@
import BN from "bn.js";
import { PoolUtil, TokenInfo } from "..";
import {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
} from "../network/public/fetcher";
import {
TokenAccountInfo,
WhirlpoolData,
WhirlpoolRewardInfo,
WhirlpoolRewardInfoData,
} from "../types/public";
export async function getTokenMintInfos(
fetcher: WhirlpoolAccountFetcherInterface,
data: WhirlpoolData,
opts?: WhirlpoolAccountFetchOptions
): Promise<TokenInfo[]> {
const mintA = data.tokenMintA;
const infoA = await fetcher.getMintInfo(mintA, opts);
if (!infoA) {
throw new Error(`Unable to fetch MintInfo for mint - ${mintA}`);
}
const mintB = data.tokenMintB;
const infoB = await fetcher.getMintInfo(mintB, opts);
if (!infoB) {
throw new Error(`Unable to fetch MintInfo for mint - ${mintB}`);
}
return [
{ mint: mintA, ...infoA },
{ mint: mintB, ...infoB },
];
}
export async function getRewardInfos(
fetcher: WhirlpoolAccountFetcherInterface,
data: WhirlpoolData,
opts?: WhirlpoolAccountFetchOptions
): Promise<WhirlpoolRewardInfo[]> {
const rewardInfos: WhirlpoolRewardInfo[] = [];
for (const rewardInfo of data.rewardInfos) {
rewardInfos.push(await getRewardInfo(fetcher, rewardInfo, opts));
}
return rewardInfos;
}
async function getRewardInfo(
fetcher: WhirlpoolAccountFetcherInterface,
data: WhirlpoolRewardInfoData,
opts?: WhirlpoolAccountFetchOptions
): Promise<WhirlpoolRewardInfo> {
const rewardInfo = { ...data, initialized: false, vaultAmount: new BN(0) };
if (PoolUtil.isRewardInitialized(data)) {
const vaultInfo = await fetcher.getTokenInfo(data.vault, opts);
if (!vaultInfo) {
throw new Error(`Unable to fetch TokenAccountInfo for vault - ${data.vault}`);
}
rewardInfo.initialized = true;
rewardInfo.vaultAmount = new BN(vaultInfo.amount.toString());
}
return rewardInfo;
}
export async function getTokenVaultAccountInfos(
fetcher: WhirlpoolAccountFetcherInterface,
data: WhirlpoolData,
opts?: WhirlpoolAccountFetchOptions
): Promise<TokenAccountInfo[]> {
const vaultA = data.tokenVaultA;
const vaultInfoA = await fetcher.getTokenInfo(vaultA, opts);
if (!vaultInfoA) {
throw new Error(`Unable to fetch TokenAccountInfo for vault - ${vaultA}`);
}
const vaultB = data.tokenVaultB;
const vaultInfoB = await fetcher.getTokenInfo(vaultB, opts);
if (!vaultInfoB) {
throw new Error(`Unable to fetch TokenAccountInfo for vault - ${vaultB}`);
}
return [vaultInfoA, vaultInfoB];
}

View File

@ -1,299 +0,0 @@
import { Address } from "@coral-xyz/anchor";
import { AddressUtil, TransactionBuilder } from "@orca-so/common-sdk";
import { Keypair, PublicKey } from "@solana/web3.js";
import invariant from "tiny-invariant";
import { WhirlpoolContext } from "../context";
import { initTickArrayIx } from "../instructions";
import {
collectAllForPositionAddressesTxns,
collectProtocolFees,
} from "../instructions/composites";
import { WhirlpoolIx } from "../ix";
import {
IGNORE_CACHE,
PREFER_CACHE,
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
} from "../network/public/fetcher";
import { WhirlpoolRouter, WhirlpoolRouterBuilder } from "../router/public";
import { WhirlpoolData } from "../types/public";
import { getTickArrayDataForPosition } from "../utils/builder/position-builder-util";
import { PDAUtil, PoolUtil, PriceMath, TickUtil } from "../utils/public";
import { Position, Whirlpool, WhirlpoolClient } from "../whirlpool-client";
import { PositionImpl } from "./position-impl";
import { getRewardInfos, getTokenMintInfos, getTokenVaultAccountInfos } from "./util";
import { WhirlpoolImpl } from "./whirlpool-impl";
export class WhirlpoolClientImpl implements WhirlpoolClient {
constructor(readonly ctx: WhirlpoolContext) {}
public getContext(): WhirlpoolContext {
return this.ctx;
}
public getFetcher(): WhirlpoolAccountFetcherInterface {
return this.ctx.fetcher;
}
public getRouter(poolAddresses: Address[]): Promise<WhirlpoolRouter> {
return WhirlpoolRouterBuilder.buildWithPools(this.ctx, poolAddresses);
}
public async getPool(poolAddress: Address, opts = PREFER_CACHE): Promise<Whirlpool> {
const account = await this.ctx.fetcher.getPool(poolAddress, opts);
if (!account) {
throw new Error(`Unable to fetch Whirlpool at address at ${poolAddress}`);
}
const tokenInfos = await getTokenMintInfos(this.ctx.fetcher, account, opts);
const vaultInfos = await getTokenVaultAccountInfos(this.ctx.fetcher, account, opts);
const rewardInfos = await getRewardInfos(this.ctx.fetcher, account, opts);
return new WhirlpoolImpl(
this.ctx,
AddressUtil.toPubKey(poolAddress),
tokenInfos[0],
tokenInfos[1],
vaultInfos[0],
vaultInfos[1],
rewardInfos,
account
);
}
public async getPools(poolAddresses: Address[], opts = PREFER_CACHE): Promise<Whirlpool[]> {
const accounts = Array.from(
(await this.ctx.fetcher.getPools(poolAddresses, opts)).values()
).filter((account): account is WhirlpoolData => !!account);
if (accounts.length !== poolAddresses.length) {
throw new Error(`Unable to fetch all Whirlpools at addresses ${poolAddresses}`);
}
const tokenMints = new Set<string>();
const tokenAccounts = new Set<string>();
accounts.forEach((account) => {
tokenMints.add(account.tokenMintA.toBase58());
tokenMints.add(account.tokenMintB.toBase58());
tokenAccounts.add(account.tokenVaultA.toBase58());
tokenAccounts.add(account.tokenVaultB.toBase58());
account.rewardInfos.forEach((rewardInfo) => {
if (PoolUtil.isRewardInitialized(rewardInfo)) {
tokenAccounts.add(rewardInfo.vault.toBase58());
}
});
});
await this.ctx.fetcher.getMintInfos(Array.from(tokenMints), opts);
await this.ctx.fetcher.getTokenInfos(Array.from(tokenAccounts), opts);
const whirlpools: Whirlpool[] = [];
for (let i = 0; i < accounts.length; i++) {
const account = accounts[i];
const poolAddress = poolAddresses[i];
const tokenInfos = await getTokenMintInfos(this.ctx.fetcher, account, PREFER_CACHE);
const vaultInfos = await getTokenVaultAccountInfos(this.ctx.fetcher, account, PREFER_CACHE);
const rewardInfos = await getRewardInfos(this.ctx.fetcher, account, PREFER_CACHE);
whirlpools.push(
new WhirlpoolImpl(
this.ctx,
AddressUtil.toPubKey(poolAddress),
tokenInfos[0],
tokenInfos[1],
vaultInfos[0],
vaultInfos[1],
rewardInfos,
account
)
);
}
return whirlpools;
}
public async getPosition(positionAddress: Address, opts = PREFER_CACHE): Promise<Position> {
const account = await this.ctx.fetcher.getPosition(positionAddress, opts);
if (!account) {
throw new Error(`Unable to fetch Position at address at ${positionAddress}`);
}
const whirlAccount = await this.ctx.fetcher.getPool(account.whirlpool, opts);
if (!whirlAccount) {
throw new Error(`Unable to fetch Whirlpool for Position at address at ${positionAddress}`);
}
const [lowerTickArray, upperTickArray] = await getTickArrayDataForPosition(
this.ctx,
account,
whirlAccount,
opts
);
if (!lowerTickArray || !upperTickArray) {
throw new Error(`Unable to fetch TickArrays for Position at address at ${positionAddress}`);
}
return new PositionImpl(
this.ctx,
AddressUtil.toPubKey(positionAddress),
account,
whirlAccount,
lowerTickArray,
upperTickArray
);
}
public async getPositions(
positionAddresses: Address[],
opts = PREFER_CACHE
): Promise<Record<string, Position | null>> {
// TODO: Prefetch and use fetcher as a cache - Think of a cleaner way to prefetch
const positions = Array.from(
(await this.ctx.fetcher.getPositions(positionAddresses, opts)).values()
);
const whirlpoolAddrs = positions
.map((position) => position?.whirlpool.toBase58())
.flatMap((x) => (!!x ? x : []));
await this.ctx.fetcher.getPools(whirlpoolAddrs, opts);
const tickArrayAddresses: Set<string> = new Set();
await Promise.all(
positions.map(async (pos) => {
if (pos) {
const pool = await this.ctx.fetcher.getPool(pos.whirlpool, PREFER_CACHE);
if (pool) {
const lowerTickArrayPda = PDAUtil.getTickArrayFromTickIndex(
pos.tickLowerIndex,
pool.tickSpacing,
pos.whirlpool,
this.ctx.program.programId
).publicKey;
const upperTickArrayPda = PDAUtil.getTickArrayFromTickIndex(
pos.tickUpperIndex,
pool.tickSpacing,
pos.whirlpool,
this.ctx.program.programId
).publicKey;
tickArrayAddresses.add(lowerTickArrayPda.toBase58());
tickArrayAddresses.add(upperTickArrayPda.toBase58());
}
}
})
);
await this.ctx.fetcher.getTickArrays(Array.from(tickArrayAddresses), IGNORE_CACHE);
// Use getPosition and the prefetched values to generate the Positions
const results = await Promise.all(
positionAddresses.map(async (pos) => {
try {
const position = await this.getPosition(pos, PREFER_CACHE);
return [pos, position];
} catch {
return [pos, null];
}
})
);
return Object.fromEntries(results);
}
public async createPool(
whirlpoolsConfig: Address,
tokenMintA: Address,
tokenMintB: Address,
tickSpacing: number,
initialTick: number,
funder: Address,
opts = PREFER_CACHE
): Promise<{ poolKey: PublicKey; tx: TransactionBuilder }> {
invariant(TickUtil.checkTickInBounds(initialTick), "initialTick is out of bounds.");
invariant(
TickUtil.isTickInitializable(initialTick, tickSpacing),
`initial tick ${initialTick} is not an initializable tick for tick-spacing ${tickSpacing}`
);
const correctTokenOrder = PoolUtil.orderMints(tokenMintA, tokenMintB).map((addr) =>
addr.toString()
);
invariant(
correctTokenOrder[0] === tokenMintA.toString(),
"Token order needs to be flipped to match the canonical ordering (i.e. sorted on the byte repr. of the mint pubkeys)"
);
whirlpoolsConfig = AddressUtil.toPubKey(whirlpoolsConfig);
const feeTierKey = PDAUtil.getFeeTier(
this.ctx.program.programId,
whirlpoolsConfig,
tickSpacing
).publicKey;
const initSqrtPrice = PriceMath.tickIndexToSqrtPriceX64(initialTick);
const tokenVaultAKeypair = Keypair.generate();
const tokenVaultBKeypair = Keypair.generate();
const whirlpoolPda = PDAUtil.getWhirlpool(
this.ctx.program.programId,
whirlpoolsConfig,
new PublicKey(tokenMintA),
new PublicKey(tokenMintB),
tickSpacing
);
const feeTier = await this.ctx.fetcher.getFeeTier(feeTierKey, opts);
invariant(!!feeTier, `Fee tier for ${tickSpacing} doesn't exist`);
const txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
const initPoolIx = WhirlpoolIx.initializePoolIx(this.ctx.program, {
initSqrtPrice,
whirlpoolsConfig,
whirlpoolPda,
tokenMintA: new PublicKey(tokenMintA),
tokenMintB: new PublicKey(tokenMintB),
tokenVaultAKeypair,
tokenVaultBKeypair,
feeTierKey,
tickSpacing,
funder: new PublicKey(funder),
});
const initialTickArrayStartTick = TickUtil.getStartTickIndex(initialTick, tickSpacing);
const initialTickArrayPda = PDAUtil.getTickArray(
this.ctx.program.programId,
whirlpoolPda.publicKey,
initialTickArrayStartTick
);
txBuilder.addInstruction(initPoolIx);
txBuilder.addInstruction(
initTickArrayIx(this.ctx.program, {
startTick: initialTickArrayStartTick,
tickArrayPda: initialTickArrayPda,
whirlpool: whirlpoolPda.publicKey,
funder: AddressUtil.toPubKey(funder),
})
);
return {
poolKey: whirlpoolPda.publicKey,
tx: txBuilder,
};
}
public async collectFeesAndRewardsForPositions(
positionAddresses: Address[],
opts?: WhirlpoolAccountFetchOptions
): Promise<TransactionBuilder[]> {
const walletKey = this.ctx.wallet.publicKey;
return collectAllForPositionAddressesTxns(
this.ctx,
{
positions: positionAddresses,
receiver: walletKey,
positionAuthority: walletKey,
positionOwner: walletKey,
payer: walletKey,
},
opts
);
}
public async collectProtocolFeesForPools(poolAddresses: Address[]): Promise<TransactionBuilder> {
return collectProtocolFees(this.ctx, poolAddresses);
}
}

View File

@ -1,624 +0,0 @@
import { Address, BN, translateAddress } from "@coral-xyz/anchor";
import {
AddressUtil,
MEASUREMENT_BLOCKHASH,
Percentage,
TokenUtil,
TransactionBuilder,
ZERO,
resolveOrCreateATAs,
} from "@orca-so/common-sdk";
import { NATIVE_MINT, getAssociatedTokenAddressSync } from "@solana/spl-token";
import { Keypair, PublicKey } from "@solana/web3.js";
import invariant from "tiny-invariant";
import { WhirlpoolContext } from "../context";
import {
DevFeeSwapInput,
IncreaseLiquidityInput,
SwapInput,
closePositionIx,
decreaseLiquidityIx,
increaseLiquidityIx,
initTickArrayIx,
openPositionIx,
openPositionWithMetadataIx,
swapAsync,
} from "../instructions";
import { IGNORE_CACHE, PREFER_CACHE } from "../network/public/fetcher";
import {
collectFeesQuote,
collectRewardsQuote,
decreaseLiquidityQuoteByLiquidityWithParams,
} from "../quotes/public";
import { TokenAccountInfo, TokenInfo, WhirlpoolData, WhirlpoolRewardInfo } from "../types/public";
import { getTickArrayDataForPosition } from "../utils/builder/position-builder-util";
import { PDAUtil, TickArrayUtil, TickUtil } from "../utils/public";
import {
TokenMintTypes,
getTokenMintsFromWhirlpools,
resolveAtaForMints,
} from "../utils/whirlpool-ata-utils";
import { Whirlpool } from "../whirlpool-client";
import { PositionImpl } from "./position-impl";
import { getRewardInfos, getTokenVaultAccountInfos } from "./util";
import { checkMergedTransactionSizeIsValid } from "../utils/txn-utils";
export class WhirlpoolImpl implements Whirlpool {
private data: WhirlpoolData;
constructor(
readonly ctx: WhirlpoolContext,
readonly address: PublicKey,
readonly tokenAInfo: TokenInfo,
readonly tokenBInfo: TokenInfo,
private tokenVaultAInfo: TokenAccountInfo,
private tokenVaultBInfo: TokenAccountInfo,
private rewardInfos: WhirlpoolRewardInfo[],
data: WhirlpoolData
) {
this.data = data;
}
getAddress(): PublicKey {
return this.address;
}
getData(): WhirlpoolData {
return this.data;
}
getTokenAInfo(): TokenInfo {
return this.tokenAInfo;
}
getTokenBInfo(): TokenInfo {
return this.tokenBInfo;
}
getTokenVaultAInfo(): TokenAccountInfo {
return this.tokenVaultAInfo;
}
getTokenVaultBInfo(): TokenAccountInfo {
return this.tokenVaultBInfo;
}
getRewardInfos(): WhirlpoolRewardInfo[] {
return this.rewardInfos;
}
async refreshData() {
await this.refresh();
return this.data;
}
async openPosition(
tickLower: number,
tickUpper: number,
liquidityInput: IncreaseLiquidityInput,
wallet?: Address,
funder?: Address,
positionMint?: PublicKey
) {
await this.refresh();
return this.getOpenPositionWithOptMetadataTx(
tickLower,
tickUpper,
liquidityInput,
!!wallet ? AddressUtil.toPubKey(wallet) : this.ctx.wallet.publicKey,
!!funder ? AddressUtil.toPubKey(funder) : this.ctx.wallet.publicKey,
false,
positionMint
);
}
async openPositionWithMetadata(
tickLower: number,
tickUpper: number,
liquidityInput: IncreaseLiquidityInput,
sourceWallet?: Address,
funder?: Address,
positionMint?: PublicKey
) {
await this.refresh();
return this.getOpenPositionWithOptMetadataTx(
tickLower,
tickUpper,
liquidityInput,
!!sourceWallet ? AddressUtil.toPubKey(sourceWallet) : this.ctx.wallet.publicKey,
!!funder ? AddressUtil.toPubKey(funder) : this.ctx.wallet.publicKey,
true,
positionMint
);
}
async initTickArrayForTicks(ticks: number[], funder?: Address, opts = IGNORE_CACHE) {
const initTickArrayStartPdas = await TickArrayUtil.getUninitializedArraysPDAs(
ticks,
this.ctx.program.programId,
this.address,
this.data.tickSpacing,
this.ctx.fetcher,
opts
);
if (!initTickArrayStartPdas.length) {
return null;
}
const txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
initTickArrayStartPdas.forEach((initTickArrayInfo) => {
txBuilder.addInstruction(
initTickArrayIx(this.ctx.program, {
startTick: initTickArrayInfo.startIndex,
tickArrayPda: initTickArrayInfo.pda,
whirlpool: this.address,
funder: !!funder ? AddressUtil.toPubKey(funder) : this.ctx.provider.wallet.publicKey,
})
);
});
return txBuilder;
}
async closePosition(
positionAddress: Address,
slippageTolerance: Percentage,
destinationWallet?: Address,
positionWallet?: Address,
payer?: Address
) {
await this.refresh();
const positionWalletKey = positionWallet
? AddressUtil.toPubKey(positionWallet)
: this.ctx.wallet.publicKey;
const destinationWalletKey = destinationWallet
? AddressUtil.toPubKey(destinationWallet)
: this.ctx.wallet.publicKey;
const payerKey = payer ? AddressUtil.toPubKey(payer) : this.ctx.wallet.publicKey;
return this.getClosePositionIx(
AddressUtil.toPubKey(positionAddress),
slippageTolerance,
destinationWalletKey,
positionWalletKey,
payerKey
);
}
async swap(quote: SwapInput, sourceWallet?: Address): Promise<TransactionBuilder> {
const sourceWalletKey = sourceWallet
? AddressUtil.toPubKey(sourceWallet)
: this.ctx.wallet.publicKey;
return swapAsync(
this.ctx,
{
swapInput: quote,
whirlpool: this,
wallet: sourceWalletKey,
},
IGNORE_CACHE
);
}
async swapWithDevFees(
quote: DevFeeSwapInput,
devFeeWallet: PublicKey,
wallet?: PublicKey | undefined,
payer?: PublicKey | undefined
): Promise<TransactionBuilder> {
const sourceWalletKey = wallet ? AddressUtil.toPubKey(wallet) : this.ctx.wallet.publicKey;
const payerKey = payer ? AddressUtil.toPubKey(payer) : this.ctx.wallet.publicKey;
const txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
if (!quote.devFeeAmount.eq(ZERO)) {
const inputToken =
quote.aToB === quote.amountSpecifiedIsInput ? this.getTokenAInfo() : this.getTokenBInfo();
txBuilder.addInstruction(
await TokenUtil.createSendTokensToWalletInstruction(
this.ctx.connection,
sourceWalletKey,
devFeeWallet,
inputToken.mint,
inputToken.decimals,
quote.devFeeAmount,
() => this.ctx.fetcher.getAccountRentExempt(),
payerKey,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
)
);
}
const swapTxBuilder = await swapAsync(
this.ctx,
{
swapInput: quote,
whirlpool: this,
wallet: sourceWalletKey,
},
IGNORE_CACHE
);
txBuilder.addInstruction(swapTxBuilder.compressIx(true));
return txBuilder;
}
/**
* Construct a transaction for opening an new position with optional metadata
*/
async getOpenPositionWithOptMetadataTx(
tickLower: number,
tickUpper: number,
liquidityInput: IncreaseLiquidityInput,
wallet: PublicKey,
funder: PublicKey,
withMetadata: boolean = false,
positionMint?: PublicKey
): Promise<{ positionMint: PublicKey; tx: TransactionBuilder }> {
invariant(TickUtil.checkTickInBounds(tickLower), "tickLower is out of bounds.");
invariant(TickUtil.checkTickInBounds(tickUpper), "tickUpper is out of bounds.");
const { liquidityAmount: liquidity, tokenMaxA, tokenMaxB } = liquidityInput;
invariant(liquidity.gt(new BN(0)), "liquidity must be greater than zero");
const whirlpool = await this.ctx.fetcher.getPool(this.address, PREFER_CACHE);
if (!whirlpool) {
throw new Error(`Whirlpool not found: ${translateAddress(this.address).toBase58()}`);
}
invariant(
TickUtil.isTickInitializable(tickLower, whirlpool.tickSpacing),
`lower tick ${tickLower} is not an initializable tick for tick-spacing ${whirlpool.tickSpacing}`
);
invariant(
TickUtil.isTickInitializable(tickUpper, whirlpool.tickSpacing),
`upper tick ${tickUpper} is not an initializable tick for tick-spacing ${whirlpool.tickSpacing}`
);
const positionMintKeypair = Keypair.generate();
const positionMintPubkey = positionMint ?? positionMintKeypair.publicKey;
const positionPda = PDAUtil.getPosition(
this.ctx.program.programId,
positionMintPubkey
);
const metadataPda = PDAUtil.getPositionMetadata(positionMintPubkey);
const positionTokenAccountAddress = getAssociatedTokenAddressSync(
positionMintPubkey,
wallet,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
const txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
const positionIx = (withMetadata ? openPositionWithMetadataIx : openPositionIx)(
this.ctx.program,
{
funder,
owner: wallet,
positionPda,
metadataPda,
positionMintAddress: positionMintPubkey,
positionTokenAccount: positionTokenAccountAddress,
whirlpool: this.address,
tickLowerIndex: tickLower,
tickUpperIndex: tickUpper,
}
);
txBuilder.addInstruction(positionIx);
if(positionMint === undefined) {
txBuilder.addSigner(positionMintKeypair);
}
const [ataA, ataB] = await resolveOrCreateATAs(
this.ctx.connection,
wallet,
[
{ tokenMint: whirlpool.tokenMintA, wrappedSolAmountIn: tokenMaxA },
{ tokenMint: whirlpool.tokenMintB, wrappedSolAmountIn: tokenMaxB },
],
() => this.ctx.fetcher.getAccountRentExempt(),
funder,
undefined, // use default
this.ctx.accountResolverOpts.allowPDAOwnerAddress,
this.ctx.accountResolverOpts.createWrappedSolAccountMethod
);
const { address: tokenOwnerAccountA, ...tokenOwnerAccountAIx } = ataA;
const { address: tokenOwnerAccountB, ...tokenOwnerAccountBIx } = ataB;
txBuilder.addInstruction(tokenOwnerAccountAIx);
txBuilder.addInstruction(tokenOwnerAccountBIx);
const tickArrayLowerPda = PDAUtil.getTickArrayFromTickIndex(
tickLower,
this.data.tickSpacing,
this.address,
this.ctx.program.programId
);
const tickArrayUpperPda = PDAUtil.getTickArrayFromTickIndex(
tickUpper,
this.data.tickSpacing,
this.address,
this.ctx.program.programId
);
const liquidityIx = increaseLiquidityIx(this.ctx.program, {
liquidityAmount: liquidity,
tokenMaxA,
tokenMaxB,
whirlpool: this.address,
positionAuthority: wallet,
position: positionPda.publicKey,
positionTokenAccount: positionTokenAccountAddress,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA: whirlpool.tokenVaultA,
tokenVaultB: whirlpool.tokenVaultB,
tickArrayLower: tickArrayLowerPda.publicKey,
tickArrayUpper: tickArrayUpperPda.publicKey,
});
txBuilder.addInstruction(liquidityIx);
return {
positionMint: positionMintPubkey,
tx: txBuilder,
};
}
async getClosePositionIx(
positionAddress: PublicKey,
slippageTolerance: Percentage,
destinationWallet: PublicKey,
positionWallet: PublicKey,
payerKey: PublicKey
): Promise<TransactionBuilder[]> {
const positionData = await this.ctx.fetcher.getPosition(positionAddress, IGNORE_CACHE);
if (!positionData) {
throw new Error(`Position not found: ${positionAddress.toBase58()}`);
}
const whirlpool = this.data;
invariant(
positionData.whirlpool.equals(this.address),
`Position ${positionAddress.toBase58()} is not a position for Whirlpool ${this.address.toBase58()}`
);
const positionTokenAccount = getAssociatedTokenAddressSync(
positionData.positionMint,
positionWallet,
this.ctx.accountResolverOpts.allowPDAOwnerAddress
);
const tokenAccountsTxBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
const accountExemption = await this.ctx.fetcher.getAccountRentExempt();
const txBuilder = new TransactionBuilder(
this.ctx.provider.connection,
this.ctx.provider.wallet,
this.ctx.txBuilderOpts
);
const tickArrayLower = PDAUtil.getTickArrayFromTickIndex(
positionData.tickLowerIndex,
whirlpool.tickSpacing,
positionData.whirlpool,
this.ctx.program.programId
).publicKey;
const tickArrayUpper = PDAUtil.getTickArrayFromTickIndex(
positionData.tickUpperIndex,
whirlpool.tickSpacing,
positionData.whirlpool,
this.ctx.program.programId
).publicKey;
const [tickArrayLowerData, tickArrayUpperData] = await getTickArrayDataForPosition(
this.ctx,
positionData,
whirlpool,
IGNORE_CACHE
);
invariant(
!!tickArrayLowerData,
`Tick array ${tickArrayLower} expected to be initialized for whirlpool ${this.address}`
);
invariant(
!!tickArrayUpperData,
`Tick array ${tickArrayUpper} expected to be initialized for whirlpool ${this.address}`
);
const position = new PositionImpl(
this.ctx,
positionAddress,
positionData,
whirlpool,
tickArrayLowerData,
tickArrayUpperData
);
const tickLower = position.getLowerTickData();
const tickUpper = position.getUpperTickData();
const feesQuote = collectFeesQuote({
position: positionData,
whirlpool,
tickLower,
tickUpper,
});
const rewardsQuote = collectRewardsQuote({
position: positionData,
whirlpool,
tickLower,
tickUpper,
});
const shouldCollectFees = feesQuote.feeOwedA.gtn(0) || feesQuote.feeOwedB.gtn(0);
invariant(
this.data.rewardInfos.length === rewardsQuote.length,
"Rewards quote does not match reward infos length"
);
const shouldDecreaseLiquidity = positionData.liquidity.gtn(0);
const rewardsToCollect = this.data.rewardInfos
.filter((_, i) => (rewardsQuote[i] ?? ZERO).gtn(0))
.map((info) => info.mint);
const shouldCollectRewards = rewardsToCollect.length > 0;
let mintType = TokenMintTypes.ALL;
if ((shouldDecreaseLiquidity || shouldCollectFees) && !shouldCollectRewards) {
mintType = TokenMintTypes.POOL_ONLY;
} else if (!(shouldDecreaseLiquidity || shouldCollectFees) && shouldCollectRewards) {
mintType = TokenMintTypes.REWARD_ONLY;
}
const affiliatedMints = getTokenMintsFromWhirlpools([whirlpool], mintType);
const { ataTokenAddresses: walletTokenAccountsByMint, resolveAtaIxs } =
await resolveAtaForMints(this.ctx, {
mints: affiliatedMints.mintMap,
accountExemption,
receiver: destinationWallet,
payer: payerKey,
});
tokenAccountsTxBuilder.addInstructions(resolveAtaIxs);
// Handle native mint
if (affiliatedMints.hasNativeMint) {
let { address: wSOLAta, ...resolveWSolIx } = TokenUtil.createWrappedNativeAccountInstruction(
destinationWallet,
ZERO,
accountExemption,
payerKey,
destinationWallet,
this.ctx.accountResolverOpts.createWrappedSolAccountMethod
);
walletTokenAccountsByMint[NATIVE_MINT.toBase58()] = wSOLAta;
txBuilder.addInstruction(resolveWSolIx);
}
if (shouldDecreaseLiquidity) {
/* Remove all liquidity remaining in the position */
const tokenOwnerAccountA = walletTokenAccountsByMint[whirlpool.tokenMintA.toBase58()];
const tokenOwnerAccountB = walletTokenAccountsByMint[whirlpool.tokenMintB.toBase58()];
const decreaseLiqQuote = decreaseLiquidityQuoteByLiquidityWithParams({
liquidity: positionData.liquidity,
slippageTolerance,
sqrtPrice: whirlpool.sqrtPrice,
tickCurrentIndex: whirlpool.tickCurrentIndex,
tickLowerIndex: positionData.tickLowerIndex,
tickUpperIndex: positionData.tickUpperIndex,
});
const liquidityIx = decreaseLiquidityIx(this.ctx.program, {
...decreaseLiqQuote,
whirlpool: positionData.whirlpool,
positionAuthority: positionWallet,
position: positionAddress,
positionTokenAccount,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA: whirlpool.tokenVaultA,
tokenVaultB: whirlpool.tokenVaultB,
tickArrayLower,
tickArrayUpper,
});
txBuilder.addInstruction(liquidityIx);
}
if (shouldCollectFees) {
const collectFeexTx = await position.collectFees(
false,
walletTokenAccountsByMint,
destinationWallet,
positionWallet,
payerKey,
IGNORE_CACHE
);
txBuilder.addInstruction(collectFeexTx.compressIx(false));
}
if (shouldCollectRewards) {
const collectRewardsTx = await position.collectRewards(
rewardsToCollect,
false,
walletTokenAccountsByMint,
destinationWallet,
positionWallet,
payerKey
);
txBuilder.addInstruction(collectRewardsTx.compressIx(false));
}
/* Close position */
const positionIx = closePositionIx(this.ctx.program, {
positionAuthority: positionWallet,
receiver: destinationWallet,
positionTokenAccount,
position: positionAddress,
positionMint: positionData.positionMint,
});
txBuilder.addInstruction(positionIx);
if (tokenAccountsTxBuilder.isEmpty()) {
return [txBuilder]
}
// This handles an edge case where the instructions are too
// large to fit in a single transaction and we need to split the
// instructions into two transactions.
const canFitInOneTransaction = await checkMergedTransactionSizeIsValid(
this.ctx,
[tokenAccountsTxBuilder, txBuilder],
MEASUREMENT_BLOCKHASH
)
if (!canFitInOneTransaction) {
return [tokenAccountsTxBuilder, txBuilder]
}
tokenAccountsTxBuilder.addInstruction(txBuilder.compressIx(false));
return [tokenAccountsTxBuilder]
}
private async refresh() {
const account = await this.ctx.fetcher.getPool(this.address, IGNORE_CACHE);
if (!!account) {
const rewardInfos = await getRewardInfos(this.ctx.fetcher, account, IGNORE_CACHE);
const [tokenVaultAInfo, tokenVaultBInfo] = await getTokenVaultAccountInfos(
this.ctx.fetcher,
account,
IGNORE_CACHE
);
this.data = account;
this.tokenVaultAInfo = tokenVaultAInfo;
this.tokenVaultBInfo = tokenVaultBInfo;
this.rewardInfos = rewardInfos;
}
}
}

View File

@ -1,19 +0,0 @@
import Decimal from "decimal.js";
export * from "./context";
export * from "./impl/position-impl";
export * from "./ix";
export * from "./network/public";
export * from "./prices";
export * from "./quotes/public";
export * from "./router/public";
export * from "./types/public";
export * from "./types/public/anchor-types";
export * from "./utils/public";
export * from "./whirlpool-client";
// Global rules for Decimals
// - 40 digits of precision for the largest number
// - 20 digits of precision for the smallest number
// - Always round towards 0 to mirror smart contract rules
Decimal.set({ precision: 40, toExpPos: 40, toExpNeg: -20, rounding: 1 });

View File

@ -1,66 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to close a bundled position in a Whirlpool.
*
* @category Instruction Types
* @param bundledPosition - PublicKey for the bundled position.
* @param positionBundle - PublicKey for the position bundle.
* @param positionBundleTokenAccount - The associated token address for the position bundle token in the owners wallet.
* @param positionBundleAuthority - authority that owns the token corresponding to this desired bundled position.
* @param bundleIndex - The bundle index that holds the bundled position.
* @param receiver - PublicKey for the wallet that will receive the rented lamports.
*/
export type CloseBundledPositionParams = {
bundledPosition: PublicKey;
positionBundle: PublicKey;
positionBundleTokenAccount: PublicKey;
positionBundleAuthority: PublicKey;
bundleIndex: number;
receiver: PublicKey;
};
/**
* Close a bundled position in a Whirlpool.
*
* #### Special Errors
* `InvalidBundleIndex` - If the provided bundle index is out of bounds.
* `ClosePositionNotEmpty` - The provided position account is not empty.
*
* @category Instructions
* @param program - program object containing services required to generate the instruction
* @param params - CloseBundledPositionParams object
* @returns - Instruction to perform the action.
*/
export function closeBundledPositionIx(
program: Program<Whirlpool>,
params: CloseBundledPositionParams
): Instruction {
const {
bundledPosition,
positionBundle,
positionBundleTokenAccount,
positionBundleAuthority,
bundleIndex,
receiver,
} = params;
const ix = program.instruction.closeBundledPosition(bundleIndex, {
accounts: {
bundledPosition,
positionBundle,
positionBundleTokenAccount,
positionBundleAuthority,
receiver,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,61 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to close a position in a Whirlpool.
*
* @category Instruction Types
* @param receiver - PublicKey for the wallet that will receive the rented lamports.
* @param position - PublicKey for the position.
* @param positionMint - PublicKey for the mint token for the Position token.
* @param positionTokenAccount - The associated token address for the position token in the owners wallet.
* @param positionAuthority - Authority that owns the position token.
*/
export type ClosePositionParams = {
receiver: PublicKey;
position: PublicKey;
positionMint: PublicKey;
positionTokenAccount: PublicKey;
positionAuthority: PublicKey;
};
/**
* Close a position in a Whirlpool. Burns the position token in the owner's wallet.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - ClosePositionParams object
* @returns - Instruction to perform the action.
*/
export function closePositionIx(
program: Program<Whirlpool>,
params: ClosePositionParams
): Instruction {
const {
positionAuthority,
receiver: receiver,
position: position,
positionMint: positionMint,
positionTokenAccount,
} = params;
const ix = program.instruction.closePosition({
accounts: {
positionAuthority,
receiver,
position,
positionMint,
positionTokenAccount,
tokenProgram: TOKEN_PROGRAM_ID,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,72 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { Instruction } from "@orca-so/common-sdk";
/**
* Parameters to collect fees from a position.
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param position - PublicKey for the position will be opened for.
* @param positionTokenAccount - PublicKey for the position token's associated token address.
* @param tokenOwnerAccountA - PublicKey for the token A account that will be withdrawed from.
* @param tokenOwnerAccountB - PublicKey for the token B account that will be withdrawed from.
* @param tokenVaultA - PublicKey for the tokenA vault for this whirlpool.
* @param tokenVaultB - PublicKey for the tokenB vault for this whirlpool.
* @param positionAuthority - authority that owns the token corresponding to this desired position.
*/
export type CollectFeesParams = {
whirlpool: PublicKey;
position: PublicKey;
positionTokenAccount: PublicKey;
tokenOwnerAccountA: PublicKey;
tokenOwnerAccountB: PublicKey;
tokenVaultA: PublicKey;
tokenVaultB: PublicKey;
positionAuthority: PublicKey;
};
/**
* Collect fees accrued for this position.
* Call updateFeesAndRewards before this to update the position to the newest accrued values.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - CollectFeesParams object
* @returns - Instruction to perform the action.
*/
export function collectFeesIx(program: Program<Whirlpool>, params: CollectFeesParams): Instruction {
const {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
} = params;
const ix = program.instruction.collectFees({
accounts: {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tokenProgram: TOKEN_PROGRAM_ID,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,69 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to collect protocol fees for a Whirlpool
*
* @category Instruction Types
* @param whirlpoolsConfig - The public key for the WhirlpoolsConfig this pool is initialized in
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param tokenVaultA - PublicKey for the tokenA vault for this whirlpool.
* @param tokenVaultB - PublicKey for the tokenB vault for this whirlpool.
* @param tokenOwnerAccountA - PublicKey for the associated token account for tokenA in the collection wallet
* @param tokenOwnerAccountB - PublicKey for the associated token account for tokenA in the collection wallet
* @param collectProtocolFeesAuthority - assigned authority in the WhirlpoolsConfig that can collect protocol fees
*/
export type CollectProtocolFeesParams = {
whirlpoolsConfig: PublicKey;
whirlpool: PublicKey;
tokenVaultA: PublicKey;
tokenVaultB: PublicKey;
tokenOwnerAccountA: PublicKey;
tokenOwnerAccountB: PublicKey;
collectProtocolFeesAuthority: PublicKey;
};
/**
* Collect protocol fees accrued in this Whirlpool.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - CollectProtocolFeesParams object
* @returns - Instruction to perform the action.
*/
export function collectProtocolFeesIx(
program: Program<Whirlpool>,
params: CollectProtocolFeesParams
): Instruction {
const {
whirlpoolsConfig,
whirlpool,
collectProtocolFeesAuthority,
tokenVaultA,
tokenVaultB,
tokenOwnerAccountA: tokenDestinationA,
tokenOwnerAccountB: tokenDestinationB,
} = params;
const ix = program.instruction.collectProtocolFees({
accounts: {
whirlpoolsConfig,
whirlpool,
collectProtocolFeesAuthority,
tokenVaultA,
tokenVaultB,
tokenDestinationA,
tokenDestinationB,
tokenProgram: TOKEN_PROGRAM_ID,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,69 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to collect rewards from a reward index in a position.
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param position - PublicKey for the position will be opened for.
* @param positionTokenAccount - PublicKey for the position token's associated token address.
* @param rewardIndex - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS).
* @param rewardOwnerAccount - PublicKey for the reward token account that the reward will deposit into.
* @param rewardVault - PublicKey of the vault account that reward will be withdrawn from.
* @param positionAuthority - authority that owns the token corresponding to this desired position.
*/
export type CollectRewardParams = {
whirlpool: PublicKey;
position: PublicKey;
positionTokenAccount: PublicKey;
rewardIndex: number;
rewardOwnerAccount: PublicKey;
rewardVault: PublicKey;
positionAuthority: PublicKey;
};
/**
* Collect rewards accrued for this reward index in a position.
* Call updateFeesAndRewards before this to update the position to the newest accrued values.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - CollectRewardParams object
* @returns - Instruction to perform the action.
*/
export function collectRewardIx(
program: Program<Whirlpool>,
params: CollectRewardParams
): Instruction {
const {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
rewardOwnerAccount,
rewardVault,
rewardIndex,
} = params;
const ix = program.instruction.collectReward(rewardIndex, {
accounts: {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
rewardOwnerAccount,
rewardVault,
tokenProgram: TOKEN_PROGRAM_ID,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,310 +0,0 @@
import { Address } from "@coral-xyz/anchor";
import {
Instruction,
ResolvedTokenAddressInstruction,
TokenUtil,
TransactionBuilder,
ZERO,
resolveOrCreateATAs,
} from "@orca-so/common-sdk";
import { NATIVE_MINT, getAssociatedTokenAddressSync } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { PositionData, WhirlpoolContext } from "../..";
import { WhirlpoolIx } from "../../ix";
import { PREFER_CACHE, WhirlpoolAccountFetchOptions } from "../../network/public/fetcher";
import { WhirlpoolData } from "../../types/public";
import { PDAUtil, PoolUtil, TickUtil } from "../../utils/public";
import { checkMergedTransactionSizeIsValid, convertListToMap } from "../../utils/txn-utils";
import { getTokenMintsFromWhirlpools } from "../../utils/whirlpool-ata-utils";
import { updateFeesAndRewardsIx } from "../update-fees-and-rewards-ix";
/**
* Parameters to collect all fees and rewards from a list of positions.
*
* @category Instruction Types
* @param positionAddrs - An array of Whirlpool position addresses.
* @param receiver - The destination wallet that collected fees & reward will be sent to. Defaults to ctx.wallet key.
* @param positionOwner - The wallet key that contains the position token. Defaults to ctx.wallet key.
* @param positionAuthority - The authority key that can authorize operation on the position. Defaults to ctx.wallet key.
* @param payer - The key that will pay for the initialization of ATA token accounts. Defaults to ctx.wallet key.
*/
export type CollectAllPositionAddressParams = {
positions: Address[];
} & CollectAllParams;
/**
* Parameters to collect all fees and rewards from a list of positions.
*
* @category Instruction Types
* @param positions - An array of Whirlpool positions.
* @param receiver - The destination wallet that collected fees & reward will be sent to. Defaults to ctx.wallet key.
* @param positionOwner - The wallet key that contains the position token. Defaults to ctx.wallet key.
* @param positionAuthority - The authority key that can authorize operation on the position. Defaults to ctx.wallet key.
* @param payer - The key that will pay for the initialization of ATA token accounts. Defaults to ctx.wallet key.
*/
export type CollectAllPositionParams = {
positions: Record<string, PositionData>;
} & CollectAllParams;
/**
* Common parameters between {@link CollectAllPositionParams} & {@link CollectAllPositionAddressParams}
*
* @category Instruction Types
* @param receiver - The destination wallet that collected fees & reward will be sent to. Defaults to ctx.wallet key.
* @param positionOwner - The wallet key that contains the position token. Defaults to ctx.wallet key.
* @param positionAuthority - The authority key that can authorize operation on the position. Defaults to ctx.wallet key.
* @param payer - The key that will pay for the initialization of ATA token accounts. Defaults to ctx.wallet key.
*/
export type CollectAllParams = {
receiver?: PublicKey;
positionOwner?: PublicKey;
positionAuthority?: PublicKey;
payer?: PublicKey;
};
/**
* Build a set of transactions to collect fees and rewards for a set of Whirlpool Positions.
*
* @category Instructions
* @experimental
* @param ctx - WhirlpoolContext object for the current environment.
* @param params - CollectAllPositionAddressParams object
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @returns A set of transaction-builders to resolve ATA for affliated tokens, collect fee & rewards for all positions.
*/
export async function collectAllForPositionAddressesTxns(
ctx: WhirlpoolContext,
params: CollectAllPositionAddressParams,
opts: WhirlpoolAccountFetchOptions = PREFER_CACHE
): Promise<TransactionBuilder[]> {
const { positions, ...rest } = params;
const fetchedPositions = await ctx.fetcher.getPositions(positions, opts);
const positionMap: Record<string, PositionData> = {};
fetchedPositions.forEach((pos, addr) => {
if (pos) {
positionMap[addr] = pos;
}
});
return collectAllForPositionsTxns(ctx, { positions: positionMap, ...rest });
}
/**
* Build a set of transactions to collect fees and rewards for a set of Whirlpool Positions.
*
* @experimental
* @param ctx - WhirlpoolContext object for the current environment.
* @param params - CollectAllPositionParams object
* @returns A set of transaction-builders to resolve ATA for affliated tokens, collect fee & rewards for all positions.
*/
export async function collectAllForPositionsTxns(
ctx: WhirlpoolContext,
params: CollectAllPositionParams
): Promise<TransactionBuilder[]> {
const { positions, receiver, positionAuthority, positionOwner, payer } = params;
const receiverKey = receiver ?? ctx.wallet.publicKey;
const positionAuthorityKey = positionAuthority ?? ctx.wallet.publicKey;
const positionOwnerKey = positionOwner ?? ctx.wallet.publicKey;
const payerKey = payer ?? ctx.wallet.publicKey;
const positionList = Object.entries(positions);
if (positionList.length === 0) {
return [];
}
const whirlpoolAddrs = positionList.map(([, pos]) => pos.whirlpool.toBase58());
const whirlpools = await ctx.fetcher.getPools(whirlpoolAddrs, PREFER_CACHE);
const allMints = getTokenMintsFromWhirlpools(Array.from(whirlpools.values()));
const accountExemption = await ctx.fetcher.getAccountRentExempt();
// resolvedAtas[mint] => Instruction & { address }
// if already ATA exists, Instruction will be EMPTY_INSTRUCTION
const resolvedAtas = convertListToMap(
await resolveOrCreateATAs(
ctx.connection,
receiverKey,
allMints.mintMap.map((tokenMint) => ({ tokenMint })),
async () => accountExemption,
payerKey,
true, // CreateIdempotent
ctx.accountResolverOpts.allowPDAOwnerAddress,
ctx.accountResolverOpts.createWrappedSolAccountMethod
),
allMints.mintMap.map((mint) => mint.toBase58())
);
const latestBlockhash = await ctx.connection.getLatestBlockhash();
const txBuilders: TransactionBuilder[] = [];
let posIndex = 0;
let pendingTxBuilder = null;
let touchedMints = null;
let reattempt = false;
while (posIndex < positionList.length) {
if (!pendingTxBuilder || !touchedMints) {
pendingTxBuilder = new TransactionBuilder(ctx.connection, ctx.wallet, ctx.txBuilderOpts);
touchedMints = new Set<string>();
resolvedAtas[NATIVE_MINT.toBase58()] = TokenUtil.createWrappedNativeAccountInstruction(
receiverKey,
ZERO,
accountExemption,
undefined, // use default
undefined, // use default
ctx.accountResolverOpts.createWrappedSolAccountMethod
);
}
// Build collect instructions
const [positionAddr, position] = positionList[posIndex];
const collectIxForPosition = constructCollectIxForPosition(
ctx,
new PublicKey(positionAddr),
position,
whirlpools,
positionOwnerKey,
positionAuthorityKey,
resolvedAtas,
touchedMints
);
const positionTxBuilder = new TransactionBuilder(ctx.connection, ctx.wallet, ctx.txBuilderOpts);
positionTxBuilder.addInstructions(collectIxForPosition);
// Attempt to push the new instructions into the pending builder
// Iterate to the next position if possible
// Create a builder and reattempt if the current one is full.
const mergeable = await checkMergedTransactionSizeIsValid(
ctx,
[pendingTxBuilder, positionTxBuilder],
latestBlockhash
);
if (mergeable) {
pendingTxBuilder.addInstruction(positionTxBuilder.compressIx(false));
posIndex += 1;
reattempt = false;
} else {
if (reattempt) {
throw new Error(
`Unable to fit collection ix for ${position.positionMint.toBase58()} in a Transaction.`
);
}
txBuilders.push(pendingTxBuilder);
pendingTxBuilder = null;
touchedMints = null;
reattempt = true;
}
}
if (pendingTxBuilder) {
txBuilders.push(pendingTxBuilder);
}
return txBuilders;
}
// TODO: Once individual collect ix for positions is implemented, maybe migrate over if it can take custom ATA?
const constructCollectIxForPosition = (
ctx: WhirlpoolContext,
positionKey: PublicKey,
position: PositionData,
whirlpools: ReadonlyMap<string, WhirlpoolData | null>,
positionOwner: PublicKey,
positionAuthority: PublicKey,
resolvedAtas: Record<string, ResolvedTokenAddressInstruction>,
touchedMints: Set<string>
) => {
const ixForPosition: Instruction[] = [];
const {
whirlpool: whirlpoolKey,
liquidity,
tickLowerIndex,
tickUpperIndex,
positionMint,
rewardInfos: positionRewardInfos,
} = position;
const whirlpool = whirlpools.get(whirlpoolKey.toBase58());
if (!whirlpool) {
throw new Error(
`Unable to process positionMint ${positionMint} - unable to derive whirlpool ${whirlpoolKey.toBase58()}`
);
}
const { tickSpacing } = whirlpool;
const mintA = whirlpool.tokenMintA.toBase58();
const mintB = whirlpool.tokenMintB.toBase58();
const positionTokenAccount = getAssociatedTokenAddressSync(
positionMint,
positionOwner,
ctx.accountResolverOpts.allowPDAOwnerAddress
);
// Update fee and reward values if necessary
if (!liquidity.eq(ZERO)) {
ixForPosition.push(
updateFeesAndRewardsIx(ctx.program, {
position: positionKey,
whirlpool: whirlpoolKey,
tickArrayLower: PDAUtil.getTickArray(
ctx.program.programId,
whirlpoolKey,
TickUtil.getStartTickIndex(tickLowerIndex, tickSpacing)
).publicKey,
tickArrayUpper: PDAUtil.getTickArray(
ctx.program.programId,
whirlpoolKey,
TickUtil.getStartTickIndex(tickUpperIndex, tickSpacing)
).publicKey,
})
);
}
// Collect Fee
if (!touchedMints.has(mintA)) {
ixForPosition.push(resolvedAtas[mintA]);
touchedMints.add(mintA);
}
if (!touchedMints.has(mintB)) {
ixForPosition.push(resolvedAtas[mintB]);
touchedMints.add(mintB);
}
ixForPosition.push(
WhirlpoolIx.collectFeesIx(ctx.program, {
whirlpool: whirlpoolKey,
position: positionKey,
positionAuthority,
positionTokenAccount,
tokenOwnerAccountA: resolvedAtas[mintA].address,
tokenOwnerAccountB: resolvedAtas[mintB].address,
tokenVaultA: whirlpool.tokenVaultA,
tokenVaultB: whirlpool.tokenVaultB,
})
);
// Collect Rewards
// TODO: handle empty vault values?
positionRewardInfos.forEach((_, index) => {
const rewardInfo = whirlpool.rewardInfos[index];
if (PoolUtil.isRewardInitialized(rewardInfo)) {
const mintReward = rewardInfo.mint.toBase58();
if (!touchedMints.has(mintReward)) {
ixForPosition.push(resolvedAtas[mintReward]);
touchedMints.add(mintReward);
}
ixForPosition.push(
WhirlpoolIx.collectRewardIx(ctx.program, {
whirlpool: whirlpoolKey,
position: positionKey,
positionAuthority,
positionTokenAccount,
rewardIndex: index,
rewardOwnerAccount: resolvedAtas[mintReward].address,
rewardVault: rewardInfo.vault,
})
);
}
});
return ixForPosition;
};

View File

@ -1,93 +0,0 @@
import { Address } from "@coral-xyz/anchor";
import { AddressUtil, Instruction, TokenUtil, TransactionBuilder } from "@orca-so/common-sdk";
import { NATIVE_MINT } from "@solana/spl-token";
import { PACKET_DATA_SIZE } from "@solana/web3.js";
import { WhirlpoolContext } from "../..";
import { PREFER_CACHE } from "../../network/public/fetcher";
import {
TokenMintTypes,
addNativeMintHandlingIx,
getTokenMintsFromWhirlpools,
resolveAtaForMints,
} from "../../utils/whirlpool-ata-utils";
import { collectProtocolFeesIx } from "../collect-protocol-fees-ix";
export async function collectProtocolFees(
ctx: WhirlpoolContext,
poolAddresses: Address[]
): Promise<TransactionBuilder> {
const receiverKey = ctx.wallet.publicKey;
const payerKey = ctx.wallet.publicKey;
const whirlpoolDatas = Array.from(
(await ctx.fetcher.getPools(poolAddresses, PREFER_CACHE)).values()
);
const accountExemption = await ctx.fetcher.getAccountRentExempt();
const { ataTokenAddresses, resolveAtaIxs } = await resolveAtaForMints(ctx, {
mints: getTokenMintsFromWhirlpools(whirlpoolDatas, TokenMintTypes.POOL_ONLY).mintMap,
accountExemption,
receiver: receiverKey,
payer: payerKey,
});
const latestBlockhash = await ctx.connection.getLatestBlockhash();
let txBuilder = new TransactionBuilder(
ctx.connection,
ctx.wallet,
ctx.txBuilderOpts
).addInstructions(resolveAtaIxs);
const instructions: Instruction[] = [];
for (const poolAddress of poolAddresses) {
const pool = await ctx.fetcher.getPool(poolAddress);
if (!pool) {
throw new Error(`Pool not found: ${poolAddress}`);
}
const poolConfig = await ctx.fetcher.getConfig(pool.whirlpoolsConfig);
if (!poolConfig) {
throw new Error(`Config not found: ${pool.whirlpoolsConfig}`);
}
if (poolConfig.collectProtocolFeesAuthority.toBase58() !== ctx.wallet.publicKey.toBase58()) {
throw new Error(`Wallet is not the collectProtocolFeesAuthority`);
}
const poolHandlesNativeMint =
TokenUtil.isNativeMint(pool.tokenMintA) || TokenUtil.isNativeMint(pool.tokenMintB);
const txBuilderHasNativeMint = !!ataTokenAddresses[NATIVE_MINT.toBase58()];
if (poolHandlesNativeMint && !txBuilderHasNativeMint) {
addNativeMintHandlingIx(
txBuilder,
ataTokenAddresses,
receiverKey,
accountExemption,
ctx.accountResolverOpts.createWrappedSolAccountMethod
);
}
// add collect ixn
instructions.push(
collectProtocolFeesIx(ctx.program, {
whirlpoolsConfig: pool.whirlpoolsConfig,
whirlpool: AddressUtil.toPubKey(poolAddress),
tokenVaultA: pool.tokenVaultA,
tokenVaultB: pool.tokenVaultB,
tokenOwnerAccountA: ataTokenAddresses[pool.tokenMintA.toBase58()],
tokenOwnerAccountB: ataTokenAddresses[pool.tokenMintB.toBase58()],
collectProtocolFeesAuthority: poolConfig.collectProtocolFeesAuthority,
})
);
}
txBuilder.addInstructions(instructions);
const txSize = await txBuilder.txnSize({ latestBlockhash });
if (txSize > PACKET_DATA_SIZE) {
throw new Error(`Transaction size is too large: ${txSize}`);
}
return txBuilder;
}

View File

@ -1,3 +0,0 @@
export * from "./collect-all-txn";
export * from "./collect-protocol-fees";
export * from "./swap-async";

View File

@ -1,72 +0,0 @@
import { resolveOrCreateATAs, TransactionBuilder, ZERO } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { SwapUtils, TickArrayUtil, Whirlpool, WhirlpoolContext } from "../..";
import { WhirlpoolAccountFetchOptions } from "../../network/public/fetcher";
import { SwapInput, swapIx } from "../swap-ix";
export type SwapAsyncParams = {
swapInput: SwapInput;
whirlpool: Whirlpool;
wallet: PublicKey;
};
/**
* Swap instruction builder method with resolveATA & additional checks.
* @param ctx - WhirlpoolContext object for the current environment.
* @param params - {@link SwapAsyncParams}
* @param opts - {@link WhirlpoolAccountFetchOptions} to use for account fetching.
* @returns
*/
export async function swapAsync(
ctx: WhirlpoolContext,
params: SwapAsyncParams,
opts: WhirlpoolAccountFetchOptions
): Promise<TransactionBuilder> {
const { wallet, whirlpool, swapInput } = params;
const { aToB, amount } = swapInput;
const txBuilder = new TransactionBuilder(ctx.connection, ctx.wallet, ctx.txBuilderOpts);
const tickArrayAddresses = [swapInput.tickArray0, swapInput.tickArray1, swapInput.tickArray2];
let uninitializedArrays = await TickArrayUtil.getUninitializedArraysString(
tickArrayAddresses,
ctx.fetcher,
opts
);
if (uninitializedArrays) {
throw new Error(`TickArray addresses - [${uninitializedArrays}] need to be initialized.`);
}
const data = whirlpool.getData();
const [resolvedAtaA, resolvedAtaB] = await resolveOrCreateATAs(
ctx.connection,
wallet,
[
{ tokenMint: data.tokenMintA, wrappedSolAmountIn: aToB ? amount : ZERO },
{ tokenMint: data.tokenMintB, wrappedSolAmountIn: !aToB ? amount : ZERO },
],
() => ctx.fetcher.getAccountRentExempt(),
undefined, // use default
true, // use idempotent to allow multiple simultaneous calls
ctx.accountResolverOpts.allowPDAOwnerAddress,
ctx.accountResolverOpts.createWrappedSolAccountMethod
);
const { address: ataAKey, ...tokenOwnerAccountAIx } = resolvedAtaA;
const { address: ataBKey, ...tokenOwnerAccountBIx } = resolvedAtaB;
txBuilder.addInstructions([tokenOwnerAccountAIx, tokenOwnerAccountBIx]);
const inputTokenAccount = aToB ? ataAKey : ataBKey;
const outputTokenAccount = aToB ? ataBKey : ataAKey;
return txBuilder.addInstruction(
swapIx(
ctx.program,
SwapUtils.getSwapParamsFromQuote(
swapInput,
ctx,
whirlpool,
inputTokenAccount,
outputTokenAccount,
wallet
)
)
);
}

View File

@ -1,384 +0,0 @@
import {
AddressUtil,
EMPTY_INSTRUCTION,
Percentage,
ResolvedTokenAddressInstruction,
TokenUtil,
TransactionBuilder,
ZERO,
} from "@orca-so/common-sdk";
import {
Account,
NATIVE_MINT,
createAssociatedTokenAccountInstruction,
createCloseAccountInstruction,
getAssociatedTokenAddressSync,
} from "@solana/spl-token";
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
import BN from "bn.js";
import {
AtaAccountInfo,
PDAUtil,
SubTradeRoute,
SwapUtils,
TickArrayUtil,
TradeRoute,
WhirlpoolContext,
twoHopSwapQuoteFromSwapQuotes,
} from "../..";
import { PREFER_CACHE, WhirlpoolAccountFetchOptions } from "../../network/public/fetcher";
import { adjustForSlippage } from "../../utils/position-util";
import { contextOptionsToBuilderOptions } from "../../utils/txn-utils";
import { swapIx } from "../swap-ix";
import { twoHopSwapIx } from "../two-hop-swap-ix";
export type SwapFromRouteParams = {
route: TradeRoute;
slippage: Percentage;
wallet: PublicKey;
resolvedAtaAccounts: AtaAccountInfo[] | null;
};
export async function getSwapFromRoute(
ctx: WhirlpoolContext,
params: SwapFromRouteParams,
opts: WhirlpoolAccountFetchOptions = PREFER_CACHE,
txBuilder: TransactionBuilder = new TransactionBuilder(
ctx.connection,
ctx.wallet,
contextOptionsToBuilderOptions(ctx.opts)
)
) {
const { route, wallet, resolvedAtaAccounts, slippage } = params;
const requiredAtas = new Set<string>();
const requiredIntermediateAtas = new Set<string>();
const requiredTickArrays = [];
let hasNativeMint = false;
let nativeMintAmount = new BN(0);
function addOrNative(mint: string, amount: BN) {
if (mint === NATIVE_MINT.toBase58()) {
hasNativeMint = true;
nativeMintAmount = nativeMintAmount.add(amount);
} else {
requiredAtas.add(mint);
}
}
for (let i = 0; i < route.subRoutes.length; i++) {
const routeFragment = route.subRoutes[i];
const slippageAdjustedRoute = adjustQuoteForSlippage(routeFragment, slippage);
if (slippageAdjustedRoute.hopQuotes.length == 1) {
const { quote, mintA, mintB } = slippageAdjustedRoute.hopQuotes[0];
requiredTickArrays.push(...[quote.tickArray0, quote.tickArray1, quote.tickArray2]);
const inputAmount = quote.amountSpecifiedIsInput ? quote.amount : quote.otherAmountThreshold;
addOrNative(mintA.toString(), quote.aToB ? inputAmount : ZERO);
addOrNative(mintB.toString(), !quote.aToB ? inputAmount : ZERO);
} else if (slippageAdjustedRoute.hopQuotes.length == 2) {
const {
quote: quoteOne,
mintA: mintOneA,
mintB: mintOneB,
} = slippageAdjustedRoute.hopQuotes[0];
const {
quote: quoteTwo,
mintA: mintTwoA,
mintB: mintTwoB,
} = slippageAdjustedRoute.hopQuotes[1];
const twoHopQuote = twoHopSwapQuoteFromSwapQuotes(quoteOne, quoteTwo);
requiredTickArrays.push(
...[
twoHopQuote.tickArrayOne0,
twoHopQuote.tickArrayOne1,
twoHopQuote.tickArrayOne2,
twoHopQuote.tickArrayTwo0,
twoHopQuote.tickArrayTwo1,
twoHopQuote.tickArrayTwo2,
]
);
const inputAmount = quoteOne.amountSpecifiedIsInput
? quoteOne.estimatedAmountIn
: quoteOne.otherAmountThreshold;
addOrNative(mintOneA.toString(), quoteOne.aToB ? inputAmount : ZERO);
addOrNative(mintOneB.toString(), !quoteOne.aToB ? inputAmount : ZERO);
addOrNative(mintTwoA.toString(), ZERO);
addOrNative(mintTwoB.toString(), ZERO);
requiredIntermediateAtas.add(quoteOne.aToB ? mintOneB.toString() : mintOneA.toString());
}
}
let uninitializedArrays = await TickArrayUtil.getUninitializedArraysString(
requiredTickArrays,
ctx.fetcher,
opts
);
if (uninitializedArrays) {
throw new Error(`TickArray addresses - [${uninitializedArrays}] need to be initialized.`);
}
// Handle non-native mints only first
requiredAtas.delete(NATIVE_MINT.toBase58());
const ataInstructionMap = await cachedResolveOrCreateNonNativeATAs(
wallet,
requiredAtas,
requiredIntermediateAtas,
(keys) => {
// TODO: if atas are not up to date, there might be failures, not sure if there's
// any good way, other than to re-fetch each time?
if (resolvedAtaAccounts != null) {
return Promise.resolve(
keys.map((key) =>
resolvedAtaAccounts.find((ata) => ata.address?.toBase58() === key.toBase58())
) as Account[]
);
} else {
return ctx.fetcher.getTokenInfos(keys, opts).then((result) => Array.from(result.values()));
}
},
undefined, // use default
ctx.accountResolverOpts.allowPDAOwnerAddress
);
const ataIxes = Object.values(ataInstructionMap);
if (hasNativeMint) {
const solIx = TokenUtil.createWrappedNativeAccountInstruction(
wallet,
nativeMintAmount,
await ctx.fetcher.getAccountRentExempt(),
undefined, // use default
undefined, // use default
ctx.accountResolverOpts.createWrappedSolAccountMethod
);
txBuilder.addInstruction(solIx);
ataInstructionMap[NATIVE_MINT.toBase58()] = solIx;
}
txBuilder.addInstructions(ataIxes);
// Slippage adjustment
const slippageAdjustedQuotes = route.subRoutes.map((quote) =>
adjustQuoteForSlippage(quote, slippage)
);
for (let i = 0; i < slippageAdjustedQuotes.length; i++) {
const routeFragment = slippageAdjustedQuotes[i];
if (routeFragment.hopQuotes.length == 1) {
const { quote, whirlpool, mintA, mintB, vaultA, vaultB } = routeFragment.hopQuotes[0];
const [wp, tokenVaultA, tokenVaultB] = AddressUtil.toPubKeys([whirlpool, vaultA, vaultB]);
const accA = ataInstructionMap[mintA.toString()].address;
const accB = ataInstructionMap[mintB.toString()].address;
const oraclePda = PDAUtil.getOracle(ctx.program.programId, wp);
txBuilder.addInstruction(
swapIx(ctx.program, {
whirlpool: wp,
tokenOwnerAccountA: accA,
tokenOwnerAccountB: accB,
tokenVaultA,
tokenVaultB,
oracle: oraclePda.publicKey,
tokenAuthority: wallet,
...quote,
})
);
} else if (routeFragment.hopQuotes.length == 2) {
const {
quote: quoteOne,
whirlpool: whirlpoolOne,
mintA: mintOneA,
mintB: mintOneB,
vaultA: vaultOneA,
vaultB: vaultOneB,
} = routeFragment.hopQuotes[0];
const {
quote: quoteTwo,
whirlpool: whirlpoolTwo,
mintA: mintTwoA,
mintB: mintTwoB,
vaultA: vaultTwoA,
vaultB: vaultTwoB,
} = routeFragment.hopQuotes[1];
const [wpOne, wpTwo, tokenVaultOneA, tokenVaultOneB, tokenVaultTwoA, tokenVaultTwoB] =
AddressUtil.toPubKeys([
whirlpoolOne,
whirlpoolTwo,
vaultOneA,
vaultOneB,
vaultTwoA,
vaultTwoB,
]);
const twoHopQuote = twoHopSwapQuoteFromSwapQuotes(quoteOne, quoteTwo);
const oracleOne = PDAUtil.getOracle(ctx.program.programId, wpOne).publicKey;
const oracleTwo = PDAUtil.getOracle(ctx.program.programId, wpTwo).publicKey;
const tokenOwnerAccountOneA = ataInstructionMap[mintOneA.toString()].address;
const tokenOwnerAccountOneB = ataInstructionMap[mintOneB.toString()].address;
const tokenOwnerAccountTwoA = ataInstructionMap[mintTwoA.toString()].address;
const tokenOwnerAccountTwoB = ataInstructionMap[mintTwoB.toString()].address;
txBuilder.addInstruction(
twoHopSwapIx(ctx.program, {
...twoHopQuote,
whirlpoolOne: wpOne,
whirlpoolTwo: wpTwo,
tokenOwnerAccountOneA,
tokenOwnerAccountOneB,
tokenOwnerAccountTwoA,
tokenOwnerAccountTwoB,
tokenVaultOneA,
tokenVaultOneB,
tokenVaultTwoA,
tokenVaultTwoB,
oracleOne,
oracleTwo,
tokenAuthority: wallet,
})
);
}
}
return txBuilder;
}
function adjustQuoteForSlippage(quote: SubTradeRoute, slippage: Percentage): SubTradeRoute {
const { hopQuotes } = quote;
if (hopQuotes.length === 1) {
return {
...quote,
hopQuotes: [
{
...hopQuotes[0],
quote: {
...hopQuotes[0].quote,
...SwapUtils.calculateSwapAmountsFromQuote(
hopQuotes[0].quote.amount,
hopQuotes[0].quote.estimatedAmountIn,
hopQuotes[0].quote.estimatedAmountOut,
slippage,
hopQuotes[0].quote.amountSpecifiedIsInput
),
},
},
],
};
} else if (quote.hopQuotes.length === 2) {
const swapQuoteOne = quote.hopQuotes[0];
const swapQuoteTwo = quote.hopQuotes[1];
const amountSpecifiedIsInput = swapQuoteOne.quote.amountSpecifiedIsInput;
let updatedQuote = {
...quote,
};
if (amountSpecifiedIsInput) {
updatedQuote.hopQuotes = [
updatedQuote.hopQuotes[0],
{
...swapQuoteTwo,
quote: {
...swapQuoteTwo.quote,
otherAmountThreshold: adjustForSlippage(
swapQuoteTwo.quote.estimatedAmountOut,
slippage,
false
),
},
},
];
} else {
updatedQuote.hopQuotes = [
{
...swapQuoteOne,
quote: {
...swapQuoteOne.quote,
otherAmountThreshold: adjustForSlippage(
swapQuoteOne.quote.estimatedAmountIn,
slippage,
true
),
},
},
updatedQuote.hopQuotes[1],
];
}
return updatedQuote;
}
return quote;
}
/**
* Internal duplicate of resolveOrCreateAta
* This could be ported over to common-sdk?
*
* IMPORTANT: wrappedSolAmountIn should only be used for input/source token that
* could be SOL. This is because when SOL is the output, it is the end
* destination, and thus does not need to be wrapped with an amount.
*
* @param ownerAddress The user's public key
* @param tokenMint Token mint address
* @param intermediateTokenMints Any mints from the tokenMint set that are intermediates in a two-hop swap
* @param getTokenAccounts Function to get token accounts
* @param payer Payer that would pay the rent for the creation of the ATAs
* @param allowPDAOwnerAddress Optional. Allow PDA to be used as the ATA owner address
* @returns
*/
async function cachedResolveOrCreateNonNativeATAs(
ownerAddress: PublicKey,
tokenMints: Set<string>,
intermediateTokenMints: Set<string>,
getTokenAccounts: (keys: PublicKey[]) => Promise<Array<AtaAccountInfo | null>>,
payer = ownerAddress,
allowPDAOwnerAddress: boolean = false
): Promise<{ [tokenMint: string]: ResolvedTokenAddressInstruction }> {
const instructionMap: { [tokenMint: string]: ResolvedTokenAddressInstruction } = {};
const tokenMintArray = Array.from(tokenMints).map((tm) => new PublicKey(tm));
const tokenAtas = tokenMintArray.map((tm) =>
getAssociatedTokenAddressSync(tm, ownerAddress, allowPDAOwnerAddress)
);
const tokenAccounts = await getTokenAccounts(tokenAtas);
tokenAccounts.forEach((tokenAccount, index) => {
const ataAddress = tokenAtas[index]!;
let resolvedInstruction;
if (tokenAccount) {
// ATA whose owner has been changed is abnormal entity.
// To prevent to send swap/withdraw/collect output to the ATA, an error should be thrown.
if (!tokenAccount.owner.equals(ownerAddress)) {
throw new Error(`ATA with change of ownership detected: ${ataAddress.toBase58()}`);
}
resolvedInstruction = { address: ataAddress, ...EMPTY_INSTRUCTION };
} else {
const tokenMint = tokenMintArray[index];
const createAtaInstructions = [createAssociatedTokenAccountInstruction(
payer,
ataAddress,
ownerAddress,
tokenMint
)];
let cleanupInstructions: TransactionInstruction[] = [];
if (intermediateTokenMints.has(tokenMint.toBase58())) {
cleanupInstructions = [createCloseAccountInstruction(
ataAddress,
ownerAddress,
ownerAddress
)];
}
resolvedInstruction = {
address: ataAddress,
instructions: createAtaInstructions,
cleanupInstructions: cleanupInstructions,
signers: [],
};
}
instructionMap[tokenMintArray[index].toBase58()] = resolvedInstruction;
});
return instructionMap;
}

View File

@ -1,101 +0,0 @@
import { BN, Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to remove liquidity from a position.
*
* @category Instruction Types
* @param liquidityAmount - The total amount of Liquidity the user is withdrawing
* @param tokenMinA - The minimum amount of token A to remove from the position.
* @param tokenMinB - The minimum amount of token B to remove from the position.
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param position - PublicKey for the position will be opened for.
* @param positionTokenAccount - PublicKey for the position token's associated token address.
* @param tokenOwnerAccountA - PublicKey for the token A account that will be withdrawed from.
* @param tokenOwnerAccountB - PublicKey for the token B account that will be withdrawed from.
* @param tokenVaultA - PublicKey for the tokenA vault for this whirlpool.
* @param tokenVaultB - PublicKey for the tokenB vault for this whirlpool.
* @param tickArrayLower - PublicKey for the tick-array account that hosts the tick at the lower tick index.
* @param tickArrayUpper - PublicKey for the tick-array account that hosts the tick at the upper tick index.
* @param positionAuthority - authority that owns the token corresponding to this desired position.
*/
export type DecreaseLiquidityParams = {
whirlpool: PublicKey;
position: PublicKey;
positionTokenAccount: PublicKey;
tokenOwnerAccountA: PublicKey;
tokenOwnerAccountB: PublicKey;
tokenVaultA: PublicKey;
tokenVaultB: PublicKey;
tickArrayLower: PublicKey;
tickArrayUpper: PublicKey;
positionAuthority: PublicKey;
} & DecreaseLiquidityInput;
/**
* @category Instruction Types
*/
export type DecreaseLiquidityInput = {
tokenMinA: BN;
tokenMinB: BN;
liquidityAmount: BN;
};
/**
* Remove liquidity to a position in the Whirlpool.
*
* #### Special Errors
* - `LiquidityZero` - Provided liquidity amount is zero.
* - `LiquidityTooHigh` - Provided liquidity exceeds u128::max.
* - `TokenMinSubceeded` - The required token to perform this operation subceeds the user defined amount.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - DecreaseLiquidityParams object
* @returns - Instruction to perform the action.
*/
export function decreaseLiquidityIx(
program: Program<Whirlpool>,
params: DecreaseLiquidityParams
): Instruction {
const {
liquidityAmount,
tokenMinA,
tokenMinB,
whirlpool,
positionAuthority,
position,
positionTokenAccount,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tickArrayLower,
tickArrayUpper,
} = params;
const ix = program.instruction.decreaseLiquidity(liquidityAmount, tokenMinA, tokenMinB, {
accounts: {
whirlpool,
tokenProgram: TOKEN_PROGRAM_ID,
positionAuthority,
position,
positionTokenAccount,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tickArrayLower,
tickArrayUpper,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,59 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to delete a PositionBundle account.
*
* @category Instruction Types
* @param owner - PublicKey for the wallet that owns the position bundle token.
* @param positionBundle - PublicKey for the position bundle.
* @param positionBundleMint - PublicKey for the mint for the position bundle token.
* @param positionBundleTokenAccount - The associated token address for the position bundle token in the owners wallet.
* @param receiver - PublicKey for the wallet that will receive the rented lamports.
*/
export type DeletePositionBundleParams = {
owner: PublicKey;
positionBundle: PublicKey;
positionBundleMint: PublicKey;
positionBundleTokenAccount: PublicKey;
receiver: PublicKey;
};
/**
* Deletes a PositionBundle account.
*
* #### Special Errors
* `PositionBundleNotDeletable` - The provided position bundle has open positions.
*
* @category Instructions
* @param program - program object containing services required to generate the instruction
* @param params - DeletePositionBundleParams object
* @returns - Instruction to perform the action.
*/
export function deletePositionBundleIx(
program: Program<Whirlpool>,
params: DeletePositionBundleParams
): Instruction {
const { owner, positionBundle, positionBundleMint, positionBundleTokenAccount, receiver } =
params;
const ix = program.instruction.deletePositionBundle({
accounts: {
positionBundle: positionBundle,
positionBundleMint: positionBundleMint,
positionBundleTokenAccount,
positionBundleOwner: owner,
receiver,
tokenProgram: TOKEN_PROGRAM_ID,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,111 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { Instruction } from "@orca-so/common-sdk";
/**
* Parameters to increase liquidity for a position.
*
* @category Instruction Types
* @param liquidityAmount - The total amount of Liquidity the user is willing to deposit.
* @param tokenMaxA - The maximum amount of token A to add to the position.
* @param tokenMaxB - The maximum amount of token B to add to the position.
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param position - PublicKey for the position will be opened for.
* @param positionTokenAccount - PublicKey for the position token's associated token address.
* @param tokenOwnerAccountA - PublicKey for the token A account that will be withdrawed from.
* @param tokenOwnerAccountB - PublicKey for the token B account that will be withdrawed from.
* @param tokenVaultA - PublicKey for the tokenA vault for this whirlpool.
* @param tokenVaultB - PublicKey for the tokenB vault for this whirlpool.
* @param tickArrayLower - PublicKey for the tick-array account that hosts the tick at the lower tick index.
* @param tickArrayUpper - PublicKey for the tick-array account that hosts the tick at the upper tick index.
* @param positionAuthority - authority that owns the token corresponding to this desired position.
*/
export type IncreaseLiquidityParams = {
whirlpool: PublicKey;
position: PublicKey;
positionTokenAccount: PublicKey;
tokenOwnerAccountA: PublicKey;
tokenOwnerAccountB: PublicKey;
tokenVaultA: PublicKey;
tokenVaultB: PublicKey;
tickArrayLower: PublicKey;
tickArrayUpper: PublicKey;
positionAuthority: PublicKey;
} & IncreaseLiquidityInput;
/**
* Input parameters to deposit liquidity into a position.
*
* This type is usually generated by a quote class to estimate the amount of tokens required to
* deposit a certain amount of liquidity into a position.
*
* @category Instruction Types
* @param tokenMaxA - the maximum amount of tokenA allowed to withdraw from the source wallet.
* @param tokenMaxB - the maximum amount of tokenB allowed to withdraw from the source wallet.
* @param liquidityAmount - the desired amount of liquidity to deposit into the position/
*/
export type IncreaseLiquidityInput = {
tokenMaxA: BN;
tokenMaxB: BN;
liquidityAmount: BN;
};
/**
* Add liquidity to a position in the Whirlpool.
*
* #### Special Errors
* `LiquidityZero` - Provided liquidity amount is zero.
* `LiquidityTooHigh` - Provided liquidity exceeds u128::max.
* `TokenMaxExceeded` - The required token to perform this operation exceeds the user defined amount.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - IncreaseLiquidityParams object
* @returns - Instruction to perform the action.
*/
export function increaseLiquidityIx(
program: Program<Whirlpool>,
params: IncreaseLiquidityParams
): Instruction {
const {
liquidityAmount,
tokenMaxA,
tokenMaxB,
whirlpool,
positionAuthority,
position,
positionTokenAccount,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tickArrayLower,
tickArrayUpper,
} = params;
const ix = program.instruction.increaseLiquidity(liquidityAmount, tokenMaxA, tokenMaxB, {
accounts: {
whirlpool,
tokenProgram: TOKEN_PROGRAM_ID,
positionAuthority,
position,
positionTokenAccount,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tickArrayLower,
tickArrayUpper,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,30 +0,0 @@
export * from "./close-bundled-position-ix";
export * from "./close-position-ix";
export * from "./collect-fees-ix";
export * from "./collect-protocol-fees-ix";
export * from "./collect-reward-ix";
export * from "./composites";
export * from "./decrease-liquidity-ix";
export * from "./delete-position-bundle-ix";
export * from "./increase-liquidity-ix";
export * from "./initialize-config-ix";
export * from "./initialize-fee-tier-ix";
export * from "./initialize-pool-ix";
export * from "./initialize-position-bundle-ix";
export * from "./initialize-reward-ix";
export * from "./initialize-tick-array-ix";
export * from "./open-bundled-position-ix";
export * from "./open-position-ix";
export * from "./set-collect-protocol-fees-authority-ix";
export * from "./set-default-fee-rate-ix";
export * from "./set-default-protocol-fee-rate-ix";
export * from "./set-fee-authority-ix";
export * from "./set-fee-rate-ix";
export * from "./set-protocol-fee-rate-ix";
export * from "./set-reward-authority-by-super-authority-ix";
export * from "./set-reward-authority-ix";
export * from "./set-reward-emissions-ix";
export * from "./set-reward-emissions-super-authority-ix";
export * from "./swap-ix";
export * from "./two-hop-swap-ix";
export * from "./update-fees-and-rewards-ix";

View File

@ -1,67 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { Instruction } from "@orca-so/common-sdk";
/**
* Parameters to initialize a WhirlpoolsConfig account.
*
* @category Instruction Types
* @param whirlpoolsConfigKeypair - Generated keypair for the WhirlpoolsConfig.
* @param feeAuthority - Authority authorized to initialize fee-tiers and set customs fees.
* @param collect_protocol_fees_authority - Authority authorized to collect protocol fees.
* @param rewardEmissionsSuperAuthority - Authority authorized to set reward authorities in pools.
* @param defaultProtocolFeeRate - The default protocol fee rate. Stored as a basis point of the total fees collected by feeRate.
* @param funder - The account that would fund the creation of this account
*/
export type InitConfigParams = {
whirlpoolsConfigKeypair: Keypair;
feeAuthority: PublicKey;
collectProtocolFeesAuthority: PublicKey;
rewardEmissionsSuperAuthority: PublicKey;
defaultProtocolFeeRate: number;
funder: PublicKey;
};
/**
* Initializes a WhirlpoolsConfig account that hosts info & authorities
* required to govern a set of Whirlpools.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - InitConfigParams object
* @returns - Instruction to perform the action.
*/
export function initializeConfigIx(
program: Program<Whirlpool>,
params: InitConfigParams
): Instruction {
const {
feeAuthority,
collectProtocolFeesAuthority,
rewardEmissionsSuperAuthority,
defaultProtocolFeeRate,
funder,
} = params;
const ix = program.instruction.initializeConfig(
feeAuthority,
collectProtocolFeesAuthority,
rewardEmissionsSuperAuthority,
defaultProtocolFeeRate,
{
accounts: {
config: params.whirlpoolsConfigKeypair.publicKey,
funder,
systemProgram: SystemProgram.programId,
},
}
);
return {
instructions: [ix],
cleanupInstructions: [],
signers: [params.whirlpoolsConfigKeypair],
};
}

View File

@ -1,61 +0,0 @@
import { Program } from "@coral-xyz/anchor";
import { PDA } from "@orca-so/common-sdk";
import { PublicKey, SystemProgram } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { Instruction } from "@orca-so/common-sdk";
/**
* Parameters to initialize a FeeTier account.
*
* @category Instruction Types
* @param whirlpoolsConfig - PublicKey for the whirlpool config space that the fee-tier will be initialized for.
* @param feeTierPda - PDA for the fee-tier account that will be initialized
* @param tickSpacing - The tick spacing this fee tier recommends its default fee rate for.
* @param defaultFeeRate - The default fee rate for this fee-tier. Stored as a hundredths of a basis point.
* @param feeAuthority - Authority authorized to initialize fee-tiers and set customs fees.
* @param funder - The account that would fund the creation of this account
*/
export type InitFeeTierParams = {
whirlpoolsConfig: PublicKey;
feeTierPda: PDA;
tickSpacing: number;
defaultFeeRate: number;
feeAuthority: PublicKey;
funder: PublicKey;
};
/**
* Initializes a fee tier account usable by Whirlpools in this WhirlpoolsConfig space.
*
* Special Errors
* `FeeRateMaxExceeded` - If the provided default_fee_rate exceeds MAX_FEE_RATE.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - InitFeeTierParams object
* @returns - Instruction to perform the action.
*/
export function initializeFeeTierIx(
program: Program<Whirlpool>,
params: InitFeeTierParams
): Instruction {
const { feeTierPda, whirlpoolsConfig, tickSpacing, feeAuthority, defaultFeeRate, funder } =
params;
const ix = program.instruction.initializeFeeTier(tickSpacing, defaultFeeRate, {
accounts: {
config: whirlpoolsConfig,
feeTier: feeTierPda.publicKey,
feeAuthority,
funder,
systemProgram: SystemProgram.programId,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,87 +0,0 @@
import { BN, Program } from "@coral-xyz/anchor";
import { Instruction, PDA } from "@orca-so/common-sdk";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { Keypair, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { WhirlpoolBumpsData } from "../types/public/anchor-types";
/**
* Parameters to initialize a Whirlpool account.
*
* @category Instruction Types
* @param initSqrtPrice - The desired initial sqrt-price for this pool
* @param whirlpoolsConfig - The public key for the WhirlpoolsConfig this pool is initialized in
* @param whirlpoolPda - PDA for the whirlpool account that would be initialized
* @param tokenMintA - Mint public key for token A
* @param tokenMintB - Mint public key for token B
* @param tokenVaultAKeypair - Keypair of the token A vault for this pool
* @param tokenVaultBKeypair - Keypair of the token B vault for this pool
* @param feeTierKey - PublicKey of the fee-tier account that this pool would use for the fee-rate
* @param tickSpacing - The desired tick spacing for this pool.
* @param funder - The account that would fund the creation of this account
*/
export type InitPoolParams = {
initSqrtPrice: BN;
whirlpoolsConfig: PublicKey;
whirlpoolPda: PDA;
tokenMintA: PublicKey;
tokenMintB: PublicKey;
tokenVaultAKeypair: Keypair;
tokenVaultBKeypair: Keypair;
feeTierKey: PublicKey;
tickSpacing: number;
funder: PublicKey;
};
/**
* Initializes a tick_array account to represent a tick-range in a Whirlpool.
*
* Special Errors
* `InvalidTokenMintOrder` - The order of mints have to be ordered by
* `SqrtPriceOutOfBounds` - provided initial_sqrt_price is not between 2^-64 to 2^64
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - InitPoolParams object
* @returns - Instruction to perform the action.
*/
export function initializePoolIx(program: Program<Whirlpool>, params: InitPoolParams): Instruction {
const {
initSqrtPrice,
tokenMintA,
tokenMintB,
whirlpoolsConfig,
whirlpoolPda,
feeTierKey,
tokenVaultAKeypair,
tokenVaultBKeypair,
tickSpacing,
funder,
} = params;
const whirlpoolBumps: WhirlpoolBumpsData = {
whirlpoolBump: whirlpoolPda.bump,
};
const ix = program.instruction.initializePool(whirlpoolBumps, tickSpacing, initSqrtPrice, {
accounts: {
whirlpoolsConfig,
tokenMintA,
tokenMintB,
funder,
whirlpool: whirlpoolPda.publicKey,
tokenVaultA: tokenVaultAKeypair.publicKey,
tokenVaultB: tokenVaultBKeypair.publicKey,
feeTier: feeTierKey,
tokenProgram: TOKEN_PROGRAM_ID,
systemProgram: SystemProgram.programId,
rent: SYSVAR_RENT_PUBKEY,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [tokenVaultAKeypair, tokenVaultBKeypair],
};
}

View File

@ -1,112 +0,0 @@
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { Instruction, PDA } from "@orca-so/common-sdk";
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
import { METADATA_PROGRAM_ADDRESS, WHIRLPOOL_NFT_UPDATE_AUTH } from "..";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to initialize a PositionBundle account.
*
* @category Instruction Types
* @param owner - PublicKey for the wallet that will host the minted position bundle token.
* @param positionBundlePda - PDA for the derived position bundle address.
* @param positionBundleMintKeypair - Keypair for the mint for the position bundle token.
* @param positionBundleTokenAccount - The associated token address for the position bundle token in the owners wallet.
* @param funder - The account that would fund the creation of this account
*/
export type InitializePositionBundleParams = {
owner: PublicKey;
positionBundlePda: PDA;
positionBundleMintKeypair: Keypair;
positionBundleTokenAccount: PublicKey;
funder: PublicKey;
};
/**
* Initializes a PositionBundle account.
*
* @category Instructions
* @param program - program object containing services required to generate the instruction
* @param params - InitializePositionBundleParams object
* @returns - Instruction to perform the action.
*/
export function initializePositionBundleIx(
program: Program<Whirlpool>,
params: InitializePositionBundleParams
): Instruction {
const {
owner,
positionBundlePda,
positionBundleMintKeypair,
positionBundleTokenAccount,
funder,
} = params;
const ix = program.instruction.initializePositionBundle({
accounts: {
positionBundle: positionBundlePda.publicKey,
positionBundleMint: positionBundleMintKeypair.publicKey,
positionBundleTokenAccount,
positionBundleOwner: owner,
funder,
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
tokenProgram: TOKEN_PROGRAM_ID,
systemProgram: SystemProgram.programId,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [positionBundleMintKeypair],
};
}
/**
* Initializes a PositionBundle account.
* Additional Metaplex metadata is appended to identify the token.
*
* @category Instructions
* @param program - program object containing services required to generate the instruction
* @param params - InitializePositionBundleParams object
* @returns - Instruction to perform the action.
*/
export function initializePositionBundleWithMetadataIx(
program: Program<Whirlpool>,
params: InitializePositionBundleParams & { positionBundleMetadataPda: PDA }
): Instruction {
const {
owner,
positionBundlePda,
positionBundleMintKeypair,
positionBundleTokenAccount,
positionBundleMetadataPda,
funder,
} = params;
const ix = program.instruction.initializePositionBundleWithMetadata({
accounts: {
positionBundle: positionBundlePda.publicKey,
positionBundleMint: positionBundleMintKeypair.publicKey,
positionBundleMetadata: positionBundleMetadataPda.publicKey,
positionBundleTokenAccount,
positionBundleOwner: owner,
funder,
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
tokenProgram: TOKEN_PROGRAM_ID,
systemProgram: SystemProgram.programId,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
metadataProgram: METADATA_PROGRAM_ADDRESS,
metadataUpdateAuth: WHIRLPOOL_NFT_UPDATE_AUTH,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [positionBundleMintKeypair],
};
}

View File

@ -1,67 +0,0 @@
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { Instruction } from "@orca-so/common-sdk";
/**
* Parameters to initialize a rewards for a Whirlpool
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool config space that the fee-tier will be initialized for.
* @param rewardIndex - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS).
* @param rewardMint - PublicKey for the reward mint that we'd use for the reward index.
* @param rewardVaultKeypair - Keypair of the vault for this reward index.
* @param rewardAuthority - Assigned authority by the reward_super_authority for the specified reward-index in this Whirlpool
* @param funder - The account that would fund the creation of this account
*/
export type InitializeRewardParams = {
whirlpool: PublicKey;
rewardIndex: number;
rewardMint: PublicKey;
rewardVaultKeypair: Keypair;
rewardAuthority: PublicKey;
funder: PublicKey;
};
/**
* Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards.
* The initial emissionsPerSecond is set to 0.
*
* #### Special Errors
* - `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized index in this pool,
* or exceeds NUM_REWARDS, or all reward slots for this pool has been initialized.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - InitializeRewardParams object
* @returns - Instruction to perform the action.
*/
export function initializeRewardIx(
program: Program<Whirlpool>,
params: InitializeRewardParams
): Instruction {
const { rewardAuthority, funder, whirlpool, rewardMint, rewardVaultKeypair, rewardIndex } =
params;
const ix = program.instruction.initializeReward(rewardIndex, {
accounts: {
rewardAuthority,
funder,
whirlpool,
rewardMint,
rewardVault: rewardVaultKeypair.publicKey,
tokenProgram: TOKEN_PROGRAM_ID,
systemProgram: SystemProgram.programId,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [rewardVaultKeypair],
};
}

View File

@ -1,54 +0,0 @@
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { Instruction, PDA } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to initialize a TickArray account.
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool that the initialized tick-array will host ticks for.
* @param tickArrayPda - PDA for the tick array account that will be initialized
* @param startTick - The starting tick index for this tick-array. Has to be a multiple of TickArray size & the tick spacing of this pool.
* @param funder - The account that would fund the creation of this account
*/
export type InitTickArrayParams = {
whirlpool: PublicKey;
tickArrayPda: PDA;
startTick: number;
funder: PublicKey;
};
/**
* Initializes a TickArray account.
*
* #### Special Errors
* `InvalidStartTick` - if the provided start tick is out of bounds or is not a multiple of TICK_ARRAY_SIZE * tick spacing.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - InitTickArrayParams object
* @returns - Instruction to perform the action.
*/
export function initTickArrayIx(
program: Program<Whirlpool>,
params: InitTickArrayParams
): Instruction {
const { whirlpool, funder, tickArrayPda } = params;
const ix = program.instruction.initializeTickArray(params.startTick, {
accounts: {
whirlpool,
funder,
tickArray: tickArrayPda.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

View File

@ -1,81 +0,0 @@
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { Instruction, PDA } from "@orca-so/common-sdk";
import { PublicKey, SystemProgram } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**
* Parameters to open a bundled position in a Whirlpool.
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool that the bundled position will be opened for.
* @param bundledPositionPda - PDA for the derived bundled position address.
* @param positionBundle - PublicKey for the position bundle.
* @param positionBundleTokenAccount - The associated token address for the position bundle token in the owners wallet.
* @param positionBundleAuthority - authority that owns the token corresponding to this desired bundled position.
* @param bundleIndex - The bundle index that holds the bundled position.
* @param tickLowerIndex - The tick specifying the lower end of the bundled position range.
* @param tickUpperIndex - The tick specifying the upper end of the bundled position range.
* @param funder - The account that would fund the creation of this account
*/
export type OpenBundledPositionParams = {
whirlpool: PublicKey;
bundledPositionPda: PDA;
positionBundle: PublicKey;
positionBundleTokenAccount: PublicKey;
positionBundleAuthority: PublicKey;
bundleIndex: number;
tickLowerIndex: number;
tickUpperIndex: number;
funder: PublicKey;
};
/**
* Open a bundled position in a Whirlpool.
* No new tokens are issued because the owner of the position bundle becomes the owner of the position.
* The position will start off with 0 liquidity.
*
* #### Special Errors
* `InvalidBundleIndex` - If the provided bundle index is out of bounds.
* `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.
*
* @category Instructions
* @param program - program object containing services required to generate the instruction
* @param params - OpenBundledPositionParams object
* @returns - Instruction to perform the action.
*/
export function openBundledPositionIx(
program: Program<Whirlpool>,
params: OpenBundledPositionParams
): Instruction {
const {
whirlpool,
bundledPositionPda,
positionBundle,
positionBundleTokenAccount,
positionBundleAuthority,
bundleIndex,
tickLowerIndex,
tickUpperIndex,
funder,
} = params;
const ix = program.instruction.openBundledPosition(bundleIndex, tickLowerIndex, tickUpperIndex, {
accounts: {
bundledPosition: bundledPositionPda.publicKey,
positionBundle,
positionBundleTokenAccount,
positionBundleAuthority,
whirlpool,
funder,
systemProgram: SystemProgram.programId,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}

Some files were not shown because too many files have changed in this diff Show More