Change param ordering for Position's resolveATA (#32)
- Change parameter ordering for resolveATA as it is the most important parameter - Default resolveATA to true. Power users who do not want to ping RPC constantly can manually turn it off - Fix up some comments
This commit is contained in:
parent
4416732e33
commit
b922062ccb
|
@ -44,9 +44,9 @@ export class PositionImpl implements Position {
|
|||
|
||||
async increaseLiquidity(
|
||||
liquidityInput: IncreaseLiquidityInput,
|
||||
resolveATA = true,
|
||||
sourceWallet?: Address,
|
||||
positionWallet?: Address,
|
||||
resolveATA?: boolean,
|
||||
ataPayer?: Address
|
||||
) {
|
||||
const sourceWalletKey = sourceWallet
|
||||
|
@ -117,9 +117,9 @@ export class PositionImpl implements Position {
|
|||
|
||||
async decreaseLiquidity(
|
||||
liquidityInput: DecreaseLiquidityInput,
|
||||
resolveATA = true,
|
||||
sourceWallet?: Address,
|
||||
positionWallet?: Address,
|
||||
resolveATA?: boolean,
|
||||
ataPayer?: Address
|
||||
) {
|
||||
const sourceWalletKey = sourceWallet
|
||||
|
|
|
@ -207,20 +207,20 @@ export interface Position {
|
|||
/**
|
||||
* Deposit additional tokens into this postiion.
|
||||
* The wallet must contain the position token and the necessary token A & B to complete the deposit.
|
||||
* If `positionWallet` are `wallet` is provided, the wallet owners have to sign this transaction.
|
||||
* If `positionWallet` and `wallet` is provided, the wallet owners have to sign this transaction.
|
||||
*
|
||||
* @param liquidityInput - input that defines the desired liquidity amount and maximum tokens willing to be to deposited.
|
||||
* @param resolveATA - optional - if true, add instructions to create associated token accounts for tokenA,B for the destinationWallet if necessary. (RPC call required)
|
||||
* @param wallet - the wallet to withdraw tokens to deposit into the position. If null, the WhirlpoolContext wallet is used.
|
||||
* @param positionWallet - optional - the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.
|
||||
* @param resolveATA - optional - if true, add instructions to create associated token accounts for tokenA,B for the destinationWallet if necessary.
|
||||
* @param ataPayer - optional - wallet that will fund the creation of the new associated token accounts
|
||||
* @return the transaction that will deposit the tokens into the position when executed.
|
||||
*/
|
||||
increaseLiquidity: (
|
||||
liquidityInput: IncreaseLiquidityInput,
|
||||
resolveATA?: boolean,
|
||||
wallet?: Address,
|
||||
positionWallet?: Address,
|
||||
resolveATA?: boolean,
|
||||
ataPayer?: Address
|
||||
) => Promise<TransactionBuilder>;
|
||||
|
||||
|
@ -230,17 +230,17 @@ export interface Position {
|
|||
* If `positionWallet` is provided, the wallet owners have to sign this transaction.
|
||||
*
|
||||
* @param liquidityInput - input that defines the desired liquidity amount and minimum tokens willing to be to withdrawn from the position.
|
||||
* @param resolveATA - optional - if true, add instructions to create associated token accounts for tokenA,B for the destinationWallet if necessary. (RPC call required)
|
||||
* @param destinationWallet - optional - the wallet to deposit tokens into when withdrawing from the position. If null, the WhirlpoolContext wallet is used.
|
||||
* @param positionWallet - optional - the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.
|
||||
* @param resolveATA - optional - if true, add instructions to create associated token accounts for tokenA,B for the destinationWallet if necessary.
|
||||
* @param ataPayer - optional - wallet that will fund the creation of the new associated token accounts
|
||||
* @return the transaction that will deposit the tokens into the position when executed.
|
||||
*/
|
||||
decreaseLiquidity: (
|
||||
liquidityInput: DecreaseLiquidityInput,
|
||||
resolveATA?: boolean,
|
||||
destinationWallet?: Address,
|
||||
positionWallet?: Address,
|
||||
resolveATA?: boolean,
|
||||
ataPayer?: Address
|
||||
) => Promise<TransactionBuilder>;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ describe("position-impl", () => {
|
|||
);
|
||||
|
||||
await (
|
||||
await position.increaseLiquidity(increase_quote, ctx.wallet.publicKey)
|
||||
await position.increaseLiquidity(increase_quote, false, ctx.wallet.publicKey)
|
||||
).buildAndExecute();
|
||||
|
||||
const postIncreaseData = await position.refreshData();
|
||||
|
@ -97,9 +97,7 @@ describe("position-impl", () => {
|
|||
pool
|
||||
);
|
||||
|
||||
await (
|
||||
await position.decreaseLiquidity(decrease_quote, ctx.wallet.publicKey, ctx.wallet.publicKey)
|
||||
).buildAndExecute();
|
||||
await (await position.decreaseLiquidity(decrease_quote, false)).buildAndExecute();
|
||||
|
||||
const postWithdrawData = await position.refreshData();
|
||||
const expectedPostWithdrawLiquidity = postIncreaseData.liquidity.sub(
|
||||
|
@ -164,9 +162,7 @@ describe("position-impl", () => {
|
|||
pool
|
||||
);
|
||||
|
||||
await (
|
||||
await position.increaseLiquidity(increase_quote, ctx.wallet.publicKey)
|
||||
).buildAndExecute();
|
||||
await (await position.increaseLiquidity(increase_quote, false)).buildAndExecute();
|
||||
|
||||
const postIncreaseData = await position.refreshData();
|
||||
const expectedPostIncreaseLiquidity = preIncreaseData.liquidity.add(
|
||||
|
@ -214,9 +210,9 @@ describe("position-impl", () => {
|
|||
await (
|
||||
await position.increaseLiquidity(
|
||||
increaseQuoteFromOtherWallet,
|
||||
true,
|
||||
otherWallet.publicKey,
|
||||
otherWallet.publicKey,
|
||||
true
|
||||
otherWallet.publicKey
|
||||
)
|
||||
)
|
||||
.addSigner(otherWallet)
|
||||
|
@ -229,9 +225,9 @@ describe("position-impl", () => {
|
|||
await (
|
||||
await position.decreaseLiquidity(
|
||||
decrease_quote,
|
||||
true,
|
||||
destinationWallet.publicKey,
|
||||
otherWallet.publicKey,
|
||||
true
|
||||
otherWallet.publicKey
|
||||
)
|
||||
)
|
||||
.addSigner(otherWallet)
|
||||
|
|
|
@ -20,12 +20,7 @@ import {
|
|||
TickUtil,
|
||||
} from "../../../src";
|
||||
import Decimal from "decimal.js";
|
||||
import {
|
||||
deriveATA,
|
||||
Percentage,
|
||||
TransactionBuilder,
|
||||
TransactionProcessor,
|
||||
} from "@orca-so/common-sdk";
|
||||
import { deriveATA, Percentage, TransactionBuilder } from "@orca-so/common-sdk";
|
||||
import { mintTokensToTestAccount } from "../../utils/test-builders";
|
||||
|
||||
describe("whirlpool-impl", () => {
|
||||
|
|
Loading…
Reference in New Issue