@gearbox-protocol/sdk 10.5.0 → 10.7.0
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/cjs/abi/310/generated.js +239 -25
- package/dist/cjs/dev/RevolverTransport.js +3 -0
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +20 -3
- package/dist/cjs/sdk/market/MarketSuite.js +4 -0
- package/dist/cjs/sdk/market/credit/CreditFacadeV300Contract.js +4 -1
- package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +2 -2
- package/dist/cjs/sdk/market/loss-policy/AliasLossPolicyV310Contract.js +66 -0
- package/dist/cjs/sdk/market/loss-policy/LossPolicyContract.js +43 -0
- package/dist/cjs/sdk/market/loss-policy/createLossPolicy.js +48 -0
- package/dist/cjs/sdk/market/loss-policy/index.js +28 -0
- package/dist/cjs/sdk/market/loss-policy/types.js +16 -0
- package/dist/esm/abi/310/generated.js +238 -25
- package/dist/esm/dev/RevolverTransport.js +4 -0
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +20 -3
- package/dist/esm/sdk/market/MarketSuite.js +6 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV300Contract.js +4 -1
- package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +2 -2
- package/dist/esm/sdk/market/loss-policy/AliasLossPolicyV310Contract.js +42 -0
- package/dist/esm/sdk/market/loss-policy/LossPolicyContract.js +19 -0
- package/dist/esm/sdk/market/loss-policy/createLossPolicy.js +24 -0
- package/dist/esm/sdk/market/loss-policy/index.js +4 -0
- package/dist/esm/sdk/market/loss-policy/types.js +0 -0
- package/dist/types/abi/310/generated.d.ts +292 -22
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +2 -2
- package/dist/types/sdk/accounts/types.d.ts +8 -1
- package/dist/types/sdk/market/MarketSuite.d.ts +2 -0
- package/dist/types/sdk/market/credit/CreditFacadeV300Contract.d.ts +2 -2
- package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +2 -2
- package/dist/types/sdk/market/loss-policy/AliasLossPolicyV310Contract.d.ts +280 -0
- package/dist/types/sdk/market/loss-policy/LossPolicyContract.d.ts +136 -0
- package/dist/types/sdk/market/loss-policy/createLossPolicy.d.ts +16 -0
- package/dist/types/sdk/market/loss-policy/index.d.ts +4 -0
- package/dist/types/sdk/market/loss-policy/types.d.ts +13 -0
- package/dist/types/sdk/types/state-human.d.ts +1 -0
- package/package.json +5 -5
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var generated_exports = {};
|
|
20
20
|
__export(generated_exports, {
|
|
21
21
|
iAddressProviderV310Abi: () => iAddressProviderV310Abi,
|
|
22
|
+
iAliasedLossPolicyV310Abi: () => iAliasedLossPolicyV310Abi,
|
|
22
23
|
iBotListV310Abi: () => iBotListV310Abi,
|
|
23
24
|
iCreditConfiguratorV310Abi: () => iCreditConfiguratorV310Abi,
|
|
24
25
|
iCreditFacadeMulticallV310Abi: () => iCreditFacadeMulticallV310Abi,
|
|
@@ -2361,101 +2362,313 @@ const iGaugeV310Abi = [
|
|
|
2361
2362
|
const iLossPolicyV310Abi = [
|
|
2362
2363
|
{
|
|
2363
2364
|
type: "function",
|
|
2364
|
-
inputs: [],
|
|
2365
2365
|
name: "accessMode",
|
|
2366
|
+
inputs: [],
|
|
2366
2367
|
outputs: [
|
|
2367
|
-
{ name: "", internalType: "enum ILossPolicy.AccessMode"
|
|
2368
|
+
{ name: "", type: "uint8", internalType: "enum ILossPolicy.AccessMode" }
|
|
2368
2369
|
],
|
|
2369
2370
|
stateMutability: "view"
|
|
2370
2371
|
},
|
|
2371
2372
|
{
|
|
2372
2373
|
type: "function",
|
|
2373
|
-
inputs: [],
|
|
2374
2374
|
name: "checksEnabled",
|
|
2375
|
-
|
|
2375
|
+
inputs: [],
|
|
2376
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2376
2377
|
stateMutability: "view"
|
|
2377
2378
|
},
|
|
2378
2379
|
{
|
|
2379
2380
|
type: "function",
|
|
2380
|
-
inputs: [],
|
|
2381
2381
|
name: "contractType",
|
|
2382
|
-
|
|
2382
|
+
inputs: [],
|
|
2383
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
2383
2384
|
stateMutability: "view"
|
|
2384
2385
|
},
|
|
2385
2386
|
{
|
|
2386
2387
|
type: "function",
|
|
2388
|
+
name: "isLiquidatableWithLoss",
|
|
2387
2389
|
inputs: [
|
|
2388
|
-
{ name: "creditAccount",
|
|
2389
|
-
{ name: "caller",
|
|
2390
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
2391
|
+
{ name: "caller", type: "address", internalType: "address" },
|
|
2390
2392
|
{
|
|
2391
2393
|
name: "params",
|
|
2394
|
+
type: "tuple",
|
|
2392
2395
|
internalType: "struct ILossPolicy.Params",
|
|
2396
|
+
components: [
|
|
2397
|
+
{ name: "totalDebtUSD", type: "uint256", internalType: "uint256" },
|
|
2398
|
+
{ name: "twvUSD", type: "uint256", internalType: "uint256" },
|
|
2399
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
2400
|
+
]
|
|
2401
|
+
}
|
|
2402
|
+
],
|
|
2403
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2404
|
+
stateMutability: "nonpayable"
|
|
2405
|
+
},
|
|
2406
|
+
{
|
|
2407
|
+
type: "function",
|
|
2408
|
+
name: "serialize",
|
|
2409
|
+
inputs: [],
|
|
2410
|
+
outputs: [{ name: "serializedData", type: "bytes", internalType: "bytes" }],
|
|
2411
|
+
stateMutability: "view"
|
|
2412
|
+
},
|
|
2413
|
+
{
|
|
2414
|
+
type: "function",
|
|
2415
|
+
name: "setAccessMode",
|
|
2416
|
+
inputs: [
|
|
2417
|
+
{
|
|
2418
|
+
name: "mode",
|
|
2419
|
+
type: "uint8",
|
|
2420
|
+
internalType: "enum ILossPolicy.AccessMode"
|
|
2421
|
+
}
|
|
2422
|
+
],
|
|
2423
|
+
outputs: [],
|
|
2424
|
+
stateMutability: "nonpayable"
|
|
2425
|
+
},
|
|
2426
|
+
{
|
|
2427
|
+
type: "function",
|
|
2428
|
+
name: "setChecksEnabled",
|
|
2429
|
+
inputs: [{ name: "enabled", type: "bool", internalType: "bool" }],
|
|
2430
|
+
outputs: [],
|
|
2431
|
+
stateMutability: "nonpayable"
|
|
2432
|
+
},
|
|
2433
|
+
{
|
|
2434
|
+
type: "function",
|
|
2435
|
+
name: "version",
|
|
2436
|
+
inputs: [],
|
|
2437
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2438
|
+
stateMutability: "view"
|
|
2439
|
+
},
|
|
2440
|
+
{
|
|
2441
|
+
type: "event",
|
|
2442
|
+
name: "SetAccessMode",
|
|
2443
|
+
inputs: [
|
|
2444
|
+
{
|
|
2445
|
+
name: "mode",
|
|
2446
|
+
type: "uint8",
|
|
2447
|
+
indexed: false,
|
|
2448
|
+
internalType: "enum ILossPolicy.AccessMode"
|
|
2449
|
+
}
|
|
2450
|
+
],
|
|
2451
|
+
anonymous: false
|
|
2452
|
+
},
|
|
2453
|
+
{
|
|
2454
|
+
type: "event",
|
|
2455
|
+
name: "SetChecksEnabled",
|
|
2456
|
+
inputs: [
|
|
2457
|
+
{ name: "enabled", type: "bool", indexed: false, internalType: "bool" }
|
|
2458
|
+
],
|
|
2459
|
+
anonymous: false
|
|
2460
|
+
}
|
|
2461
|
+
];
|
|
2462
|
+
const iAliasedLossPolicyV310Abi = [
|
|
2463
|
+
{
|
|
2464
|
+
type: "function",
|
|
2465
|
+
name: "accessMode",
|
|
2466
|
+
inputs: [],
|
|
2467
|
+
outputs: [
|
|
2468
|
+
{ name: "", type: "uint8", internalType: "enum ILossPolicy.AccessMode" }
|
|
2469
|
+
],
|
|
2470
|
+
stateMutability: "view"
|
|
2471
|
+
},
|
|
2472
|
+
{
|
|
2473
|
+
type: "function",
|
|
2474
|
+
name: "acl",
|
|
2475
|
+
inputs: [],
|
|
2476
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2477
|
+
stateMutability: "view"
|
|
2478
|
+
},
|
|
2479
|
+
{
|
|
2480
|
+
type: "function",
|
|
2481
|
+
name: "checksEnabled",
|
|
2482
|
+
inputs: [],
|
|
2483
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2484
|
+
stateMutability: "view"
|
|
2485
|
+
},
|
|
2486
|
+
{
|
|
2487
|
+
type: "function",
|
|
2488
|
+
name: "contractType",
|
|
2489
|
+
inputs: [],
|
|
2490
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
2491
|
+
stateMutability: "view"
|
|
2492
|
+
},
|
|
2493
|
+
{
|
|
2494
|
+
type: "function",
|
|
2495
|
+
name: "getAliasPriceFeedParams",
|
|
2496
|
+
inputs: [{ name: "token", type: "address", internalType: "address" }],
|
|
2497
|
+
outputs: [
|
|
2498
|
+
{
|
|
2499
|
+
name: "",
|
|
2393
2500
|
type: "tuple",
|
|
2501
|
+
internalType: "struct PriceFeedParams",
|
|
2394
2502
|
components: [
|
|
2395
|
-
{ name: "
|
|
2396
|
-
{ name: "
|
|
2397
|
-
{ name: "
|
|
2503
|
+
{ name: "priceFeed", type: "address", internalType: "address" },
|
|
2504
|
+
{ name: "stalenessPeriod", type: "uint32", internalType: "uint32" },
|
|
2505
|
+
{ name: "skipCheck", type: "bool", internalType: "bool" },
|
|
2506
|
+
{ name: "tokenDecimals", type: "uint8", internalType: "uint8" }
|
|
2398
2507
|
]
|
|
2399
2508
|
}
|
|
2400
2509
|
],
|
|
2510
|
+
stateMutability: "view"
|
|
2511
|
+
},
|
|
2512
|
+
{
|
|
2513
|
+
type: "function",
|
|
2514
|
+
name: "getRequiredAliasPriceFeeds",
|
|
2515
|
+
inputs: [
|
|
2516
|
+
{ name: "creditAccount", type: "address", internalType: "address" }
|
|
2517
|
+
],
|
|
2518
|
+
outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
|
|
2519
|
+
stateMutability: "view"
|
|
2520
|
+
},
|
|
2521
|
+
{
|
|
2522
|
+
type: "function",
|
|
2523
|
+
name: "getTokensWithAlias",
|
|
2524
|
+
inputs: [],
|
|
2525
|
+
outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
|
|
2526
|
+
stateMutability: "view"
|
|
2527
|
+
},
|
|
2528
|
+
{
|
|
2529
|
+
type: "function",
|
|
2401
2530
|
name: "isLiquidatableWithLoss",
|
|
2402
|
-
|
|
2531
|
+
inputs: [
|
|
2532
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
2533
|
+
{ name: "caller", type: "address", internalType: "address" },
|
|
2534
|
+
{
|
|
2535
|
+
name: "params",
|
|
2536
|
+
type: "tuple",
|
|
2537
|
+
internalType: "struct ILossPolicy.Params",
|
|
2538
|
+
components: [
|
|
2539
|
+
{ name: "totalDebtUSD", type: "uint256", internalType: "uint256" },
|
|
2540
|
+
{ name: "twvUSD", type: "uint256", internalType: "uint256" },
|
|
2541
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
2542
|
+
]
|
|
2543
|
+
}
|
|
2544
|
+
],
|
|
2545
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2403
2546
|
stateMutability: "nonpayable"
|
|
2404
2547
|
},
|
|
2405
2548
|
{
|
|
2406
2549
|
type: "function",
|
|
2550
|
+
name: "pool",
|
|
2551
|
+
inputs: [],
|
|
2552
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2553
|
+
stateMutability: "view"
|
|
2554
|
+
},
|
|
2555
|
+
{
|
|
2556
|
+
type: "function",
|
|
2557
|
+
name: "priceFeedStore",
|
|
2407
2558
|
inputs: [],
|
|
2559
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2560
|
+
stateMutability: "view"
|
|
2561
|
+
},
|
|
2562
|
+
{
|
|
2563
|
+
type: "function",
|
|
2408
2564
|
name: "serialize",
|
|
2409
|
-
|
|
2565
|
+
inputs: [],
|
|
2566
|
+
outputs: [{ name: "serializedData", type: "bytes", internalType: "bytes" }],
|
|
2410
2567
|
stateMutability: "view"
|
|
2411
2568
|
},
|
|
2412
2569
|
{
|
|
2413
2570
|
type: "function",
|
|
2571
|
+
name: "setAccessMode",
|
|
2414
2572
|
inputs: [
|
|
2415
2573
|
{
|
|
2416
2574
|
name: "mode",
|
|
2417
|
-
|
|
2418
|
-
|
|
2575
|
+
type: "uint8",
|
|
2576
|
+
internalType: "enum ILossPolicy.AccessMode"
|
|
2419
2577
|
}
|
|
2420
2578
|
],
|
|
2421
|
-
name: "setAccessMode",
|
|
2422
2579
|
outputs: [],
|
|
2423
2580
|
stateMutability: "nonpayable"
|
|
2424
2581
|
},
|
|
2425
2582
|
{
|
|
2426
2583
|
type: "function",
|
|
2427
|
-
|
|
2584
|
+
name: "setAliasPriceFeed",
|
|
2585
|
+
inputs: [
|
|
2586
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2587
|
+
{ name: "priceFeed", type: "address", internalType: "address" }
|
|
2588
|
+
],
|
|
2589
|
+
outputs: [],
|
|
2590
|
+
stateMutability: "nonpayable"
|
|
2591
|
+
},
|
|
2592
|
+
{
|
|
2593
|
+
type: "function",
|
|
2428
2594
|
name: "setChecksEnabled",
|
|
2595
|
+
inputs: [{ name: "enabled", type: "bool", internalType: "bool" }],
|
|
2429
2596
|
outputs: [],
|
|
2430
2597
|
stateMutability: "nonpayable"
|
|
2431
2598
|
},
|
|
2432
2599
|
{
|
|
2433
2600
|
type: "function",
|
|
2601
|
+
name: "underlying",
|
|
2434
2602
|
inputs: [],
|
|
2603
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2604
|
+
stateMutability: "view"
|
|
2605
|
+
},
|
|
2606
|
+
{
|
|
2607
|
+
type: "function",
|
|
2435
2608
|
name: "version",
|
|
2436
|
-
|
|
2609
|
+
inputs: [],
|
|
2610
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2437
2611
|
stateMutability: "view"
|
|
2438
2612
|
},
|
|
2439
2613
|
{
|
|
2440
2614
|
type: "event",
|
|
2441
|
-
|
|
2615
|
+
name: "SetAccessMode",
|
|
2442
2616
|
inputs: [
|
|
2443
2617
|
{
|
|
2444
2618
|
name: "mode",
|
|
2445
|
-
internalType: "enum ILossPolicy.AccessMode",
|
|
2446
2619
|
type: "uint8",
|
|
2447
|
-
indexed: false
|
|
2620
|
+
indexed: false,
|
|
2621
|
+
internalType: "enum ILossPolicy.AccessMode"
|
|
2448
2622
|
}
|
|
2449
2623
|
],
|
|
2450
|
-
|
|
2624
|
+
anonymous: false
|
|
2451
2625
|
},
|
|
2452
2626
|
{
|
|
2453
2627
|
type: "event",
|
|
2454
|
-
|
|
2628
|
+
name: "SetAliasPriceFeed",
|
|
2455
2629
|
inputs: [
|
|
2456
|
-
{
|
|
2630
|
+
{
|
|
2631
|
+
name: "token",
|
|
2632
|
+
type: "address",
|
|
2633
|
+
indexed: true,
|
|
2634
|
+
internalType: "address"
|
|
2635
|
+
},
|
|
2636
|
+
{
|
|
2637
|
+
name: "priceFeed",
|
|
2638
|
+
type: "address",
|
|
2639
|
+
indexed: true,
|
|
2640
|
+
internalType: "address"
|
|
2641
|
+
},
|
|
2642
|
+
{
|
|
2643
|
+
name: "stalenessPeriod",
|
|
2644
|
+
type: "uint32",
|
|
2645
|
+
indexed: false,
|
|
2646
|
+
internalType: "uint32"
|
|
2647
|
+
},
|
|
2648
|
+
{ name: "skipCheck", type: "bool", indexed: false, internalType: "bool" }
|
|
2649
|
+
],
|
|
2650
|
+
anonymous: false
|
|
2651
|
+
},
|
|
2652
|
+
{
|
|
2653
|
+
type: "event",
|
|
2654
|
+
name: "SetChecksEnabled",
|
|
2655
|
+
inputs: [
|
|
2656
|
+
{ name: "enabled", type: "bool", indexed: false, internalType: "bool" }
|
|
2657
|
+
],
|
|
2658
|
+
anonymous: false
|
|
2659
|
+
},
|
|
2660
|
+
{
|
|
2661
|
+
type: "event",
|
|
2662
|
+
name: "UnsetAliasPriceFeed",
|
|
2663
|
+
inputs: [
|
|
2664
|
+
{
|
|
2665
|
+
name: "token",
|
|
2666
|
+
type: "address",
|
|
2667
|
+
indexed: true,
|
|
2668
|
+
internalType: "address"
|
|
2669
|
+
}
|
|
2457
2670
|
],
|
|
2458
|
-
|
|
2671
|
+
anonymous: false
|
|
2459
2672
|
}
|
|
2460
2673
|
];
|
|
2461
2674
|
const iMarketConfiguratorV310Abi = [
|
|
@@ -5151,6 +5364,7 @@ const iTumblerV310Abi = [
|
|
|
5151
5364
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5152
5365
|
0 && (module.exports = {
|
|
5153
5366
|
iAddressProviderV310Abi,
|
|
5367
|
+
iAliasedLossPolicyV310Abi,
|
|
5154
5368
|
iBotListV310Abi,
|
|
5155
5369
|
iCreditConfiguratorV310Abi,
|
|
5156
5370
|
iCreditFacadeMulticallV310Abi,
|
|
@@ -184,6 +184,9 @@ const retryCodes = /* @__PURE__ */ new Set([
|
|
|
184
184
|
const defaultShouldRetry = ({
|
|
185
185
|
error
|
|
186
186
|
}) => {
|
|
187
|
+
if (error instanceof import_viem.CallExecutionError && error.details === "header not found") {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
187
190
|
if ("code" in error && typeof error.code === "number") {
|
|
188
191
|
return retryCodes.has(error.code);
|
|
189
192
|
}
|
|
@@ -265,7 +265,8 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
265
265
|
slippage = 50n,
|
|
266
266
|
force = false,
|
|
267
267
|
keepAssets,
|
|
268
|
-
ignoreReservePrices
|
|
268
|
+
ignoreReservePrices,
|
|
269
|
+
applyLossPolicy
|
|
269
270
|
} = props;
|
|
270
271
|
const cm = this.sdk.marketRegister.findCreditManager(account.creditManager);
|
|
271
272
|
const routerCloseResult = await this.sdk.routerFor(account).findBestClosePath({
|
|
@@ -281,12 +282,28 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
281
282
|
ignoreReservePrices
|
|
282
283
|
});
|
|
283
284
|
const calls = [...priceUpdates, ...routerCloseResult.calls];
|
|
285
|
+
let lossPolicyData;
|
|
286
|
+
if (applyLossPolicy) {
|
|
287
|
+
const market = this.sdk.marketRegister.findByCreditManager(
|
|
288
|
+
account.creditManager
|
|
289
|
+
);
|
|
290
|
+
lossPolicyData = await market.lossPolicy.getLiquidationData(
|
|
291
|
+
account.creditAccount
|
|
292
|
+
);
|
|
293
|
+
}
|
|
284
294
|
const tx = cm.creditFacade.liquidateCreditAccount(
|
|
285
295
|
account.creditAccount,
|
|
286
296
|
to,
|
|
287
|
-
calls
|
|
297
|
+
calls,
|
|
298
|
+
lossPolicyData
|
|
288
299
|
);
|
|
289
|
-
return {
|
|
300
|
+
return {
|
|
301
|
+
tx,
|
|
302
|
+
calls,
|
|
303
|
+
routerCloseResult,
|
|
304
|
+
lossPolicyData,
|
|
305
|
+
creditFacade: cm.creditFacade
|
|
306
|
+
};
|
|
290
307
|
}
|
|
291
308
|
/**
|
|
292
309
|
* Closes credit account or closes credit account and keeps it open with zero debt.
|
|
@@ -23,6 +23,7 @@ __export(MarketSuite_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(MarketSuite_exports);
|
|
24
24
|
var import_base = require("../base/index.js");
|
|
25
25
|
var import_credit = require("./credit/index.js");
|
|
26
|
+
var import_loss_policy = require("./loss-policy/index.js");
|
|
26
27
|
var import_MarketConfiguratorContract = require("./MarketConfiguratorContract.js");
|
|
27
28
|
var import_oracle = require("./oracle/index.js");
|
|
28
29
|
var import_pool = require("./pool/index.js");
|
|
@@ -32,6 +33,7 @@ class MarketSuite extends import_base.SDKConstruct {
|
|
|
32
33
|
configurator;
|
|
33
34
|
pool;
|
|
34
35
|
priceOracle;
|
|
36
|
+
lossPolicy;
|
|
35
37
|
creditManagers = [];
|
|
36
38
|
/**
|
|
37
39
|
* Original data received from compressor
|
|
@@ -58,6 +60,7 @@ class MarketSuite extends import_base.SDKConstruct {
|
|
|
58
60
|
this.creditManagers.push(new import_credit.CreditSuite(sdk, marketData, i));
|
|
59
61
|
}
|
|
60
62
|
this.priceOracle = (0, import_oracle.getOrCreatePriceOracle)(sdk, marketData.priceOracle);
|
|
63
|
+
this.lossPolicy = (0, import_loss_policy.createLossPolicy)(sdk, marketData.lossPolicy);
|
|
61
64
|
}
|
|
62
65
|
get dirty() {
|
|
63
66
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
@@ -77,6 +80,7 @@ class MarketSuite extends import_base.SDKConstruct {
|
|
|
77
80
|
pool: this.pool.stateHuman(raw),
|
|
78
81
|
creditManagers: this.creditManagers.map((cm) => cm.stateHuman(raw)),
|
|
79
82
|
priceOracle: this.priceOracle.stateHuman(raw),
|
|
83
|
+
lossPolicy: this.lossPolicy.stateHuman(raw),
|
|
80
84
|
pausableAdmins: this.state.pausableAdmins.map((a) => this.labelAddress(a)),
|
|
81
85
|
unpausableAdmins: this.state.unpausableAdmins.map(
|
|
82
86
|
(a) => this.labelAddress(a)
|
|
@@ -81,7 +81,10 @@ class CreditFacadeV300Contract extends import_base.BaseContract {
|
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
liquidateCreditAccount(ca, to, calls) {
|
|
84
|
+
liquidateCreditAccount(ca, to, calls, lossPolicyData) {
|
|
85
|
+
if (lossPolicyData) {
|
|
86
|
+
this.logger?.warn("loss policy data is not supported");
|
|
87
|
+
}
|
|
85
88
|
return this.createRawTx({
|
|
86
89
|
functionName: "liquidateCreditAccount",
|
|
87
90
|
args: [ca, to, calls]
|
|
@@ -81,10 +81,10 @@ class CreditFacadeV310Contract extends import_base.BaseContract {
|
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
liquidateCreditAccount(ca, to, calls) {
|
|
84
|
+
liquidateCreditAccount(ca, to, calls, lossPolicyData) {
|
|
85
85
|
return this.createRawTx({
|
|
86
86
|
functionName: "liquidateCreditAccount",
|
|
87
|
-
args: [ca, to, calls]
|
|
87
|
+
args: lossPolicyData ? [ca, to, calls, lossPolicyData] : [ca, to, calls]
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
closeCreditAccount(ca, calls) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var AliasLossPolicyV310Contract_exports = {};
|
|
20
|
+
__export(AliasLossPolicyV310Contract_exports, {
|
|
21
|
+
AliasLossPolicyV310Contract: () => AliasLossPolicyV310Contract
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(AliasLossPolicyV310Contract_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_generated = require("../../../abi/310/generated.js");
|
|
26
|
+
var import_base = require("../../base/index.js");
|
|
27
|
+
const abi = import_generated.iAliasedLossPolicyV310Abi;
|
|
28
|
+
class AliasLossPolicyV310Contract extends import_base.BaseContract {
|
|
29
|
+
constructor(sdk, params) {
|
|
30
|
+
super(sdk, {
|
|
31
|
+
abi,
|
|
32
|
+
addr: params.addr,
|
|
33
|
+
contractType: params.contractType,
|
|
34
|
+
version: params.version
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async getLiquidationData(creditAccount, blockNumber) {
|
|
38
|
+
const pfs = await this.sdk.client.readContract({
|
|
39
|
+
address: this.address,
|
|
40
|
+
abi: this.abi,
|
|
41
|
+
functionName: "getRequiredAliasPriceFeeds",
|
|
42
|
+
args: [creditAccount],
|
|
43
|
+
blockNumber
|
|
44
|
+
});
|
|
45
|
+
const updates = await this.sdk.priceFeeds.generateExternalPriceFeedsUpdates(
|
|
46
|
+
[...pfs],
|
|
47
|
+
blockNumber ? { blockNumber } : void 0
|
|
48
|
+
);
|
|
49
|
+
return (0, import_viem.encodeAbiParameters)(
|
|
50
|
+
[
|
|
51
|
+
{
|
|
52
|
+
type: "tuple[]",
|
|
53
|
+
components: [
|
|
54
|
+
{ type: "address", name: "priceFeed" },
|
|
55
|
+
{ type: "bytes", name: "data" }
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
[updates]
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
AliasLossPolicyV310Contract
|
|
66
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var LossPolicyContract_exports = {};
|
|
20
|
+
__export(LossPolicyContract_exports, {
|
|
21
|
+
LossPolicyContract: () => LossPolicyContract
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(LossPolicyContract_exports);
|
|
24
|
+
var import_generated = require("../../../abi/310/generated.js");
|
|
25
|
+
var import_base = require("../../base/index.js");
|
|
26
|
+
const abi = import_generated.iLossPolicyV310Abi;
|
|
27
|
+
class LossPolicyContract extends import_base.BaseContract {
|
|
28
|
+
constructor(sdk, params) {
|
|
29
|
+
super(sdk, {
|
|
30
|
+
abi,
|
|
31
|
+
addr: params.addr,
|
|
32
|
+
contractType: params.contractType,
|
|
33
|
+
version: params.version
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async getLiquidationData(_creditAccount, _blockNumber) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
LossPolicyContract
|
|
43
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var createLossPolicy_exports = {};
|
|
20
|
+
__export(createLossPolicy_exports, {
|
|
21
|
+
createLossPolicy: () => createLossPolicy
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(createLossPolicy_exports);
|
|
24
|
+
var import__ = require("../../index.js");
|
|
25
|
+
var import_AliasLossPolicyV310Contract = require("./AliasLossPolicyV310Contract.js");
|
|
26
|
+
var import_LossPolicyContract = require("./LossPolicyContract.js");
|
|
27
|
+
function createLossPolicy(sdk, { baseParams }) {
|
|
28
|
+
const existing = sdk.contracts.get(baseParams.addr);
|
|
29
|
+
if (existing) {
|
|
30
|
+
return existing;
|
|
31
|
+
}
|
|
32
|
+
const contractType = (0, import__.bytes32ToString)(baseParams.contractType);
|
|
33
|
+
switch (contractType) {
|
|
34
|
+
case "LOSS_POLICY::ALIASED":
|
|
35
|
+
return new import_AliasLossPolicyV310Contract.AliasLossPolicyV310Contract(sdk, baseParams);
|
|
36
|
+
case "LOSS_POLICY::DEFAULT":
|
|
37
|
+
return new import_LossPolicyContract.LossPolicyContract(sdk, baseParams);
|
|
38
|
+
default:
|
|
39
|
+
if (sdk.strictContractTypes) {
|
|
40
|
+
throw new Error(`unsupported loss policy type ${contractType}`);
|
|
41
|
+
}
|
|
42
|
+
return new import_LossPolicyContract.LossPolicyContract(sdk, baseParams);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
createLossPolicy
|
|
48
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var loss_policy_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(loss_policy_exports);
|
|
18
|
+
__reExport(loss_policy_exports, require("./AliasLossPolicyV310Contract.js"), module.exports);
|
|
19
|
+
__reExport(loss_policy_exports, require("./createLossPolicy.js"), module.exports);
|
|
20
|
+
__reExport(loss_policy_exports, require("./LossPolicyContract.js"), module.exports);
|
|
21
|
+
__reExport(loss_policy_exports, require("./types.js"), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require("./AliasLossPolicyV310Contract.js"),
|
|
25
|
+
...require("./createLossPolicy.js"),
|
|
26
|
+
...require("./LossPolicyContract.js"),
|
|
27
|
+
...require("./types.js")
|
|
28
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|