@naviprotocol/multiply 0.2.0-preview.20261118.2 → 0.2.0-preview.20261123.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/README.md +31 -12
- package/dist/amounts.d.ts +7 -1
- package/dist/amounts.d.ts.map +1 -1
- package/dist/amounts.js +49 -24
- package/dist/amounts.js.map +1 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +433 -372
- package/dist/client.js.map +1 -1
- package/dist/converters.d.ts +1 -0
- package/dist/converters.d.ts.map +1 -1
- package/dist/converters.js +231 -156
- package/dist/converters.js.map +1 -1
- package/dist/data-source.d.ts +4 -0
- package/dist/data-source.d.ts.map +1 -1
- package/dist/data-source.js +179 -195
- package/dist/data-source.js.map +1 -1
- package/dist/emode.d.ts +7 -0
- package/dist/emode.d.ts.map +1 -0
- package/dist/emode.js +95 -0
- package/dist/emode.js.map +1 -0
- package/dist/funding.d.ts.map +1 -1
- package/dist/funding.js +34 -29
- package/dist/funding.js.map +1 -1
- package/dist/planner.d.ts +1 -1
- package/dist/planner.d.ts.map +1 -1
- package/dist/planner.js +193 -184
- package/dist/planner.js.map +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +66 -52
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ quotes and builds transactions; it never signs or broadcasts them.
|
|
|
6
6
|
## Phase 1 model
|
|
7
7
|
|
|
8
8
|
The application owns product registration. Supply its validated `Strategy[]` to
|
|
9
|
-
`createMultiplyClient
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
`createMultiplyClient`. The API's phase 1 directory includes vSUI/SUI, haSUI/SUI,
|
|
10
|
+
and USDSUI/USDC. The application passes retired Registry keys alongside the active
|
|
11
|
+
strategies so wallet reads skip retired AccountCaps.
|
|
12
12
|
|
|
13
13
|
A strategy has distinct collateral and debt tokens. `principalCoinType` can equal
|
|
14
14
|
either. It is the accounting/default withdrawal unit, independent of the selected
|
|
@@ -24,17 +24,17 @@ const multiply = createMultiplyClient({
|
|
|
24
24
|
strategies: productStrategies,
|
|
25
25
|
retiredRegistryKeys: retiredProductKeys,
|
|
26
26
|
})
|
|
27
|
-
const strategy = productStrategies.find(s => s.id === '
|
|
27
|
+
const strategy = productStrategies.find(s => s.id === 'main-vsui-sui')!
|
|
28
28
|
const quote = await multiply.quote(
|
|
29
29
|
address,
|
|
30
30
|
strategy,
|
|
31
31
|
{ type: 'open', inputCoinType: strategy.collateralCoinType,
|
|
32
|
-
amount: '1000000000', targetLeverage: '
|
|
33
|
-
{ minHealthFactor: '
|
|
32
|
+
amount: '1000000000', targetLeverage: '1.5' },
|
|
33
|
+
{ minHealthFactor: '2.0', maxSlippageBps: 50 },
|
|
34
34
|
)
|
|
35
35
|
const tx = new Transaction()
|
|
36
36
|
const built = await multiply.buildPTB(tx, quote, {
|
|
37
|
-
coins: [{ coinType: strategy.collateralCoinType, coin:
|
|
37
|
+
coins: [{ coinType: strategy.collateralCoinType, coin: suppliedVsuiCoin }],
|
|
38
38
|
})
|
|
39
39
|
if (built.createdAccountCap) tx.transferObjects([built.createdAccountCap], address)
|
|
40
40
|
if (built.coins.length) tx.transferObjects(built.coins.map(c => c.coin), address)
|
|
@@ -83,7 +83,7 @@ Collateral input is supplied directly; only borrowed debt is converted. Debt
|
|
|
83
83
|
input may merge with debt flash funding before conversion. A 1x collateral opening
|
|
84
84
|
needs no conversion or flash loan. On a collateral-principal withdrawal/close,
|
|
85
85
|
only the collateral required for debt repayment is sold; the remainder is returned
|
|
86
|
-
as principal. Debt dust remains a separate output.
|
|
86
|
+
as principal. Debt dust remains a separate output.
|
|
87
87
|
|
|
88
88
|
The builder independently validates funding, conversion roles, projected balances,
|
|
89
89
|
repayment math and minimum principal output. Different token types never merge.
|
|
@@ -113,8 +113,8 @@ safe integer range. When using the converter directly, pass a validated
|
|
|
113
113
|
|
|
114
114
|
Keys `(strategyNumericId, strategyVersion)` are permanent execution identities,
|
|
115
115
|
unique per registry definition. Never reassign a deployed key to different assets
|
|
116
|
-
or market. New Caps are created and registered atomically; close retains the Cap.
|
|
117
|
-
Invalid ownership, duplicate Caps/accounts,
|
|
116
|
+
or market/mode. New Caps are created and registered atomically; close retains the Cap.
|
|
117
|
+
Invalid ownership, duplicate Caps/accounts, invalid E-Mode configuration and unknown keys
|
|
118
118
|
fail explicitly. Only **explicit** `retiredRegistryKeys` may be skipped; structural,
|
|
119
119
|
identity and duplicate checks still run first. Retiring a key does not move funds.
|
|
120
120
|
|
|
@@ -134,8 +134,8 @@ The API consequently reports lifetime yield unavailable until a conforming sourc
|
|
|
134
134
|
and complete history watermark are available. Basic positions and risk still work.
|
|
135
135
|
|
|
136
136
|
Custom adapters are trusted application code. Built-in contract deployments target
|
|
137
|
-
Sui mainnet; changing only the client URL does not switch those addresses.
|
|
138
|
-
|
|
137
|
+
Sui mainnet; changing only the client URL does not switch those addresses.
|
|
138
|
+
Isolated phase 2, third-token inputs and delayed redemption are out of scope.
|
|
139
139
|
The exported `strategies.vsuiSui`/`hasuiSui` remain legacy dedicated-market presets
|
|
140
140
|
(keys 1:1/2:1); phase 1 products must use the API-owned main-market registry.
|
|
141
141
|
|
|
@@ -161,3 +161,22 @@ threshold fallback and malformed/retired identities. Historical documents under
|
|
|
161
161
|
phase 1 hosted simulation or signed-wallet acceptance. Each product must progress
|
|
162
162
|
through open simulation → human sample creation → management simulation → human
|
|
163
163
|
management/close, with matching Registry keys and source/artifact revisions.
|
|
164
|
+
|
|
165
|
+
### Strategy E-Mode
|
|
166
|
+
|
|
167
|
+
Set `Strategy.emodeId` together with `market` to use that market's E-Mode (ID `0`
|
|
168
|
+
is valid). `getMarket()` supplies the configured group's collateral LTV/LT;
|
|
169
|
+
debt retains its reserve borrow weight. The data source checks asset direction.
|
|
170
|
+
|
|
171
|
+
Use a **new Multiply Registry strategyVersion** when switching a strategy's mode,
|
|
172
|
+
and retire the previous key through `retiredRegistryKeys`. Existing ordinary Caps
|
|
173
|
+
are not migrated. A newly created Cap enters the configured mode in the same PTB,
|
|
174
|
+
before Multiply registration and funding. A previously initialized Cap, including
|
|
175
|
+
an empty one reopened after close, is reused without a mode query or another enter.
|
|
176
|
+
No operation reads or writes the independent E-Mode Registry.
|
|
177
|
+
|
|
178
|
+
Custom DataSources must return `market.emode = { id, active }` for E-Mode strategies,
|
|
179
|
+
alongside their effective risk parameters. Paused groups disable new exposure;
|
|
180
|
+
the default source can read only that group's configuration to support repayment
|
|
181
|
+
and exit, without reading any account's current mode. Keep the existing final-byte
|
|
182
|
+
simulation requirement, especially with `buildPTBForSimulation`.
|
package/dist/amounts.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { Pool } from '@naviprotocol/lending';
|
|
2
|
-
import { MarketSnapshot, PositionAmounts } from './types.js';
|
|
2
|
+
import { MarketSnapshot, PositionAmounts, Strategy } from './types.js';
|
|
3
3
|
|
|
4
4
|
/** NAVI stores lending balances/capacity at 9 decimals, independently of Coin<T>. */
|
|
5
5
|
export declare const LENDING_DECIMALS = 9;
|
|
6
6
|
export declare function tokenDecimals(pool: Pick<Pool, 'token'>): number;
|
|
7
7
|
export declare function lendingToRaw(value: string, decimals: number, roundUp?: boolean): string;
|
|
8
|
+
/** A custom source with a rounded-down zero cannot establish an empty Cap without the protocol amount. */
|
|
9
|
+
export declare function positionSides(position: PositionAmounts, market: MarketSnapshot): {
|
|
10
|
+
collateral: boolean;
|
|
11
|
+
debt: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function isDustClose(strategy: Strategy, position: PositionAmounts, market: MarketSnapshot): boolean;
|
|
8
14
|
/** Price of one native atom, used only inside the solver. Public prices stay USD/token. */
|
|
9
15
|
export declare function atomPrices(market: MarketSnapshot): {
|
|
10
16
|
collateral: import('bignumber.js').BigNumber;
|
package/dist/amounts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amounts.d.ts","sourceRoot":"","sources":["../src/amounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"amounts.d.ts","sourceRoot":"","sources":["../src/amounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGxE,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,IAAI,CAAA;AAEjC,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,MAAM,CAQ/D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,UAAQ,UAK5E;AAED,0GAA0G;AAC1G,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc;;;EA2B9E;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,WAUhG;AAED,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc;;;EAKhD;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,oCAEtD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,oCAOpD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,oCAEpD;AAED,uFAAuF;AACvF,wBAAgB,SAAS,CACvB,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,cAAc,EACtB,cAAc,EAAE,OAAO,WAiBxB"}
|
package/dist/amounts.js
CHANGED
|
@@ -1,46 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const
|
|
1
|
+
import { decimal as i, BN as l, check as s } from "./utils.js";
|
|
2
|
+
const d = 9;
|
|
3
|
+
function o(t) {
|
|
4
|
+
const e = t.token?.decimals;
|
|
5
5
|
return s(
|
|
6
|
-
Number.isInteger(
|
|
6
|
+
Number.isInteger(e) && e >= 0 && e <= 18,
|
|
7
7
|
"MARKET_UNSUPPORTED",
|
|
8
8
|
"Token precision must be an integer from 0 to 18"
|
|
9
|
-
),
|
|
9
|
+
), e;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function m(t, e, n = !1) {
|
|
12
|
+
return i(t).shiftedBy(e - d).integerValue(n ? l.ROUND_CEIL : l.ROUND_FLOOR).toFixed(0);
|
|
13
|
+
}
|
|
14
|
+
function b(t, e) {
|
|
15
|
+
const n = (u, r, c, a) => r !== void 0 ? (s(
|
|
16
|
+
/^(0|[1-9][0-9]{0,77})$/.test(r) && m(r, c, a) === u,
|
|
17
|
+
"READ_FAILED",
|
|
18
|
+
"Invalid protocol balance or inconsistent native amount"
|
|
19
|
+
), r !== "0") : (s(
|
|
20
|
+
a || c >= d || u !== "0",
|
|
21
|
+
"READ_FAILED",
|
|
22
|
+
"Rounded collateral requires a protocol balance"
|
|
23
|
+
), u !== "0");
|
|
24
|
+
return {
|
|
25
|
+
collateral: n(
|
|
26
|
+
t.collateralAmount,
|
|
27
|
+
t.protocolCollateralAmount,
|
|
28
|
+
o(e.collateral),
|
|
29
|
+
!1
|
|
30
|
+
),
|
|
31
|
+
debt: n(t.debtAmount, t.protocolDebtAmount, o(e.debt), !0)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function D(t, e, n) {
|
|
35
|
+
return t.allowCollateralDustClose === !0 && o(n.collateral) === 6 && e.collateralAmount === "0" && e.debtAmount === "0" && e.protocolDebtAmount === "0" && typeof e.protocolCollateralAmount == "string" && /^[1-9][0-9]{0,2}$/.test(e.protocolCollateralAmount);
|
|
13
36
|
}
|
|
14
37
|
function f(t) {
|
|
15
38
|
return {
|
|
16
|
-
collateral:
|
|
17
|
-
debt:
|
|
39
|
+
collateral: i(t.collateralPrice).shiftedBy(-o(t.collateral)),
|
|
40
|
+
debt: i(t.debtPrice).shiftedBy(-o(t.debt))
|
|
18
41
|
};
|
|
19
42
|
}
|
|
20
43
|
function w(t) {
|
|
21
|
-
return
|
|
44
|
+
return l.maximum(1, new l(1).shiftedBy(o(t) - 6));
|
|
22
45
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
46
|
+
function C(t) {
|
|
47
|
+
return l.maximum(
|
|
25
48
|
0,
|
|
26
|
-
new
|
|
49
|
+
new l(t.collateral.leftSupply).shiftedBy(o(t.collateral)).integerValue(l.ROUND_FLOOR)
|
|
27
50
|
);
|
|
28
51
|
}
|
|
29
|
-
function
|
|
30
|
-
return new
|
|
52
|
+
function R(t) {
|
|
53
|
+
return new l(m(t.debt.availableBorrow, o(t.debt)));
|
|
31
54
|
}
|
|
32
|
-
function y(t,
|
|
33
|
-
const
|
|
34
|
-
return
|
|
55
|
+
function y(t, e, n, u) {
|
|
56
|
+
const r = f(n), c = new l(t.collateralAmount), a = new l(t.debtAmount);
|
|
57
|
+
return a.times(r.debt).times(n.borrowWeight).lte(c.times(r.collateral).times(n.ltv)) ? !0 : u && a.lte(e.debtAmount) && a.times(e.collateralAmount).lte(new l(e.debtAmount).times(c));
|
|
35
58
|
}
|
|
36
59
|
export {
|
|
37
|
-
|
|
60
|
+
d as LENDING_DECIMALS,
|
|
38
61
|
w as amountCushion,
|
|
39
62
|
f as atomPrices,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
63
|
+
R as borrowCapacity,
|
|
64
|
+
D as isDustClose,
|
|
65
|
+
m as lendingToRaw,
|
|
66
|
+
b as positionSides,
|
|
67
|
+
C as supplyCapacity,
|
|
68
|
+
o as tokenDecimals,
|
|
44
69
|
y as withinLtv
|
|
45
70
|
};
|
|
46
71
|
//# sourceMappingURL=amounts.js.map
|
package/dist/amounts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amounts.js","sources":["../src/amounts.ts"],"sourcesContent":["import type { Pool } from '@naviprotocol/lending'\nimport type { MarketSnapshot, PositionAmounts } from './types'\nimport { BN, check, decimal } from './utils'\n\n/** NAVI stores lending balances/capacity at 9 decimals, independently of Coin<T>. */\nexport const LENDING_DECIMALS = 9\n\nexport function tokenDecimals(pool: Pick<Pool, 'token'>): number {\n const value = pool.token?.decimals\n check(\n Number.isInteger(value) && value >= 0 && value <= 18,\n 'MARKET_UNSUPPORTED',\n 'Token precision must be an integer from 0 to 18'\n )\n return value\n}\n\nexport function lendingToRaw(value: string, decimals: number, roundUp = false) {\n return decimal(value)\n .shiftedBy(decimals - LENDING_DECIMALS)\n .integerValue(roundUp ? BN.ROUND_CEIL : BN.ROUND_FLOOR)\n .toFixed(0)\n}\n\n/** Price of one native atom, used only inside the solver. Public prices stay USD/token. */\nexport function atomPrices(market: MarketSnapshot) {\n return {\n collateral: decimal(market.collateralPrice).shiftedBy(-tokenDecimals(market.collateral)),\n debt: decimal(market.debtPrice).shiftedBy(-tokenDecimals(market.debt))\n }\n}\n\n/** Existing one-micro-token interest/drift cushion, with at least one native atom. */\nexport function amountCushion(pool: Pick<Pool, 'token'>) {\n return BN.maximum(1, new BN(1).shiftedBy(tokenDecimals(pool) - 6))\n}\n\nexport function supplyCapacity(market: MarketSnapshot) {\n return BN.maximum(\n 0,\n new BN(market.collateral.leftSupply)\n .shiftedBy(tokenDecimals(market.collateral))\n .integerValue(BN.ROUND_FLOOR)\n )\n}\n\nexport function borrowCapacity(market: MarketSnapshot) {\n return new BN(lendingToRaw(market.debt.availableBorrow, tokenDecimals(market.debt)))\n}\n\n/** A lowered borrowing cap must still permit repayment, collateral top-up and exit. */\nexport function withinLtv(\n projected: PositionAmounts,\n before: PositionAmounts,\n market: MarketSnapshot,\n allowReduction: boolean\n) {\n const prices = atomPrices(market)\n const c = new BN(projected.collateralAmount),\n d = new BN(projected.debtAmount)\n if (\n d\n .times(prices.debt)\n .times(market.borrowWeight)\n .lte(c.times(prices.collateral).times(market.ltv))\n )\n return true\n return (\n allowReduction &&\n d.lte(before.debtAmount) &&\n d.times(before.collateralAmount).lte(new BN(before.debtAmount).times(c))\n )\n}\n"],"names":["LENDING_DECIMALS","tokenDecimals","pool","value","check","lendingToRaw","decimals","roundUp","decimal","BN","
|
|
1
|
+
{"version":3,"file":"amounts.js","sources":["../src/amounts.ts"],"sourcesContent":["import type { Pool } from '@naviprotocol/lending'\nimport type { MarketSnapshot, PositionAmounts, Strategy } from './types'\nimport { BN, check, decimal } from './utils'\n\n/** NAVI stores lending balances/capacity at 9 decimals, independently of Coin<T>. */\nexport const LENDING_DECIMALS = 9\n\nexport function tokenDecimals(pool: Pick<Pool, 'token'>): number {\n const value = pool.token?.decimals\n check(\n Number.isInteger(value) && value >= 0 && value <= 18,\n 'MARKET_UNSUPPORTED',\n 'Token precision must be an integer from 0 to 18'\n )\n return value\n}\n\nexport function lendingToRaw(value: string, decimals: number, roundUp = false) {\n return decimal(value)\n .shiftedBy(decimals - LENDING_DECIMALS)\n .integerValue(roundUp ? BN.ROUND_CEIL : BN.ROUND_FLOOR)\n .toFixed(0)\n}\n\n/** A custom source with a rounded-down zero cannot establish an empty Cap without the protocol amount. */\nexport function positionSides(position: PositionAmounts, market: MarketSnapshot) {\n const side = (amount: string, protocol: string | undefined, decimals: number, debt: boolean) => {\n if (protocol !== undefined) {\n check(\n /^(0|[1-9][0-9]{0,77})$/.test(protocol) &&\n lendingToRaw(protocol, decimals, debt) === amount,\n 'READ_FAILED',\n 'Invalid protocol balance or inconsistent native amount'\n )\n return protocol !== '0'\n }\n check(\n debt || decimals >= LENDING_DECIMALS || amount !== '0',\n 'READ_FAILED',\n 'Rounded collateral requires a protocol balance'\n )\n return amount !== '0'\n }\n return {\n collateral: side(\n position.collateralAmount,\n position.protocolCollateralAmount,\n tokenDecimals(market.collateral),\n false\n ),\n debt: side(position.debtAmount, position.protocolDebtAmount, tokenDecimals(market.debt), true)\n }\n}\n\nexport function isDustClose(strategy: Strategy, position: PositionAmounts, market: MarketSnapshot) {\n return (\n strategy.allowCollateralDustClose === true &&\n tokenDecimals(market.collateral) === 6 &&\n position.collateralAmount === '0' &&\n position.debtAmount === '0' &&\n position.protocolDebtAmount === '0' &&\n typeof position.protocolCollateralAmount === 'string' &&\n /^[1-9][0-9]{0,2}$/.test(position.protocolCollateralAmount)\n )\n}\n\n/** Price of one native atom, used only inside the solver. Public prices stay USD/token. */\nexport function atomPrices(market: MarketSnapshot) {\n return {\n collateral: decimal(market.collateralPrice).shiftedBy(-tokenDecimals(market.collateral)),\n debt: decimal(market.debtPrice).shiftedBy(-tokenDecimals(market.debt))\n }\n}\n\n/** Existing one-micro-token interest/drift cushion, with at least one native atom. */\nexport function amountCushion(pool: Pick<Pool, 'token'>) {\n return BN.maximum(1, new BN(1).shiftedBy(tokenDecimals(pool) - 6))\n}\n\nexport function supplyCapacity(market: MarketSnapshot) {\n return BN.maximum(\n 0,\n new BN(market.collateral.leftSupply)\n .shiftedBy(tokenDecimals(market.collateral))\n .integerValue(BN.ROUND_FLOOR)\n )\n}\n\nexport function borrowCapacity(market: MarketSnapshot) {\n return new BN(lendingToRaw(market.debt.availableBorrow, tokenDecimals(market.debt)))\n}\n\n/** A lowered borrowing cap must still permit repayment, collateral top-up and exit. */\nexport function withinLtv(\n projected: PositionAmounts,\n before: PositionAmounts,\n market: MarketSnapshot,\n allowReduction: boolean\n) {\n const prices = atomPrices(market)\n const c = new BN(projected.collateralAmount),\n d = new BN(projected.debtAmount)\n if (\n d\n .times(prices.debt)\n .times(market.borrowWeight)\n .lte(c.times(prices.collateral).times(market.ltv))\n )\n return true\n return (\n allowReduction &&\n d.lte(before.debtAmount) &&\n d.times(before.collateralAmount).lte(new BN(before.debtAmount).times(c))\n )\n}\n"],"names":["LENDING_DECIMALS","tokenDecimals","pool","value","check","lendingToRaw","decimals","roundUp","decimal","BN","positionSides","position","market","side","amount","protocol","debt","isDustClose","strategy","atomPrices","amountCushion","supplyCapacity","borrowCapacity","withinLtv","projected","before","allowReduction","prices","d"],"mappings":";AAKO,MAAMA,IAAmB;AAEzB,SAASC,EAAcC,GAAmC;AAC/D,QAAMC,IAAQD,EAAK,OAAO;AAC1B,SAAAE;AAAA,IACE,OAAO,UAAUD,CAAK,KAAKA,KAAS,KAAKA,KAAS;AAAA,IAClD;AAAA,IACA;AAAA,EAAA,GAEKA;AACT;AAEO,SAASE,EAAaF,GAAeG,GAAkBC,IAAU,IAAO;AAC7E,SAAOC,EAAQL,CAAK,EACjB,UAAUG,IAAWN,CAAgB,EACrC,aAAaO,IAAUE,EAAG,aAAaA,EAAG,WAAW,EACrD,QAAQ,CAAC;AACd;AAGO,SAASC,EAAcC,GAA2BC,GAAwB;AAC/E,QAAMC,IAAO,CAACC,GAAgBC,GAA8BT,GAAkBU,MACxED,MAAa,UACfX;AAAA,IACE,yBAAyB,KAAKW,CAAQ,KACpCV,EAAaU,GAAUT,GAAUU,CAAI,MAAMF;AAAA,IAC7C;AAAA,IACA;AAAA,EAAA,GAEKC,MAAa,QAEtBX;AAAA,IACEY,KAAQV,KAAYN,KAAoBc,MAAW;AAAA,IACnD;AAAA,IACA;AAAA,EAAA,GAEKA,MAAW;AAEpB,SAAO;AAAA,IACL,YAAYD;AAAA,MACVF,EAAS;AAAA,MACTA,EAAS;AAAA,MACTV,EAAcW,EAAO,UAAU;AAAA,MAC/B;AAAA,IAAA;AAAA,IAEF,MAAMC,EAAKF,EAAS,YAAYA,EAAS,oBAAoBV,EAAcW,EAAO,IAAI,GAAG,EAAI;AAAA,EAAA;AAEjG;AAEO,SAASK,EAAYC,GAAoBP,GAA2BC,GAAwB;AACjG,SACEM,EAAS,6BAA6B,MACtCjB,EAAcW,EAAO,UAAU,MAAM,KACrCD,EAAS,qBAAqB,OAC9BA,EAAS,eAAe,OACxBA,EAAS,uBAAuB,OAChC,OAAOA,EAAS,4BAA6B,YAC7C,oBAAoB,KAAKA,EAAS,wBAAwB;AAE9D;AAGO,SAASQ,EAAWP,GAAwB;AACjD,SAAO;AAAA,IACL,YAAYJ,EAAQI,EAAO,eAAe,EAAE,UAAU,CAACX,EAAcW,EAAO,UAAU,CAAC;AAAA,IACvF,MAAMJ,EAAQI,EAAO,SAAS,EAAE,UAAU,CAACX,EAAcW,EAAO,IAAI,CAAC;AAAA,EAAA;AAEzE;AAGO,SAASQ,EAAclB,GAA2B;AACvD,SAAOO,EAAG,QAAQ,GAAG,IAAIA,EAAG,CAAC,EAAE,UAAUR,EAAcC,CAAI,IAAI,CAAC,CAAC;AACnE;AAEO,SAASmB,EAAeT,GAAwB;AACrD,SAAOH,EAAG;AAAA,IACR;AAAA,IACA,IAAIA,EAAGG,EAAO,WAAW,UAAU,EAChC,UAAUX,EAAcW,EAAO,UAAU,CAAC,EAC1C,aAAaH,EAAG,WAAW;AAAA,EAAA;AAElC;AAEO,SAASa,EAAeV,GAAwB;AACrD,SAAO,IAAIH,EAAGJ,EAAaO,EAAO,KAAK,iBAAiBX,EAAcW,EAAO,IAAI,CAAC,CAAC;AACrF;AAGO,SAASW,EACdC,GACAC,GACAb,GACAc,GACA;AACA,QAAMC,IAASR,EAAWP,CAAM,GAC1B,IAAI,IAAIH,EAAGe,EAAU,gBAAgB,GACzCI,IAAI,IAAInB,EAAGe,EAAU,UAAU;AACjC,SACEI,EACG,MAAMD,EAAO,IAAI,EACjB,MAAMf,EAAO,YAAY,EACzB,IAAI,EAAE,MAAMe,EAAO,UAAU,EAAE,MAAMf,EAAO,GAAG,CAAC,IAE5C,KAEPc,KACAE,EAAE,IAAIH,EAAO,UAAU,KACvBG,EAAE,MAAMH,EAAO,gBAAgB,EAAE,IAAI,IAAIhB,EAAGgB,EAAO,UAAU,EAAE,MAAM,CAAC,CAAC;AAE3E;"}
|
package/dist/client.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare function createMultiplyClient(options?: MultiplyOptions): {
|
|
|
6
6
|
strategy?: Strategy;
|
|
7
7
|
}) => Promise<Position[]>;
|
|
8
8
|
quote: (owner: string, suppliedStrategy: Strategy, action: Action, constraints: Constraints) => Promise<MultiplyQuote>;
|
|
9
|
-
buildPTB: (tx: Transaction,
|
|
9
|
+
buildPTB: (tx: Transaction, q: MultiplyQuote, inputs: BuildInputs) => Promise<BuildResult>;
|
|
10
|
+
buildPTBForSimulation: (tx: Transaction, q: MultiplyQuote, coins: BuildInputs["coins"]) => Promise<BuildResult>;
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAkC,MAAM,0BAA0B,CAAA;AACtF,OAAO,KAAK,EAEV,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EAGX,eAAe,EACf,aAAa,EACb,QAAQ,EACR,QAAQ,EACT,MAAM,SAAS,CAAA;AAmChB,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,eAAoB;yBA4IvD,MAAM,UACN;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE,KAC7B,OAAO,CAAC,QAAQ,EAAE,CAAC;mBAwBb,MAAM,oBACK,QAAQ,UAClB,MAAM,eACD,WAAW,KACvB,OAAO,CAAC,aAAa,CAAC;mBA2oBH,WAAW,KAAK,aAAa,UAAU,WAAW;gCAKrC,WAAW,KAAK,aAAa,SAAS,WAAW,CAAC,OAAO,CAAC;EAK9F"}
|