Skip to content

Commit

Permalink
Prettify & add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bathord committed May 10, 2024
1 parent 45ade32 commit 65829b9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/providers/interest/interest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,7 @@ export class InterestProtocolSingleton extends EventEmitter implements IPoolProv

const [coinPath, poolObjectIdPath, amountObject] = getBestInterestRoute(routes);
const bestRoute: SwapRouteArgs["route"] = [coinPath, poolObjectIdPath];
const { amount } = amountObject;

const amountWithSlippage = getAmountWithSlippage(amount.toString(), slippagePercentage);
const amountWithSlippage = getAmountWithSlippage(amountObject.amount.toString(), slippagePercentage);

return {
outputAmount: BigInt(amountWithSlippage),
Expand Down Expand Up @@ -376,10 +374,13 @@ export class InterestProtocolSingleton extends EventEmitter implements IPoolProv
const inputCoinObjects = await getUserCoinObjects({ coinType: inputCoinType, provider: this.provider, publicKey });
let destinationObjectId: MoveObjectArgument;

// If SUI is an input coin, just split a needed for a swap input amount from gas object.
if (isSuiCoinType(inputCoinType)) {
const [coin] = tx.splitCoins(tx.gas, [tx.pure(formattedInputAmount)]);
destinationObjectId = coin;
} else {
// If the input coin is not SUI, merge all its objects into one and split the needed for the swap input amount
// from the merge-result object.
const { destinationObjectId: mergeDestination } = WalletManagerSingleton.mergeAllCoinObjects({
coinObjects: inputCoinObjects,
txb: tx,
Expand Down

0 comments on commit 65829b9

Please sign in to comment.