@gearbox-protocol/deploy-tools 6.9.0 → 6.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +29 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -197534,6 +197534,8 @@ async function seedOnDemandPool(anvil, meta3, logger) {
|
|
|
197534
197534
|
}
|
|
197535
197535
|
|
|
197536
197536
|
// src/commands/open-rwa-accounts/flows.ts
|
|
197537
|
+
var LEVERAGE_PRECISION = 4;
|
|
197538
|
+
var LEVERAGE_ONE = 10n ** BigInt(LEVERAGE_PRECISION);
|
|
197537
197539
|
function childLogger2(logger, context) {
|
|
197538
197540
|
return logger?.child?.(context) ?? logger;
|
|
197539
197541
|
}
|
|
@@ -197666,7 +197668,7 @@ async function runSecuritizeBorrowingFlow(props) {
|
|
|
197666
197668
|
return { txHash: hash4, creditAccount };
|
|
197667
197669
|
}
|
|
197668
197670
|
async function runSecuritizeLeverageFlow(props) {
|
|
197669
|
-
const { sdk, anvil, rpcUrl, adminPrivateKey, entry, debt } = props;
|
|
197671
|
+
const { sdk, anvil, rpcUrl, adminPrivateKey, entry, debt, leverage } = props;
|
|
197670
197672
|
const logger = childLogger2(props.logger, {
|
|
197671
197673
|
flow: "leverage",
|
|
197672
197674
|
label: entry.label
|
|
@@ -197685,13 +197687,20 @@ async function runSecuritizeLeverageFlow(props) {
|
|
|
197685
197687
|
});
|
|
197686
197688
|
logger?.info(`registered investor ${investor} for ${entry.dsTokenSymbol}`);
|
|
197687
197689
|
const asset = entry.asset;
|
|
197688
|
-
const
|
|
197690
|
+
const debtBn = parseUnits(debt, entry.underlyingDecimals);
|
|
197691
|
+
const leverageBn = parseUnits(leverage, LEVERAGE_PRECISION);
|
|
197692
|
+
if (leverageBn <= LEVERAGE_ONE) {
|
|
197693
|
+
throw new Error(`leverage must be > 1, got ${leverage}`);
|
|
197694
|
+
}
|
|
197695
|
+
const assetAmount = debtBn * LEVERAGE_ONE / (leverageBn - LEVERAGE_ONE);
|
|
197689
197696
|
await anvil.deal({
|
|
197690
197697
|
erc20: asset,
|
|
197691
197698
|
account: investor,
|
|
197692
197699
|
amount: assetAmount
|
|
197693
197700
|
});
|
|
197694
|
-
logger?.info(
|
|
197701
|
+
logger?.info(
|
|
197702
|
+
`dealt ${assetAmount} of asset ${asset} to ${investor} (leverage=${leverage}, debt=${debt})`
|
|
197703
|
+
);
|
|
197695
197704
|
const approvalTarget = await sdk.accounts.getApprovalAddress({
|
|
197696
197705
|
creditManager: entry.creditManager,
|
|
197697
197706
|
borrower: investor
|
|
@@ -197726,7 +197735,6 @@ async function runSecuritizeLeverageFlow(props) {
|
|
|
197726
197735
|
requirements.requiredSignatures
|
|
197727
197736
|
);
|
|
197728
197737
|
logger?.info(`signed ${signaturesToCache.length} register-vault message(s)`);
|
|
197729
|
-
const debtBn = parseUnits(debt, entry.underlyingDecimals);
|
|
197730
197738
|
const unwrapCalls = await sdk.accounts.getRWAUnwrapCalls(
|
|
197731
197739
|
debtBn,
|
|
197732
197740
|
entry.creditManager
|
|
@@ -197805,6 +197813,7 @@ async function openAllRWAAccounts(opts) {
|
|
|
197805
197813
|
adminPrivateKey,
|
|
197806
197814
|
usdAmount,
|
|
197807
197815
|
debt,
|
|
197816
|
+
leverage,
|
|
197808
197817
|
flow,
|
|
197809
197818
|
skipSeeding,
|
|
197810
197819
|
creditManager: cmFilter
|
|
@@ -197891,6 +197900,7 @@ async function openAllRWAAccounts(opts) {
|
|
|
197891
197900
|
rwaFactories,
|
|
197892
197901
|
usdAmount,
|
|
197893
197902
|
debt,
|
|
197903
|
+
leverage,
|
|
197894
197904
|
logger
|
|
197895
197905
|
});
|
|
197896
197906
|
results.push({
|
|
@@ -197959,6 +197969,14 @@ function parseHex(value) {
|
|
|
197959
197969
|
}
|
|
197960
197970
|
return value;
|
|
197961
197971
|
}
|
|
197972
|
+
function parseLeverage(value) {
|
|
197973
|
+
if (!/^\d+(\.\d+)?$/.test(value) || Number(value) <= 1) {
|
|
197974
|
+
throw new InvalidArgumentError(
|
|
197975
|
+
`leverage must be a decimal > 1, got: ${value}`
|
|
197976
|
+
);
|
|
197977
|
+
}
|
|
197978
|
+
return value;
|
|
197979
|
+
}
|
|
197962
197980
|
function openRwaAccounts() {
|
|
197963
197981
|
return newCommand().name("open-rwa-accounts").description(
|
|
197964
197982
|
"Discovers all (creditManager, DSToken) pairs from RWA factories and opens credit accounts via Securitize for each one (borrowing and/or leverage flow)."
|
|
@@ -197982,6 +198000,11 @@ function openRwaAccounts() {
|
|
|
197982
198000
|
"--debt <amount>",
|
|
197983
198001
|
"Debt amount (no decimals; parsed with the pool underlying decimals)"
|
|
197984
198002
|
).env("DEBT").default("50000")
|
|
198003
|
+
).addOption(
|
|
198004
|
+
new Option(
|
|
198005
|
+
"--leverage <multiplier>",
|
|
198006
|
+
'Total position leverage for the leverage flow as a decimal > 1 (e.g. "6" or "5.5"); collateral is derived as debt / (leverage - 1)'
|
|
198007
|
+
).argParser(parseLeverage).env("LEVERAGE").default("6")
|
|
197985
198008
|
).addOption(
|
|
197986
198009
|
new Option("--flow <flow>", "Which flow(s) to run").argParser(parseFlow).env("FLOW").default("both")
|
|
197987
198010
|
).addOption(
|
|
@@ -198004,6 +198027,7 @@ function openRwaAccounts() {
|
|
|
198004
198027
|
adminPrivateKey,
|
|
198005
198028
|
usdAmount,
|
|
198006
198029
|
debt,
|
|
198030
|
+
leverage,
|
|
198007
198031
|
flow,
|
|
198008
198032
|
skipSeeding,
|
|
198009
198033
|
creditManager,
|
|
@@ -198027,6 +198051,7 @@ function openRwaAccounts() {
|
|
|
198027
198051
|
adminPrivateKey,
|
|
198028
198052
|
usdAmount,
|
|
198029
198053
|
debt,
|
|
198054
|
+
leverage,
|
|
198030
198055
|
flow,
|
|
198031
198056
|
skipSeeding: !!skipSeeding,
|
|
198032
198057
|
creditManager,
|