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(
|
async increaseLiquidity(
|
||||||
liquidityInput: IncreaseLiquidityInput,
|
liquidityInput: IncreaseLiquidityInput,
|
||||||
|
resolveATA = true,
|
||||||
sourceWallet?: Address,
|
sourceWallet?: Address,
|
||||||
positionWallet?: Address,
|
positionWallet?: Address,
|
||||||
resolveATA?: boolean,
|
|
||||||
ataPayer?: Address
|
ataPayer?: Address
|
||||||
) {
|
) {
|
||||||
const sourceWalletKey = sourceWallet
|
const sourceWalletKey = sourceWallet
|
||||||
|
@ -117,9 +117,9 @@ export class PositionImpl implements Position {
|
||||||
|
|
||||||
async decreaseLiquidity(
|
async decreaseLiquidity(
|
||||||
liquidityInput: DecreaseLiquidityInput,
|
liquidityInput: DecreaseLiquidityInput,
|
||||||
|
resolveATA = true,
|
||||||
sourceWallet?: Address,
|
sourceWallet?: Address,
|
||||||
positionWallet?: Address,
|
positionWallet?: Address,
|
||||||
resolveATA?: boolean,
|
|
||||||
ataPayer?: Address
|
ataPayer?: Address
|
||||||
) {
|
) {
|
||||||
const sourceWalletKey = sourceWallet
|
const sourceWalletKey = sourceWallet
|
||||||
|
|
|
@ -207,20 +207,20 @@ export interface Position {
|
||||||
/**
|
/**
|
||||||
* Deposit additional tokens into this postiion.
|
* Deposit additional tokens into this postiion.
|
||||||
* The wallet must contain the position token and the necessary token A & B to complete the deposit.
|
* 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 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 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 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
|
* @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.
|
* @return the transaction that will deposit the tokens into the position when executed.
|
||||||
*/
|
*/
|
||||||
increaseLiquidity: (
|
increaseLiquidity: (
|
||||||
liquidityInput: IncreaseLiquidityInput,
|
liquidityInput: IncreaseLiquidityInput,
|
||||||
|
resolveATA?: boolean,
|
||||||
wallet?: Address,
|
wallet?: Address,
|
||||||
positionWallet?: Address,
|
positionWallet?: Address,
|
||||||
resolveATA?: boolean,
|
|
||||||
ataPayer?: Address
|
ataPayer?: Address
|
||||||
) => Promise<TransactionBuilder>;
|
) => Promise<TransactionBuilder>;
|
||||||
|
|
||||||
|
@ -230,17 +230,17 @@ export interface Position {
|
||||||
* If `positionWallet` is provided, the wallet owners have to sign this transaction.
|
* 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 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 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 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
|
* @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.
|
* @return the transaction that will deposit the tokens into the position when executed.
|
||||||
*/
|
*/
|
||||||
decreaseLiquidity: (
|
decreaseLiquidity: (
|
||||||
liquidityInput: DecreaseLiquidityInput,
|
liquidityInput: DecreaseLiquidityInput,
|
||||||
|
resolveATA?: boolean,
|
||||||
destinationWallet?: Address,
|
destinationWallet?: Address,
|
||||||
positionWallet?: Address,
|
positionWallet?: Address,
|
||||||
resolveATA?: boolean,
|
|
||||||
ataPayer?: Address
|
ataPayer?: Address
|
||||||
) => Promise<TransactionBuilder>;
|
) => Promise<TransactionBuilder>;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ describe("position-impl", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
await (
|
await (
|
||||||
await position.increaseLiquidity(increase_quote, ctx.wallet.publicKey)
|
await position.increaseLiquidity(increase_quote, false, ctx.wallet.publicKey)
|
||||||
).buildAndExecute();
|
).buildAndExecute();
|
||||||
|
|
||||||
const postIncreaseData = await position.refreshData();
|
const postIncreaseData = await position.refreshData();
|
||||||
|
@ -97,9 +97,7 @@ describe("position-impl", () => {
|
||||||
pool
|
pool
|
||||||
);
|
);
|
||||||
|
|
||||||
await (
|
await (await position.decreaseLiquidity(decrease_quote, false)).buildAndExecute();
|
||||||
await position.decreaseLiquidity(decrease_quote, ctx.wallet.publicKey, ctx.wallet.publicKey)
|
|
||||||
).buildAndExecute();
|
|
||||||
|
|
||||||
const postWithdrawData = await position.refreshData();
|
const postWithdrawData = await position.refreshData();
|
||||||
const expectedPostWithdrawLiquidity = postIncreaseData.liquidity.sub(
|
const expectedPostWithdrawLiquidity = postIncreaseData.liquidity.sub(
|
||||||
|
@ -164,9 +162,7 @@ describe("position-impl", () => {
|
||||||
pool
|
pool
|
||||||
);
|
);
|
||||||
|
|
||||||
await (
|
await (await position.increaseLiquidity(increase_quote, false)).buildAndExecute();
|
||||||
await position.increaseLiquidity(increase_quote, ctx.wallet.publicKey)
|
|
||||||
).buildAndExecute();
|
|
||||||
|
|
||||||
const postIncreaseData = await position.refreshData();
|
const postIncreaseData = await position.refreshData();
|
||||||
const expectedPostIncreaseLiquidity = preIncreaseData.liquidity.add(
|
const expectedPostIncreaseLiquidity = preIncreaseData.liquidity.add(
|
||||||
|
@ -214,9 +210,9 @@ describe("position-impl", () => {
|
||||||
await (
|
await (
|
||||||
await position.increaseLiquidity(
|
await position.increaseLiquidity(
|
||||||
increaseQuoteFromOtherWallet,
|
increaseQuoteFromOtherWallet,
|
||||||
|
true,
|
||||||
otherWallet.publicKey,
|
otherWallet.publicKey,
|
||||||
otherWallet.publicKey,
|
otherWallet.publicKey
|
||||||
true
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addSigner(otherWallet)
|
.addSigner(otherWallet)
|
||||||
|
@ -229,9 +225,9 @@ describe("position-impl", () => {
|
||||||
await (
|
await (
|
||||||
await position.decreaseLiquidity(
|
await position.decreaseLiquidity(
|
||||||
decrease_quote,
|
decrease_quote,
|
||||||
|
true,
|
||||||
destinationWallet.publicKey,
|
destinationWallet.publicKey,
|
||||||
otherWallet.publicKey,
|
otherWallet.publicKey
|
||||||
true
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addSigner(otherWallet)
|
.addSigner(otherWallet)
|
||||||
|
|
|
@ -20,12 +20,7 @@ import {
|
||||||
TickUtil,
|
TickUtil,
|
||||||
} from "../../../src";
|
} from "../../../src";
|
||||||
import Decimal from "decimal.js";
|
import Decimal from "decimal.js";
|
||||||
import {
|
import { deriveATA, Percentage, TransactionBuilder } from "@orca-so/common-sdk";
|
||||||
deriveATA,
|
|
||||||
Percentage,
|
|
||||||
TransactionBuilder,
|
|
||||||
TransactionProcessor,
|
|
||||||
} from "@orca-so/common-sdk";
|
|
||||||
import { mintTokensToTestAccount } from "../../utils/test-builders";
|
import { mintTokensToTestAccount } from "../../utils/test-builders";
|
||||||
|
|
||||||
describe("whirlpool-impl", () => {
|
describe("whirlpool-impl", () => {
|
||||||
|
|
Loading…
Reference in New Issue