@gainsnetwork/sdk 1.3.0-rc7 → 1.4.2-rc1
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/lib/backend/tradingVariables/backend.types.d.ts +4 -11
- package/lib/backend/tradingVariables/converter.d.ts +3 -7
- package/lib/backend/tradingVariables/converter.js +7 -15
- package/lib/backend/tradingVariables/index.js +2 -5
- package/lib/backend/tradingVariables/types.d.ts +2 -4
- package/lib/constants.js +1 -1
- package/lib/contracts/addresses.d.ts +1 -1
- package/lib/contracts/addresses.js +5 -6
- package/lib/contracts/addresses.json +0 -29
- package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +40 -223
- package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +36 -312
- package/lib/contracts/utils/pairs.d.ts +2 -13
- package/lib/contracts/utils/pairs.js +11 -70
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/trade/priceImpact/cumulVol/builder.js +2 -4
- package/lib/trade/priceImpact/cumulVol/converter.d.ts +0 -63
- package/lib/trade/priceImpact/cumulVol/converter.js +1 -97
- package/lib/trade/priceImpact/cumulVol/index.d.ts +6 -7
- package/lib/trade/priceImpact/cumulVol/index.js +32 -135
- package/lib/trade/priceImpact/open/index.js +0 -3
- package/package.json +1 -1
|
@@ -3715,21 +3715,6 @@ const _abi = [
|
|
|
3715
3715
|
type: "function",
|
|
3716
3716
|
signature: "0xfed8a190",
|
|
3717
3717
|
},
|
|
3718
|
-
{
|
|
3719
|
-
inputs: [],
|
|
3720
|
-
name: "DepthBandsAboveMax",
|
|
3721
|
-
type: "error",
|
|
3722
|
-
},
|
|
3723
|
-
{
|
|
3724
|
-
inputs: [],
|
|
3725
|
-
name: "DepthBandsIncomplete",
|
|
3726
|
-
type: "error",
|
|
3727
|
-
},
|
|
3728
|
-
{
|
|
3729
|
-
inputs: [],
|
|
3730
|
-
name: "WrongDepthBandsOrder",
|
|
3731
|
-
type: "error",
|
|
3732
|
-
},
|
|
3733
3718
|
{
|
|
3734
3719
|
inputs: [],
|
|
3735
3720
|
name: "WrongWindowsCount",
|
|
@@ -3760,26 +3745,6 @@ const _abi = [
|
|
|
3760
3745
|
type: "event",
|
|
3761
3746
|
signature: "0x2742ec28d0252b4477106a77a10b04e1c1ecd2b568c7168d56c3a3154d3a3122",
|
|
3762
3747
|
},
|
|
3763
|
-
{
|
|
3764
|
-
anonymous: false,
|
|
3765
|
-
inputs: [
|
|
3766
|
-
{
|
|
3767
|
-
indexed: false,
|
|
3768
|
-
internalType: "uint256",
|
|
3769
|
-
name: "slot1",
|
|
3770
|
-
type: "uint256",
|
|
3771
|
-
},
|
|
3772
|
-
{
|
|
3773
|
-
indexed: false,
|
|
3774
|
-
internalType: "uint256",
|
|
3775
|
-
name: "slot2",
|
|
3776
|
-
type: "uint256",
|
|
3777
|
-
},
|
|
3778
|
-
],
|
|
3779
|
-
name: "DepthBandsMappingUpdated",
|
|
3780
|
-
type: "event",
|
|
3781
|
-
signature: "0x22391293f5705268ac47df15d88a7704e1267eff228801ac480dbe5ecf5ea3ef",
|
|
3782
|
-
},
|
|
3783
3748
|
{
|
|
3784
3749
|
anonymous: false,
|
|
3785
3750
|
inputs: [
|
|
@@ -3906,44 +3871,6 @@ const _abi = [
|
|
|
3906
3871
|
type: "event",
|
|
3907
3872
|
signature: "0xbe433d32d9112c2fcf91407f28314200753b05ef3e9c85b8a0e9d135e77a6c29",
|
|
3908
3873
|
},
|
|
3909
|
-
{
|
|
3910
|
-
anonymous: false,
|
|
3911
|
-
inputs: [
|
|
3912
|
-
{
|
|
3913
|
-
indexed: true,
|
|
3914
|
-
internalType: "uint256",
|
|
3915
|
-
name: "pairIndex",
|
|
3916
|
-
type: "uint256",
|
|
3917
|
-
},
|
|
3918
|
-
{
|
|
3919
|
-
indexed: false,
|
|
3920
|
-
internalType: "uint256",
|
|
3921
|
-
name: "aboveSlot1",
|
|
3922
|
-
type: "uint256",
|
|
3923
|
-
},
|
|
3924
|
-
{
|
|
3925
|
-
indexed: false,
|
|
3926
|
-
internalType: "uint256",
|
|
3927
|
-
name: "aboveSlot2",
|
|
3928
|
-
type: "uint256",
|
|
3929
|
-
},
|
|
3930
|
-
{
|
|
3931
|
-
indexed: false,
|
|
3932
|
-
internalType: "uint256",
|
|
3933
|
-
name: "belowSlot1",
|
|
3934
|
-
type: "uint256",
|
|
3935
|
-
},
|
|
3936
|
-
{
|
|
3937
|
-
indexed: false,
|
|
3938
|
-
internalType: "uint256",
|
|
3939
|
-
name: "belowSlot2",
|
|
3940
|
-
type: "uint256",
|
|
3941
|
-
},
|
|
3942
|
-
],
|
|
3943
|
-
name: "PairDepthBandsUpdated",
|
|
3944
|
-
type: "event",
|
|
3945
|
-
signature: "0x7a9ee81b0015d0b7824d14757416905ea9ace5b9ad54dc08cb426cd0ae3dff9f",
|
|
3946
|
-
},
|
|
3947
3874
|
{
|
|
3948
3875
|
anonymous: false,
|
|
3949
3876
|
inputs: [
|
|
@@ -4303,39 +4230,6 @@ const _abi = [
|
|
|
4303
4230
|
type: "function",
|
|
4304
4231
|
signature: "0x81688f7b",
|
|
4305
4232
|
},
|
|
4306
|
-
{
|
|
4307
|
-
inputs: [],
|
|
4308
|
-
name: "getDepthBandsMapping",
|
|
4309
|
-
outputs: [
|
|
4310
|
-
{
|
|
4311
|
-
internalType: "uint256",
|
|
4312
|
-
name: "slot1",
|
|
4313
|
-
type: "uint256",
|
|
4314
|
-
},
|
|
4315
|
-
{
|
|
4316
|
-
internalType: "uint256",
|
|
4317
|
-
name: "slot2",
|
|
4318
|
-
type: "uint256",
|
|
4319
|
-
},
|
|
4320
|
-
],
|
|
4321
|
-
stateMutability: "view",
|
|
4322
|
-
type: "function",
|
|
4323
|
-
signature: "0xd40e0d20",
|
|
4324
|
-
},
|
|
4325
|
-
{
|
|
4326
|
-
inputs: [],
|
|
4327
|
-
name: "getDepthBandsMappingDecoded",
|
|
4328
|
-
outputs: [
|
|
4329
|
-
{
|
|
4330
|
-
internalType: "uint16[]",
|
|
4331
|
-
name: "bands",
|
|
4332
|
-
type: "uint16[]",
|
|
4333
|
-
},
|
|
4334
|
-
],
|
|
4335
|
-
stateMutability: "view",
|
|
4336
|
-
type: "function",
|
|
4337
|
-
signature: "0x9615d82a",
|
|
4338
|
-
},
|
|
4339
4233
|
{
|
|
4340
4234
|
inputs: [],
|
|
4341
4235
|
name: "getNegPnlCumulVolMultiplier",
|
|
@@ -4465,48 +4359,6 @@ const _abi = [
|
|
|
4465
4359
|
type: "function",
|
|
4466
4360
|
signature: "0xb56df676",
|
|
4467
4361
|
},
|
|
4468
|
-
{
|
|
4469
|
-
inputs: [
|
|
4470
|
-
{
|
|
4471
|
-
internalType: "uint256[]",
|
|
4472
|
-
name: "_indices",
|
|
4473
|
-
type: "uint256[]",
|
|
4474
|
-
},
|
|
4475
|
-
],
|
|
4476
|
-
name: "getPairDepthBands",
|
|
4477
|
-
outputs: [
|
|
4478
|
-
{
|
|
4479
|
-
components: [
|
|
4480
|
-
{
|
|
4481
|
-
internalType: "uint256",
|
|
4482
|
-
name: "aboveSlot1",
|
|
4483
|
-
type: "uint256",
|
|
4484
|
-
},
|
|
4485
|
-
{
|
|
4486
|
-
internalType: "uint256",
|
|
4487
|
-
name: "aboveSlot2",
|
|
4488
|
-
type: "uint256",
|
|
4489
|
-
},
|
|
4490
|
-
{
|
|
4491
|
-
internalType: "uint256",
|
|
4492
|
-
name: "belowSlot1",
|
|
4493
|
-
type: "uint256",
|
|
4494
|
-
},
|
|
4495
|
-
{
|
|
4496
|
-
internalType: "uint256",
|
|
4497
|
-
name: "belowSlot2",
|
|
4498
|
-
type: "uint256",
|
|
4499
|
-
},
|
|
4500
|
-
],
|
|
4501
|
-
internalType: "struct IPriceImpact.PairDepthBands[]",
|
|
4502
|
-
name: "",
|
|
4503
|
-
type: "tuple[]",
|
|
4504
|
-
},
|
|
4505
|
-
],
|
|
4506
|
-
stateMutability: "view",
|
|
4507
|
-
type: "function",
|
|
4508
|
-
signature: "0x42105561",
|
|
4509
|
-
},
|
|
4510
4362
|
{
|
|
4511
4363
|
inputs: [
|
|
4512
4364
|
{
|
|
@@ -4515,74 +4367,29 @@ const _abi = [
|
|
|
4515
4367
|
type: "uint256",
|
|
4516
4368
|
},
|
|
4517
4369
|
],
|
|
4518
|
-
name: "
|
|
4370
|
+
name: "getPairDepth",
|
|
4519
4371
|
outputs: [
|
|
4520
4372
|
{
|
|
4521
4373
|
components: [
|
|
4522
4374
|
{
|
|
4523
|
-
internalType: "
|
|
4524
|
-
name: "
|
|
4525
|
-
type: "
|
|
4526
|
-
},
|
|
4527
|
-
{
|
|
4528
|
-
internalType: "uint256",
|
|
4529
|
-
name: "aboveSlot2",
|
|
4530
|
-
type: "uint256",
|
|
4531
|
-
},
|
|
4532
|
-
{
|
|
4533
|
-
internalType: "uint256",
|
|
4534
|
-
name: "belowSlot1",
|
|
4535
|
-
type: "uint256",
|
|
4375
|
+
internalType: "uint128",
|
|
4376
|
+
name: "onePercentDepthAboveUsd",
|
|
4377
|
+
type: "uint128",
|
|
4536
4378
|
},
|
|
4537
4379
|
{
|
|
4538
|
-
internalType: "
|
|
4539
|
-
name: "
|
|
4540
|
-
type: "
|
|
4380
|
+
internalType: "uint128",
|
|
4381
|
+
name: "onePercentDepthBelowUsd",
|
|
4382
|
+
type: "uint128",
|
|
4541
4383
|
},
|
|
4542
4384
|
],
|
|
4543
|
-
internalType: "struct IPriceImpact.
|
|
4385
|
+
internalType: "struct IPriceImpact.PairDepth",
|
|
4544
4386
|
name: "",
|
|
4545
4387
|
type: "tuple",
|
|
4546
4388
|
},
|
|
4547
4389
|
],
|
|
4548
4390
|
stateMutability: "view",
|
|
4549
4391
|
type: "function",
|
|
4550
|
-
signature: "
|
|
4551
|
-
},
|
|
4552
|
-
{
|
|
4553
|
-
inputs: [
|
|
4554
|
-
{
|
|
4555
|
-
internalType: "uint256",
|
|
4556
|
-
name: "_pairIndex",
|
|
4557
|
-
type: "uint256",
|
|
4558
|
-
},
|
|
4559
|
-
],
|
|
4560
|
-
name: "getPairDepthBandsDecoded",
|
|
4561
|
-
outputs: [
|
|
4562
|
-
{
|
|
4563
|
-
internalType: "uint256",
|
|
4564
|
-
name: "totalDepthAboveUsd",
|
|
4565
|
-
type: "uint256",
|
|
4566
|
-
},
|
|
4567
|
-
{
|
|
4568
|
-
internalType: "uint256",
|
|
4569
|
-
name: "totalDepthBelowUsd",
|
|
4570
|
-
type: "uint256",
|
|
4571
|
-
},
|
|
4572
|
-
{
|
|
4573
|
-
internalType: "uint16[]",
|
|
4574
|
-
name: "bandsAbove",
|
|
4575
|
-
type: "uint16[]",
|
|
4576
|
-
},
|
|
4577
|
-
{
|
|
4578
|
-
internalType: "uint16[]",
|
|
4579
|
-
name: "bandsBelow",
|
|
4580
|
-
type: "uint16[]",
|
|
4581
|
-
},
|
|
4582
|
-
],
|
|
4583
|
-
stateMutability: "view",
|
|
4584
|
-
type: "function",
|
|
4585
|
-
signature: "0x2b363e71",
|
|
4392
|
+
signature: "0x375bb2bb",
|
|
4586
4393
|
},
|
|
4587
4394
|
{
|
|
4588
4395
|
inputs: [
|
|
@@ -4592,32 +4399,29 @@ const _abi = [
|
|
|
4592
4399
|
type: "uint256[]",
|
|
4593
4400
|
},
|
|
4594
4401
|
],
|
|
4595
|
-
name: "
|
|
4402
|
+
name: "getPairDepths",
|
|
4596
4403
|
outputs: [
|
|
4597
4404
|
{
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
internalType: "uint16[][]",
|
|
4614
|
-
name: "bandsBelow",
|
|
4615
|
-
type: "uint16[][]",
|
|
4405
|
+
components: [
|
|
4406
|
+
{
|
|
4407
|
+
internalType: "uint128",
|
|
4408
|
+
name: "onePercentDepthAboveUsd",
|
|
4409
|
+
type: "uint128",
|
|
4410
|
+
},
|
|
4411
|
+
{
|
|
4412
|
+
internalType: "uint128",
|
|
4413
|
+
name: "onePercentDepthBelowUsd",
|
|
4414
|
+
type: "uint128",
|
|
4415
|
+
},
|
|
4416
|
+
],
|
|
4417
|
+
internalType: "struct IPriceImpact.PairDepth[]",
|
|
4418
|
+
name: "",
|
|
4419
|
+
type: "tuple[]",
|
|
4616
4420
|
},
|
|
4617
4421
|
],
|
|
4618
4422
|
stateMutability: "view",
|
|
4619
4423
|
type: "function",
|
|
4620
|
-
signature: "
|
|
4424
|
+
signature: "0x0d569f27",
|
|
4621
4425
|
},
|
|
4622
4426
|
{
|
|
4623
4427
|
inputs: [
|
|
@@ -5046,25 +4850,6 @@ const _abi = [
|
|
|
5046
4850
|
type: "function",
|
|
5047
4851
|
signature: "0x5a1449ab",
|
|
5048
4852
|
},
|
|
5049
|
-
{
|
|
5050
|
-
inputs: [
|
|
5051
|
-
{
|
|
5052
|
-
internalType: "uint256",
|
|
5053
|
-
name: "_slot1",
|
|
5054
|
-
type: "uint256",
|
|
5055
|
-
},
|
|
5056
|
-
{
|
|
5057
|
-
internalType: "uint256",
|
|
5058
|
-
name: "_slot2",
|
|
5059
|
-
type: "uint256",
|
|
5060
|
-
},
|
|
5061
|
-
],
|
|
5062
|
-
name: "initializeDepthBandsMapping",
|
|
5063
|
-
outputs: [],
|
|
5064
|
-
stateMutability: "nonpayable",
|
|
5065
|
-
type: "function",
|
|
5066
|
-
signature: "0xbb8f07af",
|
|
5067
|
-
},
|
|
5068
4853
|
{
|
|
5069
4854
|
inputs: [
|
|
5070
4855
|
{
|
|
@@ -5146,25 +4931,6 @@ const _abi = [
|
|
|
5146
4931
|
type: "function",
|
|
5147
4932
|
signature: "0xa7d518fc",
|
|
5148
4933
|
},
|
|
5149
|
-
{
|
|
5150
|
-
inputs: [
|
|
5151
|
-
{
|
|
5152
|
-
internalType: "uint256",
|
|
5153
|
-
name: "_slot1",
|
|
5154
|
-
type: "uint256",
|
|
5155
|
-
},
|
|
5156
|
-
{
|
|
5157
|
-
internalType: "uint256",
|
|
5158
|
-
name: "_slot2",
|
|
5159
|
-
type: "uint256",
|
|
5160
|
-
},
|
|
5161
|
-
],
|
|
5162
|
-
name: "setDepthBandsMapping",
|
|
5163
|
-
outputs: [],
|
|
5164
|
-
stateMutability: "nonpayable",
|
|
5165
|
-
type: "function",
|
|
5166
|
-
signature: "0x7e8462f7",
|
|
5167
|
-
},
|
|
5168
4934
|
{
|
|
5169
4935
|
inputs: [
|
|
5170
4936
|
{
|
|
@@ -5225,38 +4991,21 @@ const _abi = [
|
|
|
5225
4991
|
type: "uint256[]",
|
|
5226
4992
|
},
|
|
5227
4993
|
{
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
name: "aboveSlot2",
|
|
5237
|
-
type: "uint256",
|
|
5238
|
-
},
|
|
5239
|
-
{
|
|
5240
|
-
internalType: "uint256",
|
|
5241
|
-
name: "belowSlot1",
|
|
5242
|
-
type: "uint256",
|
|
5243
|
-
},
|
|
5244
|
-
{
|
|
5245
|
-
internalType: "uint256",
|
|
5246
|
-
name: "belowSlot2",
|
|
5247
|
-
type: "uint256",
|
|
5248
|
-
},
|
|
5249
|
-
],
|
|
5250
|
-
internalType: "struct IPriceImpact.PairDepthBands[]",
|
|
5251
|
-
name: "_depthBands",
|
|
5252
|
-
type: "tuple[]",
|
|
4994
|
+
internalType: "uint128[]",
|
|
4995
|
+
name: "_depthsAboveUsd",
|
|
4996
|
+
type: "uint128[]",
|
|
4997
|
+
},
|
|
4998
|
+
{
|
|
4999
|
+
internalType: "uint128[]",
|
|
5000
|
+
name: "_depthsBelowUsd",
|
|
5001
|
+
type: "uint128[]",
|
|
5253
5002
|
},
|
|
5254
5003
|
],
|
|
5255
|
-
name: "
|
|
5004
|
+
name: "setPairDepths",
|
|
5256
5005
|
outputs: [],
|
|
5257
5006
|
stateMutability: "nonpayable",
|
|
5258
5007
|
type: "function",
|
|
5259
|
-
signature: "
|
|
5008
|
+
signature: "0x6474b399",
|
|
5260
5009
|
},
|
|
5261
5010
|
{
|
|
5262
5011
|
inputs: [
|
|
@@ -16876,31 +16625,6 @@ const _abi = [
|
|
|
16876
16625
|
type: "function",
|
|
16877
16626
|
signature: "0xa91fa361",
|
|
16878
16627
|
},
|
|
16879
|
-
{
|
|
16880
|
-
inputs: [
|
|
16881
|
-
{
|
|
16882
|
-
internalType: "uint8",
|
|
16883
|
-
name: "_collateralIndex",
|
|
16884
|
-
type: "uint8",
|
|
16885
|
-
},
|
|
16886
|
-
{
|
|
16887
|
-
internalType: "uint256",
|
|
16888
|
-
name: "_gnsPriceCollateral",
|
|
16889
|
-
type: "uint256",
|
|
16890
|
-
},
|
|
16891
|
-
],
|
|
16892
|
-
name: "getGnsPriceUsd",
|
|
16893
|
-
outputs: [
|
|
16894
|
-
{
|
|
16895
|
-
internalType: "uint256",
|
|
16896
|
-
name: "",
|
|
16897
|
-
type: "uint256",
|
|
16898
|
-
},
|
|
16899
|
-
],
|
|
16900
|
-
stateMutability: "view",
|
|
16901
|
-
type: "function",
|
|
16902
|
-
signature: "0x6e27030b",
|
|
16903
|
-
},
|
|
16904
16628
|
{
|
|
16905
16629
|
inputs: [
|
|
16906
16630
|
{
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { Pair, Fee, OpenInterest, PairIndex } from "../../trade/types";
|
|
1
|
+
import { Pair, Fee, OpenInterest, PairDepth, PairIndex } from "../../trade/types";
|
|
2
2
|
import { Contracts } from "../../contracts/types";
|
|
3
3
|
export declare const fetchPairs: (contracts: Contracts, pairIxs: PairIndex[]) => Promise<Pair[]>;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const fetchPairDepthBandsDecoded: (contracts: Contracts, pairIxs: number[]) => Promise<{
|
|
6
|
-
totalDepthAboveUsd: number[];
|
|
7
|
-
totalDepthBelowUsd: number[];
|
|
8
|
-
bandsAbove: number[][];
|
|
9
|
-
bandsBelow: number[][];
|
|
10
|
-
}>;
|
|
11
|
-
export declare const fetchDepthBandsMapping: (contracts: Contracts) => Promise<{
|
|
12
|
-
slot1: string;
|
|
13
|
-
slot2: string;
|
|
14
|
-
}>;
|
|
15
|
-
export declare const fetchDepthBandsMappingDecoded: (contracts: Contracts) => Promise<number[]>;
|
|
4
|
+
export declare const fetchPairDepths: (contracts: Contracts, pairIxs: number[]) => Promise<PairDepth[]>;
|
|
16
5
|
export declare const fetchFees: (contracts: Contracts, feeIxs: PairIndex[]) => Promise<Fee[]>;
|
|
17
6
|
export declare const fetchOpenInterest: (contracts: Contracts, collateralIndex: number, pairIxs: number[]) => Promise<OpenInterest[]>;
|
|
18
7
|
export declare const getPairDescription: (pairIndex: PairIndex) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPairDescription = exports.fetchOpenInterest = exports.fetchFees = exports.
|
|
3
|
+
exports.getPairDescription = exports.fetchOpenInterest = exports.fetchFees = exports.fetchPairDepths = exports.fetchPairs = void 0;
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
@@ -31,85 +31,26 @@ const fetchPairs = async (contracts, pairIxs) => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
exports.fetchPairs = fetchPairs;
|
|
34
|
-
const
|
|
35
|
-
if (!contracts || pairIxs.length === 0) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
const { gnsMultiCollatDiamond: multiCollatContract } = contracts;
|
|
39
|
-
try {
|
|
40
|
-
// Returns array of PairDepthBands structs (encoded slots)
|
|
41
|
-
// Using quoted signature for overloaded function
|
|
42
|
-
const depthBands = await multiCollatContract["getPairDepthBands(uint256[])"](pairIxs);
|
|
43
|
-
return depthBands;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
console.error(`Unexpected error while fetching pair depth bands!`);
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
exports.fetchPairDepthBands = fetchPairDepthBands;
|
|
51
|
-
const fetchPairDepthBandsDecoded = async (contracts, pairIxs) => {
|
|
52
|
-
if (!contracts || pairIxs.length === 0) {
|
|
53
|
-
return {
|
|
54
|
-
totalDepthAboveUsd: [],
|
|
55
|
-
totalDepthBelowUsd: [],
|
|
56
|
-
bandsAbove: [],
|
|
57
|
-
bandsBelow: [],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const { gnsMultiCollatDiamond: multiCollatContract } = contracts;
|
|
61
|
-
try {
|
|
62
|
-
// Returns decoded values
|
|
63
|
-
// Using quoted signature for overloaded function
|
|
64
|
-
const [totalDepthAboveUsd, totalDepthBelowUsd, bandsAbove, bandsBelow] = await multiCollatContract["getPairDepthBandsDecoded(uint256[])"](pairIxs);
|
|
65
|
-
return {
|
|
66
|
-
totalDepthAboveUsd: totalDepthAboveUsd.map((v) => parseFloat(v.toString())),
|
|
67
|
-
totalDepthBelowUsd: totalDepthBelowUsd.map((v) => parseFloat(v.toString())),
|
|
68
|
-
bandsAbove: bandsAbove.map((bands) => bands.map((b) => parseInt(b.toString()))),
|
|
69
|
-
bandsBelow: bandsBelow.map((bands) => bands.map((b) => parseInt(b.toString()))),
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
console.error(`Unexpected error while fetching decoded pair depth bands!`);
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
exports.fetchPairDepthBandsDecoded = fetchPairDepthBandsDecoded;
|
|
78
|
-
const fetchDepthBandsMapping = async (contracts) => {
|
|
79
|
-
if (!contracts) {
|
|
80
|
-
return { slot1: "0", slot2: "0" };
|
|
81
|
-
}
|
|
82
|
-
const { gnsMultiCollatDiamond: multiCollatContract } = contracts;
|
|
83
|
-
try {
|
|
84
|
-
// Returns two uint256 slots
|
|
85
|
-
const [slot1, slot2] = await multiCollatContract.getDepthBandsMapping();
|
|
86
|
-
return {
|
|
87
|
-
slot1: slot1.toString(),
|
|
88
|
-
slot2: slot2.toString(),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
console.error(`Unexpected error while fetching depth bands mapping!`);
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
exports.fetchDepthBandsMapping = fetchDepthBandsMapping;
|
|
97
|
-
const fetchDepthBandsMappingDecoded = async (contracts) => {
|
|
34
|
+
const fetchPairDepths = async (contracts, pairIxs) => {
|
|
98
35
|
if (!contracts) {
|
|
99
36
|
return [];
|
|
100
37
|
}
|
|
101
38
|
const { gnsMultiCollatDiamond: multiCollatContract } = contracts;
|
|
102
39
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
40
|
+
const pairParams = await multiCollatContract.getPairDepths(pairIxs);
|
|
41
|
+
return pairParams.map(pair => {
|
|
42
|
+
return {
|
|
43
|
+
onePercentDepthAboveUsd: parseFloat(pair.onePercentDepthAboveUsd.toString()),
|
|
44
|
+
onePercentDepthBelowUsd: parseFloat(pair.onePercentDepthBelowUsd.toString()),
|
|
45
|
+
};
|
|
46
|
+
});
|
|
106
47
|
}
|
|
107
48
|
catch (error) {
|
|
108
|
-
console.error(`Unexpected error while fetching
|
|
49
|
+
console.error(`Unexpected error while fetching pairs!`);
|
|
109
50
|
throw error;
|
|
110
51
|
}
|
|
111
52
|
};
|
|
112
|
-
exports.
|
|
53
|
+
exports.fetchPairDepths = fetchPairDepths;
|
|
113
54
|
const fetchFees = async (contracts, feeIxs) => {
|
|
114
55
|
if (!contracts) {
|
|
115
56
|
return [];
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -22,7 +22,6 @@ __exportStar(require("./constants"), exports);
|
|
|
22
22
|
__exportStar(require("./utils"), exports);
|
|
23
23
|
__exportStar(require("./vault"), exports);
|
|
24
24
|
__exportStar(require("./backend"), exports);
|
|
25
|
-
__exportStar(require("./pricing"), exports);
|
|
26
25
|
// Not sure why this is needed, but it is. Barrel imports are not working.
|
|
27
26
|
__exportStar(require("./trade/fees/borrowing/index"), exports);
|
|
28
27
|
// Export ContractsVersion for frontend usage
|
|
@@ -15,8 +15,7 @@ const buildCumulVolContext = (globalTradingVariables, collateralIndex, pairIndex
|
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
17
|
// Get pair-specific data from global variables
|
|
18
|
-
const
|
|
19
|
-
const depthBandsMapping = globalTradingVariables.depthBandsMapping;
|
|
18
|
+
const pairDepth = globalTradingVariables.pairDepths?.[pairIndex];
|
|
20
19
|
const pairFactor = globalTradingVariables.pairFactors?.[pairIndex];
|
|
21
20
|
const oiWindows = globalTradingVariables.oiWindows?.[pairIndex];
|
|
22
21
|
// Get OI windows settings (same for all pairs)
|
|
@@ -39,8 +38,7 @@ const buildCumulVolContext = (globalTradingVariables, collateralIndex, pairIndex
|
|
|
39
38
|
contractsVersion: additionalParams.contractsVersion,
|
|
40
39
|
protectionCloseFactorWhitelist,
|
|
41
40
|
// Price impact data
|
|
42
|
-
|
|
43
|
-
depthBandsMapping,
|
|
41
|
+
pairDepth,
|
|
44
42
|
oiWindowsSettings,
|
|
45
43
|
oiWindows,
|
|
46
44
|
// User/collateral specific
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IPriceImpact } from "../../../contracts/types/generated/GNSMultiCollatDiamond";
|
|
6
6
|
import { OiWindowsSettings, OiWindow, OiWindows } from "../../types";
|
|
7
|
-
import { DepthBands, PairDepthBands, DepthBandsMapping } from "./types";
|
|
8
7
|
/**
|
|
9
8
|
* @dev Converts contract OI windows settings to SDK format
|
|
10
9
|
* @param contractData Contract OiWindowsSettings struct
|
|
@@ -30,65 +29,3 @@ export declare const convertOiWindows: (windowIds: string[], contractWindows: IP
|
|
|
30
29
|
* @returns Array of normalized OI windows settings
|
|
31
30
|
*/
|
|
32
31
|
export declare const convertOiWindowsSettingsArray: (contractDataArray: IPriceImpact.OiWindowsSettingsStructOutput[]) => OiWindowsSettings[];
|
|
33
|
-
/**
|
|
34
|
-
* @dev Converts decoded depth bands from contract to SDK format
|
|
35
|
-
* @param totalDepthUsd Total depth in USD (already decoded from contract)
|
|
36
|
-
* @param bandsBps Array of 30 band percentages in basis points from contract
|
|
37
|
-
* @returns Normalized depth bands with bands in 0-1 range
|
|
38
|
-
*/
|
|
39
|
-
export declare const convertDepthBands: (totalDepthUsd: number, bandsBps: number[]) => DepthBands;
|
|
40
|
-
/**
|
|
41
|
-
* @dev Converts decoded pair depth bands from contract to SDK format
|
|
42
|
-
* @param aboveDepth Decoded above depth bands from getPairDepthBandsDecoded
|
|
43
|
-
* @param belowDepth Decoded below depth bands from getPairDepthBandsDecoded
|
|
44
|
-
* @returns Normalized pair depth bands with above/below
|
|
45
|
-
*/
|
|
46
|
-
export declare const convertPairDepthBands: (aboveDepth: {
|
|
47
|
-
totalDepthUsd: number;
|
|
48
|
-
bands: number[];
|
|
49
|
-
} | undefined, belowDepth: {
|
|
50
|
-
totalDepthUsd: number;
|
|
51
|
-
bands: number[];
|
|
52
|
-
} | undefined) => PairDepthBands;
|
|
53
|
-
/**
|
|
54
|
-
* @dev Converts decoded depth bands mapping from contract to SDK format
|
|
55
|
-
* @param bandsBps Array of 30 band offset values in basis points from getDepthBandsMappingDecoded
|
|
56
|
-
* @returns Normalized depth bands mapping with offset values in 0-1 range
|
|
57
|
-
*/
|
|
58
|
-
export declare const convertDepthBandsMapping: (bandsBps: number[]) => DepthBandsMapping;
|
|
59
|
-
/**
|
|
60
|
-
* @dev Validates depth bands have correct number of bands
|
|
61
|
-
* @param depthBands Depth bands to validate
|
|
62
|
-
* @returns True if valid (30 bands)
|
|
63
|
-
*/
|
|
64
|
-
export declare const validateDepthBands: (depthBands: DepthBands) => boolean;
|
|
65
|
-
/**
|
|
66
|
-
* @dev Validates depth bands mapping has correct number of bands
|
|
67
|
-
* @param mapping Depth bands mapping to validate
|
|
68
|
-
* @returns True if valid (30 bands)
|
|
69
|
-
*/
|
|
70
|
-
export declare const validateDepthBandsMapping: (mapping: DepthBandsMapping) => boolean;
|
|
71
|
-
/**
|
|
72
|
-
* @dev Alternative converter for decoded pair depth bands from contract
|
|
73
|
-
* @param contractData Decoded pair depth bands from getPairDepthBandsDecoded
|
|
74
|
-
* @returns Normalized pair depth bands
|
|
75
|
-
*/
|
|
76
|
-
export declare const convertPairDepthBandsDecoded: (contractData: {
|
|
77
|
-
above: {
|
|
78
|
-
totalDepthUsd: number;
|
|
79
|
-
bands: number[];
|
|
80
|
-
};
|
|
81
|
-
below: {
|
|
82
|
-
totalDepthUsd: number;
|
|
83
|
-
bands: number[];
|
|
84
|
-
};
|
|
85
|
-
}) => PairDepthBands;
|
|
86
|
-
/**
|
|
87
|
-
* @dev Alternative converter for raw slot-based pair depth bands (if needed for legacy)
|
|
88
|
-
* @param aboveSlot1 First slot for above bands
|
|
89
|
-
* @param aboveSlot2 Second slot for above bands
|
|
90
|
-
* @param belowSlot1 First slot for below bands
|
|
91
|
-
* @param belowSlot2 Second slot for below bands
|
|
92
|
-
* @returns Normalized pair depth bands
|
|
93
|
-
*/
|
|
94
|
-
export declare const convertPairDepthBandsFromSlots: (aboveSlot1: bigint, aboveSlot2: bigint, belowSlot1: bigint, belowSlot2: bigint) => PairDepthBands;
|