@naviprotocol/lending 1.3.0-dev.5 → 1.3.0-dev.7
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 +654 -536
- package/dist/index.esm.js.map +1 -1
- package/dist/liquidate.d.ts.map +1 -1
- package/dist/pool.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,660 +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 N, SuiPythClient 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
8
|
import { bcs as h } from "@mysten/sui/bcs";
|
|
9
|
-
const
|
|
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
|
-
}), fe =
|
|
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
135
|
function E(e) {
|
|
136
|
-
const
|
|
137
|
-
return e.forEach((
|
|
138
|
-
const
|
|
139
|
-
if (typeof
|
|
140
|
-
const { client: n, disableCache: o, cacheTime:
|
|
141
|
-
|
|
136
|
+
const a = [];
|
|
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
|
+
a.push(u);
|
|
142
142
|
} else
|
|
143
|
-
|
|
144
|
-
}), JSON.stringify(
|
|
143
|
+
a.push(c);
|
|
144
|
+
}), JSON.stringify(a);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
return (...
|
|
149
|
-
const t = E(
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
})),
|
|
146
|
+
function C(e) {
|
|
147
|
+
const a = {};
|
|
148
|
+
return (...c) => {
|
|
149
|
+
const t = E(c);
|
|
150
|
+
return a[t] || (a[t] = e(...c).finally(() => {
|
|
151
|
+
a[t] = null;
|
|
152
|
+
})), a[t];
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
let
|
|
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(...
|
|
155
|
+
function I(e) {
|
|
156
|
+
let a = {};
|
|
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((
|
|
167
|
-
(
|
|
168
|
-
...
|
|
169
|
-
[W(
|
|
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
|
+
...a,
|
|
169
|
+
[W(c)]: P(e[c])
|
|
170
170
|
}),
|
|
171
171
|
{}
|
|
172
172
|
) : e;
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
return typeof e == "object" ? e :
|
|
174
|
+
function d(e, a) {
|
|
175
|
+
return typeof e == "object" ? e : a(e);
|
|
176
176
|
}
|
|
177
|
-
function X(e,
|
|
178
|
-
return typeof
|
|
177
|
+
function X(e, a) {
|
|
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
|
|
192
|
-
const
|
|
193
|
-
return
|
|
191
|
+
function D(e) {
|
|
192
|
+
const a = (e || 0) / Math.pow(10, 27);
|
|
193
|
+
return a > Math.pow(10, 5) ? 1 / 0 : a;
|
|
194
194
|
}
|
|
195
195
|
new N("https://hermes.pyth.network", {
|
|
196
196
|
timeout: 2e4
|
|
197
197
|
});
|
|
198
|
-
const Z = 27, R = (e,
|
|
199
|
-
if (!Number(e) || !Number(
|
|
200
|
-
const
|
|
201
|
-
return new T(e).multipliedBy(new T(
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
198
|
+
const Z = 27, R = (e, a) => {
|
|
199
|
+
if (!Number(e) || !Number(a)) return new T(0);
|
|
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-dev.7", 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}`;
|
|
207
|
+
return (await fetch(a).then((t) => t.json())).data;
|
|
206
208
|
})
|
|
207
209
|
), g = 1e3 * 60 * 5;
|
|
208
|
-
var
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
return (await fetch(
|
|
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) => {
|
|
213
|
+
const a = `https://open-api.naviprotocol.io/api/navi/pools?env=${(e == null ? void 0 : e.env) || "prod"}`;
|
|
214
|
+
return (await fetch(a).then((t) => t.json())).data;
|
|
213
215
|
})
|
|
214
216
|
);
|
|
215
|
-
async function v(e,
|
|
216
|
-
const
|
|
217
|
-
...
|
|
217
|
+
async function v(e, a) {
|
|
218
|
+
const c = await V({
|
|
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 v(
|
|
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]
|
|
275
|
-
}), n.id === 0 && e.moveCall({
|
|
276
|
-
target: `${
|
|
277
|
+
}), r.version === 2 && n.id === 0 && e.moveCall({
|
|
278
|
+
target: `${r.package}::pool::refresh_stake`,
|
|
277
279
|
arguments: [e.object(n.contract.pool), e.object("0x05")]
|
|
278
280
|
}), e;
|
|
279
281
|
}
|
|
280
|
-
async function
|
|
281
|
-
const
|
|
282
|
+
async function je(e, a, c, t) {
|
|
283
|
+
const r = await b({
|
|
282
284
|
...t,
|
|
283
285
|
cacheTime: g
|
|
284
|
-
}), n = await v(
|
|
285
|
-
let
|
|
286
|
-
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) {
|
|
287
324
|
const [l] = e.moveCall({
|
|
288
|
-
target: `${
|
|
325
|
+
target: `${r.package}::incentive_v3::withdraw_with_account_cap_v2`,
|
|
289
326
|
arguments: [
|
|
290
327
|
e.object("0x06"),
|
|
291
|
-
e.object(
|
|
292
|
-
e.object(
|
|
328
|
+
e.object(r.priceOracle),
|
|
329
|
+
e.object(r.storage),
|
|
293
330
|
e.object(n.contract.pool),
|
|
294
331
|
e.pure.u8(n.id),
|
|
295
332
|
o,
|
|
296
|
-
e.object(
|
|
297
|
-
e.object(
|
|
298
|
-
|
|
333
|
+
e.object(r.incentiveV2),
|
|
334
|
+
e.object(r.incentiveV3),
|
|
335
|
+
d(t.accountCap, e.object),
|
|
299
336
|
e.object("0x05")
|
|
300
337
|
],
|
|
301
338
|
typeArguments: [n.suiCoinType]
|
|
302
339
|
});
|
|
303
|
-
|
|
340
|
+
s = l;
|
|
304
341
|
} else {
|
|
305
342
|
const [l] = e.moveCall({
|
|
306
|
-
target: `${
|
|
343
|
+
target: `${r.package}::incentive_v3::withdraw_v2`,
|
|
307
344
|
arguments: [
|
|
308
345
|
e.object("0x06"),
|
|
309
|
-
e.object(
|
|
310
|
-
e.object(
|
|
346
|
+
e.object(r.priceOracle),
|
|
347
|
+
e.object(r.storage),
|
|
311
348
|
e.object(n.contract.pool),
|
|
312
349
|
e.pure.u8(n.id),
|
|
313
350
|
o,
|
|
314
|
-
e.object(
|
|
315
|
-
e.object(
|
|
351
|
+
e.object(r.incentiveV2),
|
|
352
|
+
e.object(r.incentiveV3),
|
|
316
353
|
e.object("0x05")
|
|
317
354
|
],
|
|
318
355
|
typeArguments: [n.suiCoinType]
|
|
319
356
|
});
|
|
320
|
-
|
|
357
|
+
s = l;
|
|
321
358
|
}
|
|
322
359
|
return e.moveCall({
|
|
323
360
|
target: "0x2::coin::from_balance",
|
|
324
|
-
arguments: [
|
|
361
|
+
arguments: [s],
|
|
325
362
|
typeArguments: [n.suiCoinType]
|
|
326
363
|
});
|
|
327
364
|
}
|
|
328
|
-
async function
|
|
329
|
-
const
|
|
365
|
+
async function Ce(e, a, c, t) {
|
|
366
|
+
const r = await b({
|
|
330
367
|
...t,
|
|
331
368
|
cacheTime: g
|
|
332
|
-
}), n = await v(
|
|
333
|
-
let
|
|
334
|
-
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) {
|
|
335
407
|
const [l] = e.moveCall({
|
|
336
|
-
target: `${
|
|
408
|
+
target: `${r.package}::incentive_v3::borrow_with_account_cap_v2`,
|
|
337
409
|
arguments: [
|
|
338
410
|
e.object("0x06"),
|
|
339
|
-
e.object(
|
|
340
|
-
e.object(
|
|
411
|
+
e.object(r.priceOracle),
|
|
412
|
+
e.object(r.storage),
|
|
341
413
|
e.object(n.contract.pool),
|
|
342
414
|
e.pure.u8(n.id),
|
|
343
415
|
o,
|
|
344
|
-
e.object(
|
|
345
|
-
e.object(
|
|
346
|
-
|
|
416
|
+
e.object(r.incentiveV2),
|
|
417
|
+
e.object(r.incentiveV3),
|
|
418
|
+
d(t.accountCap, e.object),
|
|
347
419
|
e.object("0x05")
|
|
348
420
|
],
|
|
349
421
|
typeArguments: [n.suiCoinType]
|
|
350
422
|
});
|
|
351
|
-
|
|
423
|
+
s = l;
|
|
352
424
|
} else {
|
|
353
425
|
const [l] = e.moveCall({
|
|
354
|
-
target: `${
|
|
426
|
+
target: `${r.package}::incentive_v3::borrow_v2`,
|
|
355
427
|
arguments: [
|
|
356
428
|
e.object("0x06"),
|
|
357
|
-
e.object(
|
|
358
|
-
e.object(
|
|
429
|
+
e.object(r.priceOracle),
|
|
430
|
+
e.object(r.storage),
|
|
359
431
|
e.object(n.contract.pool),
|
|
360
432
|
e.pure.u8(n.id),
|
|
361
433
|
o,
|
|
362
|
-
e.object(
|
|
363
|
-
e.object(
|
|
434
|
+
e.object(r.incentiveV2),
|
|
435
|
+
e.object(r.incentiveV3),
|
|
364
436
|
e.object("0x05")
|
|
365
437
|
],
|
|
366
438
|
typeArguments: [n.suiCoinType]
|
|
367
439
|
});
|
|
368
|
-
|
|
440
|
+
s = l;
|
|
369
441
|
}
|
|
370
442
|
return e.moveCall({
|
|
371
443
|
target: "0x2::coin::from_balance",
|
|
372
|
-
arguments: [e.object(
|
|
444
|
+
arguments: [e.object(s)],
|
|
373
445
|
typeArguments: [n.suiCoinType]
|
|
374
446
|
});
|
|
375
447
|
}
|
|
376
|
-
async function
|
|
377
|
-
const
|
|
448
|
+
async function _e(e, a, c, t) {
|
|
449
|
+
const r = await b({
|
|
378
450
|
...t,
|
|
379
451
|
cacheTime: g
|
|
380
|
-
}), n = await v(
|
|
381
|
-
if (
|
|
452
|
+
}), n = await v(a, t), o = typeof c == "object" && c.$kind === "GasCoin";
|
|
453
|
+
if (f(n.suiCoinType) === f("0x2::sui::SUI") && o) {
|
|
382
454
|
if (!(t != null && t.amount))
|
|
383
455
|
throw new Error("Amount is required for sui coin");
|
|
384
|
-
|
|
456
|
+
c = e.splitCoins(c, [t.amount]);
|
|
385
457
|
}
|
|
386
|
-
let
|
|
387
|
-
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({
|
|
388
460
|
target: "0x2::coin::value",
|
|
389
|
-
arguments: [
|
|
461
|
+
arguments: [d(c, e.object)],
|
|
390
462
|
typeArguments: [n.suiCoinType]
|
|
391
463
|
}), t != null && t.accountCap ? e.moveCall({
|
|
392
|
-
target: `${
|
|
464
|
+
target: `${r.package}::incentive_v3::repay_with_account_cap`,
|
|
393
465
|
arguments: [
|
|
394
466
|
e.object("0x06"),
|
|
395
|
-
e.object(
|
|
396
|
-
e.object(
|
|
467
|
+
e.object(r.priceOracle),
|
|
468
|
+
e.object(r.storage),
|
|
397
469
|
e.object(n.contract.pool),
|
|
398
470
|
e.pure.u8(n.id),
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
e.object(
|
|
402
|
-
e.object(
|
|
403
|
-
|
|
471
|
+
d(c, e.object),
|
|
472
|
+
s,
|
|
473
|
+
e.object(r.incentiveV2),
|
|
474
|
+
e.object(r.incentiveV3),
|
|
475
|
+
d(t.accountCap, e.object)
|
|
404
476
|
],
|
|
405
477
|
typeArguments: [n.suiCoinType]
|
|
406
478
|
}) : e.moveCall({
|
|
407
|
-
target: `${
|
|
479
|
+
target: `${r.package}::incentive_v3::entry_repay`,
|
|
408
480
|
arguments: [
|
|
409
481
|
e.object("0x06"),
|
|
410
|
-
e.object(
|
|
411
|
-
e.object(
|
|
482
|
+
e.object(r.priceOracle),
|
|
483
|
+
e.object(r.storage),
|
|
412
484
|
e.object(n.contract.pool),
|
|
413
485
|
e.pure.u8(n.id),
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
e.object(
|
|
417
|
-
e.object(
|
|
486
|
+
d(c, e.object),
|
|
487
|
+
s,
|
|
488
|
+
e.object(r.incentiveV2),
|
|
489
|
+
e.object(r.incentiveV3)
|
|
418
490
|
],
|
|
419
491
|
typeArguments: [n.suiCoinType]
|
|
420
492
|
}), e;
|
|
421
493
|
}
|
|
422
|
-
const
|
|
423
|
-
|
|
494
|
+
const Te = I(
|
|
495
|
+
C(
|
|
424
496
|
async (e) => {
|
|
425
|
-
var
|
|
426
|
-
const
|
|
497
|
+
var r;
|
|
498
|
+
const a = await b({
|
|
427
499
|
...e
|
|
428
500
|
});
|
|
429
501
|
if (e != null && e.address && typeof (e == null ? void 0 : e.asset) != "undefined")
|
|
430
502
|
try {
|
|
431
|
-
const n = await v(e.asset, e), o = (
|
|
432
|
-
|
|
433
|
-
target: `${
|
|
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`,
|
|
434
506
|
arguments: [
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
507
|
+
s.object(a.incentiveV3),
|
|
508
|
+
s.pure.address(e.address),
|
|
509
|
+
s.pure.u8(n.id),
|
|
510
|
+
s.pure.u64(1e4)
|
|
439
511
|
],
|
|
440
512
|
typeArguments: []
|
|
441
513
|
});
|
|
442
514
|
const u = await o.devInspectTransactionBlock({
|
|
443
|
-
transactionBlock:
|
|
515
|
+
transactionBlock: s,
|
|
444
516
|
sender: e.address
|
|
445
|
-
}), l =
|
|
517
|
+
}), l = B(u, [h.u64()]);
|
|
446
518
|
return (Number(l[0]) || 0) / 100;
|
|
447
519
|
} catch (n) {
|
|
448
520
|
console.error(n);
|
|
449
521
|
}
|
|
450
|
-
const t = (await
|
|
451
|
-
id:
|
|
522
|
+
const t = (await A.getObject({
|
|
523
|
+
id: a.incentiveV3,
|
|
452
524
|
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
453
525
|
})).data.content.fields.borrow_fee_rate;
|
|
454
526
|
return Number(t) / 100;
|
|
455
527
|
}
|
|
456
528
|
)
|
|
457
529
|
);
|
|
458
|
-
function
|
|
459
|
-
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;
|
|
460
532
|
let n = 0;
|
|
461
533
|
const o = [];
|
|
462
|
-
let
|
|
463
|
-
if (
|
|
464
|
-
if (!(t && n >=
|
|
465
|
-
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)
|
|
466
538
|
throw new Error("All coins must be of the same type");
|
|
467
539
|
n += Number(l.balance), o.push(l.coinObjectId);
|
|
468
540
|
}
|
|
469
541
|
}), o.length === 0)
|
|
470
542
|
throw new Error("No coins to merge");
|
|
471
|
-
if (t && n <
|
|
543
|
+
if (t && n < r)
|
|
472
544
|
throw new Error(
|
|
473
|
-
`Balance is less than the specified balance: ${n} < ${
|
|
545
|
+
`Balance is less than the specified balance: ${n} < ${r}`
|
|
474
546
|
);
|
|
475
|
-
if (
|
|
476
|
-
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;
|
|
477
549
|
const u = o.length === 1 ? e.object(o[0]) : e.mergeCoins(o[0], o.slice(1));
|
|
478
|
-
return t ? e.splitCoins(u, [e.pure.u64(
|
|
550
|
+
return t ? e.splitCoins(u, [e.pure.u64(r)]) : u;
|
|
479
551
|
}
|
|
480
|
-
async function
|
|
481
|
-
const
|
|
552
|
+
async function L(e, a, c, t, r, n, o) {
|
|
553
|
+
const s = await b({
|
|
482
554
|
...o,
|
|
483
555
|
cacheTime: g
|
|
484
|
-
}), u = await v(
|
|
556
|
+
}), u = await v(c, o);
|
|
485
557
|
return e.moveCall({
|
|
486
|
-
target: `${
|
|
558
|
+
target: `${s.uiGetter}::calculator_unchecked::dynamic_health_factor`,
|
|
487
559
|
arguments: [
|
|
488
560
|
e.object("0x06"),
|
|
489
|
-
e.object(
|
|
490
|
-
e.object(
|
|
561
|
+
e.object(s.storage),
|
|
562
|
+
e.object(s.oracle.priceOracle),
|
|
491
563
|
X(e, u),
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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)
|
|
497
569
|
],
|
|
498
570
|
typeArguments: [u.suiCoinType]
|
|
499
571
|
});
|
|
500
572
|
}
|
|
501
|
-
async function
|
|
502
|
-
return
|
|
573
|
+
async function ae(e, a, c) {
|
|
574
|
+
return L(e, a, 0, 0, 0, !1, c);
|
|
503
575
|
}
|
|
504
|
-
const
|
|
505
|
-
async (e,
|
|
576
|
+
const Ie = I(
|
|
577
|
+
async (e, a) => {
|
|
506
578
|
var l;
|
|
507
|
-
const
|
|
508
|
-
...
|
|
579
|
+
const c = await b({
|
|
580
|
+
...a,
|
|
509
581
|
cacheTime: g
|
|
510
|
-
}), t = new
|
|
582
|
+
}), t = new k(), r = (l = a == null ? void 0 : a.client) != null ? l : A, n = await V(a);
|
|
511
583
|
t.moveCall({
|
|
512
|
-
target: `${
|
|
513
|
-
arguments: [t.object(
|
|
584
|
+
target: `${c.uiGetter}::getter_unchecked::get_user_state`,
|
|
585
|
+
arguments: [t.object(c.storage), t.pure.address(e)]
|
|
514
586
|
});
|
|
515
|
-
const o = await
|
|
587
|
+
const o = await r.devInspectTransactionBlock({
|
|
516
588
|
transactionBlock: t,
|
|
517
589
|
sender: e
|
|
518
|
-
}),
|
|
519
|
-
return
|
|
520
|
-
|
|
521
|
-
).map((
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
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
|
|
525
597
|
).toString(), y = R(
|
|
526
|
-
|
|
527
|
-
|
|
598
|
+
p.borrowBalance,
|
|
599
|
+
w.currentBorrowIndex
|
|
528
600
|
).toString();
|
|
529
601
|
return {
|
|
530
|
-
...
|
|
531
|
-
supplyBalance:
|
|
602
|
+
...p,
|
|
603
|
+
supplyBalance: m,
|
|
532
604
|
borrowBalance: y,
|
|
533
|
-
pool:
|
|
605
|
+
pool: w
|
|
534
606
|
};
|
|
535
|
-
}).filter((
|
|
607
|
+
}).filter((p) => !!p.pool);
|
|
536
608
|
}
|
|
537
609
|
);
|
|
538
|
-
async function
|
|
610
|
+
async function $e(e, a) {
|
|
539
611
|
var o;
|
|
540
|
-
const
|
|
541
|
-
await
|
|
542
|
-
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({
|
|
543
615
|
transactionBlock: t,
|
|
544
616
|
sender: e
|
|
545
|
-
}), n =
|
|
546
|
-
return
|
|
617
|
+
}), n = B(r, [h.u256()]);
|
|
618
|
+
return D(Number(n[0]) || 0);
|
|
547
619
|
}
|
|
548
|
-
async function
|
|
549
|
-
var
|
|
550
|
-
const
|
|
551
|
-
let o = 0,
|
|
552
|
-
const u = await v(
|
|
553
|
-
if (
|
|
554
|
-
y.type ===
|
|
555
|
-
}), 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)
|
|
556
628
|
throw new Error("Invalid operations");
|
|
557
|
-
const l = o > 0 ||
|
|
558
|
-
await
|
|
629
|
+
const l = o > 0 || s > 0;
|
|
630
|
+
await L(
|
|
559
631
|
n,
|
|
560
632
|
e,
|
|
561
633
|
u,
|
|
562
634
|
Math.abs(o),
|
|
563
|
-
Math.abs(
|
|
635
|
+
Math.abs(s),
|
|
564
636
|
l,
|
|
565
637
|
t
|
|
566
638
|
);
|
|
567
|
-
const
|
|
639
|
+
const p = await r.devInspectTransactionBlock({
|
|
568
640
|
transactionBlock: n,
|
|
569
641
|
sender: e
|
|
570
|
-
}),
|
|
571
|
-
return
|
|
642
|
+
}), w = B(p, [h.u256()]);
|
|
643
|
+
return D(Number(w[0]) || 0);
|
|
572
644
|
}
|
|
573
|
-
const
|
|
574
|
-
async (e,
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
const t = `https://open-api.naviprotocol.io/api/navi/user/transactions?${
|
|
645
|
+
const Be = C(
|
|
646
|
+
async (e, a) => {
|
|
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()}`;
|
|
578
650
|
return (await fetch(t).then((n) => n.json())).data;
|
|
579
651
|
}
|
|
580
652
|
);
|
|
581
|
-
async function
|
|
653
|
+
async function Pe(e, a) {
|
|
582
654
|
var n;
|
|
583
|
-
let
|
|
584
|
-
const t = [],
|
|
655
|
+
let c = null;
|
|
656
|
+
const t = [], r = (n = a == null ? void 0 : a.client) != null ? n : A;
|
|
585
657
|
do {
|
|
586
658
|
let o;
|
|
587
|
-
if (
|
|
659
|
+
if (a != null && a.coinType ? o = await r.getCoins({
|
|
588
660
|
owner: e,
|
|
589
|
-
coinType:
|
|
590
|
-
cursor:
|
|
661
|
+
coinType: a == null ? void 0 : a.coinType,
|
|
662
|
+
cursor: c,
|
|
591
663
|
limit: 100
|
|
592
|
-
}) : o = await
|
|
664
|
+
}) : o = await r.getAllCoins({
|
|
593
665
|
owner: e,
|
|
594
|
-
cursor:
|
|
666
|
+
cursor: c,
|
|
595
667
|
limit: 100
|
|
596
668
|
}), !o.data || !o.data.length)
|
|
597
669
|
break;
|
|
598
|
-
t.push(...o.data),
|
|
599
|
-
} while (
|
|
670
|
+
t.push(...o.data), c = o.nextCursor;
|
|
671
|
+
} while (c);
|
|
600
672
|
return t;
|
|
601
673
|
}
|
|
602
674
|
const M = new N("https://hermes.pyth.network", {
|
|
603
675
|
timeout: 1e4
|
|
604
676
|
});
|
|
605
|
-
async function
|
|
677
|
+
async function re(e) {
|
|
606
678
|
try {
|
|
607
|
-
const
|
|
608
|
-
if (!
|
|
679
|
+
const a = [], c = await M.getLatestPriceFeeds(e);
|
|
680
|
+
if (!c) return a;
|
|
609
681
|
const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
610
|
-
for (const
|
|
611
|
-
const n =
|
|
682
|
+
for (const r of c) {
|
|
683
|
+
const n = r.getPriceUnchecked();
|
|
612
684
|
if (n.publishTime > t) {
|
|
613
685
|
console.warn(
|
|
614
|
-
`pyth price feed is invalid, id: ${
|
|
686
|
+
`pyth price feed is invalid, id: ${r.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
|
|
615
687
|
);
|
|
616
688
|
continue;
|
|
617
689
|
}
|
|
618
|
-
t -
|
|
619
|
-
`stale price feed, id: ${
|
|
620
|
-
),
|
|
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));
|
|
621
693
|
}
|
|
622
|
-
return
|
|
623
|
-
} catch (
|
|
624
|
-
throw new Error(`failed to get pyth stale price feed id, msg: ${
|
|
694
|
+
return a;
|
|
695
|
+
} catch (a) {
|
|
696
|
+
throw new Error(`failed to get pyth stale price feed id, msg: ${a.message}`);
|
|
625
697
|
}
|
|
626
698
|
}
|
|
627
|
-
async function
|
|
699
|
+
async function ce(e, a, c) {
|
|
628
700
|
var n;
|
|
629
|
-
const t = (n =
|
|
630
|
-
...
|
|
701
|
+
const t = (n = c == null ? void 0 : c.client) != null ? n : A, r = await b({
|
|
702
|
+
...c,
|
|
631
703
|
cacheTime: g
|
|
632
704
|
});
|
|
633
705
|
try {
|
|
634
|
-
const o = await M.getPriceFeedsUpdateData(
|
|
635
|
-
return await new
|
|
706
|
+
const o = await M.getPriceFeedsUpdateData(a);
|
|
707
|
+
return await new K(
|
|
636
708
|
t,
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
).updatePriceFeeds(e, o,
|
|
709
|
+
r.oracle.pythStateId,
|
|
710
|
+
r.oracle.wormholeStateId
|
|
711
|
+
).updatePriceFeeds(e, o, a);
|
|
640
712
|
} catch (o) {
|
|
641
713
|
throw new Error(`failed to update pyth price feeds, msg: ${o.message}`);
|
|
642
714
|
}
|
|
643
715
|
}
|
|
644
|
-
async function
|
|
645
|
-
const t = await
|
|
646
|
-
...
|
|
716
|
+
async function Ve(e, a, c) {
|
|
717
|
+
const t = await b({
|
|
718
|
+
...c,
|
|
647
719
|
cacheTime: g
|
|
648
720
|
});
|
|
649
|
-
if (
|
|
650
|
-
const
|
|
721
|
+
if (c != null && c.updatePythPriceFeeds) {
|
|
722
|
+
const r = a.filter((n) => !!n.pythPriceFeedId).map((n) => n.pythPriceFeedId);
|
|
651
723
|
try {
|
|
652
|
-
const n = await
|
|
653
|
-
n.length > 0 && await
|
|
724
|
+
const n = await re(r);
|
|
725
|
+
n.length > 0 && await ce(e, n, c);
|
|
654
726
|
} catch {
|
|
655
727
|
}
|
|
656
728
|
}
|
|
657
|
-
for (const
|
|
729
|
+
for (const r of a)
|
|
658
730
|
e.moveCall({
|
|
659
731
|
target: `${t.oracle.packageId}::oracle_pro::update_single_price`,
|
|
660
732
|
arguments: [
|
|
@@ -666,69 +738,82 @@ async function $e(e, r, a) {
|
|
|
666
738
|
// Price oracle contract
|
|
667
739
|
e.object(t.oracle.supraOracleHolder),
|
|
668
740
|
// Supra oracle holder
|
|
669
|
-
e.object(
|
|
741
|
+
e.object(r.pythPriceInfoObject),
|
|
670
742
|
// Pyth price info object
|
|
671
|
-
e.pure.address(
|
|
743
|
+
e.pure.address(r.feedId)
|
|
672
744
|
// Price feed ID
|
|
673
745
|
]
|
|
674
746
|
});
|
|
675
747
|
return e;
|
|
676
748
|
}
|
|
677
|
-
async function
|
|
678
|
-
return (await
|
|
749
|
+
async function ne(e) {
|
|
750
|
+
return (await b({
|
|
679
751
|
...e,
|
|
680
752
|
cacheTime: g
|
|
681
753
|
})).oracle.feeds;
|
|
682
754
|
}
|
|
683
|
-
function
|
|
684
|
-
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)));
|
|
685
757
|
}
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
const
|
|
689
|
-
return Object.keys(
|
|
690
|
-
...
|
|
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],
|
|
691
763
|
coinType: t
|
|
692
764
|
}));
|
|
693
765
|
})
|
|
694
766
|
);
|
|
695
|
-
async function
|
|
696
|
-
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;
|
|
697
769
|
}
|
|
698
|
-
async function
|
|
699
|
-
const
|
|
770
|
+
async function Re(e, a, c, t) {
|
|
771
|
+
const r = await b({
|
|
700
772
|
...t,
|
|
701
773
|
cacheTime: g
|
|
702
|
-
}), n = await v(
|
|
703
|
-
if (!(await
|
|
774
|
+
}), n = await v(a, t);
|
|
775
|
+
if (!(await S({
|
|
704
776
|
...t,
|
|
705
777
|
cacheTime: g
|
|
706
778
|
})).some(
|
|
707
|
-
(
|
|
779
|
+
(u) => f(u.coinType) === f(n.suiCoinType)
|
|
708
780
|
))
|
|
709
781
|
throw new Error("Pool does not support flashloan");
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
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
|
+
}
|
|
721
806
|
}
|
|
722
|
-
async function
|
|
723
|
-
const n = await
|
|
724
|
-
...
|
|
807
|
+
async function Ne(e, a, c, t, r) {
|
|
808
|
+
const n = await b({
|
|
809
|
+
...r,
|
|
725
810
|
cacheTime: g
|
|
726
|
-
}), o = await v(
|
|
727
|
-
if (!(await
|
|
728
|
-
...
|
|
811
|
+
}), o = await v(a, r);
|
|
812
|
+
if (!(await S({
|
|
813
|
+
...r,
|
|
729
814
|
cacheTime: g
|
|
730
815
|
})).some(
|
|
731
|
-
(
|
|
816
|
+
(p) => f(p.coinType) === f(o.suiCoinType)
|
|
732
817
|
))
|
|
733
818
|
throw new Error("Pool does not support flashloan");
|
|
734
819
|
const [l] = e.moveCall({
|
|
@@ -737,58 +822,91 @@ async function Ve(e, r, a, t, c) {
|
|
|
737
822
|
e.object("0x06"),
|
|
738
823
|
e.object(n.storage),
|
|
739
824
|
e.object(o.contract.pool),
|
|
740
|
-
|
|
741
|
-
|
|
825
|
+
d(c, e.object),
|
|
826
|
+
d(t, e.object)
|
|
742
827
|
],
|
|
743
828
|
typeArguments: [o.suiCoinType]
|
|
744
829
|
});
|
|
745
830
|
return [l];
|
|
746
831
|
}
|
|
747
|
-
async function
|
|
832
|
+
async function Ee(e, a, c, t, r, n) {
|
|
748
833
|
const o = {
|
|
749
834
|
...n,
|
|
750
835
|
cacheTime: g
|
|
751
|
-
},
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
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
|
+
}
|
|
782
900
|
}
|
|
783
|
-
async function
|
|
784
|
-
var
|
|
785
|
-
const
|
|
786
|
-
...
|
|
901
|
+
async function De(e, a) {
|
|
902
|
+
var p;
|
|
903
|
+
const c = await ne(a), t = await V({
|
|
904
|
+
...a,
|
|
787
905
|
cacheTime: g
|
|
788
|
-
}),
|
|
789
|
-
...
|
|
906
|
+
}), r = (p = a == null ? void 0 : a.client) != null ? p : A, n = await b({
|
|
907
|
+
...a,
|
|
790
908
|
cacheTime: g
|
|
791
|
-
}), o = new
|
|
909
|
+
}), o = new k();
|
|
792
910
|
o.moveCall({
|
|
793
911
|
target: `${n.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
|
|
794
912
|
arguments: [
|
|
@@ -802,11 +920,11 @@ async function Ne(e, r) {
|
|
|
802
920
|
// User address
|
|
803
921
|
]
|
|
804
922
|
});
|
|
805
|
-
const
|
|
923
|
+
const s = await r.devInspectTransactionBlock({
|
|
806
924
|
transactionBlock: o,
|
|
807
925
|
sender: e
|
|
808
|
-
}), u =
|
|
809
|
-
|
|
926
|
+
}), u = B(
|
|
927
|
+
s,
|
|
810
928
|
[
|
|
811
929
|
h.vector(h.string()),
|
|
812
930
|
// Asset coin types
|
|
@@ -821,95 +939,95 @@ async function Ne(e, r) {
|
|
|
821
939
|
]
|
|
822
940
|
), l = [];
|
|
823
941
|
if (u.length === 5 && Array.isArray(u[0])) {
|
|
824
|
-
const
|
|
825
|
-
for (let
|
|
826
|
-
const y =
|
|
827
|
-
(
|
|
828
|
-
),
|
|
829
|
-
(
|
|
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])
|
|
830
948
|
);
|
|
831
|
-
!y || !
|
|
832
|
-
assetId:
|
|
833
|
-
assetCoinType:
|
|
834
|
-
rewardCoinType:
|
|
835
|
-
option: Number(u[2][
|
|
836
|
-
userClaimableReward: Number(u[4][
|
|
837
|
-
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]]
|
|
838
956
|
});
|
|
839
957
|
}
|
|
840
958
|
}
|
|
841
959
|
return l;
|
|
842
960
|
}
|
|
843
|
-
function
|
|
844
|
-
const
|
|
961
|
+
function Le(e) {
|
|
962
|
+
const a = /* @__PURE__ */ new Map();
|
|
845
963
|
e.forEach((t) => {
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
assetId:
|
|
964
|
+
const r = t.assetId, n = t.option, o = `${r}-${n}-${t.rewardCoinType}`;
|
|
965
|
+
a.has(o) ? a.get(o).total += t.userClaimableReward : a.set(o, {
|
|
966
|
+
assetId: r,
|
|
849
967
|
rewardType: n,
|
|
850
968
|
coinType: t.rewardCoinType,
|
|
851
969
|
total: Number(t.userClaimableReward)
|
|
852
970
|
});
|
|
853
971
|
});
|
|
854
|
-
const
|
|
855
|
-
for (const { assetId: t, rewardType:
|
|
856
|
-
const
|
|
857
|
-
|
|
858
|
-
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);
|
|
859
977
|
u.rewards.set(n, (u.rewards.get(n) || 0) + o);
|
|
860
978
|
}
|
|
861
|
-
return Array.from(
|
|
979
|
+
return Array.from(c.values()).map((t) => ({
|
|
862
980
|
assetId: t.assetId,
|
|
863
981
|
rewardType: t.rewardType,
|
|
864
|
-
rewards: Array.from(t.rewards.entries()).map(([
|
|
865
|
-
coinType:
|
|
982
|
+
rewards: Array.from(t.rewards.entries()).map(([r, n]) => ({
|
|
983
|
+
coinType: r,
|
|
866
984
|
available: n.toFixed(6)
|
|
867
985
|
}))
|
|
868
986
|
}));
|
|
869
987
|
}
|
|
870
|
-
const
|
|
988
|
+
const Me = C(
|
|
871
989
|
async (e) => {
|
|
872
|
-
const
|
|
873
|
-
return (await fetch(
|
|
990
|
+
const a = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}`;
|
|
991
|
+
return (await fetch(a).then((t) => t.json())).data;
|
|
874
992
|
}
|
|
875
|
-
),
|
|
876
|
-
async (e,
|
|
877
|
-
const
|
|
878
|
-
return
|
|
993
|
+
), Ue = C(
|
|
994
|
+
async (e, a) => {
|
|
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({
|
|
879
997
|
data: t.data.rewards
|
|
880
998
|
});
|
|
881
999
|
}
|
|
882
1000
|
);
|
|
883
|
-
async function
|
|
884
|
-
var
|
|
885
|
-
const t = await
|
|
886
|
-
...
|
|
1001
|
+
async function Oe(e, a, c) {
|
|
1002
|
+
var s;
|
|
1003
|
+
const t = await b({
|
|
1004
|
+
...c,
|
|
887
1005
|
cacheTime: g
|
|
888
|
-
}),
|
|
889
|
-
...
|
|
1006
|
+
}), r = await V({
|
|
1007
|
+
...c,
|
|
890
1008
|
cacheTime: g
|
|
891
1009
|
}), n = /* @__PURE__ */ new Map();
|
|
892
|
-
for (const u of
|
|
893
|
-
const { rewardCoinType: l, ruleIds:
|
|
894
|
-
for (const
|
|
1010
|
+
for (const u of a) {
|
|
1011
|
+
const { rewardCoinType: l, ruleIds: p } = u;
|
|
1012
|
+
for (const w of p) {
|
|
895
1013
|
n.has(l) || n.set(l, { assetIds: [], ruleIds: [], amount: 0 });
|
|
896
|
-
const
|
|
897
|
-
|
|
1014
|
+
const m = n.get(l);
|
|
1015
|
+
m.assetIds.push(u.assetCoinType.replace("0x", "")), m.ruleIds.push(w), m.amount += u.userClaimableReward;
|
|
898
1016
|
}
|
|
899
1017
|
}
|
|
900
1018
|
const o = [];
|
|
901
|
-
for (const [u, { assetIds: l, ruleIds:
|
|
902
|
-
const
|
|
903
|
-
(
|
|
1019
|
+
for (const [u, { assetIds: l, ruleIds: p, amount: w }] of n) {
|
|
1020
|
+
const m = r.find(
|
|
1021
|
+
(j) => f(j.suiCoinType) === f(u)
|
|
904
1022
|
);
|
|
905
|
-
if (!
|
|
1023
|
+
if (!m || !m.contract.rewardFundId)
|
|
906
1024
|
throw new Error(`No matching rewardFund found for reward coin: ${u}`);
|
|
907
|
-
const y =
|
|
908
|
-
if (
|
|
1025
|
+
const y = m.contract.rewardFundId;
|
|
1026
|
+
if (c != null && c.accountCap && !c.customCoinReceive)
|
|
909
1027
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
910
|
-
if (
|
|
911
|
-
let
|
|
912
|
-
|
|
1028
|
+
if (c != null && c.customCoinReceive) {
|
|
1029
|
+
let j;
|
|
1030
|
+
c.accountCap ? j = e.moveCall({
|
|
913
1031
|
target: `${t.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
914
1032
|
arguments: [
|
|
915
1033
|
e.object("0x06"),
|
|
@@ -922,13 +1040,13 @@ async function Me(e, r, a) {
|
|
|
922
1040
|
// Reward fund
|
|
923
1041
|
e.pure.vector("string", l),
|
|
924
1042
|
// Asset IDs
|
|
925
|
-
e.pure.vector("address",
|
|
1043
|
+
e.pure.vector("address", p),
|
|
926
1044
|
// Rule IDs
|
|
927
|
-
|
|
1045
|
+
d(c.accountCap, e.object)
|
|
928
1046
|
// Account capability
|
|
929
1047
|
],
|
|
930
1048
|
typeArguments: [u]
|
|
931
|
-
}) :
|
|
1049
|
+
}) : j = e.moveCall({
|
|
932
1050
|
target: `${t.package}::incentive_v3::claim_reward`,
|
|
933
1051
|
arguments: [
|
|
934
1052
|
e.object("0x06"),
|
|
@@ -941,34 +1059,34 @@ async function Me(e, r, a) {
|
|
|
941
1059
|
// Reward fund
|
|
942
1060
|
e.pure.vector("string", l),
|
|
943
1061
|
// Asset IDs
|
|
944
|
-
e.pure.vector("address",
|
|
1062
|
+
e.pure.vector("address", p)
|
|
945
1063
|
// Rule IDs
|
|
946
1064
|
],
|
|
947
1065
|
typeArguments: [u]
|
|
948
1066
|
});
|
|
949
|
-
const [
|
|
1067
|
+
const [_] = e.moveCall({
|
|
950
1068
|
target: "0x2::coin::from_balance",
|
|
951
|
-
arguments: [
|
|
1069
|
+
arguments: [j],
|
|
952
1070
|
typeArguments: [u]
|
|
953
1071
|
});
|
|
954
|
-
if ((
|
|
955
|
-
if (!
|
|
1072
|
+
if ((c == null ? void 0 : c.customCoinReceive.type) === "transfer") {
|
|
1073
|
+
if (!c.customCoinReceive.transfer)
|
|
956
1074
|
throw new Error("customCoinReceive.transfer is required");
|
|
957
1075
|
e.transferObjects(
|
|
958
|
-
[
|
|
959
|
-
|
|
1076
|
+
[_],
|
|
1077
|
+
d(c.customCoinReceive.transfer, e.pure.address)
|
|
960
1078
|
);
|
|
961
1079
|
}
|
|
962
|
-
if ((
|
|
963
|
-
const U = T(
|
|
964
|
-
U.plus(
|
|
965
|
-
[
|
|
966
|
-
e.pure.address(
|
|
967
|
-
) : 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);
|
|
968
1086
|
} else
|
|
969
1087
|
o.push({
|
|
970
|
-
coin:
|
|
971
|
-
identifier:
|
|
1088
|
+
coin: _,
|
|
1089
|
+
identifier: m
|
|
972
1090
|
});
|
|
973
1091
|
} else
|
|
974
1092
|
e.moveCall({
|
|
@@ -984,7 +1102,7 @@ async function Me(e, r, a) {
|
|
|
984
1102
|
// Reward fund
|
|
985
1103
|
e.pure.vector("string", l),
|
|
986
1104
|
// Asset IDs
|
|
987
|
-
e.pure.vector("address",
|
|
1105
|
+
e.pure.vector("address", p)
|
|
988
1106
|
// Rule IDs
|
|
989
1107
|
],
|
|
990
1108
|
typeArguments: [u]
|
|
@@ -992,63 +1110,63 @@ async function Me(e, r, a) {
|
|
|
992
1110
|
}
|
|
993
1111
|
return o;
|
|
994
1112
|
}
|
|
995
|
-
async function
|
|
996
|
-
const
|
|
997
|
-
...
|
|
1113
|
+
async function Ge(e, a) {
|
|
1114
|
+
const c = await b({
|
|
1115
|
+
...a
|
|
998
1116
|
});
|
|
999
1117
|
return e.moveCall({
|
|
1000
|
-
target: `${
|
|
1118
|
+
target: `${c.package}::lending::create_account`,
|
|
1001
1119
|
arguments: []
|
|
1002
1120
|
});
|
|
1003
1121
|
}
|
|
1004
1122
|
export {
|
|
1005
|
-
|
|
1123
|
+
F as Address,
|
|
1006
1124
|
g as DEFAULT_CACHE_TIME,
|
|
1007
|
-
|
|
1125
|
+
be as FlashLoanAssetConfig,
|
|
1008
1126
|
fe as IncentiveAPYInfo,
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1127
|
+
Y as IncentivePoolInfo,
|
|
1128
|
+
ge as IncentivePoolInfoByPhase,
|
|
1129
|
+
ye as OracleInfo,
|
|
1130
|
+
$ as PoolOperator,
|
|
1131
|
+
we as ReserveDataInfo,
|
|
1014
1132
|
Q as UserStateInfo,
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
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,
|
|
1030
1148
|
v as getPool,
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
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
|
|
1053
1171
|
};
|
|
1054
1172
|
//# sourceMappingURL=index.esm.js.map
|