@naviprotocol/lending 1.4.5-beta.1 → 1.4.5-beta.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/account.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +651 -629
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
1
|
import { Transaction as F } from "@mysten/sui/transactions";
|
|
2
|
-
import { bcs as
|
|
3
|
-
import { SuiClient as
|
|
4
|
-
import
|
|
5
|
-
import { normalizeStructTag as
|
|
6
|
-
import { SuiPriceServiceConnection as
|
|
2
|
+
import { bcs as d, toHex as ue, fromHex as pe } from "@mysten/bcs";
|
|
3
|
+
import { SuiClient as de, getFullnodeUrl as me } from "@mysten/sui/client";
|
|
4
|
+
import fe from "lodash.camelcase";
|
|
5
|
+
import { normalizeStructTag as ye } from "@mysten/sui/utils";
|
|
6
|
+
import { SuiPriceServiceConnection as x, SuiPythClient as ge } from "@pythnetwork/pyth-sui-js";
|
|
7
7
|
import p from "bignumber.js";
|
|
8
8
|
import { bcs as C } from "@mysten/sui/bcs";
|
|
9
|
-
const
|
|
9
|
+
const J = d.bytes(32).transform({
|
|
10
10
|
// To change the input type, you need to provide a type definition for the input
|
|
11
|
-
input: (e) =>
|
|
12
|
-
output: (e) =>
|
|
13
|
-
}),
|
|
11
|
+
input: (e) => pe(e),
|
|
12
|
+
output: (e) => ue(e)
|
|
13
|
+
}), Je = d.struct("IncentiveAPYInfo", {
|
|
14
14
|
/** Asset identifier */
|
|
15
|
-
asset_id:
|
|
15
|
+
asset_id: d.u8(),
|
|
16
16
|
/** Annual Percentage Yield as a 256-bit integer */
|
|
17
|
-
apy:
|
|
17
|
+
apy: d.u256(),
|
|
18
18
|
/** List of supported coin types for this incentive */
|
|
19
|
-
coin_types:
|
|
20
|
-
}),
|
|
19
|
+
coin_types: d.vector(d.string())
|
|
20
|
+
}), he = d.struct("IncentivePoolInfo", {
|
|
21
21
|
/** Unique pool identifier */
|
|
22
|
-
pool_id:
|
|
22
|
+
pool_id: J,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
24
|
-
funds:
|
|
24
|
+
funds: J,
|
|
25
25
|
/** Current phase of the incentive program */
|
|
26
|
-
phase:
|
|
26
|
+
phase: d.u64(),
|
|
27
27
|
/** Timestamp when the incentive started */
|
|
28
|
-
start_at:
|
|
28
|
+
start_at: d.u64(),
|
|
29
29
|
/** Timestamp when the incentive ends */
|
|
30
|
-
end_at:
|
|
30
|
+
end_at: d.u64(),
|
|
31
31
|
/** Timestamp when the incentive was closed */
|
|
32
|
-
closed_at:
|
|
32
|
+
closed_at: d.u64(),
|
|
33
33
|
/** Total supply of incentive tokens */
|
|
34
|
-
total_supply:
|
|
34
|
+
total_supply: d.u64(),
|
|
35
35
|
/** Asset identifier for the incentive */
|
|
36
|
-
asset_id:
|
|
36
|
+
asset_id: d.u8(),
|
|
37
37
|
/** Option type for the incentive */
|
|
38
|
-
option:
|
|
38
|
+
option: d.u8(),
|
|
39
39
|
/** Factor used in incentive calculations */
|
|
40
|
-
factor:
|
|
40
|
+
factor: d.u256(),
|
|
41
41
|
/** Amount of incentives already distributed */
|
|
42
|
-
distributed:
|
|
42
|
+
distributed: d.u64(),
|
|
43
43
|
/** Amount of incentives currently available */
|
|
44
|
-
available:
|
|
44
|
+
available: d.u256(),
|
|
45
45
|
/** Total amount of incentives */
|
|
46
|
-
total:
|
|
47
|
-
}),
|
|
46
|
+
total: d.u256()
|
|
47
|
+
}), Ze = d.struct("IncentivePoolInfoByPhase", {
|
|
48
48
|
/** Phase number */
|
|
49
|
-
phase:
|
|
49
|
+
phase: d.u64(),
|
|
50
50
|
/** List of incentive pools in this phase */
|
|
51
|
-
pools:
|
|
52
|
-
}),
|
|
51
|
+
pools: d.vector(he)
|
|
52
|
+
}), Qe = d.struct("OracleInfo", {
|
|
53
53
|
/** Oracle identifier */
|
|
54
|
-
oracle_id:
|
|
54
|
+
oracle_id: d.u8(),
|
|
55
55
|
/** Current price as a 256-bit integer */
|
|
56
|
-
price:
|
|
56
|
+
price: d.u256(),
|
|
57
57
|
/** Number of decimal places for the price */
|
|
58
|
-
decimals:
|
|
58
|
+
decimals: d.u8(),
|
|
59
59
|
/** Whether the oracle data is valid */
|
|
60
|
-
valid:
|
|
61
|
-
}),
|
|
60
|
+
valid: d.bool()
|
|
61
|
+
}), Xe = d.struct("FlashLoanAssetConfig", {
|
|
62
62
|
/** Unique identifier for the flash loan asset */
|
|
63
|
-
id:
|
|
63
|
+
id: d.string(),
|
|
64
64
|
/** Asset identifier */
|
|
65
|
-
asset_id:
|
|
65
|
+
asset_id: d.u8(),
|
|
66
66
|
/** Coin type for the asset */
|
|
67
|
-
coin_type:
|
|
67
|
+
coin_type: d.string(),
|
|
68
68
|
/** Pool identifier for the flash loan */
|
|
69
|
-
pool_id:
|
|
69
|
+
pool_id: d.string(),
|
|
70
70
|
/** Rate paid to suppliers for flash loans */
|
|
71
|
-
rate_to_supplier:
|
|
71
|
+
rate_to_supplier: d.u64(),
|
|
72
72
|
/** Rate paid to treasury for flash loans */
|
|
73
|
-
rate_to_treasury:
|
|
73
|
+
rate_to_treasury: d.u64(),
|
|
74
74
|
/** Maximum flash loan amount */
|
|
75
|
-
max:
|
|
75
|
+
max: d.u64(),
|
|
76
76
|
/** Minimum flash loan amount */
|
|
77
|
-
min:
|
|
78
|
-
}),
|
|
77
|
+
min: d.u64()
|
|
78
|
+
}), ve = d.struct("ReserveDataInfo", {
|
|
79
79
|
/** Reserve identifier */
|
|
80
|
-
id:
|
|
80
|
+
id: d.u8(),
|
|
81
81
|
/** Oracle identifier for price feeds */
|
|
82
|
-
oracle_id:
|
|
82
|
+
oracle_id: d.u8(),
|
|
83
83
|
/** Coin type for the reserve */
|
|
84
|
-
coin_type:
|
|
84
|
+
coin_type: d.string(),
|
|
85
85
|
/** Maximum supply capacity */
|
|
86
|
-
supply_cap:
|
|
86
|
+
supply_cap: d.u256(),
|
|
87
87
|
/** Maximum borrow capacity */
|
|
88
|
-
borrow_cap:
|
|
88
|
+
borrow_cap: d.u256(),
|
|
89
89
|
/** Current supply interest rate */
|
|
90
|
-
supply_rate:
|
|
90
|
+
supply_rate: d.u256(),
|
|
91
91
|
/** Current borrow interest rate */
|
|
92
|
-
borrow_rate:
|
|
92
|
+
borrow_rate: d.u256(),
|
|
93
93
|
/** Current supply index for interest calculation */
|
|
94
|
-
supply_index:
|
|
94
|
+
supply_index: d.u256(),
|
|
95
95
|
/** Current borrow index for interest calculation */
|
|
96
|
-
borrow_index:
|
|
96
|
+
borrow_index: d.u256(),
|
|
97
97
|
/** Total amount supplied to the reserve */
|
|
98
|
-
total_supply:
|
|
98
|
+
total_supply: d.u256(),
|
|
99
99
|
/** Total amount borrowed from the reserve */
|
|
100
|
-
total_borrow:
|
|
100
|
+
total_borrow: d.u256(),
|
|
101
101
|
/** Timestamp of last update */
|
|
102
|
-
last_update_at:
|
|
102
|
+
last_update_at: d.u64(),
|
|
103
103
|
/** Loan-to-Value ratio for collateral */
|
|
104
|
-
ltv:
|
|
104
|
+
ltv: d.u256(),
|
|
105
105
|
/** Treasury factor for fee calculations */
|
|
106
|
-
treasury_factor:
|
|
106
|
+
treasury_factor: d.u256(),
|
|
107
107
|
/** Current treasury balance */
|
|
108
|
-
treasury_balance:
|
|
108
|
+
treasury_balance: d.u256(),
|
|
109
109
|
/** Base interest rate */
|
|
110
|
-
base_rate:
|
|
110
|
+
base_rate: d.u256(),
|
|
111
111
|
/** Interest rate multiplier */
|
|
112
|
-
multiplier:
|
|
112
|
+
multiplier: d.u256(),
|
|
113
113
|
/** Jump rate multiplier for high utilization */
|
|
114
|
-
jump_rate_multiplier:
|
|
114
|
+
jump_rate_multiplier: d.u256(),
|
|
115
115
|
/** Reserve factor for protocol fees */
|
|
116
|
-
reserve_factor:
|
|
116
|
+
reserve_factor: d.u256(),
|
|
117
117
|
/** Optimal utilization rate */
|
|
118
|
-
optimal_utilization:
|
|
118
|
+
optimal_utilization: d.u256(),
|
|
119
119
|
/** Liquidation ratio threshold */
|
|
120
|
-
liquidation_ratio:
|
|
120
|
+
liquidation_ratio: d.u256(),
|
|
121
121
|
/** Liquidation bonus for liquidators */
|
|
122
|
-
liquidation_bonus:
|
|
122
|
+
liquidation_bonus: d.u256(),
|
|
123
123
|
/** Liquidation threshold */
|
|
124
|
-
liquidation_threshold:
|
|
125
|
-
}),
|
|
124
|
+
liquidation_threshold: d.u256()
|
|
125
|
+
}), we = d.struct("UserStateInfo", {
|
|
126
126
|
/** Asset identifier */
|
|
127
|
-
asset_id:
|
|
127
|
+
asset_id: d.u8(),
|
|
128
128
|
/** User's current borrow balance */
|
|
129
|
-
borrow_balance:
|
|
129
|
+
borrow_balance: d.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
|
-
supply_balance:
|
|
132
|
-
}),
|
|
133
|
-
version:
|
|
134
|
-
},
|
|
131
|
+
supply_balance: d.u256()
|
|
132
|
+
}), be = "1.4.5-beta.3", E = {
|
|
133
|
+
version: be
|
|
134
|
+
}, ke = E.version, _e = () => {
|
|
135
135
|
if (typeof process < "u" && process.versions && process.versions.node)
|
|
136
136
|
try {
|
|
137
137
|
const e = require("os"), r = process.version, o = e.type(), n = e.arch();
|
|
@@ -140,13 +140,13 @@ const K = m.bytes(32).transform({
|
|
|
140
140
|
return `Node.js ${process.version}; OS/Unknown (Error)`;
|
|
141
141
|
}
|
|
142
142
|
return "Node/Unknown";
|
|
143
|
-
},
|
|
143
|
+
}, Ce = () => {
|
|
144
144
|
let e = "";
|
|
145
|
-
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${
|
|
146
|
-
},
|
|
147
|
-
url:
|
|
145
|
+
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ke} (${_e()})`), e;
|
|
146
|
+
}, Z = Ce(), V = new de({
|
|
147
|
+
url: me("mainnet")
|
|
148
148
|
});
|
|
149
|
-
function
|
|
149
|
+
function ee(e) {
|
|
150
150
|
const r = [];
|
|
151
151
|
return e.forEach((o, n) => {
|
|
152
152
|
const t = n === e.length - 1;
|
|
@@ -157,41 +157,41 @@ function X(e) {
|
|
|
157
157
|
r.push(o);
|
|
158
158
|
}), JSON.stringify(r);
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function P(e) {
|
|
161
161
|
const r = {};
|
|
162
162
|
return (...o) => {
|
|
163
|
-
const n =
|
|
163
|
+
const n = ee(o);
|
|
164
164
|
return r[n] || (r[n] = e(...o).finally(() => {
|
|
165
165
|
delete r[n];
|
|
166
166
|
})), r[n];
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function M(e) {
|
|
170
170
|
let r = {};
|
|
171
171
|
return (...o) => {
|
|
172
|
-
const n = o[o.length - 1], t =
|
|
172
|
+
const n = o[o.length - 1], t = ee(o), a = r[t];
|
|
173
173
|
return !n?.disableCache && typeof a?.data < "u" && (typeof n?.cacheTime > "u" || n.cacheTime > Date.now() - a.cacheAt) ? Promise.resolve(a.data) : e(...o).then((s) => (r[t] = {
|
|
174
174
|
data: s,
|
|
175
175
|
cacheAt: Date.now()
|
|
176
176
|
}, s));
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
return Array.isArray(e) ? e.map((r) =>
|
|
179
|
+
function K(e) {
|
|
180
|
+
return Array.isArray(e) ? e.map((r) => K(r)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
181
181
|
(r, o) => ({
|
|
182
182
|
...r,
|
|
183
|
-
[
|
|
183
|
+
[fe(o)]: K(e[o])
|
|
184
184
|
}),
|
|
185
185
|
{}
|
|
186
186
|
) : e;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function g(e, r) {
|
|
189
189
|
return typeof e == "object" ? e : r(e);
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function je(e, r) {
|
|
192
192
|
return typeof r == "string" ? e.object(r) : typeof r == "object" && r.$kind ? r : e.object(r.contract.pool);
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function H(e, r, o) {
|
|
195
195
|
if (e.results && e.results.length > 0) {
|
|
196
196
|
if (e.results[0].returnValues && e.results[0].returnValues.length > 0)
|
|
197
197
|
return e.results[0].returnValues.map((n, t) => (r[t] || r[0]).parse(Uint8Array.from(n[0])));
|
|
@@ -199,36 +199,36 @@ function W(e, r, o) {
|
|
|
199
199
|
return console.log(`Get an error, msg: ${e.error}`), [];
|
|
200
200
|
return [];
|
|
201
201
|
}
|
|
202
|
-
function
|
|
203
|
-
return
|
|
202
|
+
function k(e) {
|
|
203
|
+
return ye(e);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function te(e) {
|
|
206
206
|
const r = (e || 0) / Math.pow(10, 27);
|
|
207
207
|
return r > Math.pow(10, 5) ? 1 / 0 : r;
|
|
208
208
|
}
|
|
209
|
-
new
|
|
209
|
+
new x("https://hermes.pyth.network", {
|
|
210
210
|
timeout: 2e4
|
|
211
211
|
});
|
|
212
|
-
const
|
|
212
|
+
const Ie = 27, Q = (e, r) => {
|
|
213
213
|
if (!Number(e) || !Number(r)) return new p(0);
|
|
214
|
-
const o = new p(1).shiftedBy(1 *
|
|
214
|
+
const o = new p(1).shiftedBy(1 * Ie), n = o.multipliedBy(new p(0.5));
|
|
215
215
|
return new p(e).multipliedBy(new p(r)).plus(n).dividedBy(o).integerValue(p.ROUND_DOWN);
|
|
216
|
-
},
|
|
217
|
-
"User-Agent":
|
|
216
|
+
}, D = Z ? {
|
|
217
|
+
"User-Agent": Z
|
|
218
218
|
} : {};
|
|
219
|
-
function
|
|
219
|
+
function z(e, r = "uniqueId") {
|
|
220
220
|
return e.reduce(
|
|
221
221
|
(o, n) => (o[n[r]] = n, o),
|
|
222
222
|
{}
|
|
223
223
|
);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function X(e, r = "uniqueId") {
|
|
226
226
|
return e.reduce(
|
|
227
227
|
(o, n) => (o[n[r]] = n, o),
|
|
228
228
|
{}
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function W(e, r) {
|
|
232
232
|
const o = e.emodes.find((t) => t.emodeId === r.emodeId);
|
|
233
233
|
if (!o)
|
|
234
234
|
throw new Error("EMode not found in pool");
|
|
@@ -242,88 +242,88 @@ function L(e, r) {
|
|
|
242
242
|
isEMode: !0
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Te(e) {
|
|
246
246
|
const [r, o] = e.split("-");
|
|
247
247
|
return !r || !o ? null : {
|
|
248
248
|
marketKey: r,
|
|
249
249
|
poolId: parseInt(o)
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function $() {
|
|
253
253
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
254
254
|
}
|
|
255
255
|
var R = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(R || {});
|
|
256
|
-
const q =
|
|
257
|
-
|
|
256
|
+
const q = M(
|
|
257
|
+
P(
|
|
258
258
|
async (e) => {
|
|
259
|
-
const r = (e?.markets || [
|
|
259
|
+
const r = (e?.markets || [U.main]).map((t) => T(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.map(
|
|
260
260
|
(t) => t.key
|
|
261
|
-
)}`, n = await fetch(o, { headers:
|
|
261
|
+
)}`, n = await fetch(o, { headers: D }).then((t) => t.json());
|
|
262
262
|
return n.data.forEach((t) => {
|
|
263
263
|
const s = n.meta.emodes.filter((f) => {
|
|
264
|
-
const
|
|
265
|
-
return t.market ===
|
|
266
|
-
}).filter((f) => !!f.assets.find((
|
|
264
|
+
const w = T(f.marketId);
|
|
265
|
+
return t.market === w.key && f.isActive;
|
|
266
|
+
}).filter((f) => !!f.assets.find((w) => w.assetId === t.id));
|
|
267
267
|
t.emodes = s;
|
|
268
|
-
const i = p(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), c = p(t.borrowedAmount).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(),
|
|
268
|
+
const i = p(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), c = p(t.borrowedAmount).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), u = p(i).multipliedBy(t.oracle.price).toString(), m = p(c).multipliedBy(t.oracle.price).toString(), h = p(t.supplyCapCeiling).shiftedBy(-27).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), v = p.max(
|
|
269
269
|
p(t.borrowedAmount),
|
|
270
270
|
p(t.validBorrowAmount)
|
|
271
|
-
).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(),
|
|
272
|
-
t.poolSupplyAmount = i, t.poolBorrowAmount = c, t.poolSupplyValue =
|
|
271
|
+
).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), y = p(h).multipliedBy(t.oracle.price).toString(), l = p(v).multipliedBy(t.oracle.price).toString();
|
|
272
|
+
t.poolSupplyAmount = i, t.poolBorrowAmount = c, t.poolSupplyValue = u, t.poolBorrowValue = m, t.poolSupplyCapAmount = h, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = y, t.poolBorrowCapValue = l;
|
|
273
273
|
}), n.data;
|
|
274
274
|
}
|
|
275
275
|
)
|
|
276
276
|
);
|
|
277
|
-
async function
|
|
277
|
+
async function S(e, r) {
|
|
278
278
|
let o = r?.market;
|
|
279
279
|
if (typeof e == "string") {
|
|
280
|
-
const a =
|
|
280
|
+
const a = Te(e);
|
|
281
281
|
a && (o = a.marketKey, e = a.poolId);
|
|
282
282
|
}
|
|
283
283
|
const n = await q({
|
|
284
284
|
...r,
|
|
285
|
-
markets: [o ||
|
|
286
|
-
cacheTime:
|
|
285
|
+
markets: [o || O],
|
|
286
|
+
cacheTime: b
|
|
287
287
|
});
|
|
288
288
|
if (typeof e == "object")
|
|
289
289
|
return e;
|
|
290
|
-
const t = n.find((a) => typeof e == "string" ?
|
|
290
|
+
const t = n.find((a) => typeof e == "string" ? k(a.suiCoinType) === k(e) : typeof e == "number" ? a.id === e : !1);
|
|
291
291
|
if (!t)
|
|
292
292
|
throw new Error("Pool not found");
|
|
293
293
|
return t.isDeprecated && console.log(`The lending pool for coinType ${t.suiCoinType} is going to be deprecated.`), t;
|
|
294
294
|
}
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
const r = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${
|
|
298
|
-
return (await fetch(r, { headers:
|
|
295
|
+
const xe = M(
|
|
296
|
+
P(async (e) => {
|
|
297
|
+
const r = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${E.version}`;
|
|
298
|
+
return (await fetch(r, { headers: D }).then((n) => n.json())).data;
|
|
299
299
|
})
|
|
300
|
-
),
|
|
301
|
-
|
|
300
|
+
), et = M(
|
|
301
|
+
P(
|
|
302
302
|
async (e) => {
|
|
303
|
-
const r = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${
|
|
304
|
-
return await fetch(r, { headers:
|
|
303
|
+
const r = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${E.version}`;
|
|
304
|
+
return await fetch(r, { headers: D }).then((n) => n.json());
|
|
305
305
|
}
|
|
306
306
|
)
|
|
307
307
|
);
|
|
308
|
-
async function
|
|
308
|
+
async function Be(e, r, o, n) {
|
|
309
309
|
const t = await _({
|
|
310
310
|
...n,
|
|
311
|
-
cacheTime:
|
|
312
|
-
}), a = await
|
|
311
|
+
cacheTime: b
|
|
312
|
+
}), a = await S(r, n);
|
|
313
313
|
n?.market;
|
|
314
314
|
const s = n?.env || "prod";
|
|
315
315
|
if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
|
|
316
316
|
throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
|
|
317
317
|
const i = typeof o == "object" && o.$kind === "GasCoin";
|
|
318
|
-
if (
|
|
318
|
+
if (k(a.suiCoinType) === k("0x2::sui::SUI") && i) {
|
|
319
319
|
if (!n?.amount)
|
|
320
320
|
throw new Error("Amount is required for sui coin");
|
|
321
321
|
o = e.splitCoins(o, [n.amount]);
|
|
322
322
|
}
|
|
323
323
|
let c;
|
|
324
|
-
return typeof n?.amount < "u" ? c =
|
|
324
|
+
return typeof n?.amount < "u" ? c = g(n.amount, e.pure.u64) : c = e.moveCall({
|
|
325
325
|
target: "0x2::coin::value",
|
|
326
|
-
arguments: [
|
|
326
|
+
arguments: [g(o, e.object)],
|
|
327
327
|
typeArguments: [a.suiCoinType]
|
|
328
328
|
}), n?.accountCap ? e.moveCall({
|
|
329
329
|
target: `${t.package}::incentive_v3::deposit_with_account_cap`,
|
|
@@ -332,10 +332,10 @@ async function Ce(e, r, o, n) {
|
|
|
332
332
|
e.object(t.storage),
|
|
333
333
|
e.object(a.contract.pool),
|
|
334
334
|
e.pure.u8(a.id),
|
|
335
|
-
|
|
335
|
+
g(o, e.object),
|
|
336
336
|
e.object(t.incentiveV2),
|
|
337
337
|
e.object(t.incentiveV3),
|
|
338
|
-
|
|
338
|
+
g(n.accountCap, e.object)
|
|
339
339
|
],
|
|
340
340
|
typeArguments: [a.suiCoinType]
|
|
341
341
|
}) : e.moveCall({
|
|
@@ -345,7 +345,7 @@ async function Ce(e, r, o, n) {
|
|
|
345
345
|
e.object(t.storage),
|
|
346
346
|
e.object(a.contract.pool),
|
|
347
347
|
e.pure.u8(a.id),
|
|
348
|
-
|
|
348
|
+
g(o, e.object),
|
|
349
349
|
c,
|
|
350
350
|
e.object(t.incentiveV2),
|
|
351
351
|
e.object(t.incentiveV3)
|
|
@@ -356,15 +356,15 @@ async function Ce(e, r, o, n) {
|
|
|
356
356
|
arguments: [e.object(a.contract.pool), e.object("0x05")]
|
|
357
357
|
}), e;
|
|
358
358
|
}
|
|
359
|
-
async function
|
|
359
|
+
async function tt(e, r, o, n) {
|
|
360
360
|
const t = await _({
|
|
361
361
|
...n,
|
|
362
|
-
cacheTime:
|
|
363
|
-
}), a = await
|
|
362
|
+
cacheTime: b
|
|
363
|
+
}), a = await S(r, n), s = g(o, e.pure.u64);
|
|
364
364
|
let i;
|
|
365
365
|
if (t.version === 1)
|
|
366
366
|
if (n?.accountCap) {
|
|
367
|
-
const [
|
|
367
|
+
const [u] = e.moveCall({
|
|
368
368
|
target: `${t.package}::incentive_v3::withdraw_with_account_cap`,
|
|
369
369
|
arguments: [
|
|
370
370
|
e.object("0x06"),
|
|
@@ -375,13 +375,13 @@ async function Xe(e, r, o, n) {
|
|
|
375
375
|
s,
|
|
376
376
|
e.object(t.incentiveV2),
|
|
377
377
|
e.object(t.incentiveV3),
|
|
378
|
-
|
|
378
|
+
g(n.accountCap, e.object)
|
|
379
379
|
],
|
|
380
380
|
typeArguments: [a.suiCoinType]
|
|
381
381
|
});
|
|
382
|
-
i =
|
|
382
|
+
i = u;
|
|
383
383
|
} else {
|
|
384
|
-
const [
|
|
384
|
+
const [u] = e.moveCall({
|
|
385
385
|
target: `${t.package}::incentive_v3::withdraw`,
|
|
386
386
|
arguments: [
|
|
387
387
|
e.object("0x06"),
|
|
@@ -395,10 +395,10 @@ async function Xe(e, r, o, n) {
|
|
|
395
395
|
],
|
|
396
396
|
typeArguments: [a.suiCoinType]
|
|
397
397
|
});
|
|
398
|
-
i =
|
|
398
|
+
i = u;
|
|
399
399
|
}
|
|
400
400
|
else if (n?.accountCap) {
|
|
401
|
-
const [
|
|
401
|
+
const [u] = e.moveCall({
|
|
402
402
|
target: `${t.package}::incentive_v3::withdraw_with_account_cap_v2`,
|
|
403
403
|
arguments: [
|
|
404
404
|
e.object("0x06"),
|
|
@@ -409,14 +409,14 @@ async function Xe(e, r, o, n) {
|
|
|
409
409
|
s,
|
|
410
410
|
e.object(t.incentiveV2),
|
|
411
411
|
e.object(t.incentiveV3),
|
|
412
|
-
|
|
412
|
+
g(n.accountCap, e.object),
|
|
413
413
|
e.object("0x05")
|
|
414
414
|
],
|
|
415
415
|
typeArguments: [a.suiCoinType]
|
|
416
416
|
});
|
|
417
|
-
i =
|
|
417
|
+
i = u;
|
|
418
418
|
} else {
|
|
419
|
-
const [
|
|
419
|
+
const [u] = e.moveCall({
|
|
420
420
|
target: `${t.package}::incentive_v3::withdraw_v2`,
|
|
421
421
|
arguments: [
|
|
422
422
|
e.object("0x06"),
|
|
@@ -431,7 +431,7 @@ async function Xe(e, r, o, n) {
|
|
|
431
431
|
],
|
|
432
432
|
typeArguments: [a.suiCoinType]
|
|
433
433
|
});
|
|
434
|
-
i =
|
|
434
|
+
i = u;
|
|
435
435
|
}
|
|
436
436
|
return e.moveCall({
|
|
437
437
|
target: "0x2::coin::from_balance",
|
|
@@ -439,18 +439,18 @@ async function Xe(e, r, o, n) {
|
|
|
439
439
|
typeArguments: [a.suiCoinType]
|
|
440
440
|
});
|
|
441
441
|
}
|
|
442
|
-
async function
|
|
442
|
+
async function ot(e, r, o, n) {
|
|
443
443
|
const t = await _({
|
|
444
444
|
...n,
|
|
445
|
-
cacheTime:
|
|
446
|
-
}), a = await
|
|
445
|
+
cacheTime: b
|
|
446
|
+
}), a = await S(r, n);
|
|
447
447
|
if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
|
|
448
448
|
throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
|
|
449
|
-
const s =
|
|
449
|
+
const s = g(o, e.pure.u64);
|
|
450
450
|
let i;
|
|
451
451
|
if (t.version === 1)
|
|
452
452
|
if (n?.accountCap) {
|
|
453
|
-
const [
|
|
453
|
+
const [u] = e.moveCall({
|
|
454
454
|
target: `${t.package}::incentive_v3::borrow_with_account_cap`,
|
|
455
455
|
arguments: [
|
|
456
456
|
e.object("0x06"),
|
|
@@ -461,13 +461,13 @@ async function xe(e, r, o, n) {
|
|
|
461
461
|
s,
|
|
462
462
|
e.object(t.incentiveV2),
|
|
463
463
|
e.object(t.incentiveV3),
|
|
464
|
-
|
|
464
|
+
g(n.accountCap, e.object)
|
|
465
465
|
],
|
|
466
466
|
typeArguments: [a.suiCoinType]
|
|
467
467
|
});
|
|
468
|
-
i =
|
|
468
|
+
i = u;
|
|
469
469
|
} else {
|
|
470
|
-
const [
|
|
470
|
+
const [u] = e.moveCall({
|
|
471
471
|
target: `${t.package}::incentive_v3::borrow`,
|
|
472
472
|
arguments: [
|
|
473
473
|
e.object("0x06"),
|
|
@@ -481,10 +481,10 @@ async function xe(e, r, o, n) {
|
|
|
481
481
|
],
|
|
482
482
|
typeArguments: [a.suiCoinType]
|
|
483
483
|
});
|
|
484
|
-
i =
|
|
484
|
+
i = u;
|
|
485
485
|
}
|
|
486
486
|
else if (n?.accountCap) {
|
|
487
|
-
const [
|
|
487
|
+
const [u] = e.moveCall({
|
|
488
488
|
target: `${t.package}::incentive_v3::borrow_with_account_cap_v2`,
|
|
489
489
|
arguments: [
|
|
490
490
|
e.object("0x06"),
|
|
@@ -495,14 +495,14 @@ async function xe(e, r, o, n) {
|
|
|
495
495
|
s,
|
|
496
496
|
e.object(t.incentiveV2),
|
|
497
497
|
e.object(t.incentiveV3),
|
|
498
|
-
|
|
498
|
+
g(n.accountCap, e.object),
|
|
499
499
|
e.object("0x05")
|
|
500
500
|
],
|
|
501
501
|
typeArguments: [a.suiCoinType]
|
|
502
502
|
});
|
|
503
|
-
i =
|
|
503
|
+
i = u;
|
|
504
504
|
} else {
|
|
505
|
-
const [
|
|
505
|
+
const [u] = e.moveCall({
|
|
506
506
|
target: `${t.package}::incentive_v3::borrow_v2`,
|
|
507
507
|
arguments: [
|
|
508
508
|
e.object("0x06"),
|
|
@@ -517,7 +517,7 @@ async function xe(e, r, o, n) {
|
|
|
517
517
|
],
|
|
518
518
|
typeArguments: [a.suiCoinType]
|
|
519
519
|
});
|
|
520
|
-
i =
|
|
520
|
+
i = u;
|
|
521
521
|
}
|
|
522
522
|
return e.moveCall({
|
|
523
523
|
target: "0x2::coin::from_balance",
|
|
@@ -525,20 +525,20 @@ async function xe(e, r, o, n) {
|
|
|
525
525
|
typeArguments: [a.suiCoinType]
|
|
526
526
|
});
|
|
527
527
|
}
|
|
528
|
-
async function
|
|
528
|
+
async function rt(e, r, o, n) {
|
|
529
529
|
const t = await _({
|
|
530
530
|
...n,
|
|
531
|
-
cacheTime:
|
|
532
|
-
}), a = await
|
|
533
|
-
if (
|
|
531
|
+
cacheTime: b
|
|
532
|
+
}), a = await S(r, n), s = typeof o == "object" && o.$kind === "GasCoin";
|
|
533
|
+
if (k(a.suiCoinType) === k("0x2::sui::SUI") && s) {
|
|
534
534
|
if (!n?.amount)
|
|
535
535
|
throw new Error("Amount is required for sui coin");
|
|
536
536
|
o = e.splitCoins(o, [n.amount]);
|
|
537
537
|
}
|
|
538
538
|
let i;
|
|
539
|
-
if (typeof n?.amount < "u" ? i =
|
|
539
|
+
if (typeof n?.amount < "u" ? i = g(n.amount, e.pure.u64) : i = e.moveCall({
|
|
540
540
|
target: "0x2::coin::value",
|
|
541
|
-
arguments: [
|
|
541
|
+
arguments: [g(o, e.object)],
|
|
542
542
|
typeArguments: [a.suiCoinType]
|
|
543
543
|
}), n?.accountCap) {
|
|
544
544
|
const [c] = e.moveCall({
|
|
@@ -549,10 +549,10 @@ async function et(e, r, o, n) {
|
|
|
549
549
|
e.object(t.storage),
|
|
550
550
|
e.object(a.contract.pool),
|
|
551
551
|
e.pure.u8(a.id),
|
|
552
|
-
|
|
552
|
+
g(o, e.object),
|
|
553
553
|
e.object(t.incentiveV2),
|
|
554
554
|
e.object(t.incentiveV3),
|
|
555
|
-
|
|
555
|
+
g(n.accountCap, e.object)
|
|
556
556
|
],
|
|
557
557
|
typeArguments: [a.suiCoinType]
|
|
558
558
|
});
|
|
@@ -570,7 +570,7 @@ async function et(e, r, o, n) {
|
|
|
570
570
|
e.object(t.storage),
|
|
571
571
|
e.object(a.contract.pool),
|
|
572
572
|
e.pure.u8(a.id),
|
|
573
|
-
|
|
573
|
+
g(o, e.object),
|
|
574
574
|
i,
|
|
575
575
|
e.object(t.incentiveV2),
|
|
576
576
|
e.object(t.incentiveV3)
|
|
@@ -578,15 +578,15 @@ async function et(e, r, o, n) {
|
|
|
578
578
|
typeArguments: [a.suiCoinType]
|
|
579
579
|
}), e;
|
|
580
580
|
}
|
|
581
|
-
const
|
|
582
|
-
|
|
581
|
+
const nt = M(
|
|
582
|
+
P(
|
|
583
583
|
async (e) => {
|
|
584
584
|
const r = await _({
|
|
585
585
|
...e
|
|
586
586
|
});
|
|
587
587
|
if (e?.address && typeof e?.asset < "u")
|
|
588
588
|
try {
|
|
589
|
-
const t = await
|
|
589
|
+
const t = await S(e.asset, e), a = e?.client ?? V, s = new F();
|
|
590
590
|
s.moveCall({
|
|
591
591
|
target: `${r.package}::incentive_v3::get_borrow_fee_v2`,
|
|
592
592
|
arguments: [
|
|
@@ -600,19 +600,19 @@ const tt = P(
|
|
|
600
600
|
const i = await a.devInspectTransactionBlock({
|
|
601
601
|
transactionBlock: s,
|
|
602
602
|
sender: e.address
|
|
603
|
-
}), c =
|
|
603
|
+
}), c = H(i, [C.u64()]);
|
|
604
604
|
return (Number(c[0]) || 0) / 100;
|
|
605
605
|
} catch (t) {
|
|
606
606
|
console.error(t);
|
|
607
607
|
}
|
|
608
|
-
const n = (await
|
|
608
|
+
const n = (await V.getObject({
|
|
609
609
|
id: r.incentiveV3,
|
|
610
610
|
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
611
611
|
})).data.content.fields.borrow_fee_rate;
|
|
612
612
|
return Number(n) / 100;
|
|
613
613
|
}
|
|
614
614
|
)
|
|
615
|
-
),
|
|
615
|
+
), O = "main", U = {
|
|
616
616
|
main: {
|
|
617
617
|
id: 0,
|
|
618
618
|
key: "main",
|
|
@@ -634,34 +634,34 @@ const tt = P(
|
|
|
634
634
|
name: "Sui Eco Market"
|
|
635
635
|
}
|
|
636
636
|
};
|
|
637
|
-
class
|
|
637
|
+
class Ae {
|
|
638
638
|
constructor(r, o) {
|
|
639
639
|
this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
|
|
640
640
|
marketTotalSupplyValue: "0",
|
|
641
641
|
marketTotalBorrowValue: "0"
|
|
642
|
-
}, this.config =
|
|
642
|
+
}, this.config = T(r), this.initPools(o);
|
|
643
643
|
}
|
|
644
644
|
get overview() {
|
|
645
645
|
return this._overview;
|
|
646
646
|
}
|
|
647
647
|
initPools(r) {
|
|
648
|
-
const o =
|
|
648
|
+
const o = z(this.pools), n = X(this.emodes), t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
649
649
|
let s = p(0), i = p(0);
|
|
650
650
|
r.forEach((c) => {
|
|
651
651
|
if (!this.checkMarket(c.market)) {
|
|
652
652
|
console.warn(`Pool is not in market ${this.config.name}`, c);
|
|
653
653
|
return;
|
|
654
654
|
}
|
|
655
|
-
o[c.uniqueId] || this.pools.push(c), c?.emodes?.forEach((
|
|
656
|
-
n[
|
|
657
|
-
|
|
658
|
-
(
|
|
659
|
-
) && t.add(c.uniqueId),
|
|
655
|
+
o[c.uniqueId] || this.pools.push(c), c?.emodes?.forEach((m) => {
|
|
656
|
+
n[m.uniqueId] || this.emodes.push(m), m.assets.forEach((h) => {
|
|
657
|
+
h.isDebt && m.assets.find(
|
|
658
|
+
(y) => y.isCollateral && y.ltv > 0 && y.assetId !== c.id
|
|
659
|
+
) && t.add(c.uniqueId), h.isCollateral && m.assets.find((y) => y.isDebt && y.assetId !== c.id) && a.add(c.uniqueId);
|
|
660
660
|
});
|
|
661
661
|
}), i = i.plus(c.poolBorrowValue), s = s.plus(c.poolSupplyValue);
|
|
662
|
-
}), this.poolMap =
|
|
663
|
-
const
|
|
664
|
-
this.emodePools.push(...
|
|
662
|
+
}), this.poolMap = z(this.pools, "id"), this.emodeMap = X(this.emodes, "emodeId"), this.emodes.forEach((c) => {
|
|
663
|
+
const u = this.getEModePools(c.emodeId);
|
|
664
|
+
this.emodePools.push(...u);
|
|
665
665
|
}), this._overview = {
|
|
666
666
|
marketTotalSupplyValue: s.toString(),
|
|
667
667
|
marketTotalBorrowValue: i.toString()
|
|
@@ -697,13 +697,13 @@ class je {
|
|
|
697
697
|
return typeof r == "number" && r === this.config.id && (o = !0), typeof r == "string" && r === this.config.key && (o = !0), typeof r == "object" && r.id === this.config.id && (o = !0), o;
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
const
|
|
701
|
-
const o = Object.values(
|
|
700
|
+
const T = (e) => {
|
|
701
|
+
const o = Object.values(U).find((n) => typeof e == "number" ? n.id === e : typeof e == "string" ? n.key === e : n.id === e.id);
|
|
702
702
|
if (!o)
|
|
703
703
|
throw new Error("Market not found");
|
|
704
704
|
return o;
|
|
705
|
-
},
|
|
706
|
-
|
|
705
|
+
}, $e = M(
|
|
706
|
+
P(
|
|
707
707
|
async (e, r) => {
|
|
708
708
|
const o = await q({
|
|
709
709
|
cacheTime: 6e4,
|
|
@@ -711,26 +711,26 @@ const j = (e) => {
|
|
|
711
711
|
markets: e
|
|
712
712
|
});
|
|
713
713
|
return e.map((n) => {
|
|
714
|
-
const t =
|
|
715
|
-
return new
|
|
714
|
+
const t = T(n), a = o.filter((s) => s.market === t.key);
|
|
715
|
+
return new Ae(n, a);
|
|
716
716
|
});
|
|
717
717
|
}
|
|
718
718
|
)
|
|
719
|
-
),
|
|
720
|
-
|
|
721
|
-
async (e, r) => (await
|
|
719
|
+
), at = M(
|
|
720
|
+
P(
|
|
721
|
+
async (e, r) => (await $e([e], r))[0]
|
|
722
722
|
)
|
|
723
|
-
), _ =
|
|
724
|
-
|
|
723
|
+
), _ = M(
|
|
724
|
+
P(
|
|
725
725
|
async (e) => {
|
|
726
|
-
const r =
|
|
727
|
-
return (await fetch(o, { headers:
|
|
726
|
+
const r = T(e?.market || O), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.key}`;
|
|
727
|
+
return (await fetch(o, { headers: D }).then((t) => t.json())).data;
|
|
728
728
|
}
|
|
729
729
|
)
|
|
730
|
-
),
|
|
731
|
-
async function
|
|
730
|
+
), b = 1e3 * 60 * 5;
|
|
731
|
+
async function Pe(e, r) {
|
|
732
732
|
const o = await _({
|
|
733
|
-
cacheTime:
|
|
733
|
+
cacheTime: b,
|
|
734
734
|
...r
|
|
735
735
|
});
|
|
736
736
|
return e.moveCall({
|
|
@@ -738,9 +738,9 @@ async function Te(e, r) {
|
|
|
738
738
|
arguments: []
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
|
-
async function
|
|
741
|
+
async function Se(e, r, o) {
|
|
742
742
|
const n = await _({
|
|
743
|
-
cacheTime:
|
|
743
|
+
cacheTime: b,
|
|
744
744
|
...o
|
|
745
745
|
});
|
|
746
746
|
return e.moveCall({
|
|
@@ -748,63 +748,63 @@ async function Be(e, r, o) {
|
|
|
748
748
|
arguments: [r]
|
|
749
749
|
});
|
|
750
750
|
}
|
|
751
|
-
async function
|
|
751
|
+
async function Me(e, r, o) {
|
|
752
752
|
const n = await _({
|
|
753
753
|
...o,
|
|
754
|
-
cacheTime:
|
|
754
|
+
cacheTime: b
|
|
755
755
|
});
|
|
756
756
|
return o?.accountCap ? e.moveCall({
|
|
757
757
|
target: `${n.package}::lending::enter_emode_with_account_cap`,
|
|
758
758
|
arguments: [
|
|
759
759
|
e.object(n.storage),
|
|
760
|
-
|
|
761
|
-
|
|
760
|
+
g(r, e.pure.u64),
|
|
761
|
+
g(o.accountCap, e.object)
|
|
762
762
|
]
|
|
763
763
|
}) : e.moveCall({
|
|
764
764
|
target: `${n.package}::lending::enter_emode`,
|
|
765
|
-
arguments: [e.object(n.storage),
|
|
765
|
+
arguments: [e.object(n.storage), g(r, e.pure.u64)]
|
|
766
766
|
}), e;
|
|
767
767
|
}
|
|
768
|
-
async function
|
|
768
|
+
async function it(e, r) {
|
|
769
769
|
const o = await _({
|
|
770
770
|
...r,
|
|
771
|
-
cacheTime:
|
|
771
|
+
cacheTime: b
|
|
772
772
|
});
|
|
773
773
|
return r?.accountCap ? e.moveCall({
|
|
774
774
|
target: `${o.package}::lending::exit_emode_with_account_cap`,
|
|
775
|
-
arguments: [e.object(o.storage),
|
|
775
|
+
arguments: [e.object(o.storage), g(r.accountCap, e.object)]
|
|
776
776
|
}) : e.moveCall({
|
|
777
777
|
target: `${o.package}::lending::exit_emode`,
|
|
778
778
|
arguments: [e.object(o.storage)]
|
|
779
779
|
}), e;
|
|
780
780
|
}
|
|
781
|
-
async function
|
|
781
|
+
async function ct(e, r, o) {
|
|
782
782
|
const n = await _({
|
|
783
|
-
cacheTime:
|
|
783
|
+
cacheTime: b,
|
|
784
784
|
...o
|
|
785
|
-
}), t = await
|
|
786
|
-
await
|
|
785
|
+
}), t = await Pe(e, o);
|
|
786
|
+
await Me(e, r, {
|
|
787
787
|
...o,
|
|
788
788
|
accountCap: t
|
|
789
789
|
});
|
|
790
|
-
const a = await
|
|
790
|
+
const a = await T(o?.market || O), s = await Se(e, t, o);
|
|
791
791
|
return e.moveCall({
|
|
792
792
|
target: `${n.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
|
|
793
793
|
arguments: [
|
|
794
794
|
e.object(n.emode.contract.registryObject),
|
|
795
795
|
s,
|
|
796
|
-
|
|
797
|
-
|
|
796
|
+
g(a.id, e.pure.u64),
|
|
797
|
+
g(r, e.pure.u64)
|
|
798
798
|
]
|
|
799
799
|
}), t;
|
|
800
800
|
}
|
|
801
|
-
const
|
|
802
|
-
|
|
801
|
+
const oe = M(
|
|
802
|
+
P(
|
|
803
803
|
async (e, r) => {
|
|
804
804
|
const o = await _({
|
|
805
|
-
cacheTime:
|
|
805
|
+
cacheTime: b,
|
|
806
806
|
...r
|
|
807
|
-
}), n = new F(), t = r?.client ??
|
|
807
|
+
}), n = new F(), t = r?.client ?? V;
|
|
808
808
|
n.moveCall({
|
|
809
809
|
target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
|
|
810
810
|
arguments: [n.object(o.emode.contract.registryObject), n.pure.address(e)]
|
|
@@ -812,24 +812,24 @@ const ee = P(
|
|
|
812
812
|
const s = (await t.devInspectTransactionBlock({
|
|
813
813
|
transactionBlock: n,
|
|
814
814
|
sender: e
|
|
815
|
-
})).results[0].returnValues, i = C.vector(C.u64()).parse(Uint8Array.from(s[0][0])), c = C.vector(C.u64()).parse(Uint8Array.from(s[1][0])),
|
|
816
|
-
return i.map((
|
|
817
|
-
marketId: Number(
|
|
818
|
-
emodeId: Number(c[
|
|
819
|
-
accountCap:
|
|
815
|
+
})).results[0].returnValues, i = C.vector(C.u64()).parse(Uint8Array.from(s[0][0])), c = C.vector(C.u64()).parse(Uint8Array.from(s[1][0])), u = C.vector(C.Address).parse(Uint8Array.from(s[2][0]));
|
|
816
|
+
return i.map((m, h) => ({
|
|
817
|
+
marketId: Number(m),
|
|
818
|
+
emodeId: Number(c[h]),
|
|
819
|
+
accountCap: u[h].toString()
|
|
820
820
|
}));
|
|
821
821
|
}
|
|
822
822
|
)
|
|
823
823
|
);
|
|
824
|
-
function
|
|
825
|
-
return `${
|
|
824
|
+
function st(e) {
|
|
825
|
+
return `${T(e.marketId).key}-${e.emodeId}`;
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function lt(e, r, o) {
|
|
828
828
|
const n = typeof o?.balance == "number", t = n ? o.balance : 0;
|
|
829
829
|
let a = 0;
|
|
830
830
|
const s = [];
|
|
831
831
|
let i = "";
|
|
832
|
-
if (r.sort((c,
|
|
832
|
+
if (r.sort((c, u) => Number(u.balance) - Number(c.balance)).forEach((c) => {
|
|
833
833
|
if (!(n && a >= t) && Number(c.balance) !== 0) {
|
|
834
834
|
if (i || (i = c.coinType), i !== c.coinType)
|
|
835
835
|
throw new Error("All coins must be of the same type");
|
|
@@ -841,131 +841,153 @@ function it(e, r, o) {
|
|
|
841
841
|
throw new Error(
|
|
842
842
|
`Balance is less than the specified balance: ${a} < ${t}`
|
|
843
843
|
);
|
|
844
|
-
return
|
|
844
|
+
return k(i) === k("0x2::sui::SUI") && o?.useGasCoin ? n ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (s.length === 1 ? e.object(s[0]) : e.mergeCoins(s[0], s.slice(1)), n ? e.splitCoins(s[0], [e.pure.u64(t)]) : s[0]);
|
|
845
845
|
}
|
|
846
|
-
async function
|
|
846
|
+
async function re(e, r, o, n, t, a, s) {
|
|
847
847
|
const i = await _({
|
|
848
848
|
...s,
|
|
849
|
-
cacheTime:
|
|
850
|
-
}), c = await
|
|
849
|
+
cacheTime: b
|
|
850
|
+
}), c = await S(o, s);
|
|
851
851
|
return e.moveCall({
|
|
852
852
|
target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
|
|
853
853
|
arguments: [
|
|
854
854
|
e.object("0x06"),
|
|
855
855
|
e.object(i.storage),
|
|
856
856
|
e.object(i.oracle.priceOracle),
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
857
|
+
je(e, c),
|
|
858
|
+
g(r, e.pure.address),
|
|
859
|
+
g(c.id, e.pure.u8),
|
|
860
|
+
g(n, e.pure.u64),
|
|
861
|
+
g(t, e.pure.u64),
|
|
862
|
+
g(a, e.pure.bool)
|
|
863
863
|
],
|
|
864
864
|
typeArguments: [c.suiCoinType]
|
|
865
865
|
});
|
|
866
866
|
}
|
|
867
|
-
async function
|
|
868
|
-
return
|
|
867
|
+
async function Ve(e, r, o) {
|
|
868
|
+
return re(e, r, 0, 0, 0, !1, o);
|
|
869
869
|
}
|
|
870
|
-
async function
|
|
871
|
-
const n = new F(), t = o?.client ??
|
|
870
|
+
async function ne(e, r, o) {
|
|
871
|
+
const n = new F(), t = o?.client ?? V, a = await q({
|
|
872
872
|
...o,
|
|
873
|
-
markets: Object.values(
|
|
874
|
-
}), s =
|
|
875
|
-
for (
|
|
876
|
-
const
|
|
873
|
+
markets: Object.values(U)
|
|
874
|
+
}), s = z(a), c = Array.from(new Set(r.map((l) => l.market))).map((l) => T(l));
|
|
875
|
+
for (const l of c) {
|
|
876
|
+
const f = await _({
|
|
877
877
|
...o,
|
|
878
|
-
cacheTime:
|
|
879
|
-
market:
|
|
878
|
+
cacheTime: b,
|
|
879
|
+
market: l.key
|
|
880
880
|
});
|
|
881
881
|
n.moveCall({
|
|
882
|
-
target: `${
|
|
883
|
-
arguments: [n.object(
|
|
882
|
+
target: `${f.uiGetter}::getter::get_reserve_data`,
|
|
883
|
+
arguments: [n.object(f.storage)]
|
|
884
884
|
});
|
|
885
885
|
}
|
|
886
|
-
|
|
886
|
+
for (let l of r) {
|
|
887
|
+
const f = await _({
|
|
888
|
+
...o,
|
|
889
|
+
cacheTime: b,
|
|
890
|
+
market: l.market
|
|
891
|
+
});
|
|
892
|
+
n.moveCall({
|
|
893
|
+
target: `${f.uiGetter}::getter_unchecked::get_user_state`,
|
|
894
|
+
arguments: [n.object(f.storage), n.pure.address(l.address)]
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
const m = (await t.devInspectTransactionBlock({
|
|
887
898
|
transactionBlock: n,
|
|
888
899
|
sender: e
|
|
889
|
-
})).results || []
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
900
|
+
})).results || [], h = {};
|
|
901
|
+
c.forEach((l, f) => {
|
|
902
|
+
try {
|
|
903
|
+
const w = m[f]?.returnValues?.map((B) => C.vector(ve).parse(Uint8Array.from(B[0])))[0] || [], I = {};
|
|
904
|
+
for (const B of w)
|
|
905
|
+
I[B.id] = {
|
|
906
|
+
supplyIndex: B.supply_index,
|
|
907
|
+
borrowIndex: B.borrow_index
|
|
908
|
+
};
|
|
909
|
+
h[l.key] = I;
|
|
910
|
+
} catch (w) {
|
|
911
|
+
console.warn(
|
|
912
|
+
`[@naviprotocol/lending] Failed to decode reserve data for market "${l.key}", falling back to open-api pool indices`,
|
|
913
|
+
w
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
const v = m.slice(c.length).map((l) => l.returnValues?.map((f) => C.vector(we).parse(Uint8Array.from(f[0])))[0] || []), y = [];
|
|
918
|
+
return v.forEach((l, f) => {
|
|
919
|
+
const w = r[f], I = T(w.market), B = h[I.key] || {};
|
|
920
|
+
l.forEach((j) => {
|
|
921
|
+
if (j.supply_balance === "0" && j.borrow_balance === "0" && (w.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
|
|
894
922
|
return;
|
|
895
|
-
const
|
|
896
|
-
if (!
|
|
923
|
+
const A = s[`${I.key}-${j.asset_id}`];
|
|
924
|
+
if (!A)
|
|
897
925
|
return;
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
supplyBalance: k,
|
|
907
|
-
borrowBalance: I,
|
|
908
|
-
assetId: u.asset_id,
|
|
909
|
-
market: g.key,
|
|
910
|
-
pool: f,
|
|
911
|
-
emodeId: v.emodeId
|
|
926
|
+
const L = B[j.asset_id], G = L?.supplyIndex ?? A.currentSupplyIndex, ce = L?.borrowIndex ?? A.currentBorrowIndex, se = Q(j.supply_balance, G).toString(), le = Q(j.borrow_balance, ce).toString();
|
|
927
|
+
y.push({
|
|
928
|
+
supplyBalance: se,
|
|
929
|
+
borrowBalance: le,
|
|
930
|
+
assetId: j.asset_id,
|
|
931
|
+
market: I.key,
|
|
932
|
+
pool: A,
|
|
933
|
+
emodeId: w.emodeId
|
|
912
934
|
});
|
|
913
935
|
});
|
|
914
|
-
}),
|
|
936
|
+
}), y;
|
|
915
937
|
}
|
|
916
|
-
const
|
|
938
|
+
const ut = M(
|
|
917
939
|
async (e, r) => {
|
|
918
|
-
const n = (r?.markets || Object.keys(
|
|
940
|
+
const n = (r?.markets || Object.keys(U)).map((t) => T(t)).map((t) => ({
|
|
919
941
|
address: e,
|
|
920
942
|
market: t.key
|
|
921
943
|
}));
|
|
922
|
-
return await
|
|
944
|
+
return await ne(e, n, r);
|
|
923
945
|
}
|
|
924
946
|
);
|
|
925
|
-
async function
|
|
926
|
-
const o = r?.client ??
|
|
927
|
-
await
|
|
947
|
+
async function pt(e, r) {
|
|
948
|
+
const o = r?.client ?? V, n = new F();
|
|
949
|
+
await Ve(n, e, r);
|
|
928
950
|
const t = await o.devInspectTransactionBlock({
|
|
929
951
|
transactionBlock: n,
|
|
930
952
|
sender: e
|
|
931
|
-
}), a =
|
|
932
|
-
return
|
|
953
|
+
}), a = H(t, [C.u256()]);
|
|
954
|
+
return te(Number(a[0]) || 0);
|
|
933
955
|
}
|
|
934
|
-
async function
|
|
935
|
-
const t = n?.client ??
|
|
956
|
+
async function dt(e, r, o, n) {
|
|
957
|
+
const t = n?.client ?? V, a = new F();
|
|
936
958
|
let s = 0, i = 0;
|
|
937
|
-
const c = await
|
|
959
|
+
const c = await S(r, n);
|
|
938
960
|
if (o.forEach((v) => {
|
|
939
961
|
v.type === R.Supply ? s += v.amount : v.type === R.Withdraw ? s -= v.amount : v.type === R.Borrow ? i += v.amount : v.type === R.Repay && (i -= v.amount);
|
|
940
962
|
}), s * i < 0)
|
|
941
963
|
throw new Error("Invalid operations");
|
|
942
|
-
const
|
|
943
|
-
await
|
|
964
|
+
const u = s > 0 || i > 0;
|
|
965
|
+
await re(
|
|
944
966
|
a,
|
|
945
967
|
e,
|
|
946
968
|
c,
|
|
947
969
|
Math.abs(s),
|
|
948
970
|
Math.abs(i),
|
|
949
|
-
|
|
971
|
+
u,
|
|
950
972
|
n
|
|
951
973
|
);
|
|
952
|
-
const
|
|
974
|
+
const m = await t.devInspectTransactionBlock({
|
|
953
975
|
transactionBlock: a,
|
|
954
976
|
sender: e
|
|
955
|
-
}),
|
|
956
|
-
return
|
|
977
|
+
}), h = H(m, [C.u256()]);
|
|
978
|
+
return te(Number(h[0]) || 0);
|
|
957
979
|
}
|
|
958
|
-
const
|
|
980
|
+
const mt = P(
|
|
959
981
|
async (e, r) => {
|
|
960
982
|
const o = new URLSearchParams();
|
|
961
983
|
r?.cursor && o.set("cursor", r.cursor), o.set("userAddress", e);
|
|
962
|
-
const n = `https://open-api.naviprotocol.io/api/navi/user/transactions?${o.toString()}&sdk=${
|
|
963
|
-
return (await fetch(n, { headers:
|
|
984
|
+
const n = `https://open-api.naviprotocol.io/api/navi/user/transactions?${o.toString()}&sdk=${E.version}`;
|
|
985
|
+
return (await fetch(n, { headers: D }).then((a) => a.json())).data;
|
|
964
986
|
}
|
|
965
987
|
);
|
|
966
|
-
async function
|
|
988
|
+
async function ft(e, r) {
|
|
967
989
|
let o = null;
|
|
968
|
-
const n = [], t = r?.client ??
|
|
990
|
+
const n = [], t = r?.client ?? V;
|
|
969
991
|
do {
|
|
970
992
|
let a;
|
|
971
993
|
if (r?.coinType ? a = await t.getCoins({
|
|
@@ -983,12 +1005,12 @@ async function pt(e, r) {
|
|
|
983
1005
|
} while (o);
|
|
984
1006
|
return n;
|
|
985
1007
|
}
|
|
986
|
-
const
|
|
1008
|
+
const Ee = M(
|
|
987
1009
|
async (e, r) => {
|
|
988
|
-
const o = [], n = (r?.markets || Object.keys(
|
|
1010
|
+
const o = [], n = (r?.markets || Object.keys(U)).map((i) => T(i));
|
|
989
1011
|
let t = [];
|
|
990
1012
|
try {
|
|
991
|
-
t = await
|
|
1013
|
+
t = await oe(e, r);
|
|
992
1014
|
} catch (i) {
|
|
993
1015
|
console.error(i);
|
|
994
1016
|
}
|
|
@@ -998,33 +1020,33 @@ const $e = P(
|
|
|
998
1020
|
})).concat(
|
|
999
1021
|
t.filter((i) => !!n.find((c) => c.id === i.marketId)).map((i) => ({
|
|
1000
1022
|
address: i.accountCap,
|
|
1001
|
-
market:
|
|
1023
|
+
market: T(i.marketId).key,
|
|
1002
1024
|
emodeId: i.emodeId
|
|
1003
1025
|
}))
|
|
1004
1026
|
);
|
|
1005
|
-
return (await
|
|
1006
|
-
const c = typeof i.emodeId == "number" ? t.find((
|
|
1007
|
-
const
|
|
1008
|
-
return
|
|
1027
|
+
return (await ne(e, a, r)).forEach((i) => {
|
|
1028
|
+
const c = typeof i.emodeId == "number" ? t.find((u) => {
|
|
1029
|
+
const m = T(i.market);
|
|
1030
|
+
return u.emodeId === i.emodeId && u.marketId === m.id;
|
|
1009
1031
|
}) : void 0;
|
|
1010
1032
|
if (c) {
|
|
1011
|
-
if (!i.pool.emodes.find((
|
|
1033
|
+
if (!i.pool.emodes.find((m) => m.emodeId === c.emodeId))
|
|
1012
1034
|
return;
|
|
1013
1035
|
if (p(i.supplyBalance).gte(0)) {
|
|
1014
|
-
const
|
|
1015
|
-
if (
|
|
1036
|
+
const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), h = W(i.pool, c);
|
|
1037
|
+
if (m.gt(0) || h.emode.isCollateral)
|
|
1016
1038
|
try {
|
|
1017
1039
|
o.push({
|
|
1018
|
-
id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${
|
|
1040
|
+
id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${$()}`,
|
|
1019
1041
|
wallet: e,
|
|
1020
1042
|
protocol: "navi",
|
|
1021
1043
|
market: i.market,
|
|
1022
1044
|
type: "navi-lending-emode-supply",
|
|
1023
1045
|
"navi-lending-emode-supply": {
|
|
1024
|
-
amount:
|
|
1025
|
-
pool:
|
|
1046
|
+
amount: m.toString(),
|
|
1047
|
+
pool: W(i.pool, c),
|
|
1026
1048
|
token: i.pool.token,
|
|
1027
|
-
valueUSD:
|
|
1049
|
+
valueUSD: m.multipliedBy(i.pool.oracle.price).toString(),
|
|
1028
1050
|
emodeCap: c
|
|
1029
1051
|
}
|
|
1030
1052
|
});
|
|
@@ -1033,20 +1055,20 @@ const $e = P(
|
|
|
1033
1055
|
}
|
|
1034
1056
|
}
|
|
1035
1057
|
if (p(i.borrowBalance).gte(0)) {
|
|
1036
|
-
const
|
|
1037
|
-
if (
|
|
1058
|
+
const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), h = W(i.pool, c);
|
|
1059
|
+
if (m.gt(0) || h.emode.isDebt)
|
|
1038
1060
|
try {
|
|
1039
1061
|
o.push({
|
|
1040
|
-
id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${
|
|
1062
|
+
id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${$()}`,
|
|
1041
1063
|
wallet: e,
|
|
1042
1064
|
protocol: "navi",
|
|
1043
1065
|
market: i.market,
|
|
1044
1066
|
type: "navi-lending-emode-borrow",
|
|
1045
1067
|
"navi-lending-emode-borrow": {
|
|
1046
|
-
amount:
|
|
1047
|
-
pool:
|
|
1068
|
+
amount: m.toString(),
|
|
1069
|
+
pool: W(i.pool, c),
|
|
1048
1070
|
token: i.pool.token,
|
|
1049
|
-
valueUSD:
|
|
1071
|
+
valueUSD: m.multipliedBy(i.pool.oracle.price).toString(),
|
|
1050
1072
|
emodeCap: c
|
|
1051
1073
|
}
|
|
1052
1074
|
});
|
|
@@ -1056,34 +1078,34 @@ const $e = P(
|
|
|
1056
1078
|
}
|
|
1057
1079
|
} else {
|
|
1058
1080
|
if (p(i.supplyBalance).gt(0)) {
|
|
1059
|
-
const
|
|
1081
|
+
const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
|
|
1060
1082
|
o.push({
|
|
1061
|
-
id: `${i.pool.uniqueId}_navi-lending-supply-${
|
|
1083
|
+
id: `${i.pool.uniqueId}_navi-lending-supply-${$()}`,
|
|
1062
1084
|
wallet: e,
|
|
1063
1085
|
protocol: "navi",
|
|
1064
1086
|
type: "navi-lending-supply",
|
|
1065
1087
|
market: i.market,
|
|
1066
1088
|
"navi-lending-supply": {
|
|
1067
|
-
amount:
|
|
1089
|
+
amount: u.toString(),
|
|
1068
1090
|
pool: i.pool,
|
|
1069
1091
|
token: i.pool.token,
|
|
1070
|
-
valueUSD:
|
|
1092
|
+
valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
|
|
1071
1093
|
}
|
|
1072
1094
|
});
|
|
1073
1095
|
}
|
|
1074
1096
|
if (p(i.borrowBalance).gt(0)) {
|
|
1075
|
-
const
|
|
1097
|
+
const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
|
|
1076
1098
|
o.push({
|
|
1077
|
-
id: `${i.pool.uniqueId}_navi-lending-borrow-${
|
|
1099
|
+
id: `${i.pool.uniqueId}_navi-lending-borrow-${$()}`,
|
|
1078
1100
|
wallet: e,
|
|
1079
1101
|
protocol: "navi",
|
|
1080
1102
|
market: i.market,
|
|
1081
1103
|
type: "navi-lending-borrow",
|
|
1082
1104
|
"navi-lending-borrow": {
|
|
1083
|
-
amount:
|
|
1105
|
+
amount: u.toString(),
|
|
1084
1106
|
pool: i.pool,
|
|
1085
1107
|
token: i.pool.token,
|
|
1086
|
-
valueUSD:
|
|
1108
|
+
valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
|
|
1087
1109
|
}
|
|
1088
1110
|
});
|
|
1089
1111
|
}
|
|
@@ -1123,7 +1145,7 @@ class N {
|
|
|
1123
1145
|
return this._priceMap = r, this._overview = this.getPositionsOverview(this._positions), this;
|
|
1124
1146
|
}
|
|
1125
1147
|
getPrice(r) {
|
|
1126
|
-
const o =
|
|
1148
|
+
const o = k(r.suiCoinType);
|
|
1127
1149
|
if (this._priceMap[o] !== void 0)
|
|
1128
1150
|
return this._priceMap[o].toString();
|
|
1129
1151
|
const n = r.suiCoinType;
|
|
@@ -1143,7 +1165,7 @@ class N {
|
|
|
1143
1165
|
const n = !!r.isEMode, t = this.getPrice(r);
|
|
1144
1166
|
let a;
|
|
1145
1167
|
return n ? a = {
|
|
1146
|
-
id:
|
|
1168
|
+
id: $(),
|
|
1147
1169
|
wallet: "",
|
|
1148
1170
|
protocol: "navi",
|
|
1149
1171
|
market: "",
|
|
@@ -1156,7 +1178,7 @@ class N {
|
|
|
1156
1178
|
emodeCap: {}
|
|
1157
1179
|
}
|
|
1158
1180
|
} : a = {
|
|
1159
|
-
id:
|
|
1181
|
+
id: $(),
|
|
1160
1182
|
wallet: "",
|
|
1161
1183
|
protocol: "navi",
|
|
1162
1184
|
market: "",
|
|
@@ -1173,7 +1195,7 @@ class N {
|
|
|
1173
1195
|
const n = !!r.isEMode, t = this.getPrice(r);
|
|
1174
1196
|
let a;
|
|
1175
1197
|
return n ? a = {
|
|
1176
|
-
id:
|
|
1198
|
+
id: $(),
|
|
1177
1199
|
wallet: "",
|
|
1178
1200
|
protocol: "navi",
|
|
1179
1201
|
market: "",
|
|
@@ -1186,7 +1208,7 @@ class N {
|
|
|
1186
1208
|
emodeCap: {}
|
|
1187
1209
|
}
|
|
1188
1210
|
} : a = {
|
|
1189
|
-
id:
|
|
1211
|
+
id: $(),
|
|
1190
1212
|
wallet: "",
|
|
1191
1213
|
protocol: "navi",
|
|
1192
1214
|
market: "",
|
|
@@ -1203,7 +1225,7 @@ class N {
|
|
|
1203
1225
|
const n = !!r.isEMode, t = this.getPrice(r);
|
|
1204
1226
|
let a;
|
|
1205
1227
|
return n ? a = {
|
|
1206
|
-
id:
|
|
1228
|
+
id: $(),
|
|
1207
1229
|
wallet: "",
|
|
1208
1230
|
protocol: "navi",
|
|
1209
1231
|
market: "",
|
|
@@ -1216,7 +1238,7 @@ class N {
|
|
|
1216
1238
|
emodeCap: {}
|
|
1217
1239
|
}
|
|
1218
1240
|
} : a = {
|
|
1219
|
-
id:
|
|
1241
|
+
id: $(),
|
|
1220
1242
|
wallet: "",
|
|
1221
1243
|
protocol: "navi",
|
|
1222
1244
|
market: "",
|
|
@@ -1233,7 +1255,7 @@ class N {
|
|
|
1233
1255
|
const n = !!r.isEMode, t = this.getPrice(r);
|
|
1234
1256
|
let a;
|
|
1235
1257
|
return n ? a = {
|
|
1236
|
-
id:
|
|
1258
|
+
id: $(),
|
|
1237
1259
|
wallet: "",
|
|
1238
1260
|
protocol: "navi",
|
|
1239
1261
|
market: "",
|
|
@@ -1246,7 +1268,7 @@ class N {
|
|
|
1246
1268
|
emodeCap: {}
|
|
1247
1269
|
}
|
|
1248
1270
|
} : a = {
|
|
1249
|
-
id:
|
|
1271
|
+
id: $(),
|
|
1250
1272
|
wallet: "",
|
|
1251
1273
|
protocol: "navi",
|
|
1252
1274
|
market: "",
|
|
@@ -1264,74 +1286,74 @@ class N {
|
|
|
1264
1286
|
}
|
|
1265
1287
|
getPositionsOverview(r) {
|
|
1266
1288
|
const o = {}, n = {};
|
|
1267
|
-
let t = new p(0), a = new p(0), s = new p(0), i = new p(0), c = new p(0),
|
|
1268
|
-
r.forEach((
|
|
1269
|
-
if (
|
|
1270
|
-
const
|
|
1289
|
+
let t = new p(0), a = new p(0), s = new p(0), i = new p(0), c = new p(0), u = new p(0);
|
|
1290
|
+
r.forEach((y) => {
|
|
1291
|
+
if (y.type === "navi-lending-supply") {
|
|
1292
|
+
const l = y["navi-lending-supply"], f = this.resolveValueUSD(l);
|
|
1271
1293
|
t = t.plus(f), c = c.plus(
|
|
1272
|
-
new p(f).multipliedBy(
|
|
1273
|
-
),
|
|
1274
|
-
new p(f).multipliedBy(
|
|
1294
|
+
new p(f).multipliedBy(l.pool.liquidationFactor.threshold)
|
|
1295
|
+
), u = u.plus(
|
|
1296
|
+
new p(f).multipliedBy(l.pool.ltvValue)
|
|
1275
1297
|
);
|
|
1276
|
-
} else if (
|
|
1277
|
-
const
|
|
1278
|
-
a = a.plus(this.resolveValueUSD(
|
|
1279
|
-
} else if (
|
|
1280
|
-
const
|
|
1298
|
+
} else if (y.type === "navi-lending-borrow") {
|
|
1299
|
+
const l = y["navi-lending-borrow"];
|
|
1300
|
+
a = a.plus(this.resolveValueUSD(l));
|
|
1301
|
+
} else if (y.type === "navi-lending-emode-supply") {
|
|
1302
|
+
const l = y["navi-lending-emode-supply"], f = this.resolveValueUSD(l);
|
|
1281
1303
|
t = t.plus(f);
|
|
1282
|
-
const
|
|
1304
|
+
const w = l.pool.emode;
|
|
1283
1305
|
c = c.plus(
|
|
1284
|
-
new p(f).multipliedBy(
|
|
1285
|
-
),
|
|
1286
|
-
new p(f).multipliedBy(
|
|
1306
|
+
new p(f).multipliedBy(w.lt)
|
|
1307
|
+
), u = u.plus(
|
|
1308
|
+
new p(f).multipliedBy(w.ltv)
|
|
1287
1309
|
);
|
|
1288
|
-
} else if (
|
|
1289
|
-
const
|
|
1290
|
-
a = a.plus(this.resolveValueUSD(
|
|
1310
|
+
} else if (y.type === "navi-lending-emode-borrow") {
|
|
1311
|
+
const l = y["navi-lending-emode-borrow"];
|
|
1312
|
+
a = a.plus(this.resolveValueUSD(l));
|
|
1291
1313
|
}
|
|
1292
|
-
}), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0),
|
|
1293
|
-
if (
|
|
1294
|
-
const
|
|
1314
|
+
}), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0), u = p.max(u, 0), r.forEach((y) => {
|
|
1315
|
+
if (y.type === "navi-lending-supply") {
|
|
1316
|
+
const l = y["navi-lending-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
|
|
1295
1317
|
t.gt(0) && (s = s.plus(
|
|
1296
|
-
new p(f).dividedBy(t).multipliedBy(new p(
|
|
1297
|
-
)), o[
|
|
1298
|
-
} else if (
|
|
1299
|
-
const
|
|
1318
|
+
new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
|
|
1319
|
+
)), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
|
|
1320
|
+
} else if (y.type === "navi-lending-borrow") {
|
|
1321
|
+
const l = y["navi-lending-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
|
|
1300
1322
|
a.gt(0) && (i = i.plus(
|
|
1301
|
-
new p(f).dividedBy(a).multipliedBy(new p(
|
|
1302
|
-
)), n[
|
|
1303
|
-
} else if (
|
|
1304
|
-
const
|
|
1323
|
+
new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
|
|
1324
|
+
)), n[l.pool.suiCoinType] = p(n[l.pool.suiCoinType] || 0).plus(l.amount).toString();
|
|
1325
|
+
} else if (y.type === "navi-lending-emode-supply") {
|
|
1326
|
+
const l = y["navi-lending-emode-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
|
|
1305
1327
|
t.gt(0) && (s = s.plus(
|
|
1306
|
-
new p(f).dividedBy(t).multipliedBy(new p(
|
|
1307
|
-
)), o[
|
|
1308
|
-
} else if (
|
|
1309
|
-
const
|
|
1328
|
+
new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
|
|
1329
|
+
)), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
|
|
1330
|
+
} else if (y.type === "navi-lending-emode-borrow") {
|
|
1331
|
+
const l = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
|
|
1310
1332
|
a.gt(0) && (i = i.plus(
|
|
1311
|
-
new p(f).dividedBy(a).multipliedBy(new p(
|
|
1312
|
-
)), n[
|
|
1333
|
+
new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
|
|
1334
|
+
)), n[l.pool.suiCoinType] = p(n[l.pool.suiCoinType] || 0).plus(l.amount).toString();
|
|
1313
1335
|
}
|
|
1314
1336
|
});
|
|
1315
|
-
const
|
|
1337
|
+
const m = t.minus(a), h = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(s).minus(a.multipliedBy(i)).div(t.minus(a));
|
|
1316
1338
|
return {
|
|
1317
1339
|
hf: a.toNumber() !== 0 ? c.dividedBy(a).toNumber() : 1 / 0,
|
|
1318
|
-
netVaule:
|
|
1319
|
-
netWorthApr:
|
|
1340
|
+
netVaule: m.toString(),
|
|
1341
|
+
netWorthApr: h.toString(),
|
|
1320
1342
|
totalSupplyValue: t.toString(),
|
|
1321
1343
|
totalBorrowValue: a.toString(),
|
|
1322
1344
|
totalsupplyApy: s.toString(),
|
|
1323
1345
|
totalBorrowApy: i.toString(),
|
|
1324
1346
|
maxLiquidationValue: c.toString(),
|
|
1325
|
-
maxLoanToVaule:
|
|
1347
|
+
maxLoanToVaule: u.toString(),
|
|
1326
1348
|
supply: o,
|
|
1327
1349
|
borrow: n
|
|
1328
1350
|
};
|
|
1329
1351
|
}
|
|
1330
1352
|
}
|
|
1331
|
-
async function
|
|
1353
|
+
async function yt(e, r, o, n) {
|
|
1332
1354
|
const t = await _({
|
|
1333
1355
|
...n,
|
|
1334
|
-
cacheTime:
|
|
1356
|
+
cacheTime: b
|
|
1335
1357
|
});
|
|
1336
1358
|
t.limter && e.moveCall({
|
|
1337
1359
|
target: `${t.limter}::navi_adaptor::verify_navi_position_healthy`,
|
|
@@ -1339,17 +1361,17 @@ async function dt(e, r, o, n) {
|
|
|
1339
1361
|
e.object("0x06"),
|
|
1340
1362
|
e.object(t.storage),
|
|
1341
1363
|
e.object(t.priceOracle),
|
|
1342
|
-
|
|
1364
|
+
g(r, e.pure.address),
|
|
1343
1365
|
e.pure.u256(new p(o).shiftedBy(27).toNumber())
|
|
1344
1366
|
]
|
|
1345
1367
|
});
|
|
1346
1368
|
}
|
|
1347
|
-
const
|
|
1369
|
+
const ae = new x("https://hermes.pyth.network", {
|
|
1348
1370
|
timeout: 1e4
|
|
1349
1371
|
});
|
|
1350
|
-
async function
|
|
1372
|
+
async function gt(e) {
|
|
1351
1373
|
try {
|
|
1352
|
-
const r = [], o = await
|
|
1374
|
+
const r = [], o = await ae.getLatestPriceFeeds(e);
|
|
1353
1375
|
if (!o) return r;
|
|
1354
1376
|
const n = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
1355
1377
|
for (const t of o) {
|
|
@@ -1369,9 +1391,9 @@ async function mt(e) {
|
|
|
1369
1391
|
throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
|
|
1370
1392
|
}
|
|
1371
1393
|
}
|
|
1372
|
-
async function
|
|
1394
|
+
async function De(e, r) {
|
|
1373
1395
|
try {
|
|
1374
|
-
const o = [], n = r?.client ??
|
|
1396
|
+
const o = [], n = r?.client ?? V, t = e.map((s) => s.priceInfoObject), a = await n.multiGetObjects({
|
|
1375
1397
|
ids: Array.from(new Set(t)),
|
|
1376
1398
|
options: { showContent: !0 }
|
|
1377
1399
|
});
|
|
@@ -1381,18 +1403,18 @@ async function Se(e, r) {
|
|
|
1381
1403
|
console.warn(`fetched object ${i?.objectId} datatype should be moveObject`);
|
|
1382
1404
|
continue;
|
|
1383
1405
|
}
|
|
1384
|
-
const c = e.find((
|
|
1406
|
+
const c = e.find((l) => l.priceInfoObject == i.objectId);
|
|
1385
1407
|
if (!c) {
|
|
1386
1408
|
console.warn(`unable to find pyth info from array, priceInfoObject: ${i.objectId}`);
|
|
1387
1409
|
continue;
|
|
1388
1410
|
}
|
|
1389
|
-
const
|
|
1411
|
+
const u = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: m, negative: h } = u.price.fields, v = u.conf, y = u.timestamp;
|
|
1390
1412
|
o.push({
|
|
1391
1413
|
priceFeedId: c.priceFeedId,
|
|
1392
1414
|
priceInfoObject: c.priceInfoObject,
|
|
1393
|
-
price:
|
|
1415
|
+
price: h ? "-" + m : m,
|
|
1394
1416
|
conf: v,
|
|
1395
|
-
publishTime: Number(
|
|
1417
|
+
publishTime: Number(y),
|
|
1396
1418
|
expiration: c.expiration
|
|
1397
1419
|
});
|
|
1398
1420
|
}
|
|
@@ -1402,9 +1424,9 @@ async function Se(e, r) {
|
|
|
1402
1424
|
return;
|
|
1403
1425
|
}
|
|
1404
1426
|
}
|
|
1405
|
-
async function
|
|
1427
|
+
async function Ue(e, r) {
|
|
1406
1428
|
try {
|
|
1407
|
-
const o = [], n = await
|
|
1429
|
+
const o = [], n = await De(e, r);
|
|
1408
1430
|
if (!n) return o;
|
|
1409
1431
|
const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
1410
1432
|
for (const a of n) {
|
|
@@ -1424,14 +1446,14 @@ async function Ve(e, r) {
|
|
|
1424
1446
|
throw new Error(`failed to get pyth stale price feed id, msg: ${o.message}`);
|
|
1425
1447
|
}
|
|
1426
1448
|
}
|
|
1427
|
-
async function
|
|
1428
|
-
const n = o?.client ??
|
|
1449
|
+
async function Oe(e, r, o) {
|
|
1450
|
+
const n = o?.client ?? V, t = await _({
|
|
1429
1451
|
...o,
|
|
1430
|
-
cacheTime:
|
|
1452
|
+
cacheTime: b
|
|
1431
1453
|
});
|
|
1432
1454
|
try {
|
|
1433
|
-
const a = await
|
|
1434
|
-
return await new
|
|
1455
|
+
const a = await ae.getPriceFeedsUpdateData(r);
|
|
1456
|
+
return await new ge(
|
|
1435
1457
|
n,
|
|
1436
1458
|
t.oracle.pythStateId,
|
|
1437
1459
|
t.oracle.wormholeStateId
|
|
@@ -1440,10 +1462,10 @@ async function Me(e, r, o) {
|
|
|
1440
1462
|
throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
|
|
1441
1463
|
}
|
|
1442
1464
|
}
|
|
1443
|
-
async function
|
|
1465
|
+
async function Ne(e, r, o) {
|
|
1444
1466
|
const n = await _({
|
|
1445
1467
|
...o,
|
|
1446
|
-
cacheTime:
|
|
1468
|
+
cacheTime: b
|
|
1447
1469
|
});
|
|
1448
1470
|
if (o?.updatePythPriceFeeds) {
|
|
1449
1471
|
const t = r.filter((a) => !!a.pythPriceFeedId && !!a.pythPriceInfoObject).map((a) => ({
|
|
@@ -1452,8 +1474,8 @@ async function Ee(e, r, o) {
|
|
|
1452
1474
|
expiration: 30
|
|
1453
1475
|
}));
|
|
1454
1476
|
try {
|
|
1455
|
-
const a = await
|
|
1456
|
-
a.length > 0 && await
|
|
1477
|
+
const a = await Ue(t, o);
|
|
1478
|
+
a.length > 0 && await Oe(e, a, o);
|
|
1457
1479
|
} catch {
|
|
1458
1480
|
console.error("Failed to update Pyth price feeds");
|
|
1459
1481
|
}
|
|
@@ -1495,13 +1517,13 @@ async function Ee(e, r, o) {
|
|
|
1495
1517
|
});
|
|
1496
1518
|
return e;
|
|
1497
1519
|
}
|
|
1498
|
-
async function
|
|
1520
|
+
async function ie(e) {
|
|
1499
1521
|
return (await _({
|
|
1500
1522
|
...e,
|
|
1501
|
-
cacheTime:
|
|
1523
|
+
cacheTime: b
|
|
1502
1524
|
})).oracle.feeds;
|
|
1503
1525
|
}
|
|
1504
|
-
function
|
|
1526
|
+
function Fe(e, r) {
|
|
1505
1527
|
return e.filter((o) => !!(r?.lendingState && r.lendingState.find((t) => o.oracleId === t.pool.oracleId) || r?.lendingPositions && r.lendingPositions.find((t) => {
|
|
1506
1528
|
if (![
|
|
1507
1529
|
"navi-lending-supply",
|
|
@@ -1514,22 +1536,22 @@ function De(e, r) {
|
|
|
1514
1536
|
return o.oracleId === s?.oracleId;
|
|
1515
1537
|
}) || r?.pools && r.pools.find((t) => o.oracleId === t.oracleId)));
|
|
1516
1538
|
}
|
|
1517
|
-
async function
|
|
1539
|
+
async function ht(e, r, o, n) {
|
|
1518
1540
|
try {
|
|
1519
|
-
const t = await
|
|
1541
|
+
const t = await ie({
|
|
1520
1542
|
...n
|
|
1521
1543
|
}), a = [];
|
|
1522
|
-
o.forEach((
|
|
1523
|
-
a.includes(
|
|
1544
|
+
o.forEach((u) => {
|
|
1545
|
+
a.includes(u.market) || a.push(u.market);
|
|
1524
1546
|
});
|
|
1525
|
-
const s = await
|
|
1547
|
+
const s = await Ee(r, {
|
|
1526
1548
|
...n,
|
|
1527
1549
|
markets: a
|
|
1528
|
-
}), i =
|
|
1550
|
+
}), i = Fe(t, {
|
|
1529
1551
|
lendingPositions: s,
|
|
1530
1552
|
pools: o
|
|
1531
1553
|
});
|
|
1532
|
-
return await
|
|
1554
|
+
return await Ne(e, i, {
|
|
1533
1555
|
updatePythPriceFeeds: !0,
|
|
1534
1556
|
...n
|
|
1535
1557
|
});
|
|
@@ -1539,10 +1561,10 @@ async function ft(e, r, o, n) {
|
|
|
1539
1561
|
return console.error(t), e;
|
|
1540
1562
|
}
|
|
1541
1563
|
}
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1564
|
+
const Y = M(
|
|
1565
|
+
P(
|
|
1544
1566
|
async (e) => {
|
|
1545
|
-
const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${
|
|
1567
|
+
const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${E.version}&market=${e?.market || O}`, o = await fetch(r, { headers: D }).then((n) => n.json());
|
|
1546
1568
|
return Object.keys(o.data).map((n) => ({
|
|
1547
1569
|
...o.data[n],
|
|
1548
1570
|
coinType: n
|
|
@@ -1550,78 +1572,78 @@ const z = P(
|
|
|
1550
1572
|
}
|
|
1551
1573
|
)
|
|
1552
1574
|
);
|
|
1553
|
-
async function
|
|
1554
|
-
return (await
|
|
1575
|
+
async function vt(e, r) {
|
|
1576
|
+
return (await Y(r)).find((n) => typeof e == "string" ? k(n.coinType) === k(e) : typeof e == "number" ? n.assetId === e : n.assetId === e.id) || null;
|
|
1555
1577
|
}
|
|
1556
|
-
async function
|
|
1578
|
+
async function wt(e, r, o, n) {
|
|
1557
1579
|
const t = await _({
|
|
1558
1580
|
...n,
|
|
1559
|
-
cacheTime:
|
|
1560
|
-
}), a = await
|
|
1561
|
-
if (!(await
|
|
1581
|
+
cacheTime: b
|
|
1582
|
+
}), a = await S(r, n);
|
|
1583
|
+
if (!(await Y({
|
|
1562
1584
|
...n,
|
|
1563
|
-
cacheTime:
|
|
1585
|
+
cacheTime: b
|
|
1564
1586
|
})).some(
|
|
1565
|
-
(c) =>
|
|
1587
|
+
(c) => k(c.coinType) === k(a.suiCoinType)
|
|
1566
1588
|
))
|
|
1567
1589
|
throw new Error("Pool does not support flashloan");
|
|
1568
1590
|
if (t.version === 1) {
|
|
1569
|
-
const [c,
|
|
1591
|
+
const [c, u] = e.moveCall({
|
|
1570
1592
|
target: `${t.package}::lending::flash_loan_with_ctx`,
|
|
1571
1593
|
arguments: [
|
|
1572
1594
|
e.object(t.flashloanConfig),
|
|
1573
1595
|
e.object(a.contract.pool),
|
|
1574
|
-
|
|
1596
|
+
g(o, e.pure.u64)
|
|
1575
1597
|
],
|
|
1576
1598
|
typeArguments: [a.suiCoinType]
|
|
1577
1599
|
});
|
|
1578
|
-
return [c,
|
|
1600
|
+
return [c, u];
|
|
1579
1601
|
} else {
|
|
1580
|
-
const [c,
|
|
1602
|
+
const [c, u] = e.moveCall({
|
|
1581
1603
|
target: `${t.package}::lending::flash_loan_with_ctx_v2`,
|
|
1582
1604
|
arguments: [
|
|
1583
1605
|
e.object(t.flashloanConfig),
|
|
1584
1606
|
e.object(a.contract.pool),
|
|
1585
|
-
|
|
1607
|
+
g(o, e.pure.u64),
|
|
1586
1608
|
e.object("0x05")
|
|
1587
1609
|
],
|
|
1588
1610
|
typeArguments: [a.suiCoinType]
|
|
1589
1611
|
});
|
|
1590
|
-
return [c,
|
|
1612
|
+
return [c, u];
|
|
1591
1613
|
}
|
|
1592
1614
|
}
|
|
1593
|
-
async function
|
|
1615
|
+
async function bt(e, r, o, n, t) {
|
|
1594
1616
|
const a = await _({
|
|
1595
1617
|
...t,
|
|
1596
|
-
cacheTime:
|
|
1597
|
-
}), s = await
|
|
1598
|
-
if (!(await
|
|
1618
|
+
cacheTime: b
|
|
1619
|
+
}), s = await S(r, t);
|
|
1620
|
+
if (!(await Y({
|
|
1599
1621
|
...t,
|
|
1600
|
-
cacheTime:
|
|
1622
|
+
cacheTime: b
|
|
1601
1623
|
})).some(
|
|
1602
|
-
(
|
|
1624
|
+
(m) => k(m.coinType) === k(s.suiCoinType)
|
|
1603
1625
|
))
|
|
1604
1626
|
throw new Error("Pool does not support flashloan");
|
|
1605
|
-
const [
|
|
1627
|
+
const [u] = e.moveCall({
|
|
1606
1628
|
target: `${a.package}::lending::flash_repay_with_ctx`,
|
|
1607
1629
|
arguments: [
|
|
1608
1630
|
e.object("0x06"),
|
|
1609
1631
|
e.object(a.storage),
|
|
1610
1632
|
e.object(s.contract.pool),
|
|
1611
|
-
|
|
1612
|
-
|
|
1633
|
+
g(o, e.object),
|
|
1634
|
+
g(n, e.object)
|
|
1613
1635
|
],
|
|
1614
1636
|
typeArguments: [s.suiCoinType]
|
|
1615
1637
|
});
|
|
1616
|
-
return [
|
|
1638
|
+
return [u];
|
|
1617
1639
|
}
|
|
1618
|
-
async function
|
|
1640
|
+
async function kt(e, r, o, n, t, a) {
|
|
1619
1641
|
const s = {
|
|
1620
1642
|
...a,
|
|
1621
|
-
cacheTime:
|
|
1622
|
-
}, i = await _(s), c = await
|
|
1643
|
+
cacheTime: b
|
|
1644
|
+
}, i = await _(s), c = await S(r, s), u = await S(n, s);
|
|
1623
1645
|
if (i.version === 1) {
|
|
1624
|
-
const [
|
|
1646
|
+
const [m, h] = e.moveCall({
|
|
1625
1647
|
target: `${i.package}::incentive_v3::liquidation`,
|
|
1626
1648
|
arguments: [
|
|
1627
1649
|
e.object("0x06"),
|
|
@@ -1634,24 +1656,24 @@ async function vt(e, r, o, n, t, a) {
|
|
|
1634
1656
|
// Pay asset ID
|
|
1635
1657
|
e.object(c.contract.pool),
|
|
1636
1658
|
// Pay asset pool contract
|
|
1637
|
-
|
|
1659
|
+
g(o, e.object),
|
|
1638
1660
|
// Debt repayment amount
|
|
1639
|
-
e.pure.u8(
|
|
1661
|
+
e.pure.u8(u.id),
|
|
1640
1662
|
// Collateral asset ID
|
|
1641
|
-
e.object(
|
|
1663
|
+
e.object(u.contract.pool),
|
|
1642
1664
|
// Collateral asset pool contract
|
|
1643
|
-
|
|
1665
|
+
g(t, e.pure.address),
|
|
1644
1666
|
// Borrower address
|
|
1645
1667
|
e.object(i.incentiveV2),
|
|
1646
1668
|
// Incentive V2 contract
|
|
1647
1669
|
e.object(i.incentiveV3)
|
|
1648
1670
|
// Incentive V3 contract
|
|
1649
1671
|
],
|
|
1650
|
-
typeArguments: [c.suiCoinType,
|
|
1672
|
+
typeArguments: [c.suiCoinType, u.suiCoinType]
|
|
1651
1673
|
});
|
|
1652
|
-
return [
|
|
1674
|
+
return [m, h];
|
|
1653
1675
|
} else {
|
|
1654
|
-
const [
|
|
1676
|
+
const [m, h] = e.moveCall({
|
|
1655
1677
|
target: `${i.package}::incentive_v3::liquidation_v2`,
|
|
1656
1678
|
arguments: [
|
|
1657
1679
|
e.object("0x06"),
|
|
@@ -1664,13 +1686,13 @@ async function vt(e, r, o, n, t, a) {
|
|
|
1664
1686
|
// Pay asset ID
|
|
1665
1687
|
e.object(c.contract.pool),
|
|
1666
1688
|
// Pay asset pool contract
|
|
1667
|
-
|
|
1689
|
+
g(o, e.object),
|
|
1668
1690
|
// Debt repayment amount
|
|
1669
|
-
e.pure.u8(
|
|
1691
|
+
e.pure.u8(u.id),
|
|
1670
1692
|
// Collateral asset ID
|
|
1671
|
-
e.object(
|
|
1693
|
+
e.object(u.contract.pool),
|
|
1672
1694
|
// Collateral asset pool contract
|
|
1673
|
-
|
|
1695
|
+
g(t, e.pure.address),
|
|
1674
1696
|
// Borrower address
|
|
1675
1697
|
e.object(i.incentiveV2),
|
|
1676
1698
|
// Incentive V2 contract
|
|
@@ -1679,33 +1701,33 @@ async function vt(e, r, o, n, t, a) {
|
|
|
1679
1701
|
e.object("0x05")
|
|
1680
1702
|
// SuiSystemState object
|
|
1681
1703
|
],
|
|
1682
|
-
typeArguments: [c.suiCoinType,
|
|
1704
|
+
typeArguments: [c.suiCoinType, u.suiCoinType]
|
|
1683
1705
|
});
|
|
1684
|
-
return [
|
|
1706
|
+
return [m, h];
|
|
1685
1707
|
}
|
|
1686
1708
|
}
|
|
1687
|
-
async function
|
|
1688
|
-
const n = o?.client ??
|
|
1709
|
+
async function Re(e, r, o) {
|
|
1710
|
+
const n = o?.client ?? V, t = new F(), a = await q({
|
|
1689
1711
|
...o,
|
|
1690
|
-
markets: Object.values(
|
|
1691
|
-
cacheTime:
|
|
1692
|
-
}), s = await
|
|
1693
|
-
for (let
|
|
1694
|
-
const
|
|
1712
|
+
markets: Object.values(U),
|
|
1713
|
+
cacheTime: b
|
|
1714
|
+
}), s = await ie(o);
|
|
1715
|
+
for (let m of r) {
|
|
1716
|
+
const h = await _({
|
|
1695
1717
|
...o,
|
|
1696
|
-
cacheTime:
|
|
1697
|
-
market:
|
|
1718
|
+
cacheTime: b,
|
|
1719
|
+
market: m.market
|
|
1698
1720
|
});
|
|
1699
1721
|
t.moveCall({
|
|
1700
|
-
target: `${
|
|
1722
|
+
target: `${h.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
|
|
1701
1723
|
arguments: [
|
|
1702
1724
|
t.object("0x06"),
|
|
1703
1725
|
// Clock object
|
|
1704
|
-
t.object(
|
|
1726
|
+
t.object(h.storage),
|
|
1705
1727
|
// Protocol storage
|
|
1706
|
-
t.object(
|
|
1728
|
+
t.object(h.incentiveV3),
|
|
1707
1729
|
// Incentive V3 contract
|
|
1708
|
-
t.pure.address(
|
|
1730
|
+
t.pure.address(m.address)
|
|
1709
1731
|
// User address
|
|
1710
1732
|
]
|
|
1711
1733
|
});
|
|
@@ -1714,11 +1736,11 @@ async function Ue(e, r, o) {
|
|
|
1714
1736
|
transactionBlock: t,
|
|
1715
1737
|
sender: e
|
|
1716
1738
|
}), c = [];
|
|
1717
|
-
i?.results?.forEach((
|
|
1739
|
+
i?.results?.forEach((m) => {
|
|
1718
1740
|
c.push(
|
|
1719
|
-
|
|
1741
|
+
H(
|
|
1720
1742
|
{
|
|
1721
|
-
results: [
|
|
1743
|
+
results: [m]
|
|
1722
1744
|
},
|
|
1723
1745
|
[
|
|
1724
1746
|
C.vector(C.string()),
|
|
@@ -1735,24 +1757,24 @@ async function Ue(e, r, o) {
|
|
|
1735
1757
|
)
|
|
1736
1758
|
);
|
|
1737
1759
|
});
|
|
1738
|
-
const
|
|
1739
|
-
return c.forEach((
|
|
1740
|
-
const v = r[
|
|
1741
|
-
if (
|
|
1742
|
-
const
|
|
1743
|
-
for (let
|
|
1760
|
+
const u = [];
|
|
1761
|
+
return c.forEach((m, h) => {
|
|
1762
|
+
const v = r[h];
|
|
1763
|
+
if (m.length === 5 && Array.isArray(m[0])) {
|
|
1764
|
+
const y = m[0].length;
|
|
1765
|
+
for (let l = 0; l < y; l++) {
|
|
1744
1766
|
const f = s.find(
|
|
1745
|
-
(I) =>
|
|
1746
|
-
),
|
|
1747
|
-
(I) =>
|
|
1767
|
+
(I) => k(I.coinType) === k(m[1][l])
|
|
1768
|
+
), w = a.find(
|
|
1769
|
+
(I) => k(I.coinType) === k(m[0][l]) && I.market === v.market
|
|
1748
1770
|
);
|
|
1749
|
-
!f || !
|
|
1750
|
-
assetId:
|
|
1751
|
-
assetCoinType:
|
|
1752
|
-
rewardCoinType:
|
|
1753
|
-
option: Number(
|
|
1754
|
-
userClaimableReward: Number(
|
|
1755
|
-
ruleIds: Array.isArray(
|
|
1771
|
+
!f || !w || u.push({
|
|
1772
|
+
assetId: w.id,
|
|
1773
|
+
assetCoinType: k(m[0][l]),
|
|
1774
|
+
rewardCoinType: k(m[1][l]),
|
|
1775
|
+
option: Number(m[2][l]),
|
|
1776
|
+
userClaimableReward: Number(m[4][l]) / Math.pow(10, f.priceDecimal),
|
|
1777
|
+
ruleIds: Array.isArray(m[3][l]) ? m[3][l] : [m[3][l]],
|
|
1756
1778
|
market: v.market,
|
|
1757
1779
|
owner: v.owner,
|
|
1758
1780
|
address: v.address,
|
|
@@ -1760,13 +1782,13 @@ async function Ue(e, r, o) {
|
|
|
1760
1782
|
});
|
|
1761
1783
|
}
|
|
1762
1784
|
}
|
|
1763
|
-
}),
|
|
1785
|
+
}), u;
|
|
1764
1786
|
}
|
|
1765
|
-
async function
|
|
1766
|
-
const o = (r?.markets || [
|
|
1787
|
+
async function _t(e, r) {
|
|
1788
|
+
const o = (r?.markets || [U.main]).map((a) => T(a));
|
|
1767
1789
|
let n = [];
|
|
1768
1790
|
try {
|
|
1769
|
-
n = await
|
|
1791
|
+
n = await oe(e, r);
|
|
1770
1792
|
} catch (a) {
|
|
1771
1793
|
console.error(a);
|
|
1772
1794
|
}
|
|
@@ -1776,7 +1798,7 @@ async function wt(e, r) {
|
|
|
1776
1798
|
market: a.key
|
|
1777
1799
|
})).concat(
|
|
1778
1800
|
n.filter((a) => !!o.find((s) => s.id === a.marketId)).map((a) => {
|
|
1779
|
-
const s =
|
|
1801
|
+
const s = T(a.marketId);
|
|
1780
1802
|
return {
|
|
1781
1803
|
address: a.accountCap,
|
|
1782
1804
|
owner: e,
|
|
@@ -1785,9 +1807,9 @@ async function wt(e, r) {
|
|
|
1785
1807
|
};
|
|
1786
1808
|
})
|
|
1787
1809
|
);
|
|
1788
|
-
return await
|
|
1810
|
+
return await Re(e, t, r);
|
|
1789
1811
|
}
|
|
1790
|
-
function
|
|
1812
|
+
function Ct(e) {
|
|
1791
1813
|
const r = /* @__PURE__ */ new Map();
|
|
1792
1814
|
e.forEach((n) => {
|
|
1793
1815
|
const t = n.assetId, a = n.option, s = `${t}-${a}-${n.rewardCoinType}-${n.market}`;
|
|
@@ -1803,8 +1825,8 @@ function bt(e) {
|
|
|
1803
1825
|
for (const { assetId: n, rewardType: t, coinType: a, total: s, market: i } of r.values()) {
|
|
1804
1826
|
const c = `${n}-${t}-${i}`;
|
|
1805
1827
|
o.has(c) || o.set(c, { assetId: n, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
|
|
1806
|
-
const
|
|
1807
|
-
|
|
1828
|
+
const u = o.get(c);
|
|
1829
|
+
u.rewards.set(a, (u.rewards.get(a) || 0) + s);
|
|
1808
1830
|
}
|
|
1809
1831
|
return Array.from(o.values()).map((n) => ({
|
|
1810
1832
|
assetId: n.assetId,
|
|
@@ -1816,109 +1838,109 @@ function bt(e) {
|
|
|
1816
1838
|
}))
|
|
1817
1839
|
}));
|
|
1818
1840
|
}
|
|
1819
|
-
const
|
|
1841
|
+
const jt = P(
|
|
1820
1842
|
async (e, r) => {
|
|
1821
|
-
const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${
|
|
1822
|
-
return (await fetch(o, { headers:
|
|
1843
|
+
const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${E.version}&market=${r?.market || O}`;
|
|
1844
|
+
return (await fetch(o, { headers: D }).then((t) => t.json())).data;
|
|
1823
1845
|
}
|
|
1824
|
-
),
|
|
1846
|
+
), It = P(
|
|
1825
1847
|
async (e, r) => {
|
|
1826
|
-
const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${r?.page || 1}&pageSize=${r?.size || 400}&sdk=${
|
|
1827
|
-
return
|
|
1848
|
+
const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${r?.page || 1}&pageSize=${r?.size || 400}&sdk=${E.version}&market=${r?.market || O}`, n = await fetch(o, { headers: D }).then((t) => t.json());
|
|
1849
|
+
return K({
|
|
1828
1850
|
data: n.data.rewards
|
|
1829
1851
|
});
|
|
1830
1852
|
}
|
|
1831
1853
|
);
|
|
1832
|
-
async function
|
|
1854
|
+
async function Tt(e, r, o) {
|
|
1833
1855
|
const n = await q({
|
|
1834
1856
|
...o,
|
|
1835
|
-
markets: Object.values(
|
|
1836
|
-
cacheTime:
|
|
1857
|
+
markets: Object.values(U),
|
|
1858
|
+
cacheTime: b
|
|
1837
1859
|
}), t = /* @__PURE__ */ new Map();
|
|
1838
1860
|
for (const s of r) {
|
|
1839
|
-
const { rewardCoinType: i, ruleIds: c, market:
|
|
1840
|
-
for (const
|
|
1841
|
-
t.has(
|
|
1861
|
+
const { rewardCoinType: i, ruleIds: c, market: u, owner: m, address: h, emodeId: v } = s, y = `${i}___${h}__${u}`;
|
|
1862
|
+
for (const l of c) {
|
|
1863
|
+
t.has(y) || t.set(y, {
|
|
1842
1864
|
assetIds: [],
|
|
1843
1865
|
ruleIds: [],
|
|
1844
1866
|
amount: 0,
|
|
1845
|
-
market:
|
|
1846
|
-
owner:
|
|
1847
|
-
address:
|
|
1867
|
+
market: u,
|
|
1868
|
+
owner: m,
|
|
1869
|
+
address: h,
|
|
1848
1870
|
isEMode: typeof v < "u"
|
|
1849
1871
|
});
|
|
1850
|
-
const f = t.get(
|
|
1851
|
-
f.assetIds.push(s.assetCoinType.replace("0x", "")), f.ruleIds.push(
|
|
1872
|
+
const f = t.get(y);
|
|
1873
|
+
f.assetIds.push(s.assetCoinType.replace("0x", "")), f.ruleIds.push(l), f.amount += s.userClaimableReward;
|
|
1852
1874
|
}
|
|
1853
1875
|
}
|
|
1854
1876
|
const a = [];
|
|
1855
1877
|
for (const [
|
|
1856
1878
|
s,
|
|
1857
|
-
{ assetIds: i, ruleIds: c, amount:
|
|
1879
|
+
{ assetIds: i, ruleIds: c, amount: u, market: m, owner: h, address: v, isEMode: y }
|
|
1858
1880
|
] of t) {
|
|
1859
|
-
const
|
|
1881
|
+
const l = await _({
|
|
1860
1882
|
...o,
|
|
1861
|
-
cacheTime:
|
|
1862
|
-
market:
|
|
1863
|
-
}), f = s.split("___")[0],
|
|
1864
|
-
(
|
|
1883
|
+
cacheTime: b,
|
|
1884
|
+
market: m
|
|
1885
|
+
}), f = s.split("___")[0], w = n.filter(
|
|
1886
|
+
(j) => k(j.suiCoinType) === k(f)
|
|
1865
1887
|
);
|
|
1866
|
-
|
|
1867
|
-
const I =
|
|
1868
|
-
if (!
|
|
1869
|
-
throw new Error(`No matching rewardFund found for reward coin: ${f} ${
|
|
1888
|
+
w.sort((j, A) => j.market === m ? -1 : 1);
|
|
1889
|
+
const I = w[0], B = l.rewardFunds[k(f)];
|
|
1890
|
+
if (!B)
|
|
1891
|
+
throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
|
|
1870
1892
|
if (o?.accountCap && !o.customCoinReceive)
|
|
1871
1893
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
1872
1894
|
if (o?.customCoinReceive) {
|
|
1873
|
-
let
|
|
1874
|
-
o.accountCap ?
|
|
1875
|
-
target: `${
|
|
1895
|
+
let j;
|
|
1896
|
+
o.accountCap ? j = e.moveCall({
|
|
1897
|
+
target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1876
1898
|
arguments: [
|
|
1877
1899
|
e.object("0x06"),
|
|
1878
1900
|
// Clock object
|
|
1879
|
-
e.object(
|
|
1901
|
+
e.object(l.incentiveV3),
|
|
1880
1902
|
// Incentive V3 contract
|
|
1881
|
-
e.object(
|
|
1903
|
+
e.object(l.storage),
|
|
1882
1904
|
// Protocol storage
|
|
1883
|
-
e.object(
|
|
1905
|
+
e.object(B),
|
|
1884
1906
|
// Reward fund
|
|
1885
1907
|
e.pure.vector("string", i),
|
|
1886
1908
|
// Asset IDs
|
|
1887
1909
|
e.pure.vector("address", c),
|
|
1888
1910
|
// Rule IDs
|
|
1889
|
-
|
|
1911
|
+
g(o.accountCap, e.object)
|
|
1890
1912
|
// Account capability
|
|
1891
1913
|
],
|
|
1892
1914
|
typeArguments: [f]
|
|
1893
|
-
}) :
|
|
1894
|
-
target: `${
|
|
1915
|
+
}) : y ? j = e.moveCall({
|
|
1916
|
+
target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1895
1917
|
arguments: [
|
|
1896
1918
|
e.object("0x06"),
|
|
1897
1919
|
// Clock object
|
|
1898
|
-
e.object(
|
|
1920
|
+
e.object(l.incentiveV3),
|
|
1899
1921
|
// Incentive V3 contract
|
|
1900
|
-
e.object(
|
|
1922
|
+
e.object(l.storage),
|
|
1901
1923
|
// Protocol storage
|
|
1902
|
-
e.object(
|
|
1924
|
+
e.object(B),
|
|
1903
1925
|
// Reward fund
|
|
1904
1926
|
e.pure.vector("string", i),
|
|
1905
1927
|
// Asset IDs
|
|
1906
1928
|
e.pure.vector("address", c),
|
|
1907
1929
|
// Rule IDs
|
|
1908
|
-
|
|
1930
|
+
g(v, e.object)
|
|
1909
1931
|
// Account capability
|
|
1910
1932
|
],
|
|
1911
1933
|
typeArguments: [f]
|
|
1912
|
-
}) :
|
|
1913
|
-
target: `${
|
|
1934
|
+
}) : j = e.moveCall({
|
|
1935
|
+
target: `${l.package}::incentive_v3::claim_reward`,
|
|
1914
1936
|
arguments: [
|
|
1915
1937
|
e.object("0x06"),
|
|
1916
1938
|
// Clock object
|
|
1917
|
-
e.object(
|
|
1939
|
+
e.object(l.incentiveV3),
|
|
1918
1940
|
// Incentive V3 contract
|
|
1919
|
-
e.object(
|
|
1941
|
+
e.object(l.storage),
|
|
1920
1942
|
// Protocol storage
|
|
1921
|
-
e.object(
|
|
1943
|
+
e.object(B),
|
|
1922
1944
|
// Reward fund
|
|
1923
1945
|
e.pure.vector("string", i),
|
|
1924
1946
|
// Asset IDs
|
|
@@ -1927,75 +1949,75 @@ async function Ct(e, r, o) {
|
|
|
1927
1949
|
],
|
|
1928
1950
|
typeArguments: [f]
|
|
1929
1951
|
});
|
|
1930
|
-
const [
|
|
1952
|
+
const [A] = e.moveCall({
|
|
1931
1953
|
target: "0x2::coin::from_balance",
|
|
1932
|
-
arguments: [
|
|
1954
|
+
arguments: [j],
|
|
1933
1955
|
typeArguments: [f]
|
|
1934
1956
|
});
|
|
1935
1957
|
if (o?.customCoinReceive.type === "transfer") {
|
|
1936
1958
|
if (!o.customCoinReceive.transfer)
|
|
1937
1959
|
throw new Error("customCoinReceive.transfer is required");
|
|
1938
1960
|
e.transferObjects(
|
|
1939
|
-
[
|
|
1940
|
-
|
|
1961
|
+
[A],
|
|
1962
|
+
g(o.customCoinReceive.transfer, e.pure.address)
|
|
1941
1963
|
);
|
|
1942
1964
|
}
|
|
1943
1965
|
if (o?.customCoinReceive.type === "depositNAVI") {
|
|
1944
|
-
const
|
|
1945
|
-
|
|
1946
|
-
[
|
|
1966
|
+
const L = p(I.totalSupplyAmount).shiftedBy(-9), G = p(I.supplyCapCeiling).shiftedBy(-27);
|
|
1967
|
+
L.plus(u).isGreaterThan(G) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
|
|
1968
|
+
[A],
|
|
1947
1969
|
e.pure.address(o.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
1948
|
-
) : await
|
|
1970
|
+
) : await Be(e, I, A, {
|
|
1949
1971
|
...o,
|
|
1950
1972
|
market: I.market
|
|
1951
1973
|
});
|
|
1952
1974
|
} else
|
|
1953
1975
|
a.push({
|
|
1954
|
-
coin:
|
|
1976
|
+
coin: A,
|
|
1955
1977
|
identifier: I,
|
|
1956
|
-
owner:
|
|
1957
|
-
isEMode:
|
|
1978
|
+
owner: h,
|
|
1979
|
+
isEMode: y
|
|
1958
1980
|
});
|
|
1959
|
-
} else if (o?.accountCap ||
|
|
1960
|
-
const
|
|
1961
|
-
target: `${
|
|
1981
|
+
} else if (o?.accountCap || y) {
|
|
1982
|
+
const j = e.moveCall({
|
|
1983
|
+
target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1962
1984
|
arguments: [
|
|
1963
1985
|
e.object("0x06"),
|
|
1964
1986
|
// Clock object
|
|
1965
|
-
e.object(
|
|
1987
|
+
e.object(l.incentiveV3),
|
|
1966
1988
|
// Incentive V3 contract
|
|
1967
|
-
e.object(
|
|
1989
|
+
e.object(l.storage),
|
|
1968
1990
|
// Protocol storage
|
|
1969
|
-
e.object(
|
|
1991
|
+
e.object(B),
|
|
1970
1992
|
// Reward fund
|
|
1971
1993
|
e.pure.vector("string", i),
|
|
1972
1994
|
// Asset IDs
|
|
1973
1995
|
e.pure.vector("address", c),
|
|
1974
1996
|
// Rule IDs
|
|
1975
|
-
|
|
1997
|
+
g(o?.accountCap || v, e.object)
|
|
1976
1998
|
// Account capability
|
|
1977
1999
|
],
|
|
1978
2000
|
typeArguments: [f]
|
|
1979
|
-
}), [
|
|
2001
|
+
}), [A] = e.moveCall({
|
|
1980
2002
|
target: "0x2::coin::from_balance",
|
|
1981
|
-
arguments: [
|
|
2003
|
+
arguments: [j],
|
|
1982
2004
|
typeArguments: [f]
|
|
1983
2005
|
});
|
|
1984
2006
|
e.transferObjects(
|
|
1985
|
-
[
|
|
1986
|
-
|
|
2007
|
+
[A],
|
|
2008
|
+
g(o?.accountCap || h, e.pure.address)
|
|
1987
2009
|
);
|
|
1988
2010
|
} else
|
|
1989
2011
|
e.moveCall({
|
|
1990
|
-
target: `${
|
|
2012
|
+
target: `${l.package}::incentive_v3::claim_reward_entry`,
|
|
1991
2013
|
arguments: [
|
|
1992
2014
|
e.object("0x06"),
|
|
1993
2015
|
// Clock object
|
|
1994
|
-
e.object(
|
|
2016
|
+
e.object(l.incentiveV3),
|
|
1995
2017
|
// Incentive V3 contract
|
|
1996
|
-
e.object(
|
|
2018
|
+
e.object(l.storage),
|
|
1997
2019
|
// Protocol storage
|
|
1998
|
-
e.object(
|
|
2020
|
+
e.object(B),
|
|
1999
2021
|
// Reward fund
|
|
2000
2022
|
e.pure.vector("string", i),
|
|
2001
2023
|
// Asset IDs
|
|
@@ -2008,71 +2030,71 @@ async function Ct(e, r, o) {
|
|
|
2008
2030
|
return a;
|
|
2009
2031
|
}
|
|
2010
2032
|
export {
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2033
|
+
J as Address,
|
|
2034
|
+
b as DEFAULT_CACHE_TIME,
|
|
2035
|
+
O as DEFAULT_MARKET_IDENTITY,
|
|
2036
|
+
Xe as FlashLoanAssetConfig,
|
|
2037
|
+
Je as IncentiveAPYInfo,
|
|
2038
|
+
he as IncentivePoolInfo,
|
|
2039
|
+
Ze as IncentivePoolInfoByPhase,
|
|
2040
|
+
U as MARKETS,
|
|
2041
|
+
Ae as Market,
|
|
2042
|
+
Qe as OracleInfo,
|
|
2021
2043
|
R as PoolOperator,
|
|
2022
|
-
|
|
2044
|
+
ve as ReserveDataInfo,
|
|
2023
2045
|
N as UserPositions,
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2046
|
+
we as UserStateInfo,
|
|
2047
|
+
ot as borrowCoinPTB,
|
|
2048
|
+
Tt as claimLendingRewardsPTB,
|
|
2049
|
+
Pe as createAccountCapPTB,
|
|
2050
|
+
ct as createEModeCapPTB,
|
|
2051
|
+
Be as depositCoinPTB,
|
|
2052
|
+
st as emodeIdentityId,
|
|
2053
|
+
Me as enterEModePTB,
|
|
2054
|
+
it as exitEModePTB,
|
|
2055
|
+
Fe as filterPriceFeeds,
|
|
2056
|
+
wt as flashloanPTB,
|
|
2057
|
+
Se as getAccountCapOwnerPTB,
|
|
2058
|
+
Y as getAllFlashLoanAssets,
|
|
2059
|
+
nt as getBorrowFee,
|
|
2060
|
+
ft as getCoins,
|
|
2039
2061
|
_ as getConfig,
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2062
|
+
et as getFees,
|
|
2063
|
+
vt as getFlashLoanAsset,
|
|
2064
|
+
pt as getHealthFactor,
|
|
2065
|
+
Ve as getHealthFactorPTB,
|
|
2066
|
+
Ee as getLendingPositions,
|
|
2067
|
+
ut as getLendingState,
|
|
2068
|
+
at as getMarket,
|
|
2069
|
+
T as getMarketConfig,
|
|
2070
|
+
$e as getMarkets,
|
|
2071
|
+
S as getPool,
|
|
2050
2072
|
q as getPools,
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2073
|
+
ie as getPriceFeeds,
|
|
2074
|
+
gt as getPythStalePriceFeedId,
|
|
2075
|
+
Ue as getPythStalePriceFeedIdV2,
|
|
2076
|
+
dt as getSimulatedHealthFactor,
|
|
2077
|
+
re as getSimulatedHealthFactorPTB,
|
|
2078
|
+
xe as getStats,
|
|
2079
|
+
mt as getTransactions,
|
|
2080
|
+
_t as getUserAvailableLendingRewards,
|
|
2081
|
+
It as getUserClaimedRewardHistory,
|
|
2082
|
+
oe as getUserEModeCaps,
|
|
2083
|
+
jt as getUserTotalClaimedReward,
|
|
2084
|
+
kt as liquidatePTB,
|
|
2085
|
+
lt as mergeCoinsPTB,
|
|
2086
|
+
k as normalizeCoinType,
|
|
2087
|
+
Te as parsePoolUID,
|
|
2088
|
+
g as parseTxValue,
|
|
2089
|
+
rt as repayCoinPTB,
|
|
2090
|
+
bt as repayFlashLoanPTB,
|
|
2091
|
+
Ct as summaryLendingRewards,
|
|
2092
|
+
ht as updateOraclePriceBeforeUserOperationPTB,
|
|
2093
|
+
Ne as updateOraclePricesPTB,
|
|
2094
|
+
Oe as updatePythPriceFeeds,
|
|
2095
|
+
yt as verifyHealthFactorPTB,
|
|
2096
|
+
M as withCache,
|
|
2097
|
+
P as withSingleton,
|
|
2098
|
+
tt as withdrawCoinPTB
|
|
2077
2099
|
};
|
|
2078
2100
|
//# sourceMappingURL=index.esm.js.map
|