@naviprotocol/lending 2.0.5-dev.0 → 2.0.6
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/account-cap.d.ts +1 -1
- package/dist/account.d.ts +2 -2
- package/dist/config.d.ts +1 -1
- package/dist/emode.d.ts +1 -1
- package/dist/flashloan.d.ts +1 -1
- package/dist/index.d.ts +17 -17
- package/dist/index.esm.js +2749 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/liquidate.d.ts +1 -1
- package/dist/market.d.ts +1 -1
- package/dist/oracle.d.ts +2 -2
- package/dist/oracle.d.ts.map +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pyth.d.ts +1 -1
- package/dist/reward.d.ts +1 -1
- package/dist/sui.d.ts +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/package.json +5 -5
- package/dist/account-cap.js +0 -26
- package/dist/account-cap.js.map +0 -1
- package/dist/account.js +0 -655
- package/dist/account.js.map +0 -1
- package/dist/bcs.js +0 -137
- package/dist/bcs.js.map +0 -1
- package/dist/config.js +0 -22
- package/dist/config.js.map +0 -1
- package/dist/emode.js +0 -90
- package/dist/emode.js.map +0 -1
- package/dist/flashloan.js +0 -94
- package/dist/flashloan.js.map +0 -1
- package/dist/index.js +0 -100
- package/dist/index.js.map +0 -1
- package/dist/liquidate.js +0 -76
- package/dist/liquidate.js.map +0 -1
- package/dist/market.js +0 -121
- package/dist/market.js.map +0 -1
- package/dist/oracle.js +0 -198
- package/dist/oracle.js.map +0 -1
- package/dist/package.json.js +0 -8
- package/dist/package.json.js.map +0 -1
- package/dist/pool.js +0 -391
- package/dist/pool.js.map +0 -1
- package/dist/pyth.js +0 -305
- package/dist/pyth.js.map +0 -1
- package/dist/reward.js +0 -343
- package/dist/reward.js.map +0 -1
- package/dist/services.js +0 -52
- package/dist/services.js.map +0 -1
- package/dist/sui.js +0 -121
- package/dist/sui.js.map +0 -1
- package/dist/ua.js +0 -16
- package/dist/ua.js.map +0 -1
- package/dist/utils.js +0 -227
- package/dist/utils.js.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { UserPositions as r, getCoins as o, getHealthFactor as a, getHealthFactorPTB as i, getLendingPositions as n, getLendingState as s, getSimulatedHealthFactor as l, getSimulatedHealthFactorPTB as d, getTransactions as g, mergeCoinsPTB as P, verifyHealthFactorPTB as c } from "./account.js";
|
|
2
|
-
import { Address as T, FlashLoanAssetConfig as f, IncentiveAPYInfo as C, IncentivePoolInfo as B, IncentivePoolInfoByPhase as m, OracleInfo as h, ReserveDataInfo as A, UserStateInfo as I } from "./bcs.js";
|
|
3
|
-
import { DEFAULT_CACHE_TIME as F, getConfig as v } from "./config.js";
|
|
4
|
-
import { filterPriceFeeds as L, getPriceFeeds as S, getPythStalePriceFeedId as y, getPythStalePriceFeedIdV2 as E, updateOraclePriceBeforeUserOperationPTB as M, updateOraclePricesPTB as U, updatePythPriceFeeds as w } from "./oracle.js";
|
|
5
|
-
import { flashloanPTB as R, getAllFlashLoanAssets as O, getFlashLoanAsset as H, repayFlashLoanPTB as _ } from "./flashloan.js";
|
|
6
|
-
import { liquidatePTB as D } from "./liquidate.js";
|
|
7
|
-
import { PoolOperator as G, borrowCoinPTB as q, depositCoinPTB as z, getBorrowFee as K, getFees as Q, getPool as V, getPools as Y, getStats as j, repayCoinPTB as J, withdrawCoinPTB as W } from "./pool.js";
|
|
8
|
-
import { claimLendingRewardsPTB as Z, getUserAvailableLendingRewards as $, getUserClaimedRewardHistory as ee, getUserTotalClaimedReward as te, summaryLendingRewards as re } from "./reward.js";
|
|
9
|
-
import { normalizeCoinType as ae, parsePoolUID as ie, parseTxValue as ne, withCache as se, withSingleton as le } from "./utils.js";
|
|
10
|
-
import { createAccountCapPTB as ge, getAccountCapOwnerPTB as Pe } from "./account-cap.js";
|
|
11
|
-
import { createEModeCapPTB as pe, emodeIdentityId as Te, enterEModePTB as fe, exitEModePTB as Ce, getUserEModeCaps as Be } from "./emode.js";
|
|
12
|
-
import { DEFAULT_MARKET_IDENTITY as he, MARKETS as Ae, Market as Ie, getMarket as ue, getMarketConfig as Fe, getMarkets as ve } from "./market.js";
|
|
13
|
-
import { NaviMissingGraphQLClientError as Le, PUBLIC_MAINNET_GRPC_URL as Se, createNaviLegacyJsonRpcClient as ye, createNaviSuiClient as Ee, createNaviSuiClientBundle as Me, getAddressBalance as Ue, getCoinObjectOnlyBalance as we, listAddressBalances as Ne, normalizeAddressBalance as Re, requireNaviGraphQLClient as Oe } from "./sui.js";
|
|
14
|
-
import { SuiPriceServiceConnection as _e, SuiPythClient as ke } from "./pyth.js";
|
|
15
|
-
import { buildNaviOpenApiUrl as be, configureNaviSdk as Ge, mergeServiceHeaders as qe, resolveNaviOpenApiEndpoint as ze } from "./services.js";
|
|
16
|
-
export {
|
|
17
|
-
T as Address,
|
|
18
|
-
F as DEFAULT_CACHE_TIME,
|
|
19
|
-
he as DEFAULT_MARKET_IDENTITY,
|
|
20
|
-
f as FlashLoanAssetConfig,
|
|
21
|
-
C as IncentiveAPYInfo,
|
|
22
|
-
B as IncentivePoolInfo,
|
|
23
|
-
m as IncentivePoolInfoByPhase,
|
|
24
|
-
Ae as MARKETS,
|
|
25
|
-
Ie as Market,
|
|
26
|
-
Le as NaviMissingGraphQLClientError,
|
|
27
|
-
h as OracleInfo,
|
|
28
|
-
Se as PUBLIC_MAINNET_GRPC_URL,
|
|
29
|
-
G as PoolOperator,
|
|
30
|
-
A as ReserveDataInfo,
|
|
31
|
-
_e as SuiPriceServiceConnection,
|
|
32
|
-
ke as SuiPythClient,
|
|
33
|
-
r as UserPositions,
|
|
34
|
-
I as UserStateInfo,
|
|
35
|
-
q as borrowCoinPTB,
|
|
36
|
-
be as buildNaviOpenApiUrl,
|
|
37
|
-
Z as claimLendingRewardsPTB,
|
|
38
|
-
Ge as configureNaviSdk,
|
|
39
|
-
ge as createAccountCapPTB,
|
|
40
|
-
pe as createEModeCapPTB,
|
|
41
|
-
ye as createNaviLegacyJsonRpcClient,
|
|
42
|
-
Ee as createNaviSuiClient,
|
|
43
|
-
Me as createNaviSuiClientBundle,
|
|
44
|
-
z as depositCoinPTB,
|
|
45
|
-
Te as emodeIdentityId,
|
|
46
|
-
fe as enterEModePTB,
|
|
47
|
-
Ce as exitEModePTB,
|
|
48
|
-
L as filterPriceFeeds,
|
|
49
|
-
R as flashloanPTB,
|
|
50
|
-
Pe as getAccountCapOwnerPTB,
|
|
51
|
-
Ue as getAddressBalance,
|
|
52
|
-
O as getAllFlashLoanAssets,
|
|
53
|
-
K as getBorrowFee,
|
|
54
|
-
we as getCoinObjectOnlyBalance,
|
|
55
|
-
o as getCoins,
|
|
56
|
-
v as getConfig,
|
|
57
|
-
Q as getFees,
|
|
58
|
-
H as getFlashLoanAsset,
|
|
59
|
-
a as getHealthFactor,
|
|
60
|
-
i as getHealthFactorPTB,
|
|
61
|
-
n as getLendingPositions,
|
|
62
|
-
s as getLendingState,
|
|
63
|
-
ue as getMarket,
|
|
64
|
-
Fe as getMarketConfig,
|
|
65
|
-
ve as getMarkets,
|
|
66
|
-
V as getPool,
|
|
67
|
-
Y as getPools,
|
|
68
|
-
S as getPriceFeeds,
|
|
69
|
-
y as getPythStalePriceFeedId,
|
|
70
|
-
E as getPythStalePriceFeedIdV2,
|
|
71
|
-
l as getSimulatedHealthFactor,
|
|
72
|
-
d as getSimulatedHealthFactorPTB,
|
|
73
|
-
j as getStats,
|
|
74
|
-
g as getTransactions,
|
|
75
|
-
$ as getUserAvailableLendingRewards,
|
|
76
|
-
ee as getUserClaimedRewardHistory,
|
|
77
|
-
Be as getUserEModeCaps,
|
|
78
|
-
te as getUserTotalClaimedReward,
|
|
79
|
-
D as liquidatePTB,
|
|
80
|
-
Ne as listAddressBalances,
|
|
81
|
-
P as mergeCoinsPTB,
|
|
82
|
-
qe as mergeServiceHeaders,
|
|
83
|
-
Re as normalizeAddressBalance,
|
|
84
|
-
ae as normalizeCoinType,
|
|
85
|
-
ie as parsePoolUID,
|
|
86
|
-
ne as parseTxValue,
|
|
87
|
-
J as repayCoinPTB,
|
|
88
|
-
_ as repayFlashLoanPTB,
|
|
89
|
-
Oe as requireNaviGraphQLClient,
|
|
90
|
-
ze as resolveNaviOpenApiEndpoint,
|
|
91
|
-
re as summaryLendingRewards,
|
|
92
|
-
M as updateOraclePriceBeforeUserOperationPTB,
|
|
93
|
-
U as updateOraclePricesPTB,
|
|
94
|
-
w as updatePythPriceFeeds,
|
|
95
|
-
c as verifyHealthFactorPTB,
|
|
96
|
-
se as withCache,
|
|
97
|
-
le as withSingleton,
|
|
98
|
-
W as withdrawCoinPTB
|
|
99
|
-
};
|
|
100
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
package/dist/liquidate.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { getConfig as j, DEFAULT_CACHE_TIME as g } from "./config.js";
|
|
2
|
-
import { getPool as u } from "./pool.js";
|
|
3
|
-
import { parseTxValue as n } from "./utils.js";
|
|
4
|
-
async function C(e, s, l, b, p, m) {
|
|
5
|
-
const i = {
|
|
6
|
-
...m,
|
|
7
|
-
cacheTime: g
|
|
8
|
-
}, o = await j(i), c = await u(s, i), a = await u(b, i);
|
|
9
|
-
if (o.version === 1) {
|
|
10
|
-
const [t, r] = e.moveCall({
|
|
11
|
-
target: `${o.package}::incentive_v3::liquidation`,
|
|
12
|
-
arguments: [
|
|
13
|
-
e.object("0x06"),
|
|
14
|
-
// Clock object
|
|
15
|
-
e.object(o.priceOracle),
|
|
16
|
-
// Price oracle for asset pricing
|
|
17
|
-
e.object(o.storage),
|
|
18
|
-
// Protocol storage
|
|
19
|
-
e.pure.u8(c.id),
|
|
20
|
-
// Pay asset ID
|
|
21
|
-
e.object(c.contract.pool),
|
|
22
|
-
// Pay asset pool contract
|
|
23
|
-
n(l, e.object),
|
|
24
|
-
// Debt repayment amount
|
|
25
|
-
e.pure.u8(a.id),
|
|
26
|
-
// Collateral asset ID
|
|
27
|
-
e.object(a.contract.pool),
|
|
28
|
-
// Collateral asset pool contract
|
|
29
|
-
n(p, e.pure.address),
|
|
30
|
-
// Borrower address
|
|
31
|
-
e.object(o.incentiveV2),
|
|
32
|
-
// Incentive V2 contract
|
|
33
|
-
e.object(o.incentiveV3)
|
|
34
|
-
// Incentive V3 contract
|
|
35
|
-
],
|
|
36
|
-
typeArguments: [c.suiCoinType, a.suiCoinType]
|
|
37
|
-
});
|
|
38
|
-
return [t, r];
|
|
39
|
-
} else {
|
|
40
|
-
const [t, r] = e.moveCall({
|
|
41
|
-
target: `${o.package}::incentive_v3::liquidation_v2`,
|
|
42
|
-
arguments: [
|
|
43
|
-
e.object("0x06"),
|
|
44
|
-
// Clock object
|
|
45
|
-
e.object(o.priceOracle),
|
|
46
|
-
// Price oracle for asset pricing
|
|
47
|
-
e.object(o.storage),
|
|
48
|
-
// Protocol storage
|
|
49
|
-
e.pure.u8(c.id),
|
|
50
|
-
// Pay asset ID
|
|
51
|
-
e.object(c.contract.pool),
|
|
52
|
-
// Pay asset pool contract
|
|
53
|
-
n(l, e.object),
|
|
54
|
-
// Debt repayment amount
|
|
55
|
-
e.pure.u8(a.id),
|
|
56
|
-
// Collateral asset ID
|
|
57
|
-
e.object(a.contract.pool),
|
|
58
|
-
// Collateral asset pool contract
|
|
59
|
-
n(p, e.pure.address),
|
|
60
|
-
// Borrower address
|
|
61
|
-
e.object(o.incentiveV2),
|
|
62
|
-
// Incentive V2 contract
|
|
63
|
-
e.object(o.incentiveV3),
|
|
64
|
-
// Incentive V3 contract
|
|
65
|
-
e.object("0x05")
|
|
66
|
-
// SuiSystemState object
|
|
67
|
-
],
|
|
68
|
-
typeArguments: [c.suiCoinType, a.suiCoinType]
|
|
69
|
-
});
|
|
70
|
-
return [t, r];
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
C as liquidatePTB
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=liquidate.js.map
|
package/dist/liquidate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"liquidate.js","sources":["../src/liquidate.ts"],"sourcesContent":["/**\n * Liquidation Functionality for Lending Protocol\n *\n * This module provides liquidation capabilities for the lending protocol.\n * Liquidation allows liquidators to repay a borrower's debt in exchange for their collateral\n * when the borrower's health factor falls below the liquidation threshold.\n */\n\nimport {\n AssetIdentifier,\n CoinObject,\n EnvOption,\n TransactionResult,\n MarketOption,\n ServiceOption\n} from './types'\nimport { Transaction } from '@mysten/sui/transactions'\nimport { DEFAULT_CACHE_TIME, getConfig } from './config'\nimport { getPool } from './pool'\nimport { getAllFlashLoanAssets } from './flashloan'\nimport { normalizeCoinType, parseTxValue } from './utils'\n\n/**\n * Create a liquidation transaction in the PTB (Programmable Transaction Block)\n *\n * This function allows liquidators to liquidate a borrower's position by repaying\n * their debt in exchange for their collateral. The liquidation process uses flash loans\n * to ensure atomic execution of the liquidation transaction.\n *\n * @param tx - The transaction block to add the liquidation operation to\n * @param payAsset - Asset identifier for the debt being repaid\n * @param payCoinObject - Coin object containing the debt repayment amount\n * @param collateralAsset - Asset identifier for the collateral being liquidated\n * @param liquidateAddress - Address of the borrower being liquidated\n * @param options - Optional environment configuration\n * @returns Tuple containing [collateralBalance, remainDebtBalance] where:\n * - collateralBalance: The collateral received from liquidation\n * - remainDebtBalance: Any remaining debt after liquidation\n * @throws Error if either pay asset or collateral asset does not support flash loans\n */\nexport async function liquidatePTB(\n tx: Transaction,\n payAsset: AssetIdentifier,\n payCoinObject: CoinObject,\n collateralAsset: AssetIdentifier,\n liquidateAddress: string | TransactionResult,\n options?: Partial<EnvOption & MarketOption & ServiceOption>\n) {\n const commonOptions = {\n ...options,\n cacheTime: DEFAULT_CACHE_TIME\n }\n const config = await getConfig(commonOptions)\n const payPool = await getPool(payAsset, commonOptions)\n const collateralPool = await getPool(collateralAsset, commonOptions)\n\n if (config.version === 1) {\n // Execute the liquidation transaction\n const [collateralBalance, remainDebtBalance] = tx.moveCall({\n target: `${config.package}::incentive_v3::liquidation`,\n arguments: [\n tx.object('0x06'), // Clock object\n tx.object(config.priceOracle), // Price oracle for asset pricing\n tx.object(config.storage), // Protocol storage\n tx.pure.u8(payPool.id), // Pay asset ID\n tx.object(payPool.contract.pool), // Pay asset pool contract\n parseTxValue(payCoinObject, tx.object), // Debt repayment amount\n tx.pure.u8(collateralPool.id), // Collateral asset ID\n tx.object(collateralPool.contract.pool), // Collateral asset pool contract\n parseTxValue(liquidateAddress, tx.pure.address), // Borrower address\n tx.object(config.incentiveV2), // Incentive V2 contract\n tx.object(config.incentiveV3) // Incentive V3 contract\n ],\n typeArguments: [payPool.suiCoinType, collateralPool.suiCoinType]\n })\n\n return [collateralBalance, remainDebtBalance]\n } else {\n // Execute the liquidation transaction\n const [collateralBalance, remainDebtBalance] = tx.moveCall({\n target: `${config.package}::incentive_v3::liquidation_v2`,\n arguments: [\n tx.object('0x06'), // Clock object\n tx.object(config.priceOracle), // Price oracle for asset pricing\n tx.object(config.storage), // Protocol storage\n tx.pure.u8(payPool.id), // Pay asset ID\n tx.object(payPool.contract.pool), // Pay asset pool contract\n parseTxValue(payCoinObject, tx.object), // Debt repayment amount\n tx.pure.u8(collateralPool.id), // Collateral asset ID\n tx.object(collateralPool.contract.pool), // Collateral asset pool contract\n parseTxValue(liquidateAddress, tx.pure.address), // Borrower address\n tx.object(config.incentiveV2), // Incentive V2 contract\n tx.object(config.incentiveV3), // Incentive V3 contract\n tx.object('0x05') // SuiSystemState object\n ],\n typeArguments: [payPool.suiCoinType, collateralPool.suiCoinType]\n })\n\n return [collateralBalance, remainDebtBalance]\n }\n}\n"],"names":["liquidatePTB","tx","payAsset","payCoinObject","collateralAsset","liquidateAddress","options","commonOptions","DEFAULT_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W;AAAA,QACTR,EAAG,OAAO,MAAM;AAAA;AAAA,QAChBA,EAAG,OAAOQ,EAAO,WAAW;AAAA;AAAA,QAC5BR,EAAG,OAAOQ,EAAO,OAAO;AAAA;AAAA,QACxBR,EAAG,KAAK,GAAGU,EAAQ,EAAE;AAAA;AAAA,QACrBV,EAAG,OAAOU,EAAQ,SAAS,IAAI;AAAA;AAAA,QAC/BK,EAAab,GAAeF,EAAG,MAAM;AAAA;AAAA,QACrCA,EAAG,KAAK,GAAGY,EAAe,EAAE;AAAA;AAAA,QAC5BZ,EAAG,OAAOY,EAAe,SAAS,IAAI;AAAA;AAAA,QACtCG,EAAaX,GAAkBJ,EAAG,KAAK,OAAO;AAAA;AAAA,QAC9CA,EAAG,OAAOQ,EAAO,WAAW;AAAA;AAAA,QAC5BR,EAAG,OAAOQ,EAAO,WAAW;AAAA;AAAA,QAC5BR,EAAG,OAAO,MAAM;AAAA;AAAA,MAAA;AAAA,MAElB,eAAe,CAACU,EAAQ,aAAaE,EAAe,WAAW;AAAA,IAAA,CAChE;AAED,WAAO,CAACC,GAAmBC,CAAiB;AAAA,EAC9C;AACF;"}
|
package/dist/market.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { withCache as M, getPoolsMap as p, getEmodesMap as f, withSingleton as g } from "./utils.js";
|
|
2
|
-
import { getPools as k } from "./pool.js";
|
|
3
|
-
import m from "bignumber.js";
|
|
4
|
-
const v = "main", E = {
|
|
5
|
-
main: {
|
|
6
|
-
id: 0,
|
|
7
|
-
key: "main",
|
|
8
|
-
name: "Main Market"
|
|
9
|
-
},
|
|
10
|
-
ember: {
|
|
11
|
-
id: 1,
|
|
12
|
-
key: "ember",
|
|
13
|
-
name: "Ember Market"
|
|
14
|
-
},
|
|
15
|
-
rwa: {
|
|
16
|
-
id: 2,
|
|
17
|
-
key: "rwa",
|
|
18
|
-
name: "Matrixdock Market"
|
|
19
|
-
},
|
|
20
|
-
"sui-eco": {
|
|
21
|
-
id: 3,
|
|
22
|
-
key: "sui-eco",
|
|
23
|
-
name: "Sui Eco Market"
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
class P {
|
|
27
|
-
constructor(o, s) {
|
|
28
|
-
this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
|
|
29
|
-
marketTotalSupplyValue: "0",
|
|
30
|
-
marketTotalBorrowValue: "0"
|
|
31
|
-
}, this.config = b(o), this.initPools(s);
|
|
32
|
-
}
|
|
33
|
-
get overview() {
|
|
34
|
-
return this._overview;
|
|
35
|
-
}
|
|
36
|
-
initPools(o) {
|
|
37
|
-
const s = p(this.pools), i = f(this.emodes), t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
38
|
-
let a = m(0), l = m(0);
|
|
39
|
-
o.forEach((e) => {
|
|
40
|
-
if (!this.checkMarket(e.market)) {
|
|
41
|
-
console.warn(`Pool is not in market ${this.config.name}`, e);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
s[e.uniqueId] || this.pools.push(e), e?.emodes?.forEach((u) => {
|
|
45
|
-
i[u.uniqueId] || this.emodes.push(u), u.assets.forEach((h) => {
|
|
46
|
-
h.isDebt && u.assets.find(
|
|
47
|
-
(d) => d.isCollateral && d.ltv > 0 && d.assetId !== e.id
|
|
48
|
-
) && t.add(e.uniqueId), h.isCollateral && u.assets.find((d) => d.isDebt && d.assetId !== e.id) && n.add(e.uniqueId);
|
|
49
|
-
});
|
|
50
|
-
}), l = l.plus(e.poolBorrowValue), a = a.plus(e.poolSupplyValue);
|
|
51
|
-
}), this.poolMap = p(this.pools, "id"), this.emodeMap = f(this.emodes, "emodeId"), this.emodes.forEach((e) => {
|
|
52
|
-
const c = this.getEModePools(e.emodeId);
|
|
53
|
-
this.emodePools.push(...c);
|
|
54
|
-
}), this._overview = {
|
|
55
|
-
marketTotalSupplyValue: a.toString(),
|
|
56
|
-
marketTotalBorrowValue: l.toString()
|
|
57
|
-
}, this.emodeBorrowablePools = this.pools.filter((e) => t.has(e.uniqueId)), this.emodeSupplyablePools = this.pools.filter((e) => n.has(e.uniqueId));
|
|
58
|
-
}
|
|
59
|
-
getEMode(o) {
|
|
60
|
-
return this.emodeMap[o] || null;
|
|
61
|
-
}
|
|
62
|
-
getEModeRelatePools(o, s) {
|
|
63
|
-
const { collateral: i, debt: t, emodeId: n } = s || {}, a = [];
|
|
64
|
-
return o.emodes.forEach((l) => {
|
|
65
|
-
typeof n == "number" && n !== l.emodeId || l.assets.forEach((e) => {
|
|
66
|
-
typeof i == "boolean" && i && e.isCollateral && e.assetId === o.id && a.push(this.poolMap[e.assetId]), typeof t == "boolean" && t && e.isDebt && e.assetId === o.id && a.push(this.poolMap[e.assetId]);
|
|
67
|
-
});
|
|
68
|
-
}), a;
|
|
69
|
-
}
|
|
70
|
-
getEModePools(o) {
|
|
71
|
-
const s = this.getEMode(o);
|
|
72
|
-
return s ? s.assets.map((t) => t.assetId).map((t) => this.poolMap[t]).filter((t) => !!t).map((t) => {
|
|
73
|
-
const n = s.assets.find((a) => a.assetId === t.id);
|
|
74
|
-
return {
|
|
75
|
-
...t,
|
|
76
|
-
emode: {
|
|
77
|
-
...n,
|
|
78
|
-
emodeId: s.emodeId
|
|
79
|
-
},
|
|
80
|
-
isEMode: !0
|
|
81
|
-
};
|
|
82
|
-
}) : [];
|
|
83
|
-
}
|
|
84
|
-
checkMarket(o) {
|
|
85
|
-
let s = !1;
|
|
86
|
-
return typeof o == "number" && o === this.config.id && (s = !0), typeof o == "string" && o === this.config.key && (s = !0), typeof o == "object" && o.id === this.config.id && (s = !0), s;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const b = (r) => {
|
|
90
|
-
const s = Object.values(E).find((i) => typeof r == "number" ? i.id === r : typeof r == "string" ? i.key === r : i.id === r.id);
|
|
91
|
-
if (!s)
|
|
92
|
-
throw new Error("Market not found");
|
|
93
|
-
return s;
|
|
94
|
-
}, y = M(
|
|
95
|
-
g(
|
|
96
|
-
async (r, o) => {
|
|
97
|
-
const s = await k({
|
|
98
|
-
cacheTime: 6e4,
|
|
99
|
-
...o,
|
|
100
|
-
markets: r
|
|
101
|
-
});
|
|
102
|
-
return r.map((i) => {
|
|
103
|
-
const t = b(i), n = s.filter((a) => a.market === t.key);
|
|
104
|
-
return new P(i, n);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
), B = M(
|
|
109
|
-
g(
|
|
110
|
-
async (r, o) => (await y([r], o))[0]
|
|
111
|
-
)
|
|
112
|
-
);
|
|
113
|
-
export {
|
|
114
|
-
v as DEFAULT_MARKET_IDENTITY,
|
|
115
|
-
E as MARKETS,
|
|
116
|
-
P as Market,
|
|
117
|
-
B as getMarket,
|
|
118
|
-
b as getMarketConfig,
|
|
119
|
-
y as getMarkets
|
|
120
|
-
};
|
|
121
|
-
//# sourceMappingURL=market.js.map
|
package/dist/market.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"market.js","sources":["../src/market.ts"],"sourcesContent":["import { withCache, withSingleton, getPoolsMap, getEmodesMap } from './utils'\nimport type {\n MarketIdentity,\n EnvOption,\n CacheOption,\n EMode,\n MarketConfig,\n Pool,\n EModePool\n} from './types'\nimport { getPools } from './pool'\nimport BigNumber from 'bignumber.js'\n\nexport const DEFAULT_MARKET_IDENTITY = 'main'\n\nexport const MARKETS = {\n main: {\n id: 0,\n key: 'main',\n name: 'Main Market'\n },\n ember: {\n id: 1,\n key: 'ember',\n name: 'Ember Market'\n },\n rwa: {\n id: 2,\n key: 'rwa',\n name: 'Matrixdock Market'\n },\n 'sui-eco': {\n id: 3,\n key: 'sui-eco',\n name: 'Sui Eco Market'\n }\n}\n\nexport class Market {\n private poolMap = {} as Record<string, Pool>\n private emodeMap = {} as Record<string, EMode>\n readonly config: MarketConfig\n readonly pools: Pool[] = []\n readonly emodes: EMode[] = []\n readonly emodePools: EModePool[] = []\n emodeBorrowablePools: Pool[] = []\n emodeSupplyablePools: Pool[] = []\n\n private _overview = {\n marketTotalSupplyValue: '0',\n marketTotalBorrowValue: '0'\n }\n\n get overview() {\n return this._overview\n }\n\n constructor(marketIdentity: MarketIdentity, pools: Pool[]) {\n this.config = getMarketConfig(marketIdentity)\n this.initPools(pools)\n }\n\n private initPools(pools: Pool[]) {\n const poolsMap = getPoolsMap(this.pools)\n const emodesMap = getEmodesMap(this.emodes)\n const emodeBorrowablePoolIds = new Set<string>()\n const emodeSupplyablePoolIds = new Set<string>()\n let marketTotalSupplyValue = BigNumber(0)\n let marketTotalBorrowValue = BigNumber(0)\n\n pools.forEach((pool) => {\n const isMatch = this.checkMarket(pool.market)\n if (!isMatch) {\n console.warn(`Pool is not in market ${this.config.name}`, pool)\n return\n }\n if (!poolsMap[pool.uniqueId]) {\n this.pools.push(pool)\n }\n pool?.emodes?.forEach((emode) => {\n if (!emodesMap[emode.uniqueId]) {\n this.emodes.push(emode)\n }\n emode.assets.forEach((asset) => {\n if (asset.isDebt) {\n const debtAsset = emode.assets.find(\n (a) => a.isCollateral && a.ltv > 0 && a.assetId !== pool.id\n )\n if (debtAsset) {\n emodeBorrowablePoolIds.add(pool.uniqueId)\n }\n }\n if (asset.isCollateral) {\n const supplyAsset = emode.assets.find((a) => a.isDebt && a.assetId !== pool.id)\n if (supplyAsset) {\n emodeSupplyablePoolIds.add(pool.uniqueId)\n }\n }\n })\n })\n marketTotalBorrowValue = marketTotalBorrowValue.plus(pool.poolBorrowValue)\n marketTotalSupplyValue = marketTotalSupplyValue.plus(pool.poolSupplyValue)\n })\n this.poolMap = getPoolsMap(this.pools, 'id')\n this.emodeMap = getEmodesMap(this.emodes, 'emodeId')\n this.emodes.forEach((emode) => {\n const emodePools = this.getEModePools(emode.emodeId)\n this.emodePools.push(...emodePools)\n })\n this._overview = {\n marketTotalSupplyValue: marketTotalSupplyValue.toString(),\n marketTotalBorrowValue: marketTotalBorrowValue.toString()\n }\n this.emodeBorrowablePools = this.pools.filter((pool) => {\n return emodeBorrowablePoolIds.has(pool.uniqueId)\n })\n this.emodeSupplyablePools = this.pools.filter((pool) => {\n return emodeSupplyablePoolIds.has(pool.uniqueId)\n })\n }\n\n public getEMode(emodeId: number): EMode | null {\n const emode = this.emodeMap[emodeId]\n return emode || null\n }\n\n public getEModeRelatePools(\n pool: Pool,\n options?: {\n collateral?: boolean\n debt?: boolean\n emodeId?: number\n }\n ): Pool[] {\n const { collateral, debt, emodeId } = options || {}\n const relatePools = [] as Pool[]\n pool.emodes.forEach((emode) => {\n if (typeof emodeId === 'number' && emodeId !== emode.emodeId) {\n return\n }\n emode.assets.forEach((asset) => {\n if (\n typeof collateral === 'boolean' &&\n collateral &&\n asset.isCollateral &&\n asset.assetId === pool.id\n ) {\n relatePools.push(this.poolMap[asset.assetId])\n }\n if (typeof debt === 'boolean' && debt && asset.isDebt && asset.assetId === pool.id) {\n relatePools.push(this.poolMap[asset.assetId])\n }\n })\n })\n return relatePools\n }\n\n public getEModePools(emodeId: number): EModePool[] {\n const emode = this.getEMode(emodeId)\n if (!emode) {\n return []\n }\n const pools = emode.assets\n .map((asset) => asset.assetId)\n .map((id) => {\n return this.poolMap[id]\n })\n .filter((pool) => !!pool)\n return pools.map((pool) => {\n const asset = emode.assets.find((asset) => asset.assetId === pool.id)!\n return {\n ...pool,\n emode: {\n ...asset,\n emodeId: emode.emodeId\n },\n isEMode: true\n }\n })\n }\n\n private checkMarket(marketIdentity: MarketIdentity) {\n let isMatch = false\n if (typeof marketIdentity === 'number' && marketIdentity === this.config.id) {\n isMatch = true\n }\n if (typeof marketIdentity === 'string' && marketIdentity === this.config.key) {\n isMatch = true\n }\n if (typeof marketIdentity === 'object' && marketIdentity.id === this.config.id) {\n isMatch = true\n }\n return isMatch\n }\n}\n\nexport const getMarketConfig = (marketIdentity: MarketIdentity) => {\n const configs = Object.values(MARKETS)\n const config = configs.find((marketConfig) => {\n if (typeof marketIdentity === 'number') {\n return marketConfig.id === marketIdentity\n }\n if (typeof marketIdentity === 'string') {\n return marketConfig.key === marketIdentity\n }\n return marketConfig.id === marketIdentity.id\n })\n if (!config) {\n throw new Error(`Market not found`)\n }\n return config\n}\n\nexport const getMarkets = withCache(\n withSingleton(\n async (\n markets: MarketIdentity[],\n options?: Partial<EnvOption & CacheOption>\n ): Promise<Market[]> => {\n const pools = await getPools({\n cacheTime: 1000 * 60,\n ...options,\n markets\n })\n return markets.map((market) => {\n const marketConfig = getMarketConfig(market)\n const marketPools = pools.filter((pool) => {\n return pool.market === marketConfig.key\n })\n return new Market(market, marketPools)\n })\n }\n )\n)\n\nexport const getMarket = withCache(\n withSingleton(\n async (market: MarketIdentity, options?: Partial<EnvOption & CacheOption>): Promise<Market> => {\n const markets = await getMarkets([market], options)\n return markets[0]\n }\n )\n)\n"],"names":["DEFAULT_MARKET_IDENTITY","MARKETS","Market","marketIdentity","pools","getMarketConfig","poolsMap","getPoolsMap","emodesMap","getEmodesMap","emodeBorrowablePoolIds","emodeSupplyablePoolIds","marketTotalSupplyValue","BigNumber","marketTotalBorrowValue","pool","emode","asset","a","emodePools","emodeId","options","collateral","debt","relatePools","id","isMatch","config","marketConfig","getMarkets","withCache","withSingleton","markets","getPools","market","marketPools","getMarket"],"mappings":";;;AAaO,MAAMA,IAA0B,QAE1BC,IAAU;AAAA,EACrB,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,MAAM;AAAA,EAAA;AAAA,EAER,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,MAAM;AAAA,EAAA;AAAA,EAER,KAAK;AAAA,IACH,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,MAAM;AAAA,EAAA;AAAA,EAER,WAAW;AAAA,IACT,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,MAAM;AAAA,EAAA;AAEV;AAEO,MAAMC,EAAO;AAAA,EAmBlB,YAAYC,GAAgCC,GAAe;AAlB3D,SAAQ,UAAU,C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A,QACH,SAAAW;AAAA,MAAA,CACD;AACD,aAAOA,EAAQ,IAAI,CAACE,MAAW;AAC7B,cAAMN,IAAevB,EAAgB6B,CAAM,GACrCC,IAAc/B,EAAM,OAAO,CAACW,MACzBA,EAAK,WAAWa,EAAa,GACrC;AACD,eAAO,IAAI1B,EAAOgC,GAAQC,CAAW;AAAA,MACvC,CAAC;AAAA,IACH;AAAA,EAAA;AAEJ,GAEaC,IAAYN;AAAA,EACvBC;AAAA,IACE,OAAOG,GAAwBb,OACb,MAAMQ,EAAW,CAACK,CAAM,GAAGb,CAAO,GACnC,CAAC;AAAA,EAClB;AAEJ;"}
|
package/dist/oracle.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { getConfig as p, DEFAULT_CACHE_TIME as l } from "./config.js";
|
|
2
|
-
import { SuiPriceServiceConnection as w, SuiPythClient as j } from "./pyth.js";
|
|
3
|
-
import { suiClient as m, multiGetSuiObjects as F } from "./utils.js";
|
|
4
|
-
import { getLendingPositions as T } from "./account.js";
|
|
5
|
-
const b = new w("https://hermes.pyth.network", {
|
|
6
|
-
timeout: 1e4
|
|
7
|
-
});
|
|
8
|
-
async function U(t) {
|
|
9
|
-
try {
|
|
10
|
-
const n = [], r = await b.getLatestPriceFeeds(t);
|
|
11
|
-
if (!r) return n;
|
|
12
|
-
const c = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
13
|
-
for (const e of r) {
|
|
14
|
-
const i = e.getPriceUnchecked();
|
|
15
|
-
if (i.publishTime > c) {
|
|
16
|
-
console.warn(
|
|
17
|
-
`pyth price feed is invalid, id: ${e.id}, publish time: ${i.publishTime}, current timestamp: ${c}`
|
|
18
|
-
);
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
c - e.getPriceUnchecked().publishTime > 30 && (console.info(
|
|
22
|
-
`stale price feed, id: ${e.id}, publish time: ${i.publishTime}, current timestamp: ${c}`
|
|
23
|
-
), n.push(e.id));
|
|
24
|
-
}
|
|
25
|
-
return n;
|
|
26
|
-
} catch (n) {
|
|
27
|
-
throw new Error(`failed to get pyth stale price feed id, msg: ${n.message}`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async function O(t, n) {
|
|
31
|
-
const r = [], c = n?.client ?? m, e = t.map((o) => o.priceInfoObject), i = await F(c, {
|
|
32
|
-
ids: Array.from(new Set(e)),
|
|
33
|
-
options: { showContent: !0 }
|
|
34
|
-
});
|
|
35
|
-
for (const o of i) {
|
|
36
|
-
const a = o.data;
|
|
37
|
-
if (!a || !a.content || a.content.dataType !== "moveObject") {
|
|
38
|
-
console.warn(`fetched object ${a?.objectId} datatype should be moveObject`);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
const d = t.find((I) => I.priceInfoObject == a.objectId);
|
|
42
|
-
if (!d) {
|
|
43
|
-
console.warn(`unable to find pyth info from array, priceInfoObject: ${a.objectId}`);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
const s = a.content.fields?.price_info?.price_feed?.price, u = s?.price;
|
|
47
|
-
if (!u) {
|
|
48
|
-
console.warn(`unexpected pyth price struct, priceInfoObject: ${a.objectId}`);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const { magnitude: f, negative: y } = u, P = s.conf, g = s.timestamp;
|
|
52
|
-
r.push({
|
|
53
|
-
priceFeedId: d.priceFeedId,
|
|
54
|
-
priceInfoObject: d.priceInfoObject,
|
|
55
|
-
price: y ? "-" + f : f,
|
|
56
|
-
conf: P,
|
|
57
|
-
publishTime: Number(g),
|
|
58
|
-
expiration: d.expiration
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return r;
|
|
62
|
-
}
|
|
63
|
-
async function $(t, n) {
|
|
64
|
-
try {
|
|
65
|
-
const r = [], c = await O(t, n);
|
|
66
|
-
if (!c) return r;
|
|
67
|
-
const e = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
68
|
-
for (const i of c) {
|
|
69
|
-
if (i.publishTime > e) {
|
|
70
|
-
console.warn(
|
|
71
|
-
`pyth price feed is invalid, id: ${i.priceFeedId}, publish time: ${i.publishTime}, current timestamp: ${e}`
|
|
72
|
-
);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const o = i.expiration || 60;
|
|
76
|
-
e - i.publishTime > o && (console.info(
|
|
77
|
-
`stale price feed, id: ${i.priceFeedId}, publish time: ${i.publishTime}, current timestamp: ${e}`
|
|
78
|
-
), r.push(i.priceFeedId));
|
|
79
|
-
}
|
|
80
|
-
return r;
|
|
81
|
-
} catch (r) {
|
|
82
|
-
throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async function v(t, n, r) {
|
|
86
|
-
const c = r?.client ?? m, e = await p({
|
|
87
|
-
...r,
|
|
88
|
-
cacheTime: l
|
|
89
|
-
});
|
|
90
|
-
try {
|
|
91
|
-
const i = await b.getPriceFeedsUpdateData(n);
|
|
92
|
-
return await new j(
|
|
93
|
-
c,
|
|
94
|
-
e.oracle.pythStateId,
|
|
95
|
-
e.oracle.wormholeStateId
|
|
96
|
-
).updatePriceFeeds(t, i, n);
|
|
97
|
-
} catch (i) {
|
|
98
|
-
throw new Error(`failed to update pyth price feeds, msg: ${i.message}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async function h(t, n, r) {
|
|
102
|
-
const c = await p({
|
|
103
|
-
...r,
|
|
104
|
-
cacheTime: l
|
|
105
|
-
});
|
|
106
|
-
if (r?.updatePythPriceFeeds) {
|
|
107
|
-
const e = n.filter((o) => !!o.pythPriceFeedId && !!o.pythPriceInfoObject).map((o) => ({
|
|
108
|
-
priceFeedId: o.pythPriceFeedId,
|
|
109
|
-
priceInfoObject: o.pythPriceInfoObject,
|
|
110
|
-
expiration: 30
|
|
111
|
-
})), i = await $(e, r);
|
|
112
|
-
i.length > 0 && await v(t, i, r);
|
|
113
|
-
}
|
|
114
|
-
for (const e of n)
|
|
115
|
-
t.moveCall({
|
|
116
|
-
target: `${c.oracle.packageId}::oracle_pro::update_single_price_v2`,
|
|
117
|
-
arguments: [
|
|
118
|
-
t.object("0x6"),
|
|
119
|
-
// Clock object
|
|
120
|
-
t.object(c.oracle.oracleConfig),
|
|
121
|
-
// Oracle configuration
|
|
122
|
-
t.object(c.oracle.priceOracle),
|
|
123
|
-
// Price oracle contract
|
|
124
|
-
t.object(c.oracle.supraOracleHolder),
|
|
125
|
-
// Supra oracle holder
|
|
126
|
-
t.object(e.pythPriceInfoObject),
|
|
127
|
-
// Pyth price info object
|
|
128
|
-
t.object(c.oracle.switchboardAggregator),
|
|
129
|
-
t.pure.address(e.feedId)
|
|
130
|
-
// Price feed ID
|
|
131
|
-
]
|
|
132
|
-
});
|
|
133
|
-
return t;
|
|
134
|
-
}
|
|
135
|
-
async function S(t) {
|
|
136
|
-
return (await p({
|
|
137
|
-
...t,
|
|
138
|
-
cacheTime: l
|
|
139
|
-
})).oracle.feeds;
|
|
140
|
-
}
|
|
141
|
-
function C(t, n) {
|
|
142
|
-
return t.filter((r) => !!(n?.lendingState && n.lendingState.find((e) => r.oracleId === e.pool.oracleId) || n?.lendingPositions && n.lendingPositions.find((e) => {
|
|
143
|
-
if (![
|
|
144
|
-
"navi-lending-supply",
|
|
145
|
-
"navi-lending-borrow",
|
|
146
|
-
"navi-lending-emode-supply",
|
|
147
|
-
"navi-lending-emode-borrow"
|
|
148
|
-
].includes(e.type))
|
|
149
|
-
return !1;
|
|
150
|
-
const o = e[e.type]?.pool;
|
|
151
|
-
return r.oracleId === o?.oracleId;
|
|
152
|
-
}) || n?.pools && n.pools.find((e) => r.oracleId === e.oracleId)));
|
|
153
|
-
}
|
|
154
|
-
async function A(t, n, r, c) {
|
|
155
|
-
let e;
|
|
156
|
-
try {
|
|
157
|
-
const i = await S({
|
|
158
|
-
...c
|
|
159
|
-
}), o = [];
|
|
160
|
-
r.forEach((s) => {
|
|
161
|
-
o.includes(s.market) || o.push(s.market);
|
|
162
|
-
});
|
|
163
|
-
const a = await T(n, {
|
|
164
|
-
...c,
|
|
165
|
-
markets: o
|
|
166
|
-
});
|
|
167
|
-
return e = C(i, {
|
|
168
|
-
lendingPositions: a,
|
|
169
|
-
pools: r
|
|
170
|
-
}), await h(t, e, {
|
|
171
|
-
updatePythPriceFeeds: !0,
|
|
172
|
-
...c
|
|
173
|
-
});
|
|
174
|
-
} catch (i) {
|
|
175
|
-
if (c?.throws)
|
|
176
|
-
throw i;
|
|
177
|
-
if (console.error(i), e)
|
|
178
|
-
try {
|
|
179
|
-
return await h(t, e, {
|
|
180
|
-
...c,
|
|
181
|
-
updatePythPriceFeeds: !1
|
|
182
|
-
});
|
|
183
|
-
} catch (o) {
|
|
184
|
-
console.error(o);
|
|
185
|
-
}
|
|
186
|
-
return t;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
export {
|
|
190
|
-
C as filterPriceFeeds,
|
|
191
|
-
S as getPriceFeeds,
|
|
192
|
-
U as getPythStalePriceFeedId,
|
|
193
|
-
$ as getPythStalePriceFeedIdV2,
|
|
194
|
-
A as updateOraclePriceBeforeUserOperationPTB,
|
|
195
|
-
h as updateOraclePricesPTB,
|
|
196
|
-
v as updatePythPriceFeeds
|
|
197
|
-
};
|
|
198
|
-
//# sourceMappingURL=oracle.js.map
|
package/dist/oracle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oracle.js","sources":["../src/oracle.ts"],"sourcesContent":["/**\n * Oracle Price Feed Management for Lending Protocol\n *\n * This module provides oracle price feed functionality for the lending protocol.\n * It integrates with Pyth Network for real-time price data and manages price updates\n * for various assets used in lending operations.\n */\n\nimport { getConfig, DEFAULT_CACHE_TIME } from './config'\nimport type {\n OraclePriceFeed,\n EnvOption,\n UserLendingInfo,\n Pool,\n SuiClientOption,\n MarketOption,\n LendingPosition,\n ServiceOption\n} from './types'\nimport { SuiPriceServiceConnection, SuiPythClient } from './pyth'\nimport { Transaction } from '@mysten/sui/transactions'\nimport { multiGetSuiObjects, suiClient } from './utils'\nimport { getLendingPositions } from './account'\n\ntype PythInfo = {\n priceFeedId: string\n priceInfoObject: string\n expiration?: number\n}\n\nexport type PythPriceInfo = {\n priceFeedId: string\n priceInfoObject: string\n price: string\n conf: string\n publishTime: number\n expiration?: number\n}\n\n/**\n * Pyth Network connection for price feed data\n * Connects to the Hermes endpoint for real-time price updates\n */\nconst suiPythConnection = new SuiPriceServiceConnection('https://hermes.pyth.network', {\n timeout: 10000\n})\n\n/**\n * Get stale price feed IDs from Pyth Network\n *\n * Identifies price feeds that have not been updated recently (more than 30 seconds old).\n * This helps ensure that only fresh price data is used for lending operations.\n *\n * @param priceIds - Array of Pyth price feed IDs to check\n * @returns Array of stale price feed IDs that need updating\n * @throws Error if failed to fetch price feed data\n */\nexport async function getPythStalePriceFeedId(priceIds: string[]): Promise<string[]> {\n try {\n const returnData: string[] = []\n const latestPriceFeeds = await suiPythConnection.getLatestPriceFeeds(priceIds)\n if (!latestPriceFeeds) return returnData\n\n const currentTimestamp = Math.floor(new Date().valueOf() / 1000)\n for (const priceFeed of latestPriceFeeds) {\n const uncheckedPrice = priceFeed.getPriceUnchecked()\n if (uncheckedPrice.publishTime > currentTimestamp) {\n console.warn(\n `pyth price feed is invalid, id: ${priceFeed.id}, publish time: ${uncheckedPrice.publishTime}, current timestamp: ${currentTimestamp}`\n )\n continue\n }\n\n // From pyth state is 60, but setting it to 30 makes more sense.\n if (currentTimestamp - priceFeed.getPriceUnchecked().publishTime > 30) {\n console.info(\n `stale price feed, id: ${priceFeed.id}, publish time: ${uncheckedPrice.publishTime}, current timestamp: ${currentTimestamp}`\n )\n returnData.push(priceFeed.id)\n }\n }\n return returnData\n } catch (error) {\n throw new Error(`failed to get pyth stale price feed id, msg: ${(error as Error).message}`)\n }\n}\n\nasync function getOnChainPriceInfo(\n pythInfos: PythInfo[],\n options?: Partial<SuiClientOption>\n): Promise<PythPriceInfo[]> {\n // Whole-read failures (endpoint/RPC errors) propagate to the caller:\n // swallowing them here would silently skip the Pyth staleness update and let\n // transactions build against stale on-chain prices. Only per-feed anomalies\n // are skipped below.\n const priceInfos: PythPriceInfo[] = []\n const client = options?.client ?? suiClient\n\n const priceInfoObjectIds = pythInfos.map((k) => k.priceInfoObject)\n const priceInfoObjects = await multiGetSuiObjects(client, {\n ids: Array.from(new Set(priceInfoObjectIds)),\n options: { showContent: true }\n })\n for (const obj of priceInfoObjects) {\n const data = obj.data\n if (!data || !data.content || data.content.dataType !== 'moveObject') {\n console.warn(`fetched object ${data?.objectId} datatype should be moveObject`)\n continue\n }\n\n const pythInfo = pythInfos.find((v) => v.priceInfoObject == data.objectId)\n if (!pythInfo) {\n console.warn(`unable to find pyth info from array, priceInfoObject: ${data.objectId}`)\n continue\n }\n\n // The Sui v2 client returns nested Move structs directly, without the\n // per-level `.fields` wrapper the legacy JSON-RPC object shape carried.\n // Read the flattened shape and skip (not throw) on an unexpected object so\n // a single malformed feed can't abort the whole batch and silently leave\n // every on-chain price un-refreshed.\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n const priceStruct = data.content.fields?.price_info?.price_feed?.price\n const priceValue = priceStruct?.price\n if (!priceValue) {\n console.warn(`unexpected pyth price struct, priceInfoObject: ${data.objectId}`)\n continue\n }\n const { magnitude, negative } = priceValue\n const conf = priceStruct.conf\n const timestamp = priceStruct.timestamp\n\n priceInfos.push({\n priceFeedId: pythInfo.priceFeedId,\n priceInfoObject: pythInfo.priceInfoObject,\n price: negative ? '-' + magnitude : magnitude,\n conf,\n publishTime: Number(timestamp),\n expiration: pythInfo.expiration\n })\n }\n return priceInfos\n}\n\nexport async function getPythStalePriceFeedIdV2(\n pythInfos: PythInfo[],\n options?: Partial<SuiClientOption>\n): Promise<string[]> {\n try {\n const returnData: string[] = []\n const latestPriceFeeds = await getOnChainPriceInfo(pythInfos, options)\n if (!latestPriceFeeds) return returnData\n\n const currentTimestamp = Math.floor(new Date().valueOf() / 1000)\n\n for (const priceFeed of latestPriceFeeds) {\n if (priceFeed.publishTime > currentTimestamp) {\n console.warn(\n `pyth price feed is invalid, id: ${priceFeed.priceFeedId}, publish time: ${priceFeed.publishTime}, current timestamp: ${currentTimestamp}`\n )\n continue\n }\n\n const maxTime = priceFeed.expiration || 60\n // 3s is the margin of error for the price feed.\n if (currentTimestamp - priceFeed.publishTime > maxTime) {\n console.info(\n `stale price feed, id: ${priceFeed.priceFeedId}, publish time: ${priceFeed.publishTime}, current timestamp: ${currentTimestamp}`\n )\n returnData.push(priceFeed.priceFeedId)\n }\n }\n return returnData\n } catch (error) {\n throw new Error(`failed to get pyth stale price feed id, msg: ${(error as Error).message}`)\n }\n}\n\n/**\n * Update Pyth price feeds in a transaction\n *\n * Fetches the latest price update data from Pyth Network and adds the update\n * operations to the transaction block.\n *\n * @param tx - The transaction block to add price feed updates to\n * @param priceFeedIds - Array of Pyth price feed IDs to update\n * @param options - Optional client and environment configuration\n * @returns Promise that resolves when price feeds are updated\n * @throws Error if failed to update price feeds\n */\nexport async function updatePythPriceFeeds(\n tx: Transaction,\n priceFeedIds: string[],\n options?: Partial<SuiClientOption & EnvOption & MarketOption>\n) {\n const client = options?.client ?? suiClient\n const config = await getConfig({\n ...options,\n cacheTime: DEFAULT_CACHE_TIME\n })\n try {\n const priceUpdateData = await suiPythConnection.getPriceFeedsUpdateData(priceFeedIds)\n const suiPythClient = new SuiPythClient(\n client as any,\n config.oracle.pythStateId,\n config.oracle.wormholeStateId\n )\n\n return await suiPythClient.updatePriceFeeds(tx as any, priceUpdateData, priceFeedIds)\n } catch (error) {\n throw new Error(`failed to update pyth price feeds, msg: ${(error as Error).message}`)\n }\n}\n\n/**\n * Update oracle prices in the PTB (Programmable Transaction Block)\n *\n * This function updates price feeds for the lending protocol. It can optionally\n * update Pyth price feeds first if they are stale, then updates individual\n * price feeds in the oracle contract.\n *\n * @param tx - The transaction block to add price update operations to\n * @param priceFeeds - Array of oracle price feeds to update\n * @param options - Optional configuration including whether to update Pyth feeds\n * @returns The updated transaction block\n */\nexport async function updateOraclePricesPTB(\n tx: Transaction,\n priceFeeds: OraclePriceFeed[],\n options?: Partial<\n EnvOption &\n SuiClientOption &\n ServiceOption &\n MarketOption & {\n updatePythPriceFeeds?: boolean\n }\n >\n): Promise<Transaction> {\n const config = await getConfig({\n ...options,\n cacheTime: DEFAULT_CACHE_TIME\n })\n\n // Optionally update Pyth price feeds if they are stale\n if (options?.updatePythPriceFeeds) {\n const pythInfos = priceFeeds\n .filter((feed) => !!feed.pythPriceFeedId && !!feed.pythPriceInfoObject)\n .map((feed) => ({\n priceFeedId: feed.pythPriceFeedId,\n priceInfoObject: feed.pythPriceInfoObject,\n expiration: 30\n }))\n\n // Do not silently swallow Pyth stale-price update failures: the previous\n // catch kept building the tx with possibly stale on-chain prices and masked\n // real endpoint/RPC errors. Throw so callers are aware (avoids\n // lending/liquidation based on stale prices).\n const stalePriceFeedIds = await getPythStalePriceFeedIdV2(pythInfos, options)\n if (stalePriceFeedIds.length > 0) {\n await updatePythPriceFeeds(tx, stalePriceFeedIds, options)\n }\n }\n\n // Update individual price feeds in the oracle contract\n for (const priceFeed of priceFeeds) {\n tx.moveCall({\n target: `${config.oracle.packageId}::oracle_pro::update_single_price_v2`,\n arguments: [\n tx.object('0x6'), // Clock object\n tx.object(config.oracle.oracleConfig), // Oracle configuration\n tx.object(config.oracle.priceOracle), // Price oracle contract\n tx.object(config.oracle.supraOracleHolder), // Supra oracle holder\n tx.object(priceFeed.pythPriceInfoObject), // Pyth price info object\n tx.object(config.oracle.switchboardAggregator),\n tx.pure.address(priceFeed.feedId) // Price feed ID\n ]\n })\n }\n return tx\n}\n\n/**\n * Get all available price feeds from the configuration\n *\n * @param options - Optional environment configuration\n * @returns Array of oracle price feed configurations\n */\nexport async function getPriceFeeds(\n options?: Partial<EnvOption & ServiceOption>\n): Promise<OraclePriceFeed[]> {\n const config = await getConfig({\n ...options,\n cacheTime: DEFAULT_CACHE_TIME\n })\n return config.oracle.feeds\n}\n\n/**\n * Filter price feeds based on lending state and pools\n *\n * This function filters price feeds to only include those that are relevant\n * to the current lending state or available pools.\n *\n * @param feeds - Array of price feeds to filter\n * @param filters - Filter criteria including lending state and pools\n * @returns Filtered array of price feeds\n */\nexport function filterPriceFeeds(\n feeds: OraclePriceFeed[],\n filters: {\n lendingState?: UserLendingInfo[]\n pools?: Pool[]\n lendingPositions?: LendingPosition[]\n }\n): OraclePriceFeed[] {\n return feeds.filter((feed) => {\n // Filter by lending state (user's current positions)\n if (filters?.lendingState) {\n const inState = filters.lendingState.find((state) => {\n return feed.oracleId === state.pool.oracleId\n })\n if (inState) {\n return true\n }\n }\n\n if (filters?.lendingPositions) {\n const inPosition = filters.lendingPositions.find((position) => {\n const availableTypes = [\n 'navi-lending-supply',\n 'navi-lending-borrow',\n 'navi-lending-emode-supply',\n 'navi-lending-emode-borrow'\n ]\n if (!availableTypes.includes(position.type)) {\n return false\n }\n const pool = position[position.type]?.pool\n return feed.oracleId === pool?.oracleId\n })\n if (inPosition) {\n return true\n }\n }\n\n // Filter by available pools\n if (filters?.pools) {\n const inPool = filters.pools.find((pool) => {\n return feed.oracleId === pool.oracleId\n })\n if (inPool) {\n return true\n }\n }\n return false\n })\n}\n\nexport async function updateOraclePriceBeforeUserOperationPTB(\n tx: Transaction,\n address: string,\n pools: Pool[],\n options?: Partial<\n EnvOption &\n SuiClientOption &\n MarketOption & {\n throws?: boolean\n }\n >\n) {\n let relevantFeeds: OraclePriceFeed[] | undefined\n try {\n const allPriceFeeds = await getPriceFeeds({\n ...options\n })\n\n const markets = [] as string[]\n\n pools.forEach((pool) => {\n if (!markets.includes(pool.market)) {\n markets.push(pool.market)\n }\n })\n\n const lendingPositions = await getLendingPositions(address, {\n ...options,\n markets\n })\n\n relevantFeeds = filterPriceFeeds(allPriceFeeds, {\n lendingPositions,\n pools\n })\n\n const updatedTx = await updateOraclePricesPTB(tx, relevantFeeds, {\n updatePythPriceFeeds: true,\n ...options\n })\n return updatedTx\n } catch (e) {\n if (options?.throws) {\n throw e\n }\n console.error(e)\n // Degraded path: a Pyth refresh failure happens before any moveCall is\n // appended, so the tx is still clean. Retry the oracle update without the\n // Pyth feed refresh (matches the pre-v2 behavior where Pyth failures were\n // swallowed but update_single_price calls were still appended) instead of\n // dropping the oracle update entirely.\n if (relevantFeeds) {\n try {\n return await updateOraclePricesPTB(tx, relevantFeeds, {\n ...options,\n updatePythPriceFeeds: false\n })\n } catch (fallbackError) {\n console.error(fallbackError)\n }\n }\n return tx\n }\n}\n"],"names":["suiPythConnection","SuiPriceServiceConnection","getPythStalePriceFeedId","priceIds","returnData","latestPriceFeeds","currentTimestamp","priceFeed","uncheckedPrice","error","getOnChainPriceInfo","pythInfos","options","priceInfos","client","suiClient","priceInfoObjectIds","k","priceInfoObjects","multiGetSuiObjects","obj","data","pythInfo","v","priceStruct","priceValue","magnitude","negative","conf","timestamp","getPythStalePriceFeedIdV2","maxTime","updatePythPriceFeeds","tx","priceFeedIds","config","getConfig","DEFAULT_CACHE_TIME","priceUpdateData","SuiPythClient","updateOraclePricesPTB","priceFeeds","feed","stalePriceFeedIds","getPriceFeeds","filterPriceFeeds","feeds","filters","state","position","pool","updateOraclePriceBeforeUserOperationPTB","address","pools","relevantFeeds","allPriceFeeds","markets","lendingPositions","getLendingPositions","e","fallbackError"],"mappings":";;;;AA2CA,MAAMA,IAAoB,IAAIC,EAA0B,+BAA+B;AAAA,EACrF,SAAS;AACX,CAAC;AAYD,eAAsBC,EAAwBC,GAAuC;AACnF,MAAI;AACF,UAAMC,IAAuB,CAAA,GACvBC,IAAmB,MAAML,EAAkB,oBAAoBG,CAAQ;AAC7E,QAAI,CAACE,EAAkB,QAAOD;AAE9B,UAAME,IAAmB,KAAK,OAAM,oBAAI,QAAO,QAAA,IAAY,GAAI;AAC/D,eAAWC,KAAaF,GAAkB;AACxC,YAAMG,IAAiBD,EAAU,kBAAA;AACjC,UAAIC,EAAe,cAAcF,GAAkB;AACjD,gBAA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AAAA,IAAA,CACJ;AAAA,EAEH,SAAS+C,GAAG;AACV,QAAI/C,GAAS;AACX,YAAM+C;AAQR,QANA,QAAQ,MAAMA,CAAC,GAMXL;AACF,UAAI;AACF,eAAO,MAAMd,EAAsBP,GAAIqB,GAAe;AAAA,UACpD,GAAG1C;AAAA,UACH,sBAAsB;AAAA,QAAA,CACvB;AAAA,MACH,SAASgD,GAAe;AACtB,gBAAQ,MAAMA,CAAa;AAAA,MAC7B;AAEF,WAAO3B;AAAA,EACT;AACF;"}
|
package/dist/package.json.js
DELETED
package/dist/package.json.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|