orca-so / typescript-sdk

The Orca SDK contains a set of simple to use APIs to allow developers to integrate with the Orca platform.
155 stars 49 forks source link

Pool add getDepositQuote, getWithdrawQuote api's #47

Closed ghost closed 3 years ago

ghost commented 3 years ago

Context

Changes

Usage Example

const orca = getOrca(connection);
const pool = orca.getPool(OrcaPoolConfig.ORCA_SOL);

const orcaAmount = new Decimal(10);
const quote = await pool.getQuote(pool.getTokenA(), orcaAmount);
const solAmount = quote.getMinOutputAmount();
const poolTokenAmount = await pool.getDepositQuote(orcaAmount, solAmount); // <-- NEW

console.log(`Deposit at most ${orcaAmount} ORCA and ${solAmount} SOL, for at least ${
  poolTokenAmount
} pool tokens`);

const depositPayload = await pool.deposit(owner, orcaAmount, solAmount, poolTokenAmount);
const depositTxId = await depositPayload.execute();

console.log("Confirmation:", depositTxId);
ghost commented 3 years ago

@odcheung - Thanks for the review! Pushed new commits which makes these changes:

ghost commented 3 years ago

Hey @odcheung, haha no worries! I really appreciate all the feedback, and sdk is better for it 🙂

Agree that we should be thoughtful around one-way-door decisions. I think in this case we definitely wanted to get it right because getDepositQuote, getWithdrawQuote will be an integral part of the SDK. Tangentially though, I think it's ok to push an api, then deprecate and add new versions of it without having api breaking changes (e.g. pool.someCoolMethod, later introduce pool.someCoolMethodV2).

Updated the PR with the following changes:

ghost commented 3 years ago

@odcheung - thanks for the review! updated the commented, and merging now. I'll also bump the version and publish it