@naviprotocol/lending 1.2.2-dev.1 → 1.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts.map +1 -1
- package/dist/flashloan.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 +655 -502
- package/dist/index.esm.js.map +1 -1
- package/dist/liquidate.d.ts.map +1 -1
- package/dist/pool.d.ts +17 -4
- package/dist/pool.d.ts.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,628 +1,732 @@
|
|
|
1
|
-
import { Transaction as
|
|
2
|
-
import { bcs as
|
|
3
|
-
import { SuiClient as
|
|
1
|
+
import { Transaction as k } from "@mysten/sui/transactions";
|
|
2
|
+
import { bcs as i, toHex as G, fromHex as H } from "@mysten/bcs";
|
|
3
|
+
import { SuiClient as q, getFullnodeUrl as z } from "@mysten/sui/client";
|
|
4
4
|
import W from "lodash.camelcase";
|
|
5
|
-
import { normalizeStructTag as
|
|
6
|
-
import { SuiPriceServiceConnection as
|
|
5
|
+
import { normalizeStructTag as J } from "@mysten/sui/utils";
|
|
6
|
+
import { SuiPriceServiceConnection as N, SuiPythClient as K } from "@pythnetwork/pyth-sui-js";
|
|
7
7
|
import T from "bignumber.js";
|
|
8
|
-
import { bcs as
|
|
9
|
-
const
|
|
8
|
+
import { bcs as h } from "@mysten/sui/bcs";
|
|
9
|
+
const F = i.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) => H(e),
|
|
12
|
+
output: (e) => G(e)
|
|
13
|
+
}), fe = i.struct("IncentiveAPYInfo", {
|
|
14
14
|
/** Asset identifier */
|
|
15
|
-
asset_id:
|
|
15
|
+
asset_id: i.u8(),
|
|
16
16
|
/** Annual Percentage Yield as a 256-bit integer */
|
|
17
|
-
apy:
|
|
17
|
+
apy: i.u256(),
|
|
18
18
|
/** List of supported coin types for this incentive */
|
|
19
|
-
coin_types:
|
|
20
|
-
}),
|
|
19
|
+
coin_types: i.vector(i.string())
|
|
20
|
+
}), Y = i.struct("IncentivePoolInfo", {
|
|
21
21
|
/** Unique pool identifier */
|
|
22
|
-
pool_id:
|
|
22
|
+
pool_id: F,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
24
|
-
funds:
|
|
24
|
+
funds: F,
|
|
25
25
|
/** Current phase of the incentive program */
|
|
26
|
-
phase:
|
|
26
|
+
phase: i.u64(),
|
|
27
27
|
/** Timestamp when the incentive started */
|
|
28
|
-
start_at:
|
|
28
|
+
start_at: i.u64(),
|
|
29
29
|
/** Timestamp when the incentive ends */
|
|
30
|
-
end_at:
|
|
30
|
+
end_at: i.u64(),
|
|
31
31
|
/** Timestamp when the incentive was closed */
|
|
32
|
-
closed_at:
|
|
32
|
+
closed_at: i.u64(),
|
|
33
33
|
/** Total supply of incentive tokens */
|
|
34
|
-
total_supply:
|
|
34
|
+
total_supply: i.u64(),
|
|
35
35
|
/** Asset identifier for the incentive */
|
|
36
|
-
asset_id:
|
|
36
|
+
asset_id: i.u8(),
|
|
37
37
|
/** Option type for the incentive */
|
|
38
|
-
option:
|
|
38
|
+
option: i.u8(),
|
|
39
39
|
/** Factor used in incentive calculations */
|
|
40
|
-
factor:
|
|
40
|
+
factor: i.u256(),
|
|
41
41
|
/** Amount of incentives already distributed */
|
|
42
|
-
distributed:
|
|
42
|
+
distributed: i.u64(),
|
|
43
43
|
/** Amount of incentives currently available */
|
|
44
|
-
available:
|
|
44
|
+
available: i.u256(),
|
|
45
45
|
/** Total amount of incentives */
|
|
46
|
-
total:
|
|
47
|
-
}),
|
|
46
|
+
total: i.u256()
|
|
47
|
+
}), ge = i.struct("IncentivePoolInfoByPhase", {
|
|
48
48
|
/** Phase number */
|
|
49
|
-
phase:
|
|
49
|
+
phase: i.u64(),
|
|
50
50
|
/** List of incentive pools in this phase */
|
|
51
|
-
pools:
|
|
52
|
-
}),
|
|
51
|
+
pools: i.vector(Y)
|
|
52
|
+
}), ye = i.struct("OracleInfo", {
|
|
53
53
|
/** Oracle identifier */
|
|
54
|
-
oracle_id:
|
|
54
|
+
oracle_id: i.u8(),
|
|
55
55
|
/** Current price as a 256-bit integer */
|
|
56
|
-
price:
|
|
56
|
+
price: i.u256(),
|
|
57
57
|
/** Number of decimal places for the price */
|
|
58
|
-
decimals:
|
|
58
|
+
decimals: i.u8(),
|
|
59
59
|
/** Whether the oracle data is valid */
|
|
60
|
-
valid:
|
|
61
|
-
}),
|
|
60
|
+
valid: i.bool()
|
|
61
|
+
}), be = i.struct("FlashLoanAssetConfig", {
|
|
62
62
|
/** Unique identifier for the flash loan asset */
|
|
63
|
-
id:
|
|
63
|
+
id: i.string(),
|
|
64
64
|
/** Asset identifier */
|
|
65
|
-
asset_id:
|
|
65
|
+
asset_id: i.u8(),
|
|
66
66
|
/** Coin type for the asset */
|
|
67
|
-
coin_type:
|
|
67
|
+
coin_type: i.string(),
|
|
68
68
|
/** Pool identifier for the flash loan */
|
|
69
|
-
pool_id:
|
|
69
|
+
pool_id: i.string(),
|
|
70
70
|
/** Rate paid to suppliers for flash loans */
|
|
71
|
-
rate_to_supplier:
|
|
71
|
+
rate_to_supplier: i.u64(),
|
|
72
72
|
/** Rate paid to treasury for flash loans */
|
|
73
|
-
rate_to_treasury:
|
|
73
|
+
rate_to_treasury: i.u64(),
|
|
74
74
|
/** Maximum flash loan amount */
|
|
75
|
-
max:
|
|
75
|
+
max: i.u64(),
|
|
76
76
|
/** Minimum flash loan amount */
|
|
77
|
-
min:
|
|
78
|
-
}),
|
|
77
|
+
min: i.u64()
|
|
78
|
+
}), we = i.struct("ReserveDataInfo", {
|
|
79
79
|
/** Reserve identifier */
|
|
80
|
-
id:
|
|
80
|
+
id: i.u8(),
|
|
81
81
|
/** Oracle identifier for price feeds */
|
|
82
|
-
oracle_id:
|
|
82
|
+
oracle_id: i.u8(),
|
|
83
83
|
/** Coin type for the reserve */
|
|
84
|
-
coin_type:
|
|
84
|
+
coin_type: i.string(),
|
|
85
85
|
/** Maximum supply capacity */
|
|
86
|
-
supply_cap:
|
|
86
|
+
supply_cap: i.u256(),
|
|
87
87
|
/** Maximum borrow capacity */
|
|
88
|
-
borrow_cap:
|
|
88
|
+
borrow_cap: i.u256(),
|
|
89
89
|
/** Current supply interest rate */
|
|
90
|
-
supply_rate:
|
|
90
|
+
supply_rate: i.u256(),
|
|
91
91
|
/** Current borrow interest rate */
|
|
92
|
-
borrow_rate:
|
|
92
|
+
borrow_rate: i.u256(),
|
|
93
93
|
/** Current supply index for interest calculation */
|
|
94
|
-
supply_index:
|
|
94
|
+
supply_index: i.u256(),
|
|
95
95
|
/** Current borrow index for interest calculation */
|
|
96
|
-
borrow_index:
|
|
96
|
+
borrow_index: i.u256(),
|
|
97
97
|
/** Total amount supplied to the reserve */
|
|
98
|
-
total_supply:
|
|
98
|
+
total_supply: i.u256(),
|
|
99
99
|
/** Total amount borrowed from the reserve */
|
|
100
|
-
total_borrow:
|
|
100
|
+
total_borrow: i.u256(),
|
|
101
101
|
/** Timestamp of last update */
|
|
102
|
-
last_update_at:
|
|
102
|
+
last_update_at: i.u64(),
|
|
103
103
|
/** Loan-to-Value ratio for collateral */
|
|
104
|
-
ltv:
|
|
104
|
+
ltv: i.u256(),
|
|
105
105
|
/** Treasury factor for fee calculations */
|
|
106
|
-
treasury_factor:
|
|
106
|
+
treasury_factor: i.u256(),
|
|
107
107
|
/** Current treasury balance */
|
|
108
|
-
treasury_balance:
|
|
108
|
+
treasury_balance: i.u256(),
|
|
109
109
|
/** Base interest rate */
|
|
110
|
-
base_rate:
|
|
110
|
+
base_rate: i.u256(),
|
|
111
111
|
/** Interest rate multiplier */
|
|
112
|
-
multiplier:
|
|
112
|
+
multiplier: i.u256(),
|
|
113
113
|
/** Jump rate multiplier for high utilization */
|
|
114
|
-
jump_rate_multiplier:
|
|
114
|
+
jump_rate_multiplier: i.u256(),
|
|
115
115
|
/** Reserve factor for protocol fees */
|
|
116
|
-
reserve_factor:
|
|
116
|
+
reserve_factor: i.u256(),
|
|
117
117
|
/** Optimal utilization rate */
|
|
118
|
-
optimal_utilization:
|
|
118
|
+
optimal_utilization: i.u256(),
|
|
119
119
|
/** Liquidation ratio threshold */
|
|
120
|
-
liquidation_ratio:
|
|
120
|
+
liquidation_ratio: i.u256(),
|
|
121
121
|
/** Liquidation bonus for liquidators */
|
|
122
|
-
liquidation_bonus:
|
|
122
|
+
liquidation_bonus: i.u256(),
|
|
123
123
|
/** Liquidation threshold */
|
|
124
|
-
liquidation_threshold:
|
|
125
|
-
}), Q =
|
|
124
|
+
liquidation_threshold: i.u256()
|
|
125
|
+
}), Q = i.struct("UserStateInfo", {
|
|
126
126
|
/** Asset identifier */
|
|
127
|
-
asset_id:
|
|
127
|
+
asset_id: i.u8(),
|
|
128
128
|
/** User's current borrow balance */
|
|
129
|
-
borrow_balance:
|
|
129
|
+
borrow_balance: i.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
|
-
supply_balance:
|
|
132
|
-
}),
|
|
133
|
-
url:
|
|
131
|
+
supply_balance: i.u256()
|
|
132
|
+
}), A = new q({
|
|
133
|
+
url: z("mainnet")
|
|
134
134
|
});
|
|
135
|
-
function
|
|
135
|
+
function E(e) {
|
|
136
136
|
const a = [];
|
|
137
|
-
return e.forEach((
|
|
138
|
-
const
|
|
139
|
-
if (typeof
|
|
140
|
-
const { client: n, disableCache: o, cacheTime:
|
|
137
|
+
return e.forEach((c, t) => {
|
|
138
|
+
const r = t === e.length - 1;
|
|
139
|
+
if (typeof c == "object" && r) {
|
|
140
|
+
const { client: n, disableCache: o, cacheTime: s, ...u } = c;
|
|
141
141
|
a.push(u);
|
|
142
142
|
} else
|
|
143
|
-
a.push(
|
|
143
|
+
a.push(c);
|
|
144
144
|
}), JSON.stringify(a);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function C(e) {
|
|
147
147
|
const a = {};
|
|
148
|
-
return (...
|
|
149
|
-
const t =
|
|
150
|
-
return a[t] || (a[t] = e(...
|
|
148
|
+
return (...c) => {
|
|
149
|
+
const t = E(c);
|
|
150
|
+
return a[t] || (a[t] = e(...c).finally(() => {
|
|
151
151
|
a[t] = null;
|
|
152
152
|
})), a[t];
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function I(e) {
|
|
156
156
|
let a = {};
|
|
157
|
-
return (...
|
|
158
|
-
const t =
|
|
159
|
-
return !(t != null && t.disableCache) && typeof (n == null ? void 0 : n.data) != "undefined" && (typeof (t == null ? void 0 : t.cacheTime) == "undefined" || t.cacheTime > Date.now() - n.cacheAt) ? n.data : e(...
|
|
157
|
+
return (...c) => {
|
|
158
|
+
const t = c[c.length - 1], r = E(c), n = a[r];
|
|
159
|
+
return !(t != null && t.disableCache) && typeof (n == null ? void 0 : n.data) != "undefined" && (typeof (t == null ? void 0 : t.cacheTime) == "undefined" || t.cacheTime > Date.now() - n.cacheAt) ? n.data : e(...c).then((o) => (a[r] = {
|
|
160
160
|
data: o,
|
|
161
161
|
cacheAt: Date.now()
|
|
162
162
|
}, o));
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
return Array.isArray(e) ? e.map((a) =>
|
|
167
|
-
(a,
|
|
165
|
+
function P(e) {
|
|
166
|
+
return Array.isArray(e) ? e.map((a) => P(a)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
167
|
+
(a, c) => ({
|
|
168
168
|
...a,
|
|
169
|
-
[W(
|
|
169
|
+
[W(c)]: P(e[c])
|
|
170
170
|
}),
|
|
171
171
|
{}
|
|
172
172
|
) : e;
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function d(e, a) {
|
|
175
175
|
return typeof e == "object" ? e : a(e);
|
|
176
176
|
}
|
|
177
177
|
function X(e, a) {
|
|
178
178
|
return typeof a == "string" ? e.object(a) : typeof a == "object" && a.$kind ? a : e.object(a.contract.pool);
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function B(e, a, c) {
|
|
181
181
|
if (e.results && e.results.length > 0) {
|
|
182
182
|
if (e.results[0].returnValues && e.results[0].returnValues.length > 0)
|
|
183
|
-
return e.results[0].returnValues.map((t,
|
|
183
|
+
return e.results[0].returnValues.map((t, r) => (a[r] || a[0]).parse(Uint8Array.from(t[0])));
|
|
184
184
|
} else if (e.error)
|
|
185
185
|
return console.log(`Get an error, msg: ${e.error}`), [];
|
|
186
186
|
return [];
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
return
|
|
188
|
+
function f(e) {
|
|
189
|
+
return J(e);
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function D(e) {
|
|
192
192
|
const a = (e || 0) / Math.pow(10, 27);
|
|
193
193
|
return a > Math.pow(10, 5) ? 1 / 0 : a;
|
|
194
194
|
}
|
|
195
|
-
new
|
|
195
|
+
new N("https://hermes.pyth.network", {
|
|
196
196
|
timeout: 2e4
|
|
197
197
|
});
|
|
198
|
-
const Z = 27,
|
|
198
|
+
const Z = 27, R = (e, a) => {
|
|
199
199
|
if (!Number(e) || !Number(a)) return new T(0);
|
|
200
|
-
const
|
|
201
|
-
return new T(e).multipliedBy(new T(a)).plus(t).dividedBy(
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
const c = new T(1).shiftedBy(1 * Z), t = c.multipliedBy(new T(0.5));
|
|
201
|
+
return new T(e).multipliedBy(new T(a)).plus(t).dividedBy(c).integerValue(T.ROUND_DOWN);
|
|
202
|
+
}, x = "1.3.0-beta.1", ee = {
|
|
203
|
+
version: x
|
|
204
|
+
}, b = I(
|
|
205
|
+
C(async (e) => {
|
|
206
|
+
const a = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}&sdk=${ee.version}`;
|
|
205
207
|
return (await fetch(a).then((t) => t.json())).data;
|
|
206
208
|
})
|
|
207
209
|
), g = 1e3 * 60 * 5;
|
|
208
|
-
var
|
|
209
|
-
const
|
|
210
|
-
|
|
210
|
+
var $ = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))($ || {});
|
|
211
|
+
const V = I(
|
|
212
|
+
C(async (e) => {
|
|
211
213
|
const a = `https://open-api.naviprotocol.io/api/navi/pools?env=${(e == null ? void 0 : e.env) || "prod"}`;
|
|
212
214
|
return (await fetch(a).then((t) => t.json())).data;
|
|
213
215
|
})
|
|
214
216
|
);
|
|
215
|
-
async function
|
|
216
|
-
const
|
|
217
|
+
async function v(e, a) {
|
|
218
|
+
const c = await V({
|
|
217
219
|
...a,
|
|
218
220
|
cacheTime: g
|
|
219
221
|
});
|
|
220
222
|
if (typeof e == "object")
|
|
221
223
|
return e;
|
|
222
|
-
const t =
|
|
224
|
+
const t = c.find((r) => typeof e == "string" ? f(r.suiCoinType) === f(e) : typeof e == "number" ? r.id === e : !1);
|
|
223
225
|
if (!t)
|
|
224
226
|
throw new Error("Pool not found");
|
|
225
227
|
return t;
|
|
226
228
|
}
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
),
|
|
230
|
-
|
|
229
|
+
const he = I(
|
|
230
|
+
C(async (e) => (await fetch("https://open-api.naviprotocol.io/api/navi/stats").then((t) => t.json())).data)
|
|
231
|
+
), ve = I(
|
|
232
|
+
C(
|
|
231
233
|
async (e) => await fetch("https://open-api.naviprotocol.io/api/navi/fee").then((t) => t.json())
|
|
232
234
|
)
|
|
233
235
|
);
|
|
234
|
-
async function
|
|
235
|
-
const
|
|
236
|
+
async function te(e, a, c, t) {
|
|
237
|
+
const r = await b({
|
|
236
238
|
...t,
|
|
237
239
|
cacheTime: g
|
|
238
|
-
}), n = await
|
|
239
|
-
if (
|
|
240
|
+
}), n = await v(a, t), o = typeof c == "object" && c.$kind === "GasCoin";
|
|
241
|
+
if (f(n.suiCoinType) === f("0x2::sui::SUI") && o) {
|
|
240
242
|
if (!(t != null && t.amount))
|
|
241
243
|
throw new Error("Amount is required for sui coin");
|
|
242
|
-
|
|
244
|
+
c = e.splitCoins(c, [t.amount]);
|
|
243
245
|
}
|
|
244
|
-
let
|
|
245
|
-
return typeof (t == null ? void 0 : t.amount) != "undefined" ?
|
|
246
|
+
let s;
|
|
247
|
+
return typeof (t == null ? void 0 : t.amount) != "undefined" ? s = d(t.amount, e.pure.u64) : s = e.moveCall({
|
|
246
248
|
target: "0x2::coin::value",
|
|
247
|
-
arguments: [
|
|
249
|
+
arguments: [d(c, e.object)],
|
|
248
250
|
typeArguments: [n.suiCoinType]
|
|
249
251
|
}), t != null && t.accountCap ? e.moveCall({
|
|
250
|
-
target: `${
|
|
252
|
+
target: `${r.package}::incentive_v3::deposit_with_account_cap`,
|
|
251
253
|
arguments: [
|
|
252
254
|
e.object("0x06"),
|
|
253
|
-
e.object(
|
|
255
|
+
e.object(r.storage),
|
|
254
256
|
e.object(n.contract.pool),
|
|
255
257
|
e.pure.u8(n.id),
|
|
256
|
-
|
|
257
|
-
e.object(
|
|
258
|
-
e.object(
|
|
259
|
-
|
|
258
|
+
d(c, e.object),
|
|
259
|
+
e.object(r.incentiveV2),
|
|
260
|
+
e.object(r.incentiveV3),
|
|
261
|
+
d(t.accountCap, e.object)
|
|
260
262
|
],
|
|
261
263
|
typeArguments: [n.suiCoinType]
|
|
262
264
|
}) : e.moveCall({
|
|
263
|
-
target: `${
|
|
265
|
+
target: `${r.package}::incentive_v3::entry_deposit`,
|
|
264
266
|
arguments: [
|
|
265
267
|
e.object("0x06"),
|
|
266
|
-
e.object(
|
|
268
|
+
e.object(r.storage),
|
|
267
269
|
e.object(n.contract.pool),
|
|
268
270
|
e.pure.u8(n.id),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
e.object(
|
|
272
|
-
e.object(
|
|
271
|
+
d(c, e.object),
|
|
272
|
+
s,
|
|
273
|
+
e.object(r.incentiveV2),
|
|
274
|
+
e.object(r.incentiveV3)
|
|
273
275
|
],
|
|
274
276
|
typeArguments: [n.suiCoinType]
|
|
277
|
+
}), r.version === 2 && n.id === 0 && e.moveCall({
|
|
278
|
+
target: `${r.package}::pool::refresh_stake`,
|
|
279
|
+
arguments: [e.object(n.contract.pool), e.object("0x05")]
|
|
275
280
|
}), e;
|
|
276
281
|
}
|
|
277
|
-
async function
|
|
278
|
-
const
|
|
282
|
+
async function je(e, a, c, t) {
|
|
283
|
+
const r = await b({
|
|
279
284
|
...t,
|
|
280
285
|
cacheTime: g
|
|
281
|
-
}), n = await
|
|
282
|
-
let
|
|
283
|
-
if (
|
|
286
|
+
}), n = await v(a, t), o = d(c, e.pure.u64);
|
|
287
|
+
let s;
|
|
288
|
+
if (r.version === 1)
|
|
289
|
+
if (t != null && t.accountCap) {
|
|
290
|
+
const [l] = e.moveCall({
|
|
291
|
+
target: `${r.package}::incentive_v3::withdraw_with_account_cap`,
|
|
292
|
+
arguments: [
|
|
293
|
+
e.object("0x06"),
|
|
294
|
+
e.object(r.priceOracle),
|
|
295
|
+
e.object(r.storage),
|
|
296
|
+
e.object(n.contract.pool),
|
|
297
|
+
e.pure.u8(n.id),
|
|
298
|
+
o,
|
|
299
|
+
e.object(r.incentiveV2),
|
|
300
|
+
e.object(r.incentiveV3),
|
|
301
|
+
d(t.accountCap, e.object)
|
|
302
|
+
],
|
|
303
|
+
typeArguments: [n.suiCoinType]
|
|
304
|
+
});
|
|
305
|
+
s = l;
|
|
306
|
+
} else {
|
|
307
|
+
const [l] = e.moveCall({
|
|
308
|
+
target: `${r.package}::incentive_v3::withdraw`,
|
|
309
|
+
arguments: [
|
|
310
|
+
e.object("0x06"),
|
|
311
|
+
e.object(r.priceOracle),
|
|
312
|
+
e.object(r.storage),
|
|
313
|
+
e.object(n.contract.pool),
|
|
314
|
+
e.pure.u8(n.id),
|
|
315
|
+
o,
|
|
316
|
+
e.object(r.incentiveV2),
|
|
317
|
+
e.object(r.incentiveV3)
|
|
318
|
+
],
|
|
319
|
+
typeArguments: [n.suiCoinType]
|
|
320
|
+
});
|
|
321
|
+
s = l;
|
|
322
|
+
}
|
|
323
|
+
else if (t != null && t.accountCap) {
|
|
284
324
|
const [l] = e.moveCall({
|
|
285
|
-
target: `${
|
|
325
|
+
target: `${r.package}::incentive_v3::withdraw_with_account_cap_v2`,
|
|
286
326
|
arguments: [
|
|
287
327
|
e.object("0x06"),
|
|
288
|
-
e.object(
|
|
289
|
-
e.object(
|
|
328
|
+
e.object(r.priceOracle),
|
|
329
|
+
e.object(r.storage),
|
|
290
330
|
e.object(n.contract.pool),
|
|
291
331
|
e.pure.u8(n.id),
|
|
292
332
|
o,
|
|
293
|
-
e.object(
|
|
294
|
-
e.object(
|
|
295
|
-
|
|
333
|
+
e.object(r.incentiveV2),
|
|
334
|
+
e.object(r.incentiveV3),
|
|
335
|
+
d(t.accountCap, e.object),
|
|
336
|
+
e.object("0x05")
|
|
296
337
|
],
|
|
297
338
|
typeArguments: [n.suiCoinType]
|
|
298
339
|
});
|
|
299
|
-
|
|
340
|
+
s = l;
|
|
300
341
|
} else {
|
|
301
342
|
const [l] = e.moveCall({
|
|
302
|
-
target: `${
|
|
343
|
+
target: `${r.package}::incentive_v3::withdraw_v2`,
|
|
303
344
|
arguments: [
|
|
304
345
|
e.object("0x06"),
|
|
305
|
-
e.object(
|
|
306
|
-
e.object(
|
|
346
|
+
e.object(r.priceOracle),
|
|
347
|
+
e.object(r.storage),
|
|
307
348
|
e.object(n.contract.pool),
|
|
308
349
|
e.pure.u8(n.id),
|
|
309
350
|
o,
|
|
310
|
-
e.object(
|
|
311
|
-
e.object(
|
|
351
|
+
e.object(r.incentiveV2),
|
|
352
|
+
e.object(r.incentiveV3),
|
|
353
|
+
e.object("0x05")
|
|
312
354
|
],
|
|
313
355
|
typeArguments: [n.suiCoinType]
|
|
314
356
|
});
|
|
315
|
-
|
|
357
|
+
s = l;
|
|
316
358
|
}
|
|
317
359
|
return e.moveCall({
|
|
318
360
|
target: "0x2::coin::from_balance",
|
|
319
|
-
arguments: [
|
|
361
|
+
arguments: [s],
|
|
320
362
|
typeArguments: [n.suiCoinType]
|
|
321
363
|
});
|
|
322
364
|
}
|
|
323
|
-
async function
|
|
324
|
-
const
|
|
365
|
+
async function Ce(e, a, c, t) {
|
|
366
|
+
const r = await b({
|
|
325
367
|
...t,
|
|
326
368
|
cacheTime: g
|
|
327
|
-
}), n = await
|
|
328
|
-
let
|
|
329
|
-
if (
|
|
369
|
+
}), n = await v(a, t), o = d(c, e.pure.u64);
|
|
370
|
+
let s;
|
|
371
|
+
if (r.version === 1)
|
|
372
|
+
if (t != null && t.accountCap) {
|
|
373
|
+
const [l] = e.moveCall({
|
|
374
|
+
target: `${r.package}::incentive_v3::borrow_with_account_cap`,
|
|
375
|
+
arguments: [
|
|
376
|
+
e.object("0x06"),
|
|
377
|
+
e.object(r.priceOracle),
|
|
378
|
+
e.object(r.storage),
|
|
379
|
+
e.object(n.contract.pool),
|
|
380
|
+
e.pure.u8(n.id),
|
|
381
|
+
o,
|
|
382
|
+
e.object(r.incentiveV2),
|
|
383
|
+
e.object(r.incentiveV3),
|
|
384
|
+
d(t.accountCap, e.object)
|
|
385
|
+
],
|
|
386
|
+
typeArguments: [n.suiCoinType]
|
|
387
|
+
});
|
|
388
|
+
s = l;
|
|
389
|
+
} else {
|
|
390
|
+
const [l] = e.moveCall({
|
|
391
|
+
target: `${r.package}::incentive_v3::borrow`,
|
|
392
|
+
arguments: [
|
|
393
|
+
e.object("0x06"),
|
|
394
|
+
e.object(r.priceOracle),
|
|
395
|
+
e.object(r.storage),
|
|
396
|
+
e.object(n.contract.pool),
|
|
397
|
+
e.pure.u8(n.id),
|
|
398
|
+
o,
|
|
399
|
+
e.object(r.incentiveV2),
|
|
400
|
+
e.object(r.incentiveV3)
|
|
401
|
+
],
|
|
402
|
+
typeArguments: [n.suiCoinType]
|
|
403
|
+
});
|
|
404
|
+
s = l;
|
|
405
|
+
}
|
|
406
|
+
else if (t != null && t.accountCap) {
|
|
330
407
|
const [l] = e.moveCall({
|
|
331
|
-
target: `${
|
|
408
|
+
target: `${r.package}::incentive_v3::borrow_with_account_cap_v2`,
|
|
332
409
|
arguments: [
|
|
333
410
|
e.object("0x06"),
|
|
334
|
-
e.object(
|
|
335
|
-
e.object(
|
|
411
|
+
e.object(r.priceOracle),
|
|
412
|
+
e.object(r.storage),
|
|
336
413
|
e.object(n.contract.pool),
|
|
337
414
|
e.pure.u8(n.id),
|
|
338
415
|
o,
|
|
339
|
-
e.object(
|
|
340
|
-
e.object(
|
|
341
|
-
|
|
416
|
+
e.object(r.incentiveV2),
|
|
417
|
+
e.object(r.incentiveV3),
|
|
418
|
+
d(t.accountCap, e.object),
|
|
419
|
+
e.object("0x05")
|
|
342
420
|
],
|
|
343
421
|
typeArguments: [n.suiCoinType]
|
|
344
422
|
});
|
|
345
|
-
|
|
423
|
+
s = l;
|
|
346
424
|
} else {
|
|
347
425
|
const [l] = e.moveCall({
|
|
348
|
-
target: `${
|
|
426
|
+
target: `${r.package}::incentive_v3::borrow_v2`,
|
|
349
427
|
arguments: [
|
|
350
428
|
e.object("0x06"),
|
|
351
|
-
e.object(
|
|
352
|
-
e.object(
|
|
429
|
+
e.object(r.priceOracle),
|
|
430
|
+
e.object(r.storage),
|
|
353
431
|
e.object(n.contract.pool),
|
|
354
432
|
e.pure.u8(n.id),
|
|
355
433
|
o,
|
|
356
|
-
e.object(
|
|
357
|
-
e.object(
|
|
434
|
+
e.object(r.incentiveV2),
|
|
435
|
+
e.object(r.incentiveV3),
|
|
436
|
+
e.object("0x05")
|
|
358
437
|
],
|
|
359
438
|
typeArguments: [n.suiCoinType]
|
|
360
439
|
});
|
|
361
|
-
|
|
440
|
+
s = l;
|
|
362
441
|
}
|
|
363
442
|
return e.moveCall({
|
|
364
443
|
target: "0x2::coin::from_balance",
|
|
365
|
-
arguments: [e.object(
|
|
444
|
+
arguments: [e.object(s)],
|
|
366
445
|
typeArguments: [n.suiCoinType]
|
|
367
446
|
});
|
|
368
447
|
}
|
|
369
|
-
async function
|
|
370
|
-
const
|
|
448
|
+
async function _e(e, a, c, t) {
|
|
449
|
+
const r = await b({
|
|
371
450
|
...t,
|
|
372
451
|
cacheTime: g
|
|
373
|
-
}), n = await
|
|
374
|
-
if (
|
|
452
|
+
}), n = await v(a, t), o = typeof c == "object" && c.$kind === "GasCoin";
|
|
453
|
+
if (f(n.suiCoinType) === f("0x2::sui::SUI") && o) {
|
|
375
454
|
if (!(t != null && t.amount))
|
|
376
455
|
throw new Error("Amount is required for sui coin");
|
|
377
|
-
|
|
456
|
+
c = e.splitCoins(c, [t.amount]);
|
|
378
457
|
}
|
|
379
|
-
let
|
|
380
|
-
return typeof (t == null ? void 0 : t.amount) != "undefined" ?
|
|
458
|
+
let s;
|
|
459
|
+
return typeof (t == null ? void 0 : t.amount) != "undefined" ? s = d(t.amount, e.pure.u64) : s = e.moveCall({
|
|
381
460
|
target: "0x2::coin::value",
|
|
382
|
-
arguments: [
|
|
461
|
+
arguments: [d(c, e.object)],
|
|
383
462
|
typeArguments: [n.suiCoinType]
|
|
384
463
|
}), t != null && t.accountCap ? e.moveCall({
|
|
385
|
-
target: `${
|
|
464
|
+
target: `${r.package}::incentive_v3::repay_with_account_cap`,
|
|
386
465
|
arguments: [
|
|
387
466
|
e.object("0x06"),
|
|
388
|
-
e.object(
|
|
389
|
-
e.object(
|
|
467
|
+
e.object(r.priceOracle),
|
|
468
|
+
e.object(r.storage),
|
|
390
469
|
e.object(n.contract.pool),
|
|
391
470
|
e.pure.u8(n.id),
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
e.object(
|
|
395
|
-
e.object(
|
|
396
|
-
|
|
471
|
+
d(c, e.object),
|
|
472
|
+
s,
|
|
473
|
+
e.object(r.incentiveV2),
|
|
474
|
+
e.object(r.incentiveV3),
|
|
475
|
+
d(t.accountCap, e.object)
|
|
397
476
|
],
|
|
398
477
|
typeArguments: [n.suiCoinType]
|
|
399
478
|
}) : e.moveCall({
|
|
400
|
-
target: `${
|
|
479
|
+
target: `${r.package}::incentive_v3::entry_repay`,
|
|
401
480
|
arguments: [
|
|
402
481
|
e.object("0x06"),
|
|
403
|
-
e.object(
|
|
404
|
-
e.object(
|
|
482
|
+
e.object(r.priceOracle),
|
|
483
|
+
e.object(r.storage),
|
|
405
484
|
e.object(n.contract.pool),
|
|
406
485
|
e.pure.u8(n.id),
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
e.object(
|
|
410
|
-
e.object(
|
|
486
|
+
d(c, e.object),
|
|
487
|
+
s,
|
|
488
|
+
e.object(r.incentiveV2),
|
|
489
|
+
e.object(r.incentiveV3)
|
|
411
490
|
],
|
|
412
491
|
typeArguments: [n.suiCoinType]
|
|
413
492
|
}), e;
|
|
414
493
|
}
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
494
|
+
const Te = I(
|
|
495
|
+
C(
|
|
496
|
+
async (e) => {
|
|
497
|
+
var r;
|
|
498
|
+
const a = await b({
|
|
499
|
+
...e
|
|
500
|
+
});
|
|
501
|
+
if (e != null && e.address && typeof (e == null ? void 0 : e.asset) != "undefined")
|
|
502
|
+
try {
|
|
503
|
+
const n = await v(e.asset, e), o = (r = e == null ? void 0 : e.client) != null ? r : A, s = new k();
|
|
504
|
+
s.moveCall({
|
|
505
|
+
target: `${a.package}::incentive_v3::get_borrow_fee_v2`,
|
|
506
|
+
arguments: [
|
|
507
|
+
s.object(a.incentiveV3),
|
|
508
|
+
s.pure.address(e.address),
|
|
509
|
+
s.pure.u8(n.id),
|
|
510
|
+
s.pure.u64(1e4)
|
|
511
|
+
],
|
|
512
|
+
typeArguments: []
|
|
513
|
+
});
|
|
514
|
+
const u = await o.devInspectTransactionBlock({
|
|
515
|
+
transactionBlock: s,
|
|
516
|
+
sender: e.address
|
|
517
|
+
}), l = B(u, [h.u64()]);
|
|
518
|
+
return (Number(l[0]) || 0) / 100;
|
|
519
|
+
} catch (n) {
|
|
520
|
+
console.error(n);
|
|
521
|
+
}
|
|
522
|
+
const t = (await A.getObject({
|
|
523
|
+
id: a.incentiveV3,
|
|
524
|
+
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
525
|
+
})).data.content.fields.borrow_fee_rate;
|
|
526
|
+
return Number(t) / 100;
|
|
527
|
+
}
|
|
528
|
+
)
|
|
425
529
|
);
|
|
426
|
-
function
|
|
427
|
-
const t = typeof (
|
|
530
|
+
function Ae(e, a, c) {
|
|
531
|
+
const t = typeof (c == null ? void 0 : c.balance) == "number", r = t ? c.balance : 0;
|
|
428
532
|
let n = 0;
|
|
429
533
|
const o = [];
|
|
430
|
-
let
|
|
431
|
-
if (a.sort((l,
|
|
432
|
-
if (!(t && n >=
|
|
433
|
-
if (
|
|
534
|
+
let s = "";
|
|
535
|
+
if (a.sort((l, p) => Number(p.balance) - Number(l.balance)).forEach((l) => {
|
|
536
|
+
if (!(t && n >= r) && Number(l.balance) !== 0) {
|
|
537
|
+
if (s || (s = l.coinType), s !== l.coinType)
|
|
434
538
|
throw new Error("All coins must be of the same type");
|
|
435
539
|
n += Number(l.balance), o.push(l.coinObjectId);
|
|
436
540
|
}
|
|
437
541
|
}), o.length === 0)
|
|
438
542
|
throw new Error("No coins to merge");
|
|
439
|
-
if (t && n <
|
|
543
|
+
if (t && n < r)
|
|
440
544
|
throw new Error(
|
|
441
|
-
`Balance is less than the specified balance: ${n} < ${
|
|
545
|
+
`Balance is less than the specified balance: ${n} < ${r}`
|
|
442
546
|
);
|
|
443
|
-
if (
|
|
444
|
-
return t ? e.splitCoins(e.gas, [e.pure.u64(
|
|
547
|
+
if (f(s) === f("0x2::sui::SUI") && (c != null && c.useGasCoin))
|
|
548
|
+
return t ? e.splitCoins(e.gas, [e.pure.u64(r)]) : e.gas;
|
|
445
549
|
const u = o.length === 1 ? e.object(o[0]) : e.mergeCoins(o[0], o.slice(1));
|
|
446
|
-
return t ? e.splitCoins(u, [e.pure.u64(
|
|
550
|
+
return t ? e.splitCoins(u, [e.pure.u64(r)]) : u;
|
|
447
551
|
}
|
|
448
|
-
async function
|
|
449
|
-
const
|
|
552
|
+
async function L(e, a, c, t, r, n, o) {
|
|
553
|
+
const s = await b({
|
|
450
554
|
...o,
|
|
451
555
|
cacheTime: g
|
|
452
|
-
}), u = await
|
|
556
|
+
}), u = await v(c, o);
|
|
453
557
|
return e.moveCall({
|
|
454
|
-
target: `${
|
|
558
|
+
target: `${s.uiGetter}::calculator_unchecked::dynamic_health_factor`,
|
|
455
559
|
arguments: [
|
|
456
560
|
e.object("0x06"),
|
|
457
|
-
e.object(
|
|
458
|
-
e.object(
|
|
561
|
+
e.object(s.storage),
|
|
562
|
+
e.object(s.oracle.priceOracle),
|
|
459
563
|
X(e, u),
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
564
|
+
d(a, e.pure.address),
|
|
565
|
+
d(u.id, e.pure.u8),
|
|
566
|
+
d(t, e.pure.u64),
|
|
567
|
+
d(r, e.pure.u64),
|
|
568
|
+
d(n, e.pure.bool)
|
|
465
569
|
],
|
|
466
570
|
typeArguments: [u.suiCoinType]
|
|
467
571
|
});
|
|
468
572
|
}
|
|
469
|
-
async function
|
|
470
|
-
return
|
|
573
|
+
async function ae(e, a, c) {
|
|
574
|
+
return L(e, a, 0, 0, 0, !1, c);
|
|
471
575
|
}
|
|
472
|
-
const
|
|
576
|
+
const Ie = I(
|
|
473
577
|
async (e, a) => {
|
|
474
578
|
var l;
|
|
475
|
-
const
|
|
579
|
+
const c = await b({
|
|
476
580
|
...a,
|
|
477
581
|
cacheTime: g
|
|
478
|
-
}), t = new
|
|
582
|
+
}), t = new k(), r = (l = a == null ? void 0 : a.client) != null ? l : A, n = await V(a);
|
|
479
583
|
t.moveCall({
|
|
480
|
-
target: `${
|
|
481
|
-
arguments: [t.object(
|
|
584
|
+
target: `${c.uiGetter}::getter_unchecked::get_user_state`,
|
|
585
|
+
arguments: [t.object(c.storage), t.pure.address(e)]
|
|
482
586
|
});
|
|
483
|
-
const o = await
|
|
587
|
+
const o = await r.devInspectTransactionBlock({
|
|
484
588
|
transactionBlock: t,
|
|
485
589
|
sender: e
|
|
486
|
-
}),
|
|
487
|
-
return
|
|
488
|
-
|
|
489
|
-
).map((
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
).toString(), y =
|
|
494
|
-
|
|
495
|
-
|
|
590
|
+
}), s = B(o, [h.vector(Q)]);
|
|
591
|
+
return P(
|
|
592
|
+
s[0].filter((p) => p.supply_balance !== "0" || p.borrow_balance !== "0")
|
|
593
|
+
).map((p) => {
|
|
594
|
+
const w = n.find((j) => j.id === p.assetId), m = R(
|
|
595
|
+
p.supplyBalance,
|
|
596
|
+
w.currentSupplyIndex
|
|
597
|
+
).toString(), y = R(
|
|
598
|
+
p.borrowBalance,
|
|
599
|
+
w.currentBorrowIndex
|
|
496
600
|
).toString();
|
|
497
601
|
return {
|
|
498
|
-
...
|
|
499
|
-
supplyBalance:
|
|
602
|
+
...p,
|
|
603
|
+
supplyBalance: m,
|
|
500
604
|
borrowBalance: y,
|
|
501
|
-
pool:
|
|
605
|
+
pool: w
|
|
502
606
|
};
|
|
503
|
-
}).filter((
|
|
607
|
+
}).filter((p) => !!p.pool);
|
|
504
608
|
}
|
|
505
609
|
);
|
|
506
|
-
async function
|
|
610
|
+
async function $e(e, a) {
|
|
507
611
|
var o;
|
|
508
|
-
const
|
|
509
|
-
await
|
|
510
|
-
const
|
|
612
|
+
const c = (o = a == null ? void 0 : a.client) != null ? o : A, t = new k();
|
|
613
|
+
await ae(t, e, a);
|
|
614
|
+
const r = await c.devInspectTransactionBlock({
|
|
511
615
|
transactionBlock: t,
|
|
512
616
|
sender: e
|
|
513
|
-
}), n =
|
|
514
|
-
return
|
|
617
|
+
}), n = B(r, [h.u256()]);
|
|
618
|
+
return D(Number(n[0]) || 0);
|
|
515
619
|
}
|
|
516
|
-
async function
|
|
517
|
-
var
|
|
518
|
-
const
|
|
519
|
-
let o = 0,
|
|
520
|
-
const u = await
|
|
521
|
-
if (
|
|
522
|
-
y.type ===
|
|
523
|
-
}), o *
|
|
620
|
+
async function ke(e, a, c, t) {
|
|
621
|
+
var m;
|
|
622
|
+
const r = (m = t == null ? void 0 : t.client) != null ? m : A, n = new k();
|
|
623
|
+
let o = 0, s = 0;
|
|
624
|
+
const u = await v(a, t);
|
|
625
|
+
if (c.forEach((y) => {
|
|
626
|
+
y.type === $.Supply ? o += y.amount : y.type === $.Withdraw ? o -= y.amount : y.type === $.Borrow ? s += y.amount : y.type === $.Repay && (s -= y.amount);
|
|
627
|
+
}), o * s < 0)
|
|
524
628
|
throw new Error("Invalid operations");
|
|
525
|
-
const l = o > 0 ||
|
|
526
|
-
await
|
|
629
|
+
const l = o > 0 || s > 0;
|
|
630
|
+
await L(
|
|
527
631
|
n,
|
|
528
632
|
e,
|
|
529
633
|
u,
|
|
530
634
|
Math.abs(o),
|
|
531
|
-
Math.abs(
|
|
635
|
+
Math.abs(s),
|
|
532
636
|
l,
|
|
533
637
|
t
|
|
534
638
|
);
|
|
535
|
-
const
|
|
639
|
+
const p = await r.devInspectTransactionBlock({
|
|
536
640
|
transactionBlock: n,
|
|
537
641
|
sender: e
|
|
538
|
-
}),
|
|
539
|
-
return
|
|
642
|
+
}), w = B(p, [h.u256()]);
|
|
643
|
+
return D(Number(w[0]) || 0);
|
|
540
644
|
}
|
|
541
|
-
const
|
|
645
|
+
const Be = C(
|
|
542
646
|
async (e, a) => {
|
|
543
|
-
const
|
|
544
|
-
a != null && a.cursor &&
|
|
545
|
-
const t = `https://open-api.naviprotocol.io/api/navi/user/transactions?${
|
|
647
|
+
const c = new URLSearchParams();
|
|
648
|
+
a != null && a.cursor && c.set("cursor", a.cursor), c.set("userAddress", e);
|
|
649
|
+
const t = `https://open-api.naviprotocol.io/api/navi/user/transactions?${c.toString()}`;
|
|
546
650
|
return (await fetch(t).then((n) => n.json())).data;
|
|
547
651
|
}
|
|
548
652
|
);
|
|
549
|
-
async function
|
|
653
|
+
async function Pe(e, a) {
|
|
550
654
|
var n;
|
|
551
|
-
let
|
|
552
|
-
const t = [],
|
|
655
|
+
let c = null;
|
|
656
|
+
const t = [], r = (n = a == null ? void 0 : a.client) != null ? n : A;
|
|
553
657
|
do {
|
|
554
658
|
let o;
|
|
555
|
-
if (a != null && a.coinType ? o = await
|
|
659
|
+
if (a != null && a.coinType ? o = await r.getCoins({
|
|
556
660
|
owner: e,
|
|
557
661
|
coinType: a == null ? void 0 : a.coinType,
|
|
558
|
-
cursor:
|
|
662
|
+
cursor: c,
|
|
559
663
|
limit: 100
|
|
560
|
-
}) : o = await
|
|
664
|
+
}) : o = await r.getAllCoins({
|
|
561
665
|
owner: e,
|
|
562
|
-
cursor:
|
|
666
|
+
cursor: c,
|
|
563
667
|
limit: 100
|
|
564
668
|
}), !o.data || !o.data.length)
|
|
565
669
|
break;
|
|
566
|
-
t.push(...o.data),
|
|
567
|
-
} while (
|
|
670
|
+
t.push(...o.data), c = o.nextCursor;
|
|
671
|
+
} while (c);
|
|
568
672
|
return t;
|
|
569
673
|
}
|
|
570
|
-
const M = new
|
|
674
|
+
const M = new N("https://hermes.pyth.network", {
|
|
571
675
|
timeout: 1e4
|
|
572
676
|
});
|
|
573
|
-
async function
|
|
677
|
+
async function re(e) {
|
|
574
678
|
try {
|
|
575
|
-
const a = [],
|
|
576
|
-
if (!
|
|
679
|
+
const a = [], c = await M.getLatestPriceFeeds(e);
|
|
680
|
+
if (!c) return a;
|
|
577
681
|
const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
578
|
-
for (const
|
|
579
|
-
const n =
|
|
682
|
+
for (const r of c) {
|
|
683
|
+
const n = r.getPriceUnchecked();
|
|
580
684
|
if (n.publishTime > t) {
|
|
581
685
|
console.warn(
|
|
582
|
-
`pyth price feed is invalid, id: ${
|
|
686
|
+
`pyth price feed is invalid, id: ${r.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
|
|
583
687
|
);
|
|
584
688
|
continue;
|
|
585
689
|
}
|
|
586
|
-
t -
|
|
587
|
-
`stale price feed, id: ${
|
|
588
|
-
), a.push(
|
|
690
|
+
t - r.getPriceUnchecked().publishTime > 30 && (console.info(
|
|
691
|
+
`stale price feed, id: ${r.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
|
|
692
|
+
), a.push(r.id));
|
|
589
693
|
}
|
|
590
694
|
return a;
|
|
591
695
|
} catch (a) {
|
|
592
696
|
throw new Error(`failed to get pyth stale price feed id, msg: ${a.message}`);
|
|
593
697
|
}
|
|
594
698
|
}
|
|
595
|
-
async function
|
|
699
|
+
async function ce(e, a, c) {
|
|
596
700
|
var n;
|
|
597
|
-
const t = (n =
|
|
598
|
-
...
|
|
701
|
+
const t = (n = c == null ? void 0 : c.client) != null ? n : A, r = await b({
|
|
702
|
+
...c,
|
|
599
703
|
cacheTime: g
|
|
600
704
|
});
|
|
601
705
|
try {
|
|
602
706
|
const o = await M.getPriceFeedsUpdateData(a);
|
|
603
|
-
return await new
|
|
707
|
+
return await new K(
|
|
604
708
|
t,
|
|
605
|
-
|
|
606
|
-
|
|
709
|
+
r.oracle.pythStateId,
|
|
710
|
+
r.oracle.wormholeStateId
|
|
607
711
|
).updatePriceFeeds(e, o, a);
|
|
608
712
|
} catch (o) {
|
|
609
713
|
throw new Error(`failed to update pyth price feeds, msg: ${o.message}`);
|
|
610
714
|
}
|
|
611
715
|
}
|
|
612
|
-
async function
|
|
613
|
-
const t = await
|
|
614
|
-
...
|
|
716
|
+
async function Ve(e, a, c) {
|
|
717
|
+
const t = await b({
|
|
718
|
+
...c,
|
|
615
719
|
cacheTime: g
|
|
616
720
|
});
|
|
617
|
-
if (
|
|
618
|
-
const
|
|
721
|
+
if (c != null && c.updatePythPriceFeeds) {
|
|
722
|
+
const r = a.filter((n) => !!n.pythPriceFeedId).map((n) => n.pythPriceFeedId);
|
|
619
723
|
try {
|
|
620
|
-
const n = await
|
|
621
|
-
n.length > 0 && await
|
|
724
|
+
const n = await re(r);
|
|
725
|
+
n.length > 0 && await ce(e, n, c);
|
|
622
726
|
} catch {
|
|
623
727
|
}
|
|
624
728
|
}
|
|
625
|
-
for (const
|
|
729
|
+
for (const r of a)
|
|
626
730
|
e.moveCall({
|
|
627
731
|
target: `${t.oracle.packageId}::oracle_pro::update_single_price`,
|
|
628
732
|
arguments: [
|
|
@@ -634,68 +738,82 @@ async function $e(e, a, r) {
|
|
|
634
738
|
// Price oracle contract
|
|
635
739
|
e.object(t.oracle.supraOracleHolder),
|
|
636
740
|
// Supra oracle holder
|
|
637
|
-
e.object(
|
|
741
|
+
e.object(r.pythPriceInfoObject),
|
|
638
742
|
// Pyth price info object
|
|
639
|
-
e.pure.address(
|
|
743
|
+
e.pure.address(r.feedId)
|
|
640
744
|
// Price feed ID
|
|
641
745
|
]
|
|
642
746
|
});
|
|
643
747
|
return e;
|
|
644
748
|
}
|
|
645
|
-
async function
|
|
646
|
-
return (await
|
|
749
|
+
async function ne(e) {
|
|
750
|
+
return (await b({
|
|
647
751
|
...e,
|
|
648
752
|
cacheTime: g
|
|
649
753
|
})).oracle.feeds;
|
|
650
754
|
}
|
|
651
|
-
function
|
|
652
|
-
return e.filter((
|
|
755
|
+
function Se(e, a) {
|
|
756
|
+
return e.filter((c) => !!(a != null && a.lendingState && a.lendingState.find((r) => r.assetId === c.assetId) || a != null && a.pools && a.pools.find((r) => r.id === c.assetId)));
|
|
653
757
|
}
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
const a = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${(e == null ? void 0 : e.env) || "prod"}`,
|
|
657
|
-
return Object.keys(
|
|
658
|
-
...
|
|
758
|
+
const S = I(
|
|
759
|
+
C(async (e) => {
|
|
760
|
+
const a = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${(e == null ? void 0 : e.env) || "prod"}`, c = await fetch(a).then((t) => t.json());
|
|
761
|
+
return Object.keys(c.data).map((t) => ({
|
|
762
|
+
...c.data[t],
|
|
659
763
|
coinType: t
|
|
660
764
|
}));
|
|
661
765
|
})
|
|
662
766
|
);
|
|
663
|
-
async function
|
|
664
|
-
return (await
|
|
767
|
+
async function Fe(e, a) {
|
|
768
|
+
return (await S(a)).find((t) => typeof e == "string" ? f(t.coinType) === f(e) : typeof e == "number" ? t.assetId === e : t.assetId === e.id) || null;
|
|
665
769
|
}
|
|
666
|
-
async function
|
|
667
|
-
const
|
|
770
|
+
async function Re(e, a, c, t) {
|
|
771
|
+
const r = await b({
|
|
668
772
|
...t,
|
|
669
773
|
cacheTime: g
|
|
670
|
-
}), n = await
|
|
671
|
-
if (!(await
|
|
774
|
+
}), n = await v(a, t);
|
|
775
|
+
if (!(await S({
|
|
672
776
|
...t,
|
|
673
777
|
cacheTime: g
|
|
674
778
|
})).some(
|
|
675
|
-
(
|
|
779
|
+
(u) => f(u.coinType) === f(n.suiCoinType)
|
|
676
780
|
))
|
|
677
781
|
throw new Error("Pool does not support flashloan");
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
782
|
+
if (r.version === 1) {
|
|
783
|
+
const [u, l] = e.moveCall({
|
|
784
|
+
target: `${r.package}::lending::flash_loan_with_ctx`,
|
|
785
|
+
arguments: [
|
|
786
|
+
e.object(r.flashloanConfig),
|
|
787
|
+
e.object(n.contract.pool),
|
|
788
|
+
d(c, e.pure.u64)
|
|
789
|
+
],
|
|
790
|
+
typeArguments: [n.suiCoinType]
|
|
791
|
+
});
|
|
792
|
+
return [u, l];
|
|
793
|
+
} else {
|
|
794
|
+
const [u, l] = e.moveCall({
|
|
795
|
+
target: `${r.package}::lending::flash_loan_with_ctx_v2`,
|
|
796
|
+
arguments: [
|
|
797
|
+
e.object(r.flashloanConfig),
|
|
798
|
+
e.object(n.contract.pool),
|
|
799
|
+
d(c, e.pure.u64),
|
|
800
|
+
e.object("0x05")
|
|
801
|
+
],
|
|
802
|
+
typeArguments: [n.suiCoinType]
|
|
803
|
+
});
|
|
804
|
+
return [u, l];
|
|
805
|
+
}
|
|
688
806
|
}
|
|
689
|
-
async function
|
|
690
|
-
const n = await
|
|
691
|
-
...
|
|
807
|
+
async function Ne(e, a, c, t, r) {
|
|
808
|
+
const n = await b({
|
|
809
|
+
...r,
|
|
692
810
|
cacheTime: g
|
|
693
|
-
}), o = await
|
|
694
|
-
if (!(await
|
|
695
|
-
...
|
|
811
|
+
}), o = await v(a, r);
|
|
812
|
+
if (!(await S({
|
|
813
|
+
...r,
|
|
696
814
|
cacheTime: g
|
|
697
815
|
})).some(
|
|
698
|
-
(
|
|
816
|
+
(p) => f(p.coinType) === f(o.suiCoinType)
|
|
699
817
|
))
|
|
700
818
|
throw new Error("Pool does not support flashloan");
|
|
701
819
|
const [l] = e.moveCall({
|
|
@@ -704,56 +822,91 @@ async function Re(e, a, r, t, c) {
|
|
|
704
822
|
e.object("0x06"),
|
|
705
823
|
e.object(n.storage),
|
|
706
824
|
e.object(o.contract.pool),
|
|
707
|
-
|
|
708
|
-
|
|
825
|
+
d(c, e.object),
|
|
826
|
+
d(t, e.object)
|
|
709
827
|
],
|
|
710
828
|
typeArguments: [o.suiCoinType]
|
|
711
829
|
});
|
|
712
830
|
return [l];
|
|
713
831
|
}
|
|
714
|
-
async function
|
|
832
|
+
async function Ee(e, a, c, t, r, n) {
|
|
715
833
|
const o = {
|
|
716
834
|
...n,
|
|
717
835
|
cacheTime: g
|
|
718
|
-
},
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
836
|
+
}, s = await b(o), u = await v(a, o), l = await v(t, o);
|
|
837
|
+
if (s.version === 1) {
|
|
838
|
+
const [p, w] = e.moveCall({
|
|
839
|
+
target: `${s.package}::incentive_v3::liquidation`,
|
|
840
|
+
arguments: [
|
|
841
|
+
e.object("0x06"),
|
|
842
|
+
// Clock object
|
|
843
|
+
e.object(s.priceOracle),
|
|
844
|
+
// Price oracle for asset pricing
|
|
845
|
+
e.object(s.storage),
|
|
846
|
+
// Protocol storage
|
|
847
|
+
e.pure.u8(u.id),
|
|
848
|
+
// Pay asset ID
|
|
849
|
+
e.object(u.contract.pool),
|
|
850
|
+
// Pay asset pool contract
|
|
851
|
+
d(c, e.object),
|
|
852
|
+
// Debt repayment amount
|
|
853
|
+
e.pure.u8(l.id),
|
|
854
|
+
// Collateral asset ID
|
|
855
|
+
e.object(l.contract.pool),
|
|
856
|
+
// Collateral asset pool contract
|
|
857
|
+
d(r, e.pure.address),
|
|
858
|
+
// Borrower address
|
|
859
|
+
e.object(s.incentiveV2),
|
|
860
|
+
// Incentive V2 contract
|
|
861
|
+
e.object(s.incentiveV3)
|
|
862
|
+
// Incentive V3 contract
|
|
863
|
+
],
|
|
864
|
+
typeArguments: [u.suiCoinType, l.suiCoinType]
|
|
865
|
+
});
|
|
866
|
+
return [p, w];
|
|
867
|
+
} else {
|
|
868
|
+
const [p, w] = e.moveCall({
|
|
869
|
+
target: `${s.package}::incentive_v3::liquidation_v2`,
|
|
870
|
+
arguments: [
|
|
871
|
+
e.object("0x06"),
|
|
872
|
+
// Clock object
|
|
873
|
+
e.object(s.priceOracle),
|
|
874
|
+
// Price oracle for asset pricing
|
|
875
|
+
e.object(s.storage),
|
|
876
|
+
// Protocol storage
|
|
877
|
+
e.pure.u8(u.id),
|
|
878
|
+
// Pay asset ID
|
|
879
|
+
e.object(u.contract.pool),
|
|
880
|
+
// Pay asset pool contract
|
|
881
|
+
d(c, e.object),
|
|
882
|
+
// Debt repayment amount
|
|
883
|
+
e.pure.u8(l.id),
|
|
884
|
+
// Collateral asset ID
|
|
885
|
+
e.object(l.contract.pool),
|
|
886
|
+
// Collateral asset pool contract
|
|
887
|
+
d(r, e.pure.address),
|
|
888
|
+
// Borrower address
|
|
889
|
+
e.object(s.incentiveV2),
|
|
890
|
+
// Incentive V2 contract
|
|
891
|
+
e.object(s.incentiveV3),
|
|
892
|
+
// Incentive V3 contract
|
|
893
|
+
e.object("0x05")
|
|
894
|
+
// SuiSystemState object
|
|
895
|
+
],
|
|
896
|
+
typeArguments: [u.suiCoinType, l.suiCoinType]
|
|
897
|
+
});
|
|
898
|
+
return [p, w];
|
|
899
|
+
}
|
|
747
900
|
}
|
|
748
|
-
async function
|
|
749
|
-
var
|
|
750
|
-
const
|
|
901
|
+
async function De(e, a) {
|
|
902
|
+
var p;
|
|
903
|
+
const c = await ne(a), t = await V({
|
|
751
904
|
...a,
|
|
752
905
|
cacheTime: g
|
|
753
|
-
}),
|
|
906
|
+
}), r = (p = a == null ? void 0 : a.client) != null ? p : A, n = await b({
|
|
754
907
|
...a,
|
|
755
908
|
cacheTime: g
|
|
756
|
-
}), o = new
|
|
909
|
+
}), o = new k();
|
|
757
910
|
o.moveCall({
|
|
758
911
|
target: `${n.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
|
|
759
912
|
arguments: [
|
|
@@ -767,114 +920,114 @@ async function Ee(e, a) {
|
|
|
767
920
|
// User address
|
|
768
921
|
]
|
|
769
922
|
});
|
|
770
|
-
const
|
|
923
|
+
const s = await r.devInspectTransactionBlock({
|
|
771
924
|
transactionBlock: o,
|
|
772
925
|
sender: e
|
|
773
|
-
}), u =
|
|
774
|
-
|
|
926
|
+
}), u = B(
|
|
927
|
+
s,
|
|
775
928
|
[
|
|
776
|
-
|
|
929
|
+
h.vector(h.string()),
|
|
777
930
|
// Asset coin types
|
|
778
|
-
|
|
931
|
+
h.vector(h.string()),
|
|
779
932
|
// Reward coin types
|
|
780
|
-
|
|
933
|
+
h.vector(h.u8()),
|
|
781
934
|
// Reward options
|
|
782
|
-
|
|
935
|
+
h.vector(h.Address),
|
|
783
936
|
// Rule IDs
|
|
784
|
-
|
|
937
|
+
h.vector(h.u256())
|
|
785
938
|
// Claimable amounts
|
|
786
939
|
]
|
|
787
940
|
), l = [];
|
|
788
941
|
if (u.length === 5 && Array.isArray(u[0])) {
|
|
789
|
-
const
|
|
790
|
-
for (let
|
|
791
|
-
const y =
|
|
792
|
-
(
|
|
793
|
-
),
|
|
794
|
-
(
|
|
942
|
+
const w = u[0].length;
|
|
943
|
+
for (let m = 0; m < w; m++) {
|
|
944
|
+
const y = c.find(
|
|
945
|
+
(_) => f(_.coinType) === f(u[1][m])
|
|
946
|
+
), j = t.find(
|
|
947
|
+
(_) => f(_.coinType) === f(u[0][m])
|
|
795
948
|
);
|
|
796
|
-
!y || !
|
|
797
|
-
assetId:
|
|
798
|
-
assetCoinType:
|
|
799
|
-
rewardCoinType:
|
|
800
|
-
option: Number(u[2][
|
|
801
|
-
userClaimableReward: Number(u[4][
|
|
802
|
-
ruleIds: Array.isArray(u[3][
|
|
949
|
+
!y || !j || l.push({
|
|
950
|
+
assetId: j.id,
|
|
951
|
+
assetCoinType: f(u[0][m]),
|
|
952
|
+
rewardCoinType: f(u[1][m]),
|
|
953
|
+
option: Number(u[2][m]),
|
|
954
|
+
userClaimableReward: Number(u[4][m]) / Math.pow(10, y.priceDecimal),
|
|
955
|
+
ruleIds: Array.isArray(u[3][m]) ? u[3][m] : [u[3][m]]
|
|
803
956
|
});
|
|
804
957
|
}
|
|
805
958
|
}
|
|
806
959
|
return l;
|
|
807
960
|
}
|
|
808
|
-
function
|
|
961
|
+
function Le(e) {
|
|
809
962
|
const a = /* @__PURE__ */ new Map();
|
|
810
963
|
e.forEach((t) => {
|
|
811
|
-
const
|
|
964
|
+
const r = t.assetId, n = t.option, o = `${r}-${n}-${t.rewardCoinType}`;
|
|
812
965
|
a.has(o) ? a.get(o).total += t.userClaimableReward : a.set(o, {
|
|
813
|
-
assetId:
|
|
966
|
+
assetId: r,
|
|
814
967
|
rewardType: n,
|
|
815
968
|
coinType: t.rewardCoinType,
|
|
816
969
|
total: Number(t.userClaimableReward)
|
|
817
970
|
});
|
|
818
971
|
});
|
|
819
|
-
const
|
|
820
|
-
for (const { assetId: t, rewardType:
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
const u =
|
|
972
|
+
const c = /* @__PURE__ */ new Map();
|
|
973
|
+
for (const { assetId: t, rewardType: r, coinType: n, total: o } of a.values()) {
|
|
974
|
+
const s = `${t}-${r}`;
|
|
975
|
+
c.has(s) || c.set(s, { assetId: t, rewardType: r, rewards: /* @__PURE__ */ new Map() });
|
|
976
|
+
const u = c.get(s);
|
|
824
977
|
u.rewards.set(n, (u.rewards.get(n) || 0) + o);
|
|
825
978
|
}
|
|
826
|
-
return Array.from(
|
|
979
|
+
return Array.from(c.values()).map((t) => ({
|
|
827
980
|
assetId: t.assetId,
|
|
828
981
|
rewardType: t.rewardType,
|
|
829
|
-
rewards: Array.from(t.rewards.entries()).map(([
|
|
830
|
-
coinType:
|
|
982
|
+
rewards: Array.from(t.rewards.entries()).map(([r, n]) => ({
|
|
983
|
+
coinType: r,
|
|
831
984
|
available: n.toFixed(6)
|
|
832
985
|
}))
|
|
833
986
|
}));
|
|
834
987
|
}
|
|
835
|
-
const
|
|
988
|
+
const Me = C(
|
|
836
989
|
async (e) => {
|
|
837
990
|
const a = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}`;
|
|
838
991
|
return (await fetch(a).then((t) => t.json())).data;
|
|
839
992
|
}
|
|
840
|
-
),
|
|
993
|
+
), Ue = C(
|
|
841
994
|
async (e, a) => {
|
|
842
|
-
const
|
|
843
|
-
return
|
|
995
|
+
const c = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${(a == null ? void 0 : a.page) || 1}&pageSize=${(a == null ? void 0 : a.size) || 400}`, t = await fetch(c).then((r) => r.json());
|
|
996
|
+
return P({
|
|
844
997
|
data: t.data.rewards
|
|
845
998
|
});
|
|
846
999
|
}
|
|
847
1000
|
);
|
|
848
|
-
async function
|
|
849
|
-
var
|
|
850
|
-
const t = await
|
|
851
|
-
...
|
|
1001
|
+
async function Oe(e, a, c) {
|
|
1002
|
+
var s;
|
|
1003
|
+
const t = await b({
|
|
1004
|
+
...c,
|
|
852
1005
|
cacheTime: g
|
|
853
|
-
}),
|
|
854
|
-
...
|
|
1006
|
+
}), r = await V({
|
|
1007
|
+
...c,
|
|
855
1008
|
cacheTime: g
|
|
856
1009
|
}), n = /* @__PURE__ */ new Map();
|
|
857
1010
|
for (const u of a) {
|
|
858
|
-
const { rewardCoinType: l, ruleIds:
|
|
859
|
-
for (const
|
|
1011
|
+
const { rewardCoinType: l, ruleIds: p } = u;
|
|
1012
|
+
for (const w of p) {
|
|
860
1013
|
n.has(l) || n.set(l, { assetIds: [], ruleIds: [], amount: 0 });
|
|
861
|
-
const
|
|
862
|
-
|
|
1014
|
+
const m = n.get(l);
|
|
1015
|
+
m.assetIds.push(u.assetCoinType.replace("0x", "")), m.ruleIds.push(w), m.amount += u.userClaimableReward;
|
|
863
1016
|
}
|
|
864
1017
|
}
|
|
865
1018
|
const o = [];
|
|
866
|
-
for (const [u, { assetIds: l, ruleIds:
|
|
867
|
-
const
|
|
868
|
-
(
|
|
1019
|
+
for (const [u, { assetIds: l, ruleIds: p, amount: w }] of n) {
|
|
1020
|
+
const m = r.find(
|
|
1021
|
+
(j) => f(j.suiCoinType) === f(u)
|
|
869
1022
|
);
|
|
870
|
-
if (!
|
|
1023
|
+
if (!m || !m.contract.rewardFundId)
|
|
871
1024
|
throw new Error(`No matching rewardFund found for reward coin: ${u}`);
|
|
872
|
-
const y =
|
|
873
|
-
if (
|
|
1025
|
+
const y = m.contract.rewardFundId;
|
|
1026
|
+
if (c != null && c.accountCap && !c.customCoinReceive)
|
|
874
1027
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
875
|
-
if (
|
|
876
|
-
let
|
|
877
|
-
|
|
1028
|
+
if (c != null && c.customCoinReceive) {
|
|
1029
|
+
let j;
|
|
1030
|
+
c.accountCap ? j = e.moveCall({
|
|
878
1031
|
target: `${t.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
879
1032
|
arguments: [
|
|
880
1033
|
e.object("0x06"),
|
|
@@ -887,13 +1040,13 @@ async function Me(e, a, r) {
|
|
|
887
1040
|
// Reward fund
|
|
888
1041
|
e.pure.vector("string", l),
|
|
889
1042
|
// Asset IDs
|
|
890
|
-
e.pure.vector("address",
|
|
1043
|
+
e.pure.vector("address", p),
|
|
891
1044
|
// Rule IDs
|
|
892
|
-
|
|
1045
|
+
d(c.accountCap, e.object)
|
|
893
1046
|
// Account capability
|
|
894
1047
|
],
|
|
895
1048
|
typeArguments: [u]
|
|
896
|
-
}) :
|
|
1049
|
+
}) : j = e.moveCall({
|
|
897
1050
|
target: `${t.package}::incentive_v3::claim_reward`,
|
|
898
1051
|
arguments: [
|
|
899
1052
|
e.object("0x06"),
|
|
@@ -906,34 +1059,34 @@ async function Me(e, a, r) {
|
|
|
906
1059
|
// Reward fund
|
|
907
1060
|
e.pure.vector("string", l),
|
|
908
1061
|
// Asset IDs
|
|
909
|
-
e.pure.vector("address",
|
|
1062
|
+
e.pure.vector("address", p)
|
|
910
1063
|
// Rule IDs
|
|
911
1064
|
],
|
|
912
1065
|
typeArguments: [u]
|
|
913
1066
|
});
|
|
914
|
-
const [
|
|
1067
|
+
const [_] = e.moveCall({
|
|
915
1068
|
target: "0x2::coin::from_balance",
|
|
916
|
-
arguments: [
|
|
1069
|
+
arguments: [j],
|
|
917
1070
|
typeArguments: [u]
|
|
918
1071
|
});
|
|
919
|
-
if ((
|
|
920
|
-
if (!
|
|
1072
|
+
if ((c == null ? void 0 : c.customCoinReceive.type) === "transfer") {
|
|
1073
|
+
if (!c.customCoinReceive.transfer)
|
|
921
1074
|
throw new Error("customCoinReceive.transfer is required");
|
|
922
1075
|
e.transferObjects(
|
|
923
|
-
[
|
|
924
|
-
|
|
1076
|
+
[_],
|
|
1077
|
+
d(c.customCoinReceive.transfer, e.pure.address)
|
|
925
1078
|
);
|
|
926
1079
|
}
|
|
927
|
-
if ((
|
|
928
|
-
const U = T(
|
|
929
|
-
U.plus(
|
|
930
|
-
[
|
|
931
|
-
e.pure.address(
|
|
932
|
-
) : await
|
|
1080
|
+
if ((c == null ? void 0 : c.customCoinReceive.type) === "depositNAVI") {
|
|
1081
|
+
const U = T(m.totalSupplyAmount).shiftedBy(-9), O = T(m.supplyCapCeiling).shiftedBy(-27);
|
|
1082
|
+
U.plus(w).isGreaterThan(O) && ((s = c == null ? void 0 : c.customCoinReceive.depositNAVI) != null && s.fallbackReceiveAddress) ? e.transferObjects(
|
|
1083
|
+
[_],
|
|
1084
|
+
e.pure.address(c.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
1085
|
+
) : await te(e, m, _, c);
|
|
933
1086
|
} else
|
|
934
1087
|
o.push({
|
|
935
|
-
coin:
|
|
936
|
-
identifier:
|
|
1088
|
+
coin: _,
|
|
1089
|
+
identifier: m
|
|
937
1090
|
});
|
|
938
1091
|
} else
|
|
939
1092
|
e.moveCall({
|
|
@@ -949,7 +1102,7 @@ async function Me(e, a, r) {
|
|
|
949
1102
|
// Reward fund
|
|
950
1103
|
e.pure.vector("string", l),
|
|
951
1104
|
// Asset IDs
|
|
952
|
-
e.pure.vector("address",
|
|
1105
|
+
e.pure.vector("address", p)
|
|
953
1106
|
// Rule IDs
|
|
954
1107
|
],
|
|
955
1108
|
typeArguments: [u]
|
|
@@ -957,63 +1110,63 @@ async function Me(e, a, r) {
|
|
|
957
1110
|
}
|
|
958
1111
|
return o;
|
|
959
1112
|
}
|
|
960
|
-
async function
|
|
961
|
-
const
|
|
1113
|
+
async function Ge(e, a) {
|
|
1114
|
+
const c = await b({
|
|
962
1115
|
...a
|
|
963
1116
|
});
|
|
964
1117
|
return e.moveCall({
|
|
965
|
-
target: `${
|
|
1118
|
+
target: `${c.package}::lending::create_account`,
|
|
966
1119
|
arguments: []
|
|
967
1120
|
});
|
|
968
1121
|
}
|
|
969
1122
|
export {
|
|
970
|
-
|
|
1123
|
+
F as Address,
|
|
971
1124
|
g as DEFAULT_CACHE_TIME,
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1125
|
+
be as FlashLoanAssetConfig,
|
|
1126
|
+
fe as IncentiveAPYInfo,
|
|
1127
|
+
Y as IncentivePoolInfo,
|
|
1128
|
+
ge as IncentivePoolInfoByPhase,
|
|
1129
|
+
ye as OracleInfo,
|
|
1130
|
+
$ as PoolOperator,
|
|
1131
|
+
we as ReserveDataInfo,
|
|
979
1132
|
Q as UserStateInfo,
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1133
|
+
Ce as borrowCoinPTB,
|
|
1134
|
+
Oe as claimLendingRewardsPTB,
|
|
1135
|
+
Ge as createAccountCapPTB,
|
|
1136
|
+
te as depositCoinPTB,
|
|
1137
|
+
Se as filterPriceFeeds,
|
|
1138
|
+
Re as flashloanPTB,
|
|
1139
|
+
S as getAllFlashLoanAssets,
|
|
1140
|
+
Te as getBorrowFee,
|
|
1141
|
+
Pe as getCoins,
|
|
1142
|
+
b as getConfig,
|
|
1143
|
+
ve as getFees,
|
|
1144
|
+
Fe as getFlashLoanAsset,
|
|
1145
|
+
$e as getHealthFactor,
|
|
1146
|
+
ae as getHealthFactorPTB,
|
|
1147
|
+
Ie as getLendingState,
|
|
1148
|
+
v as getPool,
|
|
1149
|
+
V as getPools,
|
|
1150
|
+
ne as getPriceFeeds,
|
|
1151
|
+
re as getPythStalePriceFeedId,
|
|
1152
|
+
ke as getSimulatedHealthFactor,
|
|
1153
|
+
L as getSimulatedHealthFactorPTB,
|
|
1154
|
+
he as getStats,
|
|
1155
|
+
Be as getTransactions,
|
|
1156
|
+
De as getUserAvailableLendingRewards,
|
|
1157
|
+
Ue as getUserClaimedRewardHistory,
|
|
1158
|
+
Me as getUserTotalClaimedReward,
|
|
1159
|
+
Ee as liquidatePTB,
|
|
1160
|
+
Ae as mergeCoinsPTB,
|
|
1161
|
+
f as normalizeCoinType,
|
|
1162
|
+
d as parseTxValue,
|
|
1163
|
+
_e as repayCoinPTB,
|
|
1164
|
+
Ne as repayFlashLoanPTB,
|
|
1165
|
+
Le as summaryLendingRewards,
|
|
1166
|
+
Ve as updateOraclePricesPTB,
|
|
1167
|
+
ce as updatePythPriceFeeds,
|
|
1168
|
+
I as withCache,
|
|
1169
|
+
C as withSingleton,
|
|
1170
|
+
je as withdrawCoinPTB
|
|
1018
1171
|
};
|
|
1019
1172
|
//# sourceMappingURL=index.esm.js.map
|