@naviprotocol/multiply 0.2.0-preview.20261124.2 → 0.2.0-preview.20261124.4
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/README.md +70 -46
- package/dist/amounts.d.ts +3 -3
- package/dist/amounts.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +406 -344
- package/dist/client.js.map +1 -1
- package/dist/converters.d.ts.map +1 -1
- package/dist/converters.js +221 -199
- package/dist/converters.js.map +1 -1
- package/dist/data-source.d.ts +2 -1
- package/dist/data-source.d.ts.map +1 -1
- package/dist/data-source.js +210 -196
- package/dist/data-source.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/dist/market-prices.d.ts +8 -0
- package/dist/market-prices.d.ts.map +1 -0
- package/dist/market-prices.js +45 -0
- package/dist/market-prices.js.map +1 -0
- package/dist/native-redemption.d.ts +13 -0
- package/dist/native-redemption.d.ts.map +1 -0
- package/dist/native-redemption.js +154 -0
- package/dist/native-redemption.js.map +1 -0
- package/dist/planner.d.ts +4 -1
- package/dist/planner.d.ts.map +1 -1
- package/dist/planner.js +437 -341
- package/dist/planner.js.map +1 -1
- package/dist/rate-hints.d.ts +8 -0
- package/dist/rate-hints.d.ts.map +1 -0
- package/dist/rate-hints.js +58 -0
- package/dist/rate-hints.js.map +1 -0
- package/dist/types.d.ts +41 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/data-source.js
CHANGED
|
@@ -1,295 +1,309 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { marketOraclePrices as W } from "./market-prices.js";
|
|
2
|
+
import { Transaction as N } from "@mysten/sui/transactions";
|
|
3
|
+
import { bcs as u } from "@mysten/sui/bcs";
|
|
4
|
+
import { SuiGrpcClient as H } from "@mysten/sui/grpc";
|
|
5
|
+
import { ReserveDataInfo as K, UserStateInfo as J, getConfig as G, getMarket as Q, getAllFlashLoanAssets as X, updateOraclePricesPTB as Z } from "@naviprotocol/lending";
|
|
6
|
+
import { jsonCopy as ee, check as s, coinType as M, sameCoin as j, inspect as x, RAY as P, BN as h, address as k, MultiplyError as L, recordReadVersion as te } from "./utils.js";
|
|
7
|
+
import { lendingToRaw as q, tokenDecimals as S } from "./amounts.js";
|
|
8
|
+
import { resolveEMode as re } from "./emode.js";
|
|
9
|
+
import { normalizeEnv as ae, normalizeCapRegistry as se, MAINNET_CAP_REGISTRY as ne, indexRegistryStrategies as oe, registryKeyString as z, assertRegistryUsable as ie, accountCapType as ce, decodeRegistryEntries as le } from "./cap-registry.js";
|
|
10
|
+
import { ACCOUNT_CAP_TYPE as Ee } from "./cap-registry.js";
|
|
11
|
+
import { strategies as de } from "./strategies.js";
|
|
12
|
+
const Y = (n) => n.ratioOracleId !== void 0 && n.ratioOracleId !== null;
|
|
13
|
+
function ue(n, y) {
|
|
14
|
+
const b = [];
|
|
14
15
|
for (const D of /* @__PURE__ */ new Set([
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
M(y.collateralCoinType),
|
|
17
|
+
M(y.debtCoinType)
|
|
17
18
|
])) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const T = n.filter((C) => j(C.coinType, D)), R = T.filter((C) => !Y(C)), E = T.filter(Y);
|
|
20
|
+
s(
|
|
21
|
+
R.length === 1,
|
|
21
22
|
"MARKET_UNSUPPORTED",
|
|
22
|
-
`Expected one own price feed for ${D}, found ${
|
|
23
|
-
),
|
|
24
|
-
|
|
23
|
+
`Expected one own price feed for ${D}, found ${R.length}`
|
|
24
|
+
), s(
|
|
25
|
+
E.length <= 1,
|
|
25
26
|
"MARKET_UNSUPPORTED",
|
|
26
|
-
`Expected at most one ratio feed for ${D}, found ${
|
|
27
|
-
),
|
|
27
|
+
`Expected at most one ratio feed for ${D}, found ${E.length}`
|
|
28
|
+
), b.push(R[0], ...E);
|
|
28
29
|
}
|
|
29
|
-
return
|
|
30
|
+
return b;
|
|
30
31
|
}
|
|
31
|
-
const
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
),
|
|
36
|
-
|
|
37
|
-
[...
|
|
32
|
+
const ge = () => new H({ network: "mainnet", baseUrl: "https://fullnode.mainnet.sui.io:443" });
|
|
33
|
+
function he(n = {}) {
|
|
34
|
+
const y = ae(n.env), b = n.client ?? ge(), D = n.capRegistry !== void 0, T = se(n.capRegistry ?? ne), R = oe(
|
|
35
|
+
ee(n.strategies ?? Object.values(de))
|
|
36
|
+
), E = new Set((n.retiredRegistryKeys ?? []).map(z));
|
|
37
|
+
s(
|
|
38
|
+
[...E].every((a) => !R.has(a)),
|
|
38
39
|
"INVALID_ARGUMENT",
|
|
39
40
|
"Active and retired Registry keys overlap"
|
|
40
41
|
);
|
|
41
|
-
const
|
|
42
|
-
services:
|
|
42
|
+
const C = n.measure ?? ((a, g) => g()), O = {
|
|
43
|
+
services: n.services,
|
|
43
44
|
disableCache: !0,
|
|
44
|
-
...
|
|
45
|
+
...n.env === void 0 ? {} : { env: y }
|
|
45
46
|
};
|
|
46
|
-
async function
|
|
47
|
-
const
|
|
48
|
-
await
|
|
49
|
-
...
|
|
50
|
-
market:
|
|
51
|
-
client:
|
|
47
|
+
async function $(a, g, t) {
|
|
48
|
+
const o = ue(t.config.oracle.feeds, g);
|
|
49
|
+
await Z(a, o, {
|
|
50
|
+
...O,
|
|
51
|
+
market: g.market,
|
|
52
|
+
client: b,
|
|
52
53
|
updatePythPriceFeeds: !0
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const B = {
|
|
57
|
+
marketPriceMode: n.marketPriceMode,
|
|
58
|
+
prepareOracle: $,
|
|
59
|
+
capRegistry: T,
|
|
60
|
+
env: y,
|
|
61
|
+
async listAccountCaps(a) {
|
|
62
|
+
a = k(a), ie(y, D);
|
|
63
|
+
const g = ce(y);
|
|
62
64
|
try {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
target: `${
|
|
66
|
-
arguments: [
|
|
65
|
+
const t = new N();
|
|
66
|
+
t.setSender(a), t.moveCall({
|
|
67
|
+
target: `${T.packageId}::multiply_registry::find_user_mul_account_caps`,
|
|
68
|
+
arguments: [t.object(T.objectId), t.pure.address(a)]
|
|
67
69
|
});
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
const o = n.onReadEvidence ? {} : void 0, p = await x(b, t, o), c = le(p[0]?.returnValues);
|
|
71
|
+
s(
|
|
72
|
+
c.every((r) => r.capId !== k("0x0")),
|
|
71
73
|
"INVALID_ACCOUNT_CAP",
|
|
72
74
|
"Registry contains a zero Cap"
|
|
73
|
-
),
|
|
74
|
-
new Set(
|
|
75
|
+
), s(
|
|
76
|
+
new Set(c.map((r) => r.capId)).size === c.length,
|
|
75
77
|
"DUPLICATE_ACCOUNT_CAP",
|
|
76
78
|
"One Cap is registered to multiple strategies"
|
|
77
79
|
);
|
|
78
|
-
const
|
|
79
|
-
(
|
|
80
|
-
),
|
|
81
|
-
const
|
|
82
|
-
return
|
|
83
|
-
|
|
80
|
+
const m = c.filter(
|
|
81
|
+
(r) => !E.has(z(r.registryKey))
|
|
82
|
+
), f = m.map((r) => {
|
|
83
|
+
const e = `${r.registryKey.strategyNumericId}:${r.registryKey.strategyVersion}`, l = R.get(e);
|
|
84
|
+
return s(
|
|
85
|
+
l,
|
|
84
86
|
"UNSUPPORTED_REGISTRY_STRATEGY",
|
|
85
|
-
`Unknown Multiply Registry strategy: ${
|
|
86
|
-
),
|
|
87
|
-
|
|
87
|
+
`Unknown Multiply Registry strategy: ${e}`
|
|
88
|
+
), s(
|
|
89
|
+
r.capId !== k("0x0"),
|
|
88
90
|
"INVALID_ACCOUNT_CAP",
|
|
89
91
|
"Registry contains a zero Cap"
|
|
90
|
-
),
|
|
92
|
+
), l;
|
|
91
93
|
});
|
|
92
|
-
|
|
93
|
-
new Set(
|
|
94
|
+
s(
|
|
95
|
+
new Set(m.map((r) => r.capId)).size === m.length,
|
|
94
96
|
"DUPLICATE_ACCOUNT_CAP",
|
|
95
97
|
"One Cap is registered to multiple strategies"
|
|
96
98
|
);
|
|
97
|
-
const
|
|
98
|
-
for (let
|
|
99
|
-
const
|
|
100
|
-
objectIds:
|
|
99
|
+
const _ = /* @__PURE__ */ new Map();
|
|
100
|
+
for (let r = 0; r < m.length; r += 50) {
|
|
101
|
+
const e = m.slice(r, r + 50).map((d) => d.capId), l = await b.core.getObjects({
|
|
102
|
+
objectIds: e,
|
|
101
103
|
include: { content: !0 }
|
|
102
104
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
s(
|
|
106
|
+
l.objects.length === e.length,
|
|
105
107
|
"READ_FAILED",
|
|
106
108
|
"Incomplete Cap object response"
|
|
107
109
|
);
|
|
108
|
-
for (const d of
|
|
109
|
-
|
|
110
|
+
for (const d of l.objects) {
|
|
111
|
+
s(
|
|
110
112
|
!(d instanceof Error),
|
|
111
113
|
"INVALID_ACCOUNT_CAP",
|
|
112
114
|
"Registered Cap is unavailable"
|
|
113
115
|
);
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
const w = k(d.objectId);
|
|
117
|
+
s(
|
|
118
|
+
e.includes(w) && !_.has(w),
|
|
117
119
|
"READ_FAILED",
|
|
118
120
|
"Unexpected or duplicate Cap response"
|
|
119
|
-
),
|
|
121
|
+
), _.set(w, d);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
|
-
const I = /* @__PURE__ */ new Set(),
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const I = /* @__PURE__ */ new Set(), v = u.struct("AccountCap", { id: u.Address, owner: u.Address }), i = m.map((r, e) => {
|
|
125
|
+
const l = _.get(r.capId);
|
|
126
|
+
s(
|
|
127
|
+
l && M(l.type) === g,
|
|
126
128
|
"INVALID_ACCOUNT_CAP",
|
|
127
129
|
"Registry object is not an AccountCap"
|
|
128
|
-
),
|
|
129
|
-
|
|
130
|
+
), s(
|
|
131
|
+
l.owner.$kind === "AddressOwner" && k(l.owner.AddressOwner) === a,
|
|
130
132
|
"INVALID_ACCOUNT_CAP",
|
|
131
133
|
"Registered Cap is not owned by this wallet"
|
|
132
134
|
);
|
|
133
135
|
let d;
|
|
134
136
|
try {
|
|
135
|
-
d =
|
|
137
|
+
d = v.parse(l.content);
|
|
136
138
|
} catch {
|
|
137
|
-
throw new
|
|
139
|
+
throw new L("INVALID_ACCOUNT_CAP", "Invalid AccountCap content");
|
|
138
140
|
}
|
|
139
|
-
return
|
|
140
|
-
d.id ===
|
|
141
|
+
return s(
|
|
142
|
+
d.id === r.capId && d.owner !== k("0x0"),
|
|
141
143
|
"INVALID_ACCOUNT_CAP",
|
|
142
144
|
"Invalid AccountCap identity"
|
|
143
|
-
),
|
|
145
|
+
), s(
|
|
144
146
|
!I.has(d.owner),
|
|
145
147
|
"DUPLICATE_ACCOUNT_CAP",
|
|
146
148
|
"Multiple strategies share one lending account"
|
|
147
|
-
), I.add(d.owner),
|
|
148
|
-
id:
|
|
149
|
+
), I.add(d.owner), o && te(o, r.capId, l.version), {
|
|
150
|
+
id: r.capId,
|
|
149
151
|
accountOwner: d.owner,
|
|
150
|
-
strategyId:
|
|
151
|
-
registryKey: { ...
|
|
152
|
+
strategyId: f[e].id,
|
|
153
|
+
registryKey: { ...r.registryKey }
|
|
152
154
|
};
|
|
153
155
|
});
|
|
154
|
-
return
|
|
155
|
-
} catch (
|
|
156
|
-
throw
|
|
156
|
+
return o && n.onReadEvidence?.("caps", o), i;
|
|
157
|
+
} catch (t) {
|
|
158
|
+
throw t instanceof L ? t : new L("READ_FAILED", "Unable to read complete Multiply Registry snapshot");
|
|
157
159
|
}
|
|
158
160
|
},
|
|
159
|
-
async readMarket(
|
|
160
|
-
const [
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
]),
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
async readMarket(a, g = n.marketPriceMode ?? "live") {
|
|
162
|
+
const [t, o, p, c] = await Promise.all([
|
|
163
|
+
C("market_config", () => G({ ...O, market: a.market })),
|
|
164
|
+
C("market_pools", () => Q(a.market, O)),
|
|
165
|
+
C("flash_config", () => G({ ...O, market: "main" })),
|
|
166
|
+
C("flash_assets", () => X({ ...O, market: "main" }))
|
|
167
|
+
]), m = o.pools, f = m.find((A) => j(A.suiCoinType, a.collateralCoinType)), _ = m.find((A) => j(A.suiCoinType, a.debtCoinType)), I = c.find((A) => j(A.coinType, a.debtCoinType));
|
|
168
|
+
s(
|
|
169
|
+
f && _ && I,
|
|
168
170
|
"MARKET_UNSUPPORTED",
|
|
169
171
|
"Missing collateral, debt or main-market flash liquidity"
|
|
170
|
-
),
|
|
171
|
-
|
|
172
|
+
), s(
|
|
173
|
+
t.version === 2 && t.limter,
|
|
172
174
|
"MARKET_UNSUPPORTED",
|
|
173
175
|
"Requires lending v2 and an on-chain HF limiter"
|
|
174
176
|
);
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
config:
|
|
179
|
-
...
|
|
180
|
-
collateral:
|
|
181
|
-
debt:
|
|
177
|
+
const v = await re(b, a, t, o, f, _);
|
|
178
|
+
S(f), S(_);
|
|
179
|
+
const i = {
|
|
180
|
+
config: t,
|
|
181
|
+
...v ? { emode: { id: v.emodeId, active: v.isActive } } : {},
|
|
182
|
+
collateral: f,
|
|
183
|
+
debt: _,
|
|
182
184
|
collateralPrice: "",
|
|
183
185
|
debtPrice: "",
|
|
184
186
|
ltv: "",
|
|
185
187
|
liquidationThreshold: "",
|
|
186
188
|
borrowWeight: "",
|
|
187
189
|
flash: {
|
|
188
|
-
config:
|
|
189
|
-
poolId:
|
|
190
|
-
max:
|
|
191
|
-
min:
|
|
190
|
+
config: p,
|
|
191
|
+
poolId: I.poolId,
|
|
192
|
+
max: I.max,
|
|
193
|
+
min: I.min,
|
|
192
194
|
feeBps: "0"
|
|
193
195
|
},
|
|
194
196
|
observedAt: Date.now()
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
}, r = g === "live" ? void 0 : await C(
|
|
198
|
+
"market_price_validate",
|
|
199
|
+
async () => W(a, t, y, f, _)
|
|
200
|
+
);
|
|
201
|
+
s(
|
|
202
|
+
r || g !== "market-only",
|
|
203
|
+
"PRICE_DATA_UNAVAILABLE",
|
|
204
|
+
"Fresh market oracle prices are required"
|
|
205
|
+
), r && Object.assign(i, r);
|
|
206
|
+
const e = new N();
|
|
207
|
+
r || await C("market_oracle", () => $(e, a, i));
|
|
208
|
+
const l = r ? [] : [f, _].map((A) => {
|
|
209
|
+
const F = e.getData().commands.length;
|
|
210
|
+
return e.moveCall({
|
|
211
|
+
target: `${t.package}::calculator::calculate_value`,
|
|
201
212
|
arguments: [
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
213
|
+
e.object("0x6"),
|
|
214
|
+
e.object(t.priceOracle),
|
|
215
|
+
e.pure.u256("1000000000000000000"),
|
|
216
|
+
e.pure.u8(A.oracleId)
|
|
206
217
|
]
|
|
207
|
-
}),
|
|
208
|
-
}),
|
|
209
|
-
|
|
210
|
-
target: `${
|
|
211
|
-
arguments: [
|
|
212
|
-
}),
|
|
213
|
-
target: `${
|
|
214
|
-
arguments: [
|
|
215
|
-
}),
|
|
216
|
-
target: `${
|
|
217
|
-
typeArguments: [
|
|
218
|
-
arguments: [
|
|
218
|
+
}), F;
|
|
219
|
+
}), d = e.getData().commands.length;
|
|
220
|
+
e.moveCall({
|
|
221
|
+
target: `${t.uiGetter}::getter::get_reserve_data`,
|
|
222
|
+
arguments: [e.object(t.storage)]
|
|
223
|
+
}), e.moveCall({
|
|
224
|
+
target: `${t.package}::storage::get_borrow_weight`,
|
|
225
|
+
arguments: [e.object(t.storage), e.pure.u8(_.id)]
|
|
226
|
+
}), e.moveCall({
|
|
227
|
+
target: `${p.package}::flash_loan::get_asset`,
|
|
228
|
+
typeArguments: [a.debtCoinType],
|
|
229
|
+
arguments: [e.object(p.flashloanConfig)]
|
|
219
230
|
});
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
231
|
+
const w = await C(
|
|
232
|
+
r ? "market_risk_inspect" : "market_inspect",
|
|
233
|
+
() => x(b, e)
|
|
234
|
+
), U = w[d + 2].returnValues;
|
|
235
|
+
s(
|
|
236
|
+
u.Address.parse(U[3].bcs) === I.poolId,
|
|
223
237
|
"READ_FAILED",
|
|
224
238
|
"Flash pool differs from live configuration"
|
|
225
|
-
),
|
|
226
|
-
|
|
227
|
-
).div("1e18").toFixed(),
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
const
|
|
231
|
-
|
|
239
|
+
), i.flash.feeBps = (BigInt(u.u64().parse(U[4].bcs)) + BigInt(u.u64().parse(U[5].bcs))).toString(), i.flash.max = u.u64().parse(U[6].bcs), i.flash.min = u.u64().parse(U[7].bcs), r || (i.collateralPrice = new h(
|
|
240
|
+
u.u256().parse(w[l[0]].returnValues[0].bcs)
|
|
241
|
+
).div("1e18").toFixed(), i.debtPrice = new h(u.u256().parse(w[l[1]].returnValues[0].bcs)).div("1e18").toFixed());
|
|
242
|
+
const V = u.vector(K).parse(w[d].returnValues[0].bcs).find((A) => A.id === f.id);
|
|
243
|
+
if (s(V, "READ_FAILED", "Missing collateral risk parameters"), i.ltv = new h(V.ltv).div(P.toString()).toFixed(), i.liquidationThreshold = new h(V.liquidation_threshold).div(P.toString()).toFixed(), v) {
|
|
244
|
+
const A = v.assets.find((F) => F.assetId === f.id);
|
|
245
|
+
i.ltv = new h(A.ltv).toFixed(), i.liquidationThreshold = new h(A.lt).toFixed();
|
|
232
246
|
}
|
|
233
|
-
return
|
|
247
|
+
return i.borrowWeight = new h(u.u64().parse(w[d + 1].returnValues[0].bcs)).div(1e4).toFixed(), i.observedAt = Date.now(), i;
|
|
234
248
|
},
|
|
235
|
-
async readPosition(
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
target: `${
|
|
239
|
-
arguments: [
|
|
240
|
-
}),
|
|
241
|
-
target: `${
|
|
242
|
-
arguments: [
|
|
243
|
-
}),
|
|
244
|
-
target: `${
|
|
245
|
-
arguments: [
|
|
249
|
+
async readPosition(a, g, t) {
|
|
250
|
+
const o = t ?? await B.readMarket(g), { config: p } = o, c = new N();
|
|
251
|
+
c.moveCall({
|
|
252
|
+
target: `${p.package}::lending::update_state_of_user`,
|
|
253
|
+
arguments: [c.object("0x6"), c.object(p.storage), c.pure.address(a.accountOwner)]
|
|
254
|
+
}), c.moveCall({
|
|
255
|
+
target: `${p.uiGetter}::getter::get_reserve_data`,
|
|
256
|
+
arguments: [c.object(p.storage)]
|
|
257
|
+
}), c.moveCall({
|
|
258
|
+
target: `${p.uiGetter}::getter_unchecked::get_user_state`,
|
|
259
|
+
arguments: [c.object(p.storage), c.pure.address(a.accountOwner)]
|
|
246
260
|
});
|
|
247
|
-
const
|
|
248
|
-
let
|
|
249
|
-
for (const
|
|
250
|
-
|
|
251
|
-
(
|
|
261
|
+
const m = n.onReadEvidence ? {} : void 0, f = await x(b, c, m), _ = u.vector(K).parse(f[1].returnValues[0].bcs), I = u.vector(J).parse(f[2].returnValues[0].bcs);
|
|
262
|
+
let v = "0", i = "0";
|
|
263
|
+
for (const e of I) {
|
|
264
|
+
s(
|
|
265
|
+
(e.asset_id === o.collateral.id || BigInt(e.supply_balance) === 0n) && (e.asset_id === o.debt.id || BigInt(e.borrow_balance) === 0n),
|
|
252
266
|
"POSITION_UNSUPPORTED",
|
|
253
267
|
"Account contains assets outside this strategy"
|
|
254
268
|
);
|
|
255
|
-
const
|
|
256
|
-
|
|
269
|
+
const l = _.find((d) => d.id === e.asset_id);
|
|
270
|
+
s(l, "READ_FAILED", "Position references an unknown reserve"), e.asset_id === o.collateral.id && (v = ((BigInt(e.supply_balance) * BigInt(l.supply_index) + P / 2n) / P).toString()), e.asset_id === o.debt.id && (i = ((BigInt(e.borrow_balance) * BigInt(l.borrow_index) + P / 2n) / P).toString());
|
|
257
271
|
}
|
|
258
|
-
const
|
|
259
|
-
collateralAmount:
|
|
260
|
-
debtAmount:
|
|
261
|
-
protocolCollateralAmount:
|
|
262
|
-
protocolDebtAmount:
|
|
272
|
+
const r = {
|
|
273
|
+
collateralAmount: q(v, S(o.collateral)),
|
|
274
|
+
debtAmount: q(i, S(o.debt), !0),
|
|
275
|
+
protocolCollateralAmount: v,
|
|
276
|
+
protocolDebtAmount: i
|
|
263
277
|
};
|
|
264
|
-
return
|
|
278
|
+
return m && n.onReadEvidence?.("position", m), r;
|
|
265
279
|
},
|
|
266
|
-
async readBorrowFeeBps(
|
|
267
|
-
const
|
|
268
|
-
target: `${
|
|
280
|
+
async readBorrowFeeBps(a, g) {
|
|
281
|
+
const t = new N(), o = g ? t.pure.address(g) : t.moveCall({
|
|
282
|
+
target: `${a.config.package}::account::account_owner`,
|
|
269
283
|
arguments: [
|
|
270
|
-
|
|
284
|
+
t.moveCall({ target: `${a.config.package}::lending::create_account` })
|
|
271
285
|
]
|
|
272
|
-
}),
|
|
273
|
-
|
|
274
|
-
target: `${
|
|
286
|
+
}), p = t.getData().commands.length;
|
|
287
|
+
t.moveCall({
|
|
288
|
+
target: `${a.config.package}::incentive_v3::get_borrow_fee_v2`,
|
|
275
289
|
arguments: [
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
290
|
+
t.object(a.config.incentiveV3),
|
|
291
|
+
o,
|
|
292
|
+
t.pure.u8(a.debt.id),
|
|
293
|
+
t.pure.u64(1e4)
|
|
280
294
|
]
|
|
281
295
|
});
|
|
282
|
-
const
|
|
283
|
-
return
|
|
296
|
+
const c = await x(b, t);
|
|
297
|
+
return u.u64().parse(c[p].returnValues[0].bcs);
|
|
284
298
|
}
|
|
285
299
|
};
|
|
286
|
-
return
|
|
300
|
+
return B;
|
|
287
301
|
}
|
|
288
302
|
export {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
303
|
+
Ee as ACCOUNT_CAP_TYPE,
|
|
304
|
+
he as createNaviDataSource,
|
|
305
|
+
ge as defaultClient,
|
|
306
|
+
Y as isRatioFeed,
|
|
307
|
+
ue as selectStrategyFeeds
|
|
294
308
|
};
|
|
295
309
|
//# sourceMappingURL=data-source.js.map
|