@naviprotocol/wallet-client 1.0.3-dev.2 → 1.0.3-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getFullnodeUrl as le, SuiClient as ie } from "@mysten/sui/client";
2
2
  import re from "mitt";
3
3
  import ce from "axios";
4
- import { withSingleton as L, getCoins as oe, mergeCoinsPTB as y, getPriceFeeds as Q, updateOraclePricesPTB as q, filterPriceFeeds as K, getFlashLoanAsset as V, flashloanPTB as X, depositCoinPTB as A, withdrawCoinPTB as Y, repayFlashLoanPTB as Z, repayCoinPTB as ee, borrowCoinPTB as te, getPools as ue, getPool as P, getHealthFactor as de, liquidatePTB as we, getUserAvailableLendingRewards as H, getUserClaimedRewardHistory as he, claimLendingRewardsPTB as fe, getLendingState as ge, createAccountCapPTB as me, withCache as ae, parseTxValue as x } from "@naviprotocol/lending";
4
+ import { withSingleton as L, getCoins as oe, mergeCoinsPTB as y, getPriceFeeds as Q, updateOraclePricesPTB as q, filterPriceFeeds as K, getFlashLoanAsset as V, flashloanPTB as X, depositCoinPTB as F, withdrawCoinPTB as Y, repayFlashLoanPTB as Z, repayCoinPTB as ee, borrowCoinPTB as te, getPools as ue, getPool as P, getHealthFactor as de, liquidatePTB as we, getUserAvailableLendingRewards as H, getUserClaimedRewardHistory as he, claimLendingRewardsPTB as fe, getLendingState as ge, createAccountCapPTB as me, withCache as ae, parseTxValue as x } from "@naviprotocol/lending";
5
5
  import p, { BigNumber as M } from "bignumber.js";
6
6
  import { normalizeStructTag as T } from "@mysten/sui/utils";
7
7
  import { Transaction as w } from "@mysten/sui/transactions";
@@ -328,11 +328,11 @@ function Te(r, e = 2) {
328
328
  return r ? new p(r.toString()).shiftedBy(-1 * Pe).multipliedBy(100).decimalPlaces(e, p.ROUND_DOWN).toFixed(e) : "0.00";
329
329
  }
330
330
  async function D(r, e, a, t) {
331
- var S, F;
331
+ var S, O;
332
332
  if (!this.walletClient)
333
333
  throw new Error("Wallet client not found");
334
- await this.walletClient.balance.waitForUpdate();
335
- const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), l = c.find((O) => O.pool.id === s.id), i = this.walletClient.address;
334
+ await this.walletClient.balance.updatePortfolio();
335
+ const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), l = c.find((A) => A.pool.id === s.id), i = this.walletClient.address;
336
336
  if (console.log("migrateBetweenSupplyPTB", {
337
337
  lendingState: c,
338
338
  fromPoolLending: l,
@@ -356,7 +356,7 @@ async function D(r, e, a, t) {
356
356
  });
357
357
  if (!d)
358
358
  throw new Error(`${n.token.symbol} pool not support flashloan`);
359
- const h = (S = t == null ? void 0 : t.slippage) != null ? S : 5e-3, f = (F = t == null ? void 0 : t.amount) != null ? F : Number(l.supplyBalance), b = await this.walletClient.swap.getQuote(
359
+ const h = (S = t == null ? void 0 : t.slippage) != null ? S : 5e-3, f = (O = t == null ? void 0 : t.amount) != null ? O : Number(l.supplyBalance), b = await this.walletClient.swap.getQuote(
360
360
  s.suiCoinType,
361
361
  n.suiCoinType,
362
362
  f
@@ -371,31 +371,31 @@ async function D(r, e, a, t) {
371
371
  arguments: [B],
372
372
  typeArguments: [n.suiCoinType]
373
373
  });
374
- await A(r, n, k, {
374
+ await F(r, n, k, {
375
375
  amount: g
376
376
  });
377
- const j = await Y(r, s, f), U = await $(
377
+ const j = await Y(r, s, f), _ = await $(
378
378
  i,
379
379
  r,
380
380
  C,
381
381
  j,
382
382
  b
383
- ), _ = r.moveCall({
383
+ ), U = r.moveCall({
384
384
  target: "0x2::coin::into_balance",
385
- arguments: [U],
385
+ arguments: [_],
386
386
  typeArguments: [n.suiCoinType]
387
- }), [W] = await Z(r, n, v, _), [N] = r.moveCall({
387
+ }), [W] = await Z(r, n, v, U), [N] = r.moveCall({
388
388
  target: "0x2::coin::from_balance",
389
389
  arguments: [W],
390
390
  typeArguments: [n.suiCoinType]
391
391
  });
392
- return await A(r, n, N), r;
392
+ return await F(r, n, N), r;
393
393
  }
394
394
  async function J(r, e, a, t) {
395
- var O, G;
395
+ var A, G;
396
396
  if (!this.walletClient)
397
397
  throw new Error("Wallet client not found");
398
- await this.walletClient.balance.waitForUpdate();
398
+ await this.walletClient.balance.updatePortfolio();
399
399
  const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a), l = await this.getLendingState(), i = l.find((I) => I.pool.id === n.id);
400
400
  if (console.log("migrateBetweenBorrowPTB", {
401
401
  lendingState: l,
@@ -415,7 +415,7 @@ async function J(r, e, a, t) {
415
415
  pools: u
416
416
  })
417
417
  );
418
- let d = (O = t == null ? void 0 : t.amount) != null ? O : Number(i.borrowBalance);
418
+ let d = (A = t == null ? void 0 : t.amount) != null ? A : Number(i.borrowBalance);
419
419
  if (Number(i.borrowBalance) === d) {
420
420
  const I = parseFloat(Te(n.currentBorrowRate, 8)) / 100;
421
421
  d = Math.ceil(
@@ -445,36 +445,36 @@ async function J(r, e, a, t) {
445
445
  n.suiCoinType,
446
446
  B
447
447
  );
448
- const [k, j] = await X(r, n, d), [U] = r.moveCall({
448
+ const [k, j] = await X(r, n, d), [_] = r.moveCall({
449
449
  target: "0x2::coin::from_balance",
450
450
  arguments: [k],
451
451
  typeArguments: [n.suiCoinType]
452
452
  });
453
- await ee(r, n, U, {
453
+ await ee(r, n, _, {
454
454
  amount: d
455
455
  });
456
- const _ = await te(r, c, B), W = await $(
456
+ const U = await te(r, c, B), W = await $(
457
457
  s,
458
458
  r,
459
459
  b,
460
- _,
460
+ U,
461
461
  v
462
462
  ), N = r.moveCall({
463
463
  target: "0x2::coin::into_balance",
464
464
  arguments: [W],
465
465
  typeArguments: [n.suiCoinType]
466
- }), [S] = await Z(r, n, j, N), [F] = r.moveCall({
466
+ }), [S] = await Z(r, n, j, N), [O] = r.moveCall({
467
467
  target: "0x2::coin::from_balance",
468
468
  arguments: [S],
469
469
  typeArguments: [n.suiCoinType]
470
470
  });
471
- return r.transferObjects([F], s), r;
471
+ return r.transferObjects([O], s), r;
472
472
  }
473
473
  async function z(r, e, a, t) {
474
474
  var o, u;
475
475
  if (!this.walletClient)
476
476
  throw new Error("Wallet client not found");
477
- await this.walletClient.balance.waitForUpdate(), this.walletClient.address;
477
+ await this.walletClient.balance.updatePortfolio(), this.walletClient.address;
478
478
  const s = await this.getPool(a), n = this.walletClient.balance.portfolio.getBalance(e);
479
479
  if (n.amount.eq(0))
480
480
  throw new Error(`No balance of ${e}`);
@@ -494,7 +494,7 @@ async function z(r, e, a, t) {
494
494
  l
495
495
  );
496
496
  }
497
- return await A(r, s, i), r;
497
+ return await F(r, s, i), r;
498
498
  }
499
499
  class ve extends R {
500
500
  constructor() {
@@ -547,7 +547,7 @@ class ve extends R {
547
547
  balance: a,
548
548
  useGasCoin: !0
549
549
  });
550
- await A(n, s, l, {
550
+ await F(n, s, l, {
551
551
  env: this.config.env,
552
552
  amount: a,
553
553
  accountCap: t == null ? void 0 : t.accountCap
@@ -1158,7 +1158,7 @@ const Se = {
1158
1158
  swap: new Ee(),
1159
1159
  /** Haedal protocol module */
1160
1160
  haedal: new Re()
1161
- }, Fe = {
1161
+ }, Oe = {
1162
1162
  url: le("mainnet")
1163
1163
  };
1164
1164
  class Ie {
@@ -1169,7 +1169,7 @@ class Ie {
1169
1169
  constructor(e) {
1170
1170
  this.modules = Se, this.userConfigs = {}, this.events = re();
1171
1171
  const a = {
1172
- ...Fe,
1172
+ ...Oe,
1173
1173
  ...e.client
1174
1174
  };
1175
1175
  a.transport = a.transport || new ye(a.url), this.client = new ie(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {