@t2000/sdk 1.0.0 → 1.0.1

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.
@@ -77,14 +77,18 @@ interface LendingAdapter {
77
77
  buildSaveTx(address: string, amount: number, asset: string, options?: {
78
78
  collectFee?: boolean;
79
79
  }): Promise<AdapterTxResult>;
80
- buildWithdrawTx(address: string, amount: number, asset: string): Promise<AdapterTxResult & {
80
+ buildWithdrawTx(address: string, amount: number, asset: string, options?: {
81
+ skipPythUpdate?: boolean;
82
+ }): Promise<AdapterTxResult & {
81
83
  effectiveAmount: number;
82
84
  }>;
83
85
  buildBorrowTx(address: string, amount: number, asset: string, options?: {
84
86
  collectFee?: boolean;
87
+ skipPythUpdate?: boolean;
85
88
  }): Promise<AdapterTxResult>;
86
89
  buildRepayTx(address: string, amount: number, asset: string, options?: {
87
90
  skipOracle?: boolean;
91
+ skipPythUpdate?: boolean;
88
92
  }): Promise<AdapterTxResult>;
89
93
  maxWithdraw(address: string, asset: string): Promise<{
90
94
  maxAmount: number;
@@ -96,14 +100,18 @@ interface LendingAdapter {
96
100
  healthFactorAfter: number;
97
101
  currentHF: number;
98
102
  }>;
99
- addWithdrawToTx?(tx: Transaction, address: string, amount: number, asset: string): Promise<{
103
+ addWithdrawToTx?(tx: Transaction, address: string, amount: number, asset: string, options?: {
104
+ skipPythUpdate?: boolean;
105
+ }): Promise<{
100
106
  coin: TransactionObjectArgument;
101
107
  effectiveAmount: number;
102
108
  }>;
103
109
  addSaveToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
104
110
  collectFee?: boolean;
105
111
  }): Promise<void>;
106
- addRepayToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
112
+ addRepayToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
113
+ skipPythUpdate?: boolean;
114
+ }): Promise<void>;
107
115
  getPendingRewards?(address: string): Promise<PendingReward[]>;
108
116
  addClaimRewardsToTx?(tx: Transaction, address: string): Promise<PendingReward[]>;
109
117
  }
@@ -77,14 +77,18 @@ interface LendingAdapter {
77
77
  buildSaveTx(address: string, amount: number, asset: string, options?: {
78
78
  collectFee?: boolean;
79
79
  }): Promise<AdapterTxResult>;
80
- buildWithdrawTx(address: string, amount: number, asset: string): Promise<AdapterTxResult & {
80
+ buildWithdrawTx(address: string, amount: number, asset: string, options?: {
81
+ skipPythUpdate?: boolean;
82
+ }): Promise<AdapterTxResult & {
81
83
  effectiveAmount: number;
82
84
  }>;
83
85
  buildBorrowTx(address: string, amount: number, asset: string, options?: {
84
86
  collectFee?: boolean;
87
+ skipPythUpdate?: boolean;
85
88
  }): Promise<AdapterTxResult>;
86
89
  buildRepayTx(address: string, amount: number, asset: string, options?: {
87
90
  skipOracle?: boolean;
91
+ skipPythUpdate?: boolean;
88
92
  }): Promise<AdapterTxResult>;
89
93
  maxWithdraw(address: string, asset: string): Promise<{
90
94
  maxAmount: number;
@@ -96,14 +100,18 @@ interface LendingAdapter {
96
100
  healthFactorAfter: number;
97
101
  currentHF: number;
98
102
  }>;
99
- addWithdrawToTx?(tx: Transaction, address: string, amount: number, asset: string): Promise<{
103
+ addWithdrawToTx?(tx: Transaction, address: string, amount: number, asset: string, options?: {
104
+ skipPythUpdate?: boolean;
105
+ }): Promise<{
100
106
  coin: TransactionObjectArgument;
101
107
  effectiveAmount: number;
102
108
  }>;
103
109
  addSaveToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
104
110
  collectFee?: boolean;
105
111
  }): Promise<void>;
106
- addRepayToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
112
+ addRepayToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
113
+ skipPythUpdate?: boolean;
114
+ }): Promise<void>;
107
115
  getPendingRewards?(address: string): Promise<PendingReward[]>;
108
116
  addClaimRewardsToTx?(tx: Transaction, address: string): Promise<PendingReward[]>;
109
117
  }
package/dist/index.cjs CHANGED
@@ -5311,7 +5311,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
5311
5311
  }
5312
5312
  const tx = new transactions.Transaction();
5313
5313
  tx.setSender(address);
5314
- await refreshOracle(tx, client, address);
5314
+ await refreshOracle(tx, client, address, { skipPythUpdate: options.skipPythUpdate });
5315
5315
  try {
5316
5316
  const coin = await Qe(tx, assetInfo.type, rawAmount, sdkOptions(client));
5317
5317
  tx.transferObjects([coin], address);
@@ -5340,7 +5340,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
5340
5340
  });
5341
5341
  return { coin, effectiveAmount: 0 };
5342
5342
  }
5343
- await refreshOracle(tx, client, address);
5343
+ await refreshOracle(tx, client, address, { skipPythUpdate: options.skipPythUpdate });
5344
5344
  try {
5345
5345
  const coin = await Qe(tx, assetInfo.type, rawAmount, sdkOptions(client));
5346
5346
  return { coin, effectiveAmount };
@@ -5365,7 +5365,7 @@ async function addSaveToTx(tx, _client, _address, coin, options = {}) {
5365
5365
  async function addRepayToTx(tx, client, address, coin, options = {}) {
5366
5366
  const asset = options.asset ?? "USDC";
5367
5367
  const assetInfo = resolveAssetInfo(asset);
5368
- await refreshOracle(tx, client, address);
5368
+ await refreshOracle(tx, client, address, { skipPythUpdate: options.skipPythUpdate });
5369
5369
  try {
5370
5370
  await xe(tx, assetInfo.type, coin, { env: "prod" });
5371
5371
  } catch (err) {
@@ -5382,7 +5382,7 @@ async function buildBorrowTx(client, address, amount, options = {}) {
5382
5382
  const rawAmount = Number(stableToRaw(amount, assetInfo.decimals));
5383
5383
  const tx = new transactions.Transaction();
5384
5384
  tx.setSender(address);
5385
- await refreshOracle(tx, client, address);
5385
+ await refreshOracle(tx, client, address, { skipPythUpdate: options.skipPythUpdate });
5386
5386
  try {
5387
5387
  const borrowedCoin = await Xe(tx, assetInfo.type, rawAmount, sdkOptions(client));
5388
5388
  if (options.collectFee) {
@@ -5413,7 +5413,10 @@ async function buildRepayTx(client, address, amount, options = {}) {
5413
5413
  const coinObj = mergeCoins(tx, coins);
5414
5414
  const rawAmount = Math.min(rawRequested, Number(totalBalance));
5415
5415
  const [repayCoin] = tx.splitCoins(coinObj, [rawAmount]);
5416
- await refreshOracle(tx, client, address, { skipOracle: options.skipOracle });
5416
+ await refreshOracle(tx, client, address, {
5417
+ skipOracle: options.skipOracle,
5418
+ skipPythUpdate: options.skipPythUpdate
5419
+ });
5417
5420
  try {
5418
5421
  await xe(tx, assetInfo.type, repayCoin, {
5419
5422
  ...sdkOptions(client),
@@ -5724,9 +5727,12 @@ var NaviAdapter = class {
5724
5727
  const tx = await buildSaveTx(this.client, address, amount, { ...options, asset: normalized });
5725
5728
  return { tx };
5726
5729
  }
5727
- async buildWithdrawTx(address, amount, asset) {
5730
+ async buildWithdrawTx(address, amount, asset, options) {
5728
5731
  const normalized = normalizeAsset(asset);
5729
- const result = await buildWithdrawTx(this.client, address, amount, { asset: normalized });
5732
+ const result = await buildWithdrawTx(this.client, address, amount, {
5733
+ asset: normalized,
5734
+ skipPythUpdate: options?.skipPythUpdate
5735
+ });
5730
5736
  return { tx: result.tx, effectiveAmount: result.effectiveAmount };
5731
5737
  }
5732
5738
  async buildBorrowTx(address, amount, asset, options) {
@@ -5738,7 +5744,8 @@ var NaviAdapter = class {
5738
5744
  const normalized = normalizeAsset(asset);
5739
5745
  const tx = await buildRepayTx(this.client, address, amount, {
5740
5746
  asset: normalized,
5741
- skipOracle: options?.skipOracle
5747
+ skipOracle: options?.skipOracle,
5748
+ skipPythUpdate: options?.skipPythUpdate
5742
5749
  });
5743
5750
  return { tx };
5744
5751
  }
@@ -5748,17 +5755,23 @@ var NaviAdapter = class {
5748
5755
  async maxBorrow(address, _asset) {
5749
5756
  return maxBorrowAmount(this.client, address);
5750
5757
  }
5751
- async addWithdrawToTx(tx, address, amount, asset) {
5758
+ async addWithdrawToTx(tx, address, amount, asset, options) {
5752
5759
  const normalized = normalizeAsset(asset);
5753
- return addWithdrawToTx(tx, this.client, address, amount, { asset: normalized });
5760
+ return addWithdrawToTx(tx, this.client, address, amount, {
5761
+ asset: normalized,
5762
+ skipPythUpdate: options?.skipPythUpdate
5763
+ });
5754
5764
  }
5755
5765
  async addSaveToTx(tx, address, coin, asset, options) {
5756
5766
  const normalized = normalizeAsset(asset);
5757
5767
  return addSaveToTx(tx, this.client, address, coin, { ...options, asset: normalized });
5758
5768
  }
5759
- async addRepayToTx(tx, address, coin, asset) {
5769
+ async addRepayToTx(tx, address, coin, asset, options) {
5760
5770
  const normalized = normalizeAsset(asset);
5761
- return addRepayToTx(tx, this.client, address, coin, { asset: normalized });
5771
+ return addRepayToTx(tx, this.client, address, coin, {
5772
+ asset: normalized,
5773
+ skipPythUpdate: options?.skipPythUpdate
5774
+ });
5762
5775
  }
5763
5776
  async getPendingRewards(address) {
5764
5777
  return getPendingRewards(this.client, address);