@gearbox-protocol/sdk 10.5.0 → 10.6.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/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 +40 -0
- package/dist/cjs/sdk/market/loss-policy/LossPolicyContract.js +40 -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/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 +16 -0
- package/dist/esm/sdk/market/loss-policy/LossPolicyContract.js +16 -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/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 +277 -0
- package/dist/types/sdk/market/loss-policy/LossPolicyContract.d.ts +133 -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 +5 -0
- package/dist/types/sdk/types/state-human.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2326,101 +2326,313 @@ const iGaugeV310Abi = [
|
|
|
2326
2326
|
const iLossPolicyV310Abi = [
|
|
2327
2327
|
{
|
|
2328
2328
|
type: "function",
|
|
2329
|
-
inputs: [],
|
|
2330
2329
|
name: "accessMode",
|
|
2330
|
+
inputs: [],
|
|
2331
2331
|
outputs: [
|
|
2332
|
-
{ name: "", internalType: "enum ILossPolicy.AccessMode"
|
|
2332
|
+
{ name: "", type: "uint8", internalType: "enum ILossPolicy.AccessMode" }
|
|
2333
2333
|
],
|
|
2334
2334
|
stateMutability: "view"
|
|
2335
2335
|
},
|
|
2336
2336
|
{
|
|
2337
2337
|
type: "function",
|
|
2338
|
-
inputs: [],
|
|
2339
2338
|
name: "checksEnabled",
|
|
2340
|
-
|
|
2339
|
+
inputs: [],
|
|
2340
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2341
2341
|
stateMutability: "view"
|
|
2342
2342
|
},
|
|
2343
2343
|
{
|
|
2344
2344
|
type: "function",
|
|
2345
|
-
inputs: [],
|
|
2346
2345
|
name: "contractType",
|
|
2347
|
-
|
|
2346
|
+
inputs: [],
|
|
2347
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
2348
2348
|
stateMutability: "view"
|
|
2349
2349
|
},
|
|
2350
2350
|
{
|
|
2351
2351
|
type: "function",
|
|
2352
|
+
name: "isLiquidatableWithLoss",
|
|
2352
2353
|
inputs: [
|
|
2353
|
-
{ name: "creditAccount",
|
|
2354
|
-
{ name: "caller",
|
|
2354
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
2355
|
+
{ name: "caller", type: "address", internalType: "address" },
|
|
2355
2356
|
{
|
|
2356
2357
|
name: "params",
|
|
2358
|
+
type: "tuple",
|
|
2357
2359
|
internalType: "struct ILossPolicy.Params",
|
|
2360
|
+
components: [
|
|
2361
|
+
{ name: "totalDebtUSD", type: "uint256", internalType: "uint256" },
|
|
2362
|
+
{ name: "twvUSD", type: "uint256", internalType: "uint256" },
|
|
2363
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
2364
|
+
]
|
|
2365
|
+
}
|
|
2366
|
+
],
|
|
2367
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2368
|
+
stateMutability: "nonpayable"
|
|
2369
|
+
},
|
|
2370
|
+
{
|
|
2371
|
+
type: "function",
|
|
2372
|
+
name: "serialize",
|
|
2373
|
+
inputs: [],
|
|
2374
|
+
outputs: [{ name: "serializedData", type: "bytes", internalType: "bytes" }],
|
|
2375
|
+
stateMutability: "view"
|
|
2376
|
+
},
|
|
2377
|
+
{
|
|
2378
|
+
type: "function",
|
|
2379
|
+
name: "setAccessMode",
|
|
2380
|
+
inputs: [
|
|
2381
|
+
{
|
|
2382
|
+
name: "mode",
|
|
2383
|
+
type: "uint8",
|
|
2384
|
+
internalType: "enum ILossPolicy.AccessMode"
|
|
2385
|
+
}
|
|
2386
|
+
],
|
|
2387
|
+
outputs: [],
|
|
2388
|
+
stateMutability: "nonpayable"
|
|
2389
|
+
},
|
|
2390
|
+
{
|
|
2391
|
+
type: "function",
|
|
2392
|
+
name: "setChecksEnabled",
|
|
2393
|
+
inputs: [{ name: "enabled", type: "bool", internalType: "bool" }],
|
|
2394
|
+
outputs: [],
|
|
2395
|
+
stateMutability: "nonpayable"
|
|
2396
|
+
},
|
|
2397
|
+
{
|
|
2398
|
+
type: "function",
|
|
2399
|
+
name: "version",
|
|
2400
|
+
inputs: [],
|
|
2401
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2402
|
+
stateMutability: "view"
|
|
2403
|
+
},
|
|
2404
|
+
{
|
|
2405
|
+
type: "event",
|
|
2406
|
+
name: "SetAccessMode",
|
|
2407
|
+
inputs: [
|
|
2408
|
+
{
|
|
2409
|
+
name: "mode",
|
|
2410
|
+
type: "uint8",
|
|
2411
|
+
indexed: false,
|
|
2412
|
+
internalType: "enum ILossPolicy.AccessMode"
|
|
2413
|
+
}
|
|
2414
|
+
],
|
|
2415
|
+
anonymous: false
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
type: "event",
|
|
2419
|
+
name: "SetChecksEnabled",
|
|
2420
|
+
inputs: [
|
|
2421
|
+
{ name: "enabled", type: "bool", indexed: false, internalType: "bool" }
|
|
2422
|
+
],
|
|
2423
|
+
anonymous: false
|
|
2424
|
+
}
|
|
2425
|
+
];
|
|
2426
|
+
const iAliasedLossPolicyV310Abi = [
|
|
2427
|
+
{
|
|
2428
|
+
type: "function",
|
|
2429
|
+
name: "accessMode",
|
|
2430
|
+
inputs: [],
|
|
2431
|
+
outputs: [
|
|
2432
|
+
{ name: "", type: "uint8", internalType: "enum ILossPolicy.AccessMode" }
|
|
2433
|
+
],
|
|
2434
|
+
stateMutability: "view"
|
|
2435
|
+
},
|
|
2436
|
+
{
|
|
2437
|
+
type: "function",
|
|
2438
|
+
name: "acl",
|
|
2439
|
+
inputs: [],
|
|
2440
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2441
|
+
stateMutability: "view"
|
|
2442
|
+
},
|
|
2443
|
+
{
|
|
2444
|
+
type: "function",
|
|
2445
|
+
name: "checksEnabled",
|
|
2446
|
+
inputs: [],
|
|
2447
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2448
|
+
stateMutability: "view"
|
|
2449
|
+
},
|
|
2450
|
+
{
|
|
2451
|
+
type: "function",
|
|
2452
|
+
name: "contractType",
|
|
2453
|
+
inputs: [],
|
|
2454
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
2455
|
+
stateMutability: "view"
|
|
2456
|
+
},
|
|
2457
|
+
{
|
|
2458
|
+
type: "function",
|
|
2459
|
+
name: "getAliasPriceFeedParams",
|
|
2460
|
+
inputs: [{ name: "token", type: "address", internalType: "address" }],
|
|
2461
|
+
outputs: [
|
|
2462
|
+
{
|
|
2463
|
+
name: "",
|
|
2358
2464
|
type: "tuple",
|
|
2465
|
+
internalType: "struct PriceFeedParams",
|
|
2359
2466
|
components: [
|
|
2360
|
-
{ name: "
|
|
2361
|
-
{ name: "
|
|
2362
|
-
{ name: "
|
|
2467
|
+
{ name: "priceFeed", type: "address", internalType: "address" },
|
|
2468
|
+
{ name: "stalenessPeriod", type: "uint32", internalType: "uint32" },
|
|
2469
|
+
{ name: "skipCheck", type: "bool", internalType: "bool" },
|
|
2470
|
+
{ name: "tokenDecimals", type: "uint8", internalType: "uint8" }
|
|
2363
2471
|
]
|
|
2364
2472
|
}
|
|
2365
2473
|
],
|
|
2474
|
+
stateMutability: "view"
|
|
2475
|
+
},
|
|
2476
|
+
{
|
|
2477
|
+
type: "function",
|
|
2478
|
+
name: "getRequiredAliasPriceFeeds",
|
|
2479
|
+
inputs: [
|
|
2480
|
+
{ name: "creditAccount", type: "address", internalType: "address" }
|
|
2481
|
+
],
|
|
2482
|
+
outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
|
|
2483
|
+
stateMutability: "view"
|
|
2484
|
+
},
|
|
2485
|
+
{
|
|
2486
|
+
type: "function",
|
|
2487
|
+
name: "getTokensWithAlias",
|
|
2488
|
+
inputs: [],
|
|
2489
|
+
outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
|
|
2490
|
+
stateMutability: "view"
|
|
2491
|
+
},
|
|
2492
|
+
{
|
|
2493
|
+
type: "function",
|
|
2366
2494
|
name: "isLiquidatableWithLoss",
|
|
2367
|
-
|
|
2495
|
+
inputs: [
|
|
2496
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
2497
|
+
{ name: "caller", type: "address", internalType: "address" },
|
|
2498
|
+
{
|
|
2499
|
+
name: "params",
|
|
2500
|
+
type: "tuple",
|
|
2501
|
+
internalType: "struct ILossPolicy.Params",
|
|
2502
|
+
components: [
|
|
2503
|
+
{ name: "totalDebtUSD", type: "uint256", internalType: "uint256" },
|
|
2504
|
+
{ name: "twvUSD", type: "uint256", internalType: "uint256" },
|
|
2505
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
2506
|
+
]
|
|
2507
|
+
}
|
|
2508
|
+
],
|
|
2509
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2368
2510
|
stateMutability: "nonpayable"
|
|
2369
2511
|
},
|
|
2370
2512
|
{
|
|
2371
2513
|
type: "function",
|
|
2514
|
+
name: "pool",
|
|
2515
|
+
inputs: [],
|
|
2516
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2517
|
+
stateMutability: "view"
|
|
2518
|
+
},
|
|
2519
|
+
{
|
|
2520
|
+
type: "function",
|
|
2521
|
+
name: "priceFeedStore",
|
|
2372
2522
|
inputs: [],
|
|
2523
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2524
|
+
stateMutability: "view"
|
|
2525
|
+
},
|
|
2526
|
+
{
|
|
2527
|
+
type: "function",
|
|
2373
2528
|
name: "serialize",
|
|
2374
|
-
|
|
2529
|
+
inputs: [],
|
|
2530
|
+
outputs: [{ name: "serializedData", type: "bytes", internalType: "bytes" }],
|
|
2375
2531
|
stateMutability: "view"
|
|
2376
2532
|
},
|
|
2377
2533
|
{
|
|
2378
2534
|
type: "function",
|
|
2535
|
+
name: "setAccessMode",
|
|
2379
2536
|
inputs: [
|
|
2380
2537
|
{
|
|
2381
2538
|
name: "mode",
|
|
2382
|
-
|
|
2383
|
-
|
|
2539
|
+
type: "uint8",
|
|
2540
|
+
internalType: "enum ILossPolicy.AccessMode"
|
|
2384
2541
|
}
|
|
2385
2542
|
],
|
|
2386
|
-
name: "setAccessMode",
|
|
2387
2543
|
outputs: [],
|
|
2388
2544
|
stateMutability: "nonpayable"
|
|
2389
2545
|
},
|
|
2390
2546
|
{
|
|
2391
2547
|
type: "function",
|
|
2392
|
-
|
|
2548
|
+
name: "setAliasPriceFeed",
|
|
2549
|
+
inputs: [
|
|
2550
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2551
|
+
{ name: "priceFeed", type: "address", internalType: "address" }
|
|
2552
|
+
],
|
|
2553
|
+
outputs: [],
|
|
2554
|
+
stateMutability: "nonpayable"
|
|
2555
|
+
},
|
|
2556
|
+
{
|
|
2557
|
+
type: "function",
|
|
2393
2558
|
name: "setChecksEnabled",
|
|
2559
|
+
inputs: [{ name: "enabled", type: "bool", internalType: "bool" }],
|
|
2394
2560
|
outputs: [],
|
|
2395
2561
|
stateMutability: "nonpayable"
|
|
2396
2562
|
},
|
|
2397
2563
|
{
|
|
2398
2564
|
type: "function",
|
|
2565
|
+
name: "underlying",
|
|
2399
2566
|
inputs: [],
|
|
2567
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2568
|
+
stateMutability: "view"
|
|
2569
|
+
},
|
|
2570
|
+
{
|
|
2571
|
+
type: "function",
|
|
2400
2572
|
name: "version",
|
|
2401
|
-
|
|
2573
|
+
inputs: [],
|
|
2574
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2402
2575
|
stateMutability: "view"
|
|
2403
2576
|
},
|
|
2404
2577
|
{
|
|
2405
2578
|
type: "event",
|
|
2406
|
-
|
|
2579
|
+
name: "SetAccessMode",
|
|
2407
2580
|
inputs: [
|
|
2408
2581
|
{
|
|
2409
2582
|
name: "mode",
|
|
2410
|
-
internalType: "enum ILossPolicy.AccessMode",
|
|
2411
2583
|
type: "uint8",
|
|
2412
|
-
indexed: false
|
|
2584
|
+
indexed: false,
|
|
2585
|
+
internalType: "enum ILossPolicy.AccessMode"
|
|
2413
2586
|
}
|
|
2414
2587
|
],
|
|
2415
|
-
|
|
2588
|
+
anonymous: false
|
|
2416
2589
|
},
|
|
2417
2590
|
{
|
|
2418
2591
|
type: "event",
|
|
2419
|
-
|
|
2592
|
+
name: "SetAliasPriceFeed",
|
|
2420
2593
|
inputs: [
|
|
2421
|
-
{
|
|
2594
|
+
{
|
|
2595
|
+
name: "token",
|
|
2596
|
+
type: "address",
|
|
2597
|
+
indexed: true,
|
|
2598
|
+
internalType: "address"
|
|
2599
|
+
},
|
|
2600
|
+
{
|
|
2601
|
+
name: "priceFeed",
|
|
2602
|
+
type: "address",
|
|
2603
|
+
indexed: true,
|
|
2604
|
+
internalType: "address"
|
|
2605
|
+
},
|
|
2606
|
+
{
|
|
2607
|
+
name: "stalenessPeriod",
|
|
2608
|
+
type: "uint32",
|
|
2609
|
+
indexed: false,
|
|
2610
|
+
internalType: "uint32"
|
|
2611
|
+
},
|
|
2612
|
+
{ name: "skipCheck", type: "bool", indexed: false, internalType: "bool" }
|
|
2613
|
+
],
|
|
2614
|
+
anonymous: false
|
|
2615
|
+
},
|
|
2616
|
+
{
|
|
2617
|
+
type: "event",
|
|
2618
|
+
name: "SetChecksEnabled",
|
|
2619
|
+
inputs: [
|
|
2620
|
+
{ name: "enabled", type: "bool", indexed: false, internalType: "bool" }
|
|
2621
|
+
],
|
|
2622
|
+
anonymous: false
|
|
2623
|
+
},
|
|
2624
|
+
{
|
|
2625
|
+
type: "event",
|
|
2626
|
+
name: "UnsetAliasPriceFeed",
|
|
2627
|
+
inputs: [
|
|
2628
|
+
{
|
|
2629
|
+
name: "token",
|
|
2630
|
+
type: "address",
|
|
2631
|
+
indexed: true,
|
|
2632
|
+
internalType: "address"
|
|
2633
|
+
}
|
|
2422
2634
|
],
|
|
2423
|
-
|
|
2635
|
+
anonymous: false
|
|
2424
2636
|
}
|
|
2425
2637
|
];
|
|
2426
2638
|
const iMarketConfiguratorV310Abi = [
|
|
@@ -5115,6 +5327,7 @@ const iTumblerV310Abi = [
|
|
|
5115
5327
|
];
|
|
5116
5328
|
export {
|
|
5117
5329
|
iAddressProviderV310Abi,
|
|
5330
|
+
iAliasedLossPolicyV310Abi,
|
|
5118
5331
|
iBotListV310Abi,
|
|
5119
5332
|
iCreditConfiguratorV310Abi,
|
|
5120
5333
|
iCreditFacadeMulticallV310Abi,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseError,
|
|
3
|
+
CallExecutionError,
|
|
3
4
|
HttpRequestError,
|
|
4
5
|
http,
|
|
5
6
|
InvalidInputRpcError,
|
|
@@ -171,6 +172,9 @@ const retryCodes = /* @__PURE__ */ new Set([
|
|
|
171
172
|
const defaultShouldRetry = ({
|
|
172
173
|
error
|
|
173
174
|
}) => {
|
|
175
|
+
if (error instanceof CallExecutionError && error.details === "header not found") {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
174
178
|
if ("code" in error && typeof error.code === "number") {
|
|
175
179
|
return retryCodes.has(error.code);
|
|
176
180
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { SDKConstruct } from "../base/index.js";
|
|
2
2
|
import { CreditSuite } from "./credit/index.js";
|
|
3
|
+
import {
|
|
4
|
+
createLossPolicy
|
|
5
|
+
} from "./loss-policy/index.js";
|
|
3
6
|
import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
4
7
|
import { getOrCreatePriceOracle } from "./oracle/index.js";
|
|
5
8
|
import { PoolSuite } from "./pool/index.js";
|
|
@@ -9,6 +12,7 @@ class MarketSuite extends SDKConstruct {
|
|
|
9
12
|
configurator;
|
|
10
13
|
pool;
|
|
11
14
|
priceOracle;
|
|
15
|
+
lossPolicy;
|
|
12
16
|
creditManagers = [];
|
|
13
17
|
/**
|
|
14
18
|
* Original data received from compressor
|
|
@@ -35,6 +39,7 @@ class MarketSuite extends SDKConstruct {
|
|
|
35
39
|
this.creditManagers.push(new CreditSuite(sdk, marketData, i));
|
|
36
40
|
}
|
|
37
41
|
this.priceOracle = getOrCreatePriceOracle(sdk, marketData.priceOracle);
|
|
42
|
+
this.lossPolicy = createLossPolicy(sdk, marketData.lossPolicy);
|
|
38
43
|
}
|
|
39
44
|
get dirty() {
|
|
40
45
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
@@ -54,6 +59,7 @@ class MarketSuite extends SDKConstruct {
|
|
|
54
59
|
pool: this.pool.stateHuman(raw),
|
|
55
60
|
creditManagers: this.creditManagers.map((cm) => cm.stateHuman(raw)),
|
|
56
61
|
priceOracle: this.priceOracle.stateHuman(raw),
|
|
62
|
+
lossPolicy: this.lossPolicy.stateHuman(raw),
|
|
57
63
|
pausableAdmins: this.state.pausableAdmins.map((a) => this.labelAddress(a)),
|
|
58
64
|
unpausableAdmins: this.state.unpausableAdmins.map(
|
|
59
65
|
(a) => this.labelAddress(a)
|
|
@@ -61,7 +61,10 @@ class CreditFacadeV300Contract extends BaseContract {
|
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
liquidateCreditAccount(ca, to, calls) {
|
|
64
|
+
liquidateCreditAccount(ca, to, calls, lossPolicyData) {
|
|
65
|
+
if (lossPolicyData) {
|
|
66
|
+
this.logger?.warn("loss policy data is not supported");
|
|
67
|
+
}
|
|
65
68
|
return this.createRawTx({
|
|
66
69
|
functionName: "liquidateCreditAccount",
|
|
67
70
|
args: [ca, to, calls]
|
|
@@ -61,10 +61,10 @@ class CreditFacadeV310Contract extends BaseContract {
|
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
liquidateCreditAccount(ca, to, calls) {
|
|
64
|
+
liquidateCreditAccount(ca, to, calls, lossPolicyData) {
|
|
65
65
|
return this.createRawTx({
|
|
66
66
|
functionName: "liquidateCreditAccount",
|
|
67
|
-
args: [ca, to, calls]
|
|
67
|
+
args: lossPolicyData ? [ca, to, calls, lossPolicyData] : [ca, to, calls]
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
closeCreditAccount(ca, calls) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { iAliasedLossPolicyV310Abi } from "../../../abi/310/generated.js";
|
|
2
|
+
import { BaseContract } from "../../base/index.js";
|
|
3
|
+
const abi = iAliasedLossPolicyV310Abi;
|
|
4
|
+
class AliasLossPolicyV310Contract extends BaseContract {
|
|
5
|
+
constructor(sdk, params) {
|
|
6
|
+
super(sdk, {
|
|
7
|
+
abi,
|
|
8
|
+
addr: params.addr,
|
|
9
|
+
contractType: params.contractType,
|
|
10
|
+
version: params.version
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
AliasLossPolicyV310Contract
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { iLossPolicyV310Abi } from "../../../abi/310/generated.js";
|
|
2
|
+
import { BaseContract } from "../../base/index.js";
|
|
3
|
+
const abi = iLossPolicyV310Abi;
|
|
4
|
+
class LossPolicyContract extends BaseContract {
|
|
5
|
+
constructor(sdk, params) {
|
|
6
|
+
super(sdk, {
|
|
7
|
+
abi,
|
|
8
|
+
addr: params.addr,
|
|
9
|
+
contractType: params.contractType,
|
|
10
|
+
version: params.version
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
LossPolicyContract
|
|
16
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { bytes32ToString } from "../../index.js";
|
|
2
|
+
import { AliasLossPolicyV310Contract } from "./AliasLossPolicyV310Contract.js";
|
|
3
|
+
import { LossPolicyContract } from "./LossPolicyContract.js";
|
|
4
|
+
function createLossPolicy(sdk, { baseParams }) {
|
|
5
|
+
const existing = sdk.contracts.get(baseParams.addr);
|
|
6
|
+
if (existing) {
|
|
7
|
+
return existing;
|
|
8
|
+
}
|
|
9
|
+
const contractType = bytes32ToString(baseParams.contractType);
|
|
10
|
+
switch (contractType) {
|
|
11
|
+
case "LOSS_POLICY::ALIASED":
|
|
12
|
+
return new AliasLossPolicyV310Contract(sdk, baseParams);
|
|
13
|
+
case "LOSS_POLICY::DEFAULT":
|
|
14
|
+
return new LossPolicyContract(sdk, baseParams);
|
|
15
|
+
default:
|
|
16
|
+
if (sdk.strictContractTypes) {
|
|
17
|
+
throw new Error(`unsupported loss policy type ${contractType}`);
|
|
18
|
+
}
|
|
19
|
+
return new LossPolicyContract(sdk, baseParams);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
createLossPolicy
|
|
24
|
+
};
|
|
File without changes
|