@gearbox-protocol/deploy-tools 5.16.11 → 5.16.13
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 +197 -139
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -345871,6 +345871,7 @@ init_toHex();
|
|
|
345871
345871
|
init_fromBytes();
|
|
345872
345872
|
init_concat();
|
|
345873
345873
|
init_getChainContractAddress();
|
|
345874
|
+
init_formatEther();
|
|
345874
345875
|
init_fromHex();
|
|
345875
345876
|
init_getAddress();
|
|
345876
345877
|
init_toFunctionSelector();
|
|
@@ -354823,10 +354824,22 @@ var BaseContract = class extends SDKConstruct {
|
|
|
354823
354824
|
}
|
|
354824
354825
|
/**
|
|
354825
354826
|
* Converts contract calldata to some human-friendly string
|
|
354827
|
+
* This is safe function which should not throw
|
|
354826
354828
|
* @param calldata
|
|
354827
354829
|
* @returns
|
|
354828
354830
|
*/
|
|
354829
354831
|
parseFunctionData(calldata) {
|
|
354832
|
+
try {
|
|
354833
|
+
return this.mustParseFunctionData(calldata);
|
|
354834
|
+
} catch (e) {
|
|
354835
|
+
const selector = calldata.slice(0, 10);
|
|
354836
|
+
this.logger?.warn(
|
|
354837
|
+
`error parsing function with selector ${selector} in ${this.name} v${this.version} at ${this.address}: ${e}`
|
|
354838
|
+
);
|
|
354839
|
+
return `unknown: ${this.labelAddress(this.address)}.${selector}`;
|
|
354840
|
+
}
|
|
354841
|
+
}
|
|
354842
|
+
mustParseFunctionData(calldata) {
|
|
354830
354843
|
const decoded = decodeFunctionData({
|
|
354831
354844
|
abi: this.abi,
|
|
354832
354845
|
data: calldata
|
|
@@ -371686,12 +371699,13 @@ var PriceOracleBaseContract = class extends BaseContract {
|
|
|
371686
371699
|
)
|
|
371687
371700
|
);
|
|
371688
371701
|
}
|
|
371702
|
+
const [address] = this.sdk.addressProvider.getLatestVersion(
|
|
371703
|
+
AP_PRICE_FEED_COMPRESSOR
|
|
371704
|
+
);
|
|
371689
371705
|
return {
|
|
371690
371706
|
call: {
|
|
371691
371707
|
abi: iPriceFeedCompressorAbi,
|
|
371692
|
-
address
|
|
371693
|
-
AP_PRICE_FEED_COMPRESSOR
|
|
371694
|
-
),
|
|
371708
|
+
address,
|
|
371695
371709
|
functionName: "getPriceFeeds",
|
|
371696
371710
|
args
|
|
371697
371711
|
},
|
|
@@ -373185,6 +373199,54 @@ var iSwapperV300Abi = [
|
|
|
373185
373199
|
}
|
|
373186
373200
|
];
|
|
373187
373201
|
|
|
373202
|
+
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/router/AbstractRouterContract.js
|
|
373203
|
+
var AbstractRouterContract = class extends BaseContract {
|
|
373204
|
+
hooks = new Hooks();
|
|
373205
|
+
addHook = this.hooks.addHook.bind(this.hooks);
|
|
373206
|
+
removeHook = this.hooks.removeHook.bind(this.hooks);
|
|
373207
|
+
getExpectedAndLeftover(ca, cm, balances) {
|
|
373208
|
+
const b = balances || this.getDefaultExpectedAndLeftover(ca);
|
|
373209
|
+
const { leftoverBalances, expectedBalances } = b;
|
|
373210
|
+
const expected = new AddressMap();
|
|
373211
|
+
const leftover = new AddressMap();
|
|
373212
|
+
for (const token of cm.collateralTokens) {
|
|
373213
|
+
const actual = expectedBalances.get(token)?.balance || 0n;
|
|
373214
|
+
expected.upsert(token, { token, balance: actual > 10n ? actual : 0n });
|
|
373215
|
+
leftover.upsert(token, {
|
|
373216
|
+
token,
|
|
373217
|
+
balance: leftoverBalances.get(token)?.balance || 1n
|
|
373218
|
+
});
|
|
373219
|
+
}
|
|
373220
|
+
return { expectedBalances: expected, leftoverBalances: leftover };
|
|
373221
|
+
}
|
|
373222
|
+
getDefaultExpectedAndLeftover(ca) {
|
|
373223
|
+
const expectedBalances = new AddressMap();
|
|
373224
|
+
const leftoverBalances = new AddressMap();
|
|
373225
|
+
for (const { token: t, balance, mask } of ca.tokens) {
|
|
373226
|
+
const token = t;
|
|
373227
|
+
const isEnabled = (mask & ca.enabledTokensMask) !== 0n;
|
|
373228
|
+
expectedBalances.upsert(token, { token, balance });
|
|
373229
|
+
const decimals2 = this.sdk.tokensMeta.decimals(token);
|
|
373230
|
+
const minBalance = 10n ** BigInt(Math.max(8, decimals2) - 8);
|
|
373231
|
+
if (balance < minBalance || !isEnabled) {
|
|
373232
|
+
leftoverBalances.upsert(token, { token, balance });
|
|
373233
|
+
}
|
|
373234
|
+
}
|
|
373235
|
+
return { expectedBalances, leftoverBalances };
|
|
373236
|
+
}
|
|
373237
|
+
};
|
|
373238
|
+
|
|
373239
|
+
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/router/helpers.js
|
|
373240
|
+
function balancesMap(assets) {
|
|
373241
|
+
return new AddressMap(assets.map(({ token, balance }) => [token, balance]));
|
|
373242
|
+
}
|
|
373243
|
+
function compareRouterResults(a, b) {
|
|
373244
|
+
return a.amount > b.amount ? a : b;
|
|
373245
|
+
}
|
|
373246
|
+
function assetsMap(assets) {
|
|
373247
|
+
return new AddressMap(assets.map((a) => [a.token, a]));
|
|
373248
|
+
}
|
|
373249
|
+
|
|
373188
373250
|
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/router/PathOptionFactory.js
|
|
373189
373251
|
var PathOptionFactory = class _PathOptionFactory {
|
|
373190
373252
|
// TODO: get rid of token data from SDK
|
|
@@ -373263,7 +373325,7 @@ var PathOptionFactory = class _PathOptionFactory {
|
|
|
373263
373325
|
}
|
|
373264
373326
|
};
|
|
373265
373327
|
|
|
373266
|
-
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/router/
|
|
373328
|
+
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/router/RouterV300Contract.js
|
|
373267
373329
|
var MAX_GAS_PER_ROUTE = 200000000n;
|
|
373268
373330
|
var GAS_PER_BLOCK = 400000000n;
|
|
373269
373331
|
var LOOPS_PER_TX = Number(GAS_PER_BLOCK / MAX_GAS_PER_ROUTE);
|
|
@@ -373280,19 +373342,16 @@ var PT_IN = {
|
|
|
373280
373342
|
var OUT = {
|
|
373281
373343
|
["0x9D39A5DE30e57443BfF2A8307A4256c8797A3497".toLowerCase()]: "sUSDe"
|
|
373282
373344
|
};
|
|
373283
|
-
var
|
|
373345
|
+
var RouterV300Contract = class extends AbstractRouterContract {
|
|
373284
373346
|
#connectors;
|
|
373285
|
-
#hooks = new Hooks();
|
|
373286
373347
|
constructor(sdk, address) {
|
|
373287
373348
|
super(sdk, {
|
|
373288
373349
|
addr: address,
|
|
373289
|
-
name: "
|
|
373350
|
+
name: "RouterV300",
|
|
373290
373351
|
abi: iRouterV300Abi
|
|
373291
373352
|
});
|
|
373292
373353
|
this.#connectors = getConnectors(sdk.provider.networkType);
|
|
373293
373354
|
}
|
|
373294
|
-
addHook = this.#hooks.addHook.bind(this.#hooks);
|
|
373295
|
-
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
373296
373355
|
/**
|
|
373297
373356
|
* Finds all available swaps for NORMAL tokens
|
|
373298
373357
|
* @param ca
|
|
@@ -373365,7 +373424,7 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
373365
373424
|
creditManager.collateralTokens
|
|
373366
373425
|
);
|
|
373367
373426
|
const isPTOverrideRedeem = PT_IN[tokenIn.toLowerCase()] && OUT[tokenOut.toLowerCase()];
|
|
373368
|
-
const { result } = await (isPTOverrideRedeem ? this
|
|
373427
|
+
const { result } = await (isPTOverrideRedeem ? this.#overridePTRedeem(props) : this.contract.simulate.findOneTokenPath(
|
|
373369
373428
|
[
|
|
373370
373429
|
tokenIn,
|
|
373371
373430
|
amount,
|
|
@@ -373384,74 +373443,6 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
373384
373443
|
calls: [...result.calls]
|
|
373385
373444
|
};
|
|
373386
373445
|
}
|
|
373387
|
-
// TODO: remove me when new router will be added
|
|
373388
|
-
async overridePTRedeem({
|
|
373389
|
-
creditAccount,
|
|
373390
|
-
creditManager,
|
|
373391
|
-
tokenIn,
|
|
373392
|
-
tokenOut,
|
|
373393
|
-
amount,
|
|
373394
|
-
slippage
|
|
373395
|
-
}) {
|
|
373396
|
-
const pendleSwapperAddress = await this.contract.read.componentAddressById([
|
|
373397
|
-
37
|
|
373398
|
-
]);
|
|
373399
|
-
const cm = this.sdk.marketRegister.findCreditManager(creditManager.address);
|
|
373400
|
-
const PENDLE_ROUTER_BY_NETWORK = {
|
|
373401
|
-
Mainnet: "0x888888888889758F76e7103c6CbF23ABbF58F946",
|
|
373402
|
-
Arbitrum: "0x0",
|
|
373403
|
-
Optimism: "0x0",
|
|
373404
|
-
Base: "0x0",
|
|
373405
|
-
Sonic: "0x0"
|
|
373406
|
-
};
|
|
373407
|
-
const pendleRouter = PENDLE_ROUTER_BY_NETWORK[this.sdk.provider.networkType];
|
|
373408
|
-
const pendleAdapter = cm.creditManager.adapters.mustGet(pendleRouter);
|
|
373409
|
-
const pendleSwapper = getContract({
|
|
373410
|
-
address: pendleSwapperAddress,
|
|
373411
|
-
abi: iSwapperV300Abi,
|
|
373412
|
-
client: this.sdk.provider.publicClient
|
|
373413
|
-
});
|
|
373414
|
-
const result = await pendleSwapper.simulate.getBestDirectPairSwap([
|
|
373415
|
-
{
|
|
373416
|
-
swapOperation: 1,
|
|
373417
|
-
creditAccount: creditAccount.creditAccount,
|
|
373418
|
-
tokenIn,
|
|
373419
|
-
tokenOut,
|
|
373420
|
-
connectors: [],
|
|
373421
|
-
amount,
|
|
373422
|
-
leftoverAmount: 0n
|
|
373423
|
-
},
|
|
373424
|
-
pendleAdapter.address
|
|
373425
|
-
]);
|
|
373426
|
-
const minAmount = result.result.amount * (PERCENTAGE_FACTOR - BigInt(slippage)) / PERCENTAGE_FACTOR;
|
|
373427
|
-
const storeExpectedBalances = {
|
|
373428
|
-
target: creditManager.creditFacade,
|
|
373429
|
-
callData: encodeFunctionData({
|
|
373430
|
-
abi: iCreditFacadeV300MulticallAbi,
|
|
373431
|
-
functionName: "storeExpectedBalances",
|
|
373432
|
-
args: [[{ token: tokenOut, amount: minAmount }]]
|
|
373433
|
-
})
|
|
373434
|
-
};
|
|
373435
|
-
const compareBalances = {
|
|
373436
|
-
target: creditManager.creditFacade,
|
|
373437
|
-
callData: encodeFunctionData({
|
|
373438
|
-
abi: iCreditFacadeV300MulticallAbi,
|
|
373439
|
-
functionName: "compareBalances",
|
|
373440
|
-
args: []
|
|
373441
|
-
})
|
|
373442
|
-
};
|
|
373443
|
-
return {
|
|
373444
|
-
result: {
|
|
373445
|
-
amount: result.result.amount,
|
|
373446
|
-
minAmount,
|
|
373447
|
-
calls: [
|
|
373448
|
-
storeExpectedBalances,
|
|
373449
|
-
result.result.multiCall,
|
|
373450
|
-
compareBalances
|
|
373451
|
-
]
|
|
373452
|
-
}
|
|
373453
|
-
};
|
|
373454
|
-
}
|
|
373455
373446
|
/**
|
|
373456
373447
|
* @dev Finds the best path for opening Credit Account and converting all NORMAL tokens and LP token in the way to TARGET
|
|
373457
373448
|
* @param creditManager CreditManagerData which represents credit manager you want to use to open Credit Account
|
|
@@ -373532,7 +373523,7 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
373532
373523
|
leftoverBalances: assetsMap(balances.leftoverBalances)
|
|
373533
373524
|
} : void 0
|
|
373534
373525
|
);
|
|
373535
|
-
await this
|
|
373526
|
+
await this.hooks.triggerHooks("foundPathOptions", {
|
|
373536
373527
|
creditAccount: ca.creditAccount,
|
|
373537
373528
|
pathOptions,
|
|
373538
373529
|
expected,
|
|
@@ -373580,61 +373571,112 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
373580
373571
|
}
|
|
373581
373572
|
/**
|
|
373582
373573
|
* Finds input to be used with findBestClosePath
|
|
373574
|
+
* Is used by batch liquidator
|
|
373583
373575
|
* @param ca
|
|
373584
373576
|
* @param cm
|
|
373585
373577
|
* @returns
|
|
373586
373578
|
*/
|
|
373587
373579
|
getFindClosePathInput(ca, cm, balances) {
|
|
373588
|
-
const
|
|
373589
|
-
|
|
373580
|
+
const { expectedBalances, leftoverBalances } = this.getExpectedAndLeftover(
|
|
373581
|
+
ca,
|
|
373582
|
+
cm,
|
|
373583
|
+
balances
|
|
373584
|
+
);
|
|
373590
373585
|
const pathOptions = PathOptionFactory.generatePathOptions(
|
|
373591
373586
|
ca.tokens,
|
|
373592
373587
|
this.provider.networkType,
|
|
373593
373588
|
LOOPS_PER_TX
|
|
373594
373589
|
);
|
|
373595
|
-
const expected = cm.collateralTokens.map((token) => {
|
|
373596
|
-
const actual = expectedBalances.get(token)?.balance || 0n;
|
|
373597
|
-
return {
|
|
373598
|
-
token,
|
|
373599
|
-
balance: actual > 10n ? actual : 0n
|
|
373600
|
-
};
|
|
373601
|
-
});
|
|
373602
|
-
const leftover = cm.collateralTokens.map((token) => ({
|
|
373603
|
-
token,
|
|
373604
|
-
balance: leftoverBalances.get(token)?.balance || 1n
|
|
373605
|
-
}));
|
|
373606
373590
|
const connectors2 = this.getAvailableConnectors(cm.collateralTokens);
|
|
373607
|
-
return {
|
|
373608
|
-
|
|
373609
|
-
|
|
373610
|
-
|
|
373611
|
-
|
|
373612
|
-
|
|
373613
|
-
const token = t;
|
|
373614
|
-
const isEnabled = (mask & ca.enabledTokensMask) !== 0n;
|
|
373615
|
-
expectedBalances.upsert(token, { token, balance });
|
|
373616
|
-
const decimals2 = this.sdk.tokensMeta.decimals(token);
|
|
373617
|
-
const minBalance = 10n ** BigInt(Math.max(8, decimals2) - 8);
|
|
373618
|
-
if (balance < minBalance || !isEnabled) {
|
|
373619
|
-
leftoverBalances.upsert(token, { token, balance });
|
|
373620
|
-
}
|
|
373621
|
-
}
|
|
373622
|
-
return { expectedBalances, leftoverBalances };
|
|
373591
|
+
return {
|
|
373592
|
+
expected: expectedBalances.values(),
|
|
373593
|
+
leftover: leftoverBalances.values(),
|
|
373594
|
+
connectors: connectors2,
|
|
373595
|
+
pathOptions
|
|
373596
|
+
};
|
|
373623
373597
|
}
|
|
373624
373598
|
getAvailableConnectors(collateralTokens) {
|
|
373625
373599
|
return collateralTokens.filter(
|
|
373626
373600
|
(t) => this.#connectors.includes(t.toLowerCase())
|
|
373627
373601
|
);
|
|
373628
373602
|
}
|
|
373603
|
+
// TODO: remove me when new router will be added
|
|
373604
|
+
async #overridePTRedeem({
|
|
373605
|
+
creditAccount,
|
|
373606
|
+
creditManager,
|
|
373607
|
+
tokenIn,
|
|
373608
|
+
tokenOut,
|
|
373609
|
+
amount,
|
|
373610
|
+
slippage
|
|
373611
|
+
}) {
|
|
373612
|
+
const pendleSwapperAddress = await this.contract.read.componentAddressById([
|
|
373613
|
+
37
|
|
373614
|
+
]);
|
|
373615
|
+
const cm = this.sdk.marketRegister.findCreditManager(creditManager.address);
|
|
373616
|
+
const PENDLE_ROUTER_BY_NETWORK = {
|
|
373617
|
+
Mainnet: "0x888888888889758F76e7103c6CbF23ABbF58F946",
|
|
373618
|
+
Arbitrum: "0x0",
|
|
373619
|
+
Optimism: "0x0",
|
|
373620
|
+
Base: "0x0",
|
|
373621
|
+
Sonic: "0x0"
|
|
373622
|
+
};
|
|
373623
|
+
const pendleRouter = PENDLE_ROUTER_BY_NETWORK[this.sdk.provider.networkType];
|
|
373624
|
+
const pendleAdapter = cm.creditManager.adapters.mustGet(pendleRouter);
|
|
373625
|
+
const pendleSwapper = getContract({
|
|
373626
|
+
address: pendleSwapperAddress,
|
|
373627
|
+
abi: iSwapperV300Abi,
|
|
373628
|
+
client: this.sdk.provider.publicClient
|
|
373629
|
+
});
|
|
373630
|
+
const result = await pendleSwapper.simulate.getBestDirectPairSwap([
|
|
373631
|
+
{
|
|
373632
|
+
swapOperation: 1,
|
|
373633
|
+
creditAccount: creditAccount.creditAccount,
|
|
373634
|
+
tokenIn,
|
|
373635
|
+
tokenOut,
|
|
373636
|
+
connectors: [],
|
|
373637
|
+
amount,
|
|
373638
|
+
leftoverAmount: 0n
|
|
373639
|
+
},
|
|
373640
|
+
pendleAdapter.address
|
|
373641
|
+
]);
|
|
373642
|
+
const minAmount = result.result.amount * (PERCENTAGE_FACTOR - BigInt(slippage)) / PERCENTAGE_FACTOR;
|
|
373643
|
+
const storeExpectedBalances = {
|
|
373644
|
+
target: creditManager.creditFacade,
|
|
373645
|
+
callData: encodeFunctionData({
|
|
373646
|
+
abi: iCreditFacadeV300MulticallAbi,
|
|
373647
|
+
functionName: "storeExpectedBalances",
|
|
373648
|
+
args: [[{ token: tokenOut, amount: minAmount }]]
|
|
373649
|
+
})
|
|
373650
|
+
};
|
|
373651
|
+
const compareBalances = {
|
|
373652
|
+
target: creditManager.creditFacade,
|
|
373653
|
+
callData: encodeFunctionData({
|
|
373654
|
+
abi: iCreditFacadeV300MulticallAbi,
|
|
373655
|
+
functionName: "compareBalances",
|
|
373656
|
+
args: []
|
|
373657
|
+
})
|
|
373658
|
+
};
|
|
373659
|
+
return {
|
|
373660
|
+
result: {
|
|
373661
|
+
amount: result.result.amount,
|
|
373662
|
+
minAmount,
|
|
373663
|
+
calls: [
|
|
373664
|
+
storeExpectedBalances,
|
|
373665
|
+
result.result.multiCall,
|
|
373666
|
+
compareBalances
|
|
373667
|
+
]
|
|
373668
|
+
}
|
|
373669
|
+
};
|
|
373670
|
+
}
|
|
373629
373671
|
};
|
|
373630
|
-
|
|
373631
|
-
|
|
373632
|
-
|
|
373633
|
-
|
|
373634
|
-
|
|
373635
|
-
|
|
373636
|
-
|
|
373637
|
-
|
|
373672
|
+
|
|
373673
|
+
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/router/createRouter.js
|
|
373674
|
+
function createRouter(sdk) {
|
|
373675
|
+
const [address, v] = sdk.addressProvider.getLatestVersion(AP_ROUTER);
|
|
373676
|
+
if (v >= 300 && v < 310) {
|
|
373677
|
+
return new RouterV300Contract(sdk, address);
|
|
373678
|
+
}
|
|
373679
|
+
throw new Error(`Unsupported router version ${v}`);
|
|
373638
373680
|
}
|
|
373639
373681
|
|
|
373640
373682
|
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/accounts/CreditAccountsService.js
|
|
@@ -373644,7 +373686,7 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
373644
373686
|
#logger;
|
|
373645
373687
|
constructor(sdk, options) {
|
|
373646
373688
|
super(sdk);
|
|
373647
|
-
this.#compressor = sdk.addressProvider.getLatestVersion(
|
|
373689
|
+
[this.#compressor] = sdk.addressProvider.getLatestVersion(
|
|
373648
373690
|
AP_CREDIT_ACCOUNT_COMPRESSOR
|
|
373649
373691
|
);
|
|
373650
373692
|
this.#batchSize = options?.batchSize;
|
|
@@ -374406,10 +374448,12 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
374406
374448
|
return this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
374407
374449
|
}
|
|
374408
374450
|
get rewardCompressor() {
|
|
374409
|
-
return this.sdk.addressProvider.getLatestVersion(AP_REWARDS_COMPRESSOR);
|
|
374451
|
+
return this.sdk.addressProvider.getLatestVersion(AP_REWARDS_COMPRESSOR)[0];
|
|
374410
374452
|
}
|
|
374411
374453
|
get peripheryCompressor() {
|
|
374412
|
-
return this.sdk.addressProvider.getLatestVersion(
|
|
374454
|
+
return this.sdk.addressProvider.getLatestVersion(
|
|
374455
|
+
AP_PERIPHERY_COMPRESSOR
|
|
374456
|
+
)[0];
|
|
374413
374457
|
}
|
|
374414
374458
|
};
|
|
374415
374459
|
|
|
@@ -374443,13 +374487,12 @@ var AbstractAddressProviderContract = class extends BaseContract {
|
|
|
374443
374487
|
return result;
|
|
374444
374488
|
}
|
|
374445
374489
|
getLatestVersion(contract) {
|
|
374446
|
-
|
|
374490
|
+
const version4 = this.#latest[contract];
|
|
374491
|
+
if (!version4) {
|
|
374447
374492
|
throw new Error(`Latest version for ${contract} not found`);
|
|
374448
374493
|
}
|
|
374449
|
-
this.logger?.debug(
|
|
374450
|
-
|
|
374451
|
-
);
|
|
374452
|
-
return this.getAddress(contract, this.#latest[contract]);
|
|
374494
|
+
this.logger?.debug(`Latest version found for ${contract} : ${version4}`);
|
|
374495
|
+
return [this.getAddress(contract, version4), version4];
|
|
374453
374496
|
}
|
|
374454
374497
|
get state() {
|
|
374455
374498
|
return {
|
|
@@ -374613,8 +374656,8 @@ var AddressProviderContractV3 = class extends AbstractAddressProviderContract {
|
|
|
374613
374656
|
}
|
|
374614
374657
|
};
|
|
374615
374658
|
|
|
374616
|
-
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/core/address-provider/
|
|
374617
|
-
async function
|
|
374659
|
+
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/core/address-provider/createAddressProvider.js
|
|
374660
|
+
async function createAddressProvider(sdk, address, options) {
|
|
374618
374661
|
const addr = options?.state?.baseParams.addr ?? address;
|
|
374619
374662
|
let v = options?.state?.baseParams.version ?? options?.version;
|
|
374620
374663
|
if (!v) {
|
|
@@ -374896,7 +374939,7 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
374896
374939
|
},
|
|
374897
374940
|
"attaching"
|
|
374898
374941
|
);
|
|
374899
|
-
this.#addressProvider = await
|
|
374942
|
+
this.#addressProvider = await createAddressProvider(this, addressProvider);
|
|
374900
374943
|
this.logger?.debug(
|
|
374901
374944
|
`address provider version: ${this.#addressProvider.version}`
|
|
374902
374945
|
);
|
|
@@ -374921,8 +374964,7 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
374921
374964
|
ignoreUpdateablePrices
|
|
374922
374965
|
);
|
|
374923
374966
|
try {
|
|
374924
|
-
|
|
374925
|
-
this.#router = new RouterV3Contract(this, router);
|
|
374967
|
+
this.#router = createRouter(this);
|
|
374926
374968
|
} catch (e) {
|
|
374927
374969
|
this.logger?.warn("Router not found", e);
|
|
374928
374970
|
}
|
|
@@ -400383,7 +400425,7 @@ var AccountOpener = class extends SDKConstruct {
|
|
|
400383
400425
|
);
|
|
400384
400426
|
const depositor = await this.#createAccount();
|
|
400385
400427
|
this.#logger?.debug(`created depositor ${depositor.address}`);
|
|
400386
|
-
await this.#claimFromFaucet(depositor, totalUSD);
|
|
400428
|
+
await this.#claimFromFaucet(depositor, "depositor", totalUSD);
|
|
400387
400429
|
for (const [pool, amount] of deposits) {
|
|
400388
400430
|
try {
|
|
400389
400431
|
await this.#depositToPool(pool, depositor, amount);
|
|
@@ -400462,16 +400504,20 @@ var AccountOpener = class extends SDKConstruct {
|
|
|
400462
400504
|
}
|
|
400463
400505
|
}
|
|
400464
400506
|
claimUSD = claimUSD * 11n / 10n;
|
|
400465
|
-
await this.#claimFromFaucet(borrower, claimUSD);
|
|
400507
|
+
await this.#claimFromFaucet(borrower, "borrower", claimUSD);
|
|
400466
400508
|
for (const [degenNFT, amount] of Object.entries(degenNFTS)) {
|
|
400467
400509
|
await this.#mintDegenNft(degenNFT, borrower.address, amount);
|
|
400468
400510
|
}
|
|
400469
400511
|
this.#logger?.debug("prepared borrower");
|
|
400470
400512
|
return borrower;
|
|
400471
400513
|
}
|
|
400472
|
-
async #claimFromFaucet(claimer, amountUSD) {
|
|
400514
|
+
async #claimFromFaucet(claimer, role, amountUSD) {
|
|
400473
400515
|
const [usr, amnt] = [claimer.address, formatBN(amountUSD, 8)];
|
|
400474
|
-
this.#logger?.debug(
|
|
400516
|
+
this.#logger?.debug(`${role} ${usr} claiming ${amnt} USD from faucet`);
|
|
400517
|
+
if (amountUSD === 0n) {
|
|
400518
|
+
this.#logger?.debug("amount is 0, skipping claim");
|
|
400519
|
+
return;
|
|
400520
|
+
}
|
|
400475
400521
|
const hash2 = await this.#anvil.writeContract({
|
|
400476
400522
|
account: claimer,
|
|
400477
400523
|
address: this.#faucet,
|
|
@@ -400495,11 +400541,11 @@ var AccountOpener = class extends SDKConstruct {
|
|
|
400495
400541
|
});
|
|
400496
400542
|
if (receipt.status === "reverted") {
|
|
400497
400543
|
throw new Error(
|
|
400498
|
-
|
|
400544
|
+
`${role} ${usr} failed to claimed equivalent of ${amnt} USD from faucet, tx: ${hash2}`
|
|
400499
400545
|
);
|
|
400500
400546
|
}
|
|
400501
400547
|
this.#logger?.debug(
|
|
400502
|
-
|
|
400548
|
+
`${role} ${usr} claimed equivalent of ${amnt} USD from faucet, tx: ${hash2}`
|
|
400503
400549
|
);
|
|
400504
400550
|
}
|
|
400505
400551
|
async #approve(token, cm) {
|
|
@@ -400755,15 +400801,27 @@ var SDKExample = class {
|
|
|
400755
400801
|
await anvil.impersonateAccount({ address: owner });
|
|
400756
400802
|
await anvil.setBalance({
|
|
400757
400803
|
address: owner,
|
|
400758
|
-
value: parseEther("
|
|
400804
|
+
value: parseEther("1000")
|
|
400805
|
+
});
|
|
400806
|
+
const balance = await anvil.getBalance({ address: owner });
|
|
400807
|
+
this.#logger?.debug(`owner balance: ${formatEther(balance)} ETH`);
|
|
400808
|
+
const { request } = await anvil.simulateContract({
|
|
400809
|
+
chain: anvil.chain,
|
|
400810
|
+
account: owner,
|
|
400811
|
+
address: addressProvider,
|
|
400812
|
+
abi: iAddressProviderV310Abi,
|
|
400813
|
+
functionName: "setAddress",
|
|
400814
|
+
args: [stringToHex("FAUCET", { size: 32 }), faucetAddr, false]
|
|
400759
400815
|
});
|
|
400816
|
+
this.#logger?.debug("estimated setAddress call");
|
|
400760
400817
|
const hash2 = await anvil.writeContract({
|
|
400761
400818
|
chain: anvil.chain,
|
|
400762
400819
|
account: owner,
|
|
400763
400820
|
address: addressProvider,
|
|
400764
400821
|
abi: iAddressProviderV310Abi,
|
|
400765
400822
|
functionName: "setAddress",
|
|
400766
|
-
args: [stringToHex("FAUCET", { size: 32 }), faucetAddr,
|
|
400823
|
+
args: [stringToHex("FAUCET", { size: 32 }), faucetAddr, false],
|
|
400824
|
+
gas: request.gas ? request.gas * 11n / 10n : void 0
|
|
400767
400825
|
});
|
|
400768
400826
|
const receipt = await anvil.waitForTransactionReceipt({ hash: hash2 });
|
|
400769
400827
|
await anvil.stopImpersonatingAccount({ address: owner });
|
|
@@ -407566,7 +407624,7 @@ function getRenderer(opts) {
|
|
|
407566
407624
|
var package_default = {
|
|
407567
407625
|
name: "@gearbox-protocol/deploy-tools",
|
|
407568
407626
|
description: "Gearbox deploy tools",
|
|
407569
|
-
version: "5.16.
|
|
407627
|
+
version: "5.16.13",
|
|
407570
407628
|
homepage: "https://gearbox.fi",
|
|
407571
407629
|
keywords: [
|
|
407572
407630
|
"gearbox"
|
|
@@ -407609,7 +407667,7 @@ var package_default = {
|
|
|
407609
407667
|
"@gearbox-protocol/deploy-tools-node": "0.0.0",
|
|
407610
407668
|
"@gearbox-protocol/deploy-tools-shared": "0.0.0",
|
|
407611
407669
|
"@gearbox-protocol/deploy-tools-types": "0.0.0",
|
|
407612
|
-
"@gearbox-protocol/sdk": "3.0.0-vfour.
|
|
407670
|
+
"@gearbox-protocol/sdk": "3.0.0-vfour.279",
|
|
407613
407671
|
"@gearbox-protocol/sdk-gov": "^2.36.5",
|
|
407614
407672
|
"@types/lodash-es": "^4.17.12",
|
|
407615
407673
|
"@types/node": "^22.13.5",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/deploy-tools",
|
|
3
3
|
"description": "Gearbox deploy tools",
|
|
4
|
-
"version": "5.16.
|
|
4
|
+
"version": "5.16.13",
|
|
5
5
|
"homepage": "https://gearbox.fi",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"gearbox"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@gearbox-protocol/deploy-tools-node": "0.0.0",
|
|
45
45
|
"@gearbox-protocol/deploy-tools-shared": "0.0.0",
|
|
46
46
|
"@gearbox-protocol/deploy-tools-types": "0.0.0",
|
|
47
|
-
"@gearbox-protocol/sdk": "3.0.0-vfour.
|
|
47
|
+
"@gearbox-protocol/sdk": "3.0.0-vfour.279",
|
|
48
48
|
"@gearbox-protocol/sdk-gov": "^2.36.5",
|
|
49
49
|
"@types/lodash-es": "^4.17.12",
|
|
50
50
|
"@types/node": "^22.13.5",
|