whirlpools-client/docs/index.html

83 lines
19 KiB
HTML

<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@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"><h1>@orca-so/whirlpools-sdk </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><div class="tsd-panel tsd-typography">
<a href="#whirlpools" id="whirlpools" style="color: inherit; text-decoration: none;">
<h1>Whirlpools</h1>
</a>
<p>Whirpools is an open-source concentrated liquidity AMM contract on the Solana blockchain.
This repository contains the Rust smart contract as well as the Typescript SDK (<code>@orca-so/whirlpools-sdk</code>) to interact with a deployed program.</p>
<p>The contract has been audited by Kudelski and Neodyme.</p>
<a href="#requirements" id="requirements" style="color: inherit; text-decoration: none;">
<h2>Requirements</h2>
</a>
<ul>
<li>Anchor 0.20.1</li>
<li>Solana 1.9.3</li>
<li>Rust 1.59.0</li>
</ul>
<a href="#setup" id="setup" style="color: inherit; text-decoration: none;">
<h2>Setup</h2>
</a>
<p>Install Anchor using instructions found <a href="https://project-serum.github.io/anchor/getting-started/installation.html#install-rust">here</a>.</p>
<p>Set up a valid Solana keypair at the path specified in the <code>wallet</code> in <code>Anchor.toml</code> to do local testing with <code>anchor test</code> flows.</p>
<p><code>$NODE_PATH</code> must be set to the <code>node_modules</code> directory of your global installs.
For example, using Node 16.10.0 installed through <code>nvm</code>, the $NODE_PATH is the following:</p>
<pre><code><span class="hl-0">$</span><span class="hl-1"> </span><span class="hl-0">echo</span><span class="hl-1"> </span><span class="hl-0">$NODE_PATH</span><br/><span class="hl-2">/Users/</span><span class="hl-1">&lt;</span><span class="hl-0">home_dir</span><span class="hl-1">&gt;/.</span><span class="hl-0">nvm</span><span class="hl-1">/</span><span class="hl-0">versions</span><span class="hl-1">/</span><span class="hl-0">node</span><span class="hl-1">/</span><span class="hl-0">v16</span><span class="hl-1">.</span><span class="hl-3">10.0</span><span class="hl-1">/</span><span class="hl-0">lib</span><span class="hl-1">/</span><span class="hl-0">node_modules</span>
</code></pre>
<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
<h2>Usage</h2>
</a>
<p>Instructions on how to interact with the Whirlpools contract is documented in the Orca Developer Portal.</p>
<a href="#tests" id="tests" style="color: inherit; text-decoration: none;">
<h2>Tests</h2>
</a>
<ul>
<li>Run &quot;cargo test --lib&quot; to run Rust unit tests</li>
</ul>
<hr>
<a href="#whirlpool-sdk" id="whirlpool-sdk" style="color: inherit; text-decoration: none;">
<h1>Whirlpool SDK</h1>
</a>
<p>Use the SDK to interact with a deployed Whirlpools program via Typescript.</p>
<a href="#installation" id="installation" style="color: inherit; text-decoration: none;">
<h2>Installation</h2>
</a>
<p>In your package, run:</p>
<pre><code><span class="hl-0">yarn</span><span class="hl-1"> </span><span class="hl-0">add</span><span class="hl-1"> </span><span class="hl-4">`@orca-so/whirlpools-sdk`</span>
</code></pre>
<a href="#usage-1" id="usage-1" style="color: inherit; text-decoration: none;">
<h2>Usage</h2>
</a>
<p>Read instructions on how to use the SDK on the Orca Developer Portal.</p>
<a href="#run-typescript-tests-via-local-validator" id="run-typescript-tests-via-local-validator" style="color: inherit; text-decoration: none;">
<h2>Run Typescript tests via local validator</h2>
</a>
<p>In the whirlpools/sdk folder, run:</p>
<pre><code><span class="hl-0">anchor</span><span class="hl-1"> </span><span class="hl-0">test</span>
</code></pre>
<a href="#generate-typedoc" id="generate-typedoc" style="color: inherit; text-decoration: none;">
<h2>Generate TypeDoc</h2>
</a>
<p>In the <code>sdk</code> folder, run <code>yarn run docs</code></p>
<hr>
<a href="#support" id="support" style="color: inherit; text-decoration: none;">
<h1>Support</h1>
</a>
<p><strong>Integration Questions</strong></p>
<p>Have problems integrating with the SDK? Pop by over to the Orca <a href="https://discord.gg/nSwGWn5KSG">Discord</a> #integrations channel and chat with one of our engineers.</p>
<p><strong>Feedback</strong></p>
<p>Got ideas on how to improve the system? Open up an issue on github with the prefix [FEEDBACK] and let&#39;s brainstorm more about it together!</p>
<a href="#license" id="license" style="color: inherit; text-decoration: none;">
<h1>License</h1>
</a>
<p><a href="https://choosealicense.com/licenses/apache-2.0/">Apache 2.0</a></p>
</div></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-enum"><a href="enums/AccountName.html" class="tsd-kind-icon">Account<wbr/>Name</a></li><li class="tsd-kind-class"><a href="classes/AccountFetcher.html" class="tsd-kind-icon">Account<wbr/>Fetcher</a></li><li class="tsd-kind-class"><a href="classes/PDAUtil.html" class="tsd-kind-icon">PDAUtil</a></li><li class="tsd-kind-class"><a href="classes/ParsableFeeTier.html" class="tsd-kind-icon">Parsable<wbr/>Fee<wbr/>Tier</a></li><li class="tsd-kind-class"><a href="classes/ParsableMintInfo.html" class="tsd-kind-icon">Parsable<wbr/>Mint<wbr/>Info</a></li><li class="tsd-kind-class"><a href="classes/ParsablePosition.html" class="tsd-kind-icon">Parsable<wbr/>Position</a></li><li class="tsd-kind-class"><a href="classes/ParsableTickArray.html" class="tsd-kind-icon">Parsable<wbr/>Tick<wbr/>Array</a></li><li class="tsd-kind-class"><a href="classes/ParsableTokenInfo.html" class="tsd-kind-icon">Parsable<wbr/>Token<wbr/>Info</a></li><li class="tsd-kind-class"><a href="classes/ParsableWhirlpool.html" class="tsd-kind-icon">Parsable<wbr/>Whirlpool</a></li><li class="tsd-kind-class"><a href="classes/ParsableWhirlpoolsConfig.html" class="tsd-kind-icon">Parsable<wbr/>Whirlpools<wbr/>Config</a></li><li class="tsd-kind-class"><a href="classes/PoolUtil.html" class="tsd-kind-icon">Pool<wbr/>Util</a></li><li class="tsd-kind-class"><a href="classes/PriceMath.html" class="tsd-kind-icon">Price<wbr/>Math</a></li><li class="tsd-kind-class"><a href="classes/TickArrayUtil.html" class="tsd-kind-icon">Tick<wbr/>Array<wbr/>Util</a></li><li class="tsd-kind-class"><a href="classes/TickUtil.html" class="tsd-kind-icon">Tick<wbr/>Util</a></li><li class="tsd-kind-class"><a href="classes/WhirlpoolContext.html" class="tsd-kind-icon">Whirlpool<wbr/>Context</a></li><li class="tsd-kind-class"><a href="classes/WhirlpoolIx.html" class="tsd-kind-icon">Whirlpool<wbr/>Ix</a></li><li class="tsd-kind-interface tsd-has-type-parameter"><a href="interfaces/ParsableEntity.html" class="tsd-kind-icon">Parsable<wbr/>Entity</a></li><li class="tsd-kind-interface"><a href="interfaces/Position.html" class="tsd-kind-icon">Position</a></li><li class="tsd-kind-interface"><a href="interfaces/Whirlpool.html" class="tsd-kind-icon">Whirlpool</a></li><li class="tsd-kind-interface"><a href="interfaces/WhirlpoolClient.html" class="tsd-kind-icon">Whirlpool<wbr/>Client</a></li><li class="tsd-kind-type-alias"><a href="modules.html#ClosePositionParams" class="tsd-kind-icon">Close<wbr/>Position<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#CollectFeesParams" class="tsd-kind-icon">Collect<wbr/>Fees<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#CollectFeesQuote" class="tsd-kind-icon">Collect<wbr/>Fees<wbr/>Quote</a></li><li class="tsd-kind-type-alias"><a href="modules.html#CollectFeesQuoteParam" class="tsd-kind-icon">Collect<wbr/>Fees<wbr/>Quote<wbr/>Param</a></li><li class="tsd-kind-type-alias"><a href="modules.html#CollectProtocolFeesParams" class="tsd-kind-icon">Collect<wbr/>Protocol<wbr/>Fees<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#CollectRewardParams" class="tsd-kind-icon">Collect<wbr/>Reward<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#CollectRewardsQuote" class="tsd-kind-icon">Collect<wbr/>Rewards<wbr/>Quote</a></li><li class="tsd-kind-type-alias"><a href="modules.html#CollectRewardsQuoteParam" class="tsd-kind-icon">Collect<wbr/>Rewards<wbr/>Quote<wbr/>Param</a></li><li class="tsd-kind-type-alias"><a href="modules.html#DecreaseLiquidityInput" class="tsd-kind-icon">Decrease<wbr/>Liquidity<wbr/>Input</a></li><li class="tsd-kind-type-alias"><a href="modules.html#DecreaseLiquidityParams" class="tsd-kind-icon">Decrease<wbr/>Liquidity<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#DecreaseLiquidityQuoteParam" class="tsd-kind-icon">Decrease<wbr/>Liquidity<wbr/>Quote<wbr/>Param</a></li><li class="tsd-kind-type-alias"><a href="modules.html#FeeTierData" class="tsd-kind-icon">Fee<wbr/>Tier<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#IncreaseLiquidityInput" class="tsd-kind-icon">Increase<wbr/>Liquidity<wbr/>Input</a></li><li class="tsd-kind-type-alias"><a href="modules.html#IncreaseLiquidityParams" class="tsd-kind-icon">Increase<wbr/>Liquidity<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#IncreaseLiquidityQuoteParam" class="tsd-kind-icon">Increase<wbr/>Liquidity<wbr/>Quote<wbr/>Param</a></li><li class="tsd-kind-type-alias"><a href="modules.html#InitConfigParams" class="tsd-kind-icon">Init<wbr/>Config<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#InitFeeTierParams" class="tsd-kind-icon">Init<wbr/>Fee<wbr/>Tier<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#InitPoolParams" class="tsd-kind-icon">Init<wbr/>Pool<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#InitTickArrayParams" class="tsd-kind-icon">Init<wbr/>Tick<wbr/>Array<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#InitializeRewardParams" class="tsd-kind-icon">Initialize<wbr/>Reward<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#OpenPositionBumpsData" class="tsd-kind-icon">Open<wbr/>Position<wbr/>Bumps<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#OpenPositionParams" class="tsd-kind-icon">Open<wbr/>Position<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#OpenPositionWithMetadataBumpsData" class="tsd-kind-icon">Open<wbr/>Position<wbr/>With<wbr/>Metadata<wbr/>Bumps<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#PositionData" class="tsd-kind-icon">Position<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#PositionRewardInfoData" class="tsd-kind-icon">Position<wbr/>Reward<wbr/>Info<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetCollectProtocolFeesAuthorityParams" class="tsd-kind-icon">Set<wbr/>Collect<wbr/>Protocol<wbr/>Fees<wbr/>Authority<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetDefaultFeeRateParams" class="tsd-kind-icon">Set<wbr/>Default<wbr/>Fee<wbr/>Rate<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetDefaultProtocolFeeRateParams" class="tsd-kind-icon">Set<wbr/>Default<wbr/>Protocol<wbr/>Fee<wbr/>Rate<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetFeeAuthorityParams" class="tsd-kind-icon">Set<wbr/>Fee<wbr/>Authority<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetFeeRateParams" class="tsd-kind-icon">Set<wbr/>Fee<wbr/>Rate<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetProtocolFeeRateParams" class="tsd-kind-icon">Set<wbr/>Protocol<wbr/>Fee<wbr/>Rate<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetRewardAuthorityBySuperAuthorityParams" class="tsd-kind-icon">Set<wbr/>Reward<wbr/>Authority<wbr/>By<wbr/>Super<wbr/>Authority<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetRewardAuthorityParams" class="tsd-kind-icon">Set<wbr/>Reward<wbr/>Authority<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetRewardEmissionsParams" class="tsd-kind-icon">Set<wbr/>Reward<wbr/>Emissions<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SetRewardEmissionsSuperAuthorityParams" class="tsd-kind-icon">Set<wbr/>Reward<wbr/>Emissions<wbr/>Super<wbr/>Authority<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SwapInput" class="tsd-kind-icon">Swap<wbr/>Input</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SwapParams" class="tsd-kind-icon">Swap<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SwapQuote" class="tsd-kind-icon">Swap<wbr/>Quote</a></li><li class="tsd-kind-type-alias"><a href="modules.html#SwapQuoteParam" class="tsd-kind-icon">Swap<wbr/>Quote<wbr/>Param</a></li><li class="tsd-kind-type-alias"><a href="modules.html#TickArrayData" class="tsd-kind-icon">Tick<wbr/>Array<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#TickData" class="tsd-kind-icon">Tick<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#TokenAmounts" class="tsd-kind-icon">Token<wbr/>Amounts</a></li><li class="tsd-kind-type-alias"><a href="modules.html#TokenInfo" class="tsd-kind-icon">Token<wbr/>Info</a></li><li class="tsd-kind-type-alias"><a href="modules.html#UpdateFeesAndRewardsParams" class="tsd-kind-icon">Update<wbr/>Fees<wbr/>And<wbr/>Rewards<wbr/>Params</a></li><li class="tsd-kind-type-alias"><a href="modules.html#WhirlpoolBumpsData" class="tsd-kind-icon">Whirlpool<wbr/>Bumps<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#WhirlpoolData" class="tsd-kind-icon">Whirlpool<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#WhirlpoolRewardInfoData" class="tsd-kind-icon">Whirlpool<wbr/>Reward<wbr/>Info<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#WhirlpoolsConfigData" class="tsd-kind-icon">Whirlpools<wbr/>Config<wbr/>Data</a></li><li class="tsd-kind-variable"><a href="modules.html#MAX_SQRT_PRICE" class="tsd-kind-icon">MAX_<wbr/>SQRT_<wbr/>PRICE</a></li><li class="tsd-kind-variable"><a href="modules.html#MAX_TICK_ARRAY_CROSSINGS" class="tsd-kind-icon">MAX_<wbr/>TICK_<wbr/>ARRAY_<wbr/>CROSSINGS</a></li><li class="tsd-kind-variable"><a href="modules.html#MAX_TICK_INDEX" class="tsd-kind-icon">MAX_<wbr/>TICK_<wbr/>INDEX</a></li><li class="tsd-kind-variable"><a href="modules.html#METADATA_PROGRAM_ADDRESS" class="tsd-kind-icon">METADATA_<wbr/>PROGRAM_<wbr/>ADDRESS</a></li><li class="tsd-kind-variable"><a href="modules.html#MIN_SQRT_PRICE" class="tsd-kind-icon">MIN_<wbr/>SQRT_<wbr/>PRICE</a></li><li class="tsd-kind-variable"><a href="modules.html#MIN_TICK_INDEX" class="tsd-kind-icon">MIN_<wbr/>TICK_<wbr/>INDEX</a></li><li class="tsd-kind-variable"><a href="modules.html#NUM_REWARDS" class="tsd-kind-icon">NUM_<wbr/>REWARDS</a></li><li class="tsd-kind-variable"><a href="modules.html#ORCA_WHIRLPOOLS_CONFIG" class="tsd-kind-icon">ORCA_<wbr/>WHIRLPOOLS_<wbr/>CONFIG</a></li><li class="tsd-kind-variable"><a href="modules.html#ORCA_WHIRLPOOL_PROGRAM_ID" class="tsd-kind-icon">ORCA_<wbr/>WHIRLPOOL_<wbr/>PROGRAM_<wbr/>ID</a></li><li class="tsd-kind-variable"><a href="modules.html#TICK_ARRAY_SIZE" class="tsd-kind-icon">TICK_<wbr/>ARRAY_<wbr/>SIZE</a></li><li class="tsd-kind-function"><a href="modules.html#buildWhirlpoolClient" class="tsd-kind-icon">build<wbr/>Whirlpool<wbr/>Client</a></li><li class="tsd-kind-function"><a href="modules.html#collectFeesQuote" class="tsd-kind-icon">collect<wbr/>Fees<wbr/>Quote</a></li><li class="tsd-kind-function"><a href="modules.html#collectRewardsQuote" class="tsd-kind-icon">collect<wbr/>Rewards<wbr/>Quote</a></li><li class="tsd-kind-function"><a href="modules.html#decreaseLiquidityQuoteByLiquidity" class="tsd-kind-icon">decrease<wbr/>Liquidity<wbr/>Quote<wbr/>By<wbr/>Liquidity</a></li><li class="tsd-kind-function"><a href="modules.html#decreaseLiquidityQuoteByLiquidityWithParams" class="tsd-kind-icon">decrease<wbr/>Liquidity<wbr/>Quote<wbr/>By<wbr/>Liquidity<wbr/>With<wbr/>Params</a></li><li class="tsd-kind-function"><a href="modules.html#increaseLiquidityQuoteByInputToken" class="tsd-kind-icon">increase<wbr/>Liquidity<wbr/>Quote<wbr/>By<wbr/>Input<wbr/>Token</a></li><li class="tsd-kind-function"><a href="modules.html#increaseLiquidityQuoteByInputTokenWithParams" class="tsd-kind-icon">increase<wbr/>Liquidity<wbr/>Quote<wbr/>By<wbr/>Input<wbr/>Token<wbr/>With<wbr/>Params</a></li><li class="tsd-kind-function"><a href="modules.html#swapQuoteByInputToken" class="tsd-kind-icon">swap<wbr/>Quote<wbr/>By<wbr/>Input<wbr/>Token</a></li><li class="tsd-kind-function"><a href="modules.html#toTokenAmount" class="tsd-kind-icon">to<wbr/>Token<wbr/>Amount</a></li><li class="tsd-kind-function"><a href="modules.html#toTx" class="tsd-kind-icon">to<wbr/>Tx</a></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-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><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>