@gainsnetwork/sdk 0.2.54-rc1 → 0.2.55-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/constants.d.ts +4 -0
- package/lib/constants.js +6 -1
- package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +7 -192
- package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +2 -322
- package/lib/contracts/utils/borrowingFees.js +1 -3
- package/lib/contracts/utils/pairs.js +4 -0
- package/lib/trade/fees/borrowing/converter.d.ts +3 -5
- package/lib/trade/fees/borrowing/converter.js +3 -8
- package/lib/trade/fees/borrowing/index.d.ts +4 -9
- package/lib/trade/fees/borrowing/index.js +11 -53
- package/lib/trade/fees/borrowing/types.d.ts +0 -5
- package/lib/trade/types.d.ts +5 -1
- package/lib/trade/types.js +4 -0
- package/package.json +1 -1
|
@@ -10969,26 +10969,6 @@ const _abi = [
|
|
|
10969
10969
|
name: "BorrowingZeroGroup",
|
|
10970
10970
|
type: "error",
|
|
10971
10971
|
},
|
|
10972
|
-
{
|
|
10973
|
-
anonymous: false,
|
|
10974
|
-
inputs: [
|
|
10975
|
-
{
|
|
10976
|
-
indexed: false,
|
|
10977
|
-
internalType: "uint32",
|
|
10978
|
-
name: "minP",
|
|
10979
|
-
type: "uint32",
|
|
10980
|
-
},
|
|
10981
|
-
{
|
|
10982
|
-
indexed: false,
|
|
10983
|
-
internalType: "uint32",
|
|
10984
|
-
name: "maxP",
|
|
10985
|
-
type: "uint32",
|
|
10986
|
-
},
|
|
10987
|
-
],
|
|
10988
|
-
name: "BorrowingFeePerBlockCapUpdated",
|
|
10989
|
-
type: "event",
|
|
10990
|
-
signature: "0xca38800286190b44d87a61aaf551868afbd46f1f76ed5b145e4e975e446a2964",
|
|
10991
|
-
},
|
|
10992
10972
|
{
|
|
10993
10973
|
anonymous: false,
|
|
10994
10974
|
inputs: [
|
|
@@ -11203,38 +11183,6 @@ const _abi = [
|
|
|
11203
11183
|
type: "event",
|
|
11204
11184
|
signature: "0x12515cf8712ede0f0e48dd7513c14f22f116a6b3f95bd493da7511cf7dcbadd7",
|
|
11205
11185
|
},
|
|
11206
|
-
{
|
|
11207
|
-
anonymous: false,
|
|
11208
|
-
inputs: [
|
|
11209
|
-
{
|
|
11210
|
-
indexed: true,
|
|
11211
|
-
internalType: "uint8",
|
|
11212
|
-
name: "collateralIndex",
|
|
11213
|
-
type: "uint8",
|
|
11214
|
-
},
|
|
11215
|
-
{
|
|
11216
|
-
indexed: true,
|
|
11217
|
-
internalType: "uint16",
|
|
11218
|
-
name: "pairIndex",
|
|
11219
|
-
type: "uint16",
|
|
11220
|
-
},
|
|
11221
|
-
{
|
|
11222
|
-
indexed: false,
|
|
11223
|
-
internalType: "uint32",
|
|
11224
|
-
name: "minP",
|
|
11225
|
-
type: "uint32",
|
|
11226
|
-
},
|
|
11227
|
-
{
|
|
11228
|
-
indexed: false,
|
|
11229
|
-
internalType: "uint32",
|
|
11230
|
-
name: "maxP",
|
|
11231
|
-
type: "uint32",
|
|
11232
|
-
},
|
|
11233
|
-
],
|
|
11234
|
-
name: "BorrowingPairFeePerBlockCapUpdated",
|
|
11235
|
-
type: "event",
|
|
11236
|
-
signature: "0xf5413841beaa3a78d74ab0e0e7528e0f5d357a193b9f600eb87c8746475109f6",
|
|
11237
|
-
},
|
|
11238
11186
|
{
|
|
11239
11187
|
anonymous: false,
|
|
11240
11188
|
inputs: [
|
|
@@ -11537,32 +11485,6 @@ const _abi = [
|
|
|
11537
11485
|
type: "function",
|
|
11538
11486
|
signature: "0x48da5b38",
|
|
11539
11487
|
},
|
|
11540
|
-
{
|
|
11541
|
-
inputs: [],
|
|
11542
|
-
name: "getBorrowingFeePerBlockCap",
|
|
11543
|
-
outputs: [
|
|
11544
|
-
{
|
|
11545
|
-
components: [
|
|
11546
|
-
{
|
|
11547
|
-
internalType: "uint32",
|
|
11548
|
-
name: "minP",
|
|
11549
|
-
type: "uint32",
|
|
11550
|
-
},
|
|
11551
|
-
{
|
|
11552
|
-
internalType: "uint32",
|
|
11553
|
-
name: "maxP",
|
|
11554
|
-
type: "uint32",
|
|
11555
|
-
},
|
|
11556
|
-
],
|
|
11557
|
-
internalType: "struct IBorrowingFees.BorrowingFeePerBlockCap",
|
|
11558
|
-
name: "",
|
|
11559
|
-
type: "tuple",
|
|
11560
|
-
},
|
|
11561
|
-
],
|
|
11562
|
-
stateMutability: "view",
|
|
11563
|
-
type: "function",
|
|
11564
|
-
signature: "0x06c01bef",
|
|
11565
|
-
},
|
|
11566
11488
|
{
|
|
11567
11489
|
inputs: [
|
|
11568
11490
|
{
|
|
@@ -11694,12 +11616,7 @@ const _abi = [
|
|
|
11694
11616
|
},
|
|
11695
11617
|
{
|
|
11696
11618
|
internalType: "uint64",
|
|
11697
|
-
name: "
|
|
11698
|
-
type: "uint64",
|
|
11699
|
-
},
|
|
11700
|
-
{
|
|
11701
|
-
internalType: "uint64",
|
|
11702
|
-
name: "groupAccFeeShortDelta",
|
|
11619
|
+
name: "groupAccFeeDelta",
|
|
11703
11620
|
type: "uint64",
|
|
11704
11621
|
},
|
|
11705
11622
|
],
|
|
@@ -11890,80 +11807,6 @@ const _abi = [
|
|
|
11890
11807
|
type: "function",
|
|
11891
11808
|
signature: "0x5d5bf24d",
|
|
11892
11809
|
},
|
|
11893
|
-
{
|
|
11894
|
-
inputs: [
|
|
11895
|
-
{
|
|
11896
|
-
internalType: "uint8",
|
|
11897
|
-
name: "_collateralIndex",
|
|
11898
|
-
type: "uint8",
|
|
11899
|
-
},
|
|
11900
|
-
{
|
|
11901
|
-
internalType: "uint16",
|
|
11902
|
-
name: "_pairIndex",
|
|
11903
|
-
type: "uint16",
|
|
11904
|
-
},
|
|
11905
|
-
],
|
|
11906
|
-
name: "getBorrowingPairFeePerBlockCap",
|
|
11907
|
-
outputs: [
|
|
11908
|
-
{
|
|
11909
|
-
components: [
|
|
11910
|
-
{
|
|
11911
|
-
internalType: "uint32",
|
|
11912
|
-
name: "minP",
|
|
11913
|
-
type: "uint32",
|
|
11914
|
-
},
|
|
11915
|
-
{
|
|
11916
|
-
internalType: "uint32",
|
|
11917
|
-
name: "maxP",
|
|
11918
|
-
type: "uint32",
|
|
11919
|
-
},
|
|
11920
|
-
],
|
|
11921
|
-
internalType: "struct IBorrowingFees.BorrowingFeePerBlockCap",
|
|
11922
|
-
name: "",
|
|
11923
|
-
type: "tuple",
|
|
11924
|
-
},
|
|
11925
|
-
],
|
|
11926
|
-
stateMutability: "view",
|
|
11927
|
-
type: "function",
|
|
11928
|
-
signature: "0x7bdbfe5a",
|
|
11929
|
-
},
|
|
11930
|
-
{
|
|
11931
|
-
inputs: [
|
|
11932
|
-
{
|
|
11933
|
-
internalType: "uint8",
|
|
11934
|
-
name: "_collateralIndex",
|
|
11935
|
-
type: "uint8",
|
|
11936
|
-
},
|
|
11937
|
-
{
|
|
11938
|
-
internalType: "uint16[]",
|
|
11939
|
-
name: "_indices",
|
|
11940
|
-
type: "uint16[]",
|
|
11941
|
-
},
|
|
11942
|
-
],
|
|
11943
|
-
name: "getBorrowingPairFeePerBlockCaps",
|
|
11944
|
-
outputs: [
|
|
11945
|
-
{
|
|
11946
|
-
components: [
|
|
11947
|
-
{
|
|
11948
|
-
internalType: "uint32",
|
|
11949
|
-
name: "minP",
|
|
11950
|
-
type: "uint32",
|
|
11951
|
-
},
|
|
11952
|
-
{
|
|
11953
|
-
internalType: "uint32",
|
|
11954
|
-
name: "maxP",
|
|
11955
|
-
type: "uint32",
|
|
11956
|
-
},
|
|
11957
|
-
],
|
|
11958
|
-
internalType: "struct IBorrowingFees.BorrowingFeePerBlockCap[]",
|
|
11959
|
-
name: "",
|
|
11960
|
-
type: "tuple[]",
|
|
11961
|
-
},
|
|
11962
|
-
],
|
|
11963
|
-
stateMutability: "view",
|
|
11964
|
-
type: "function",
|
|
11965
|
-
signature: "0x0a67b9a3",
|
|
11966
|
-
},
|
|
11967
11810
|
{
|
|
11968
11811
|
inputs: [
|
|
11969
11812
|
{
|
|
@@ -12140,12 +11983,7 @@ const _abi = [
|
|
|
12140
11983
|
},
|
|
12141
11984
|
{
|
|
12142
11985
|
internalType: "uint64",
|
|
12143
|
-
name: "
|
|
12144
|
-
type: "uint64",
|
|
12145
|
-
},
|
|
12146
|
-
{
|
|
12147
|
-
internalType: "uint64",
|
|
12148
|
-
name: "pairAccFeeShortDelta",
|
|
11986
|
+
name: "pairAccFeeDelta",
|
|
12149
11987
|
type: "uint64",
|
|
12150
11988
|
},
|
|
12151
11989
|
],
|
|
@@ -12463,32 +12301,6 @@ const _abi = [
|
|
|
12463
12301
|
type: "function",
|
|
12464
12302
|
signature: "0xfc79e929",
|
|
12465
12303
|
},
|
|
12466
|
-
{
|
|
12467
|
-
inputs: [
|
|
12468
|
-
{
|
|
12469
|
-
components: [
|
|
12470
|
-
{
|
|
12471
|
-
internalType: "uint32",
|
|
12472
|
-
name: "minP",
|
|
12473
|
-
type: "uint32",
|
|
12474
|
-
},
|
|
12475
|
-
{
|
|
12476
|
-
internalType: "uint32",
|
|
12477
|
-
name: "maxP",
|
|
12478
|
-
type: "uint32",
|
|
12479
|
-
},
|
|
12480
|
-
],
|
|
12481
|
-
internalType: "struct IBorrowingFees.BorrowingFeePerBlockCap",
|
|
12482
|
-
name: "_feePerBlockCap",
|
|
12483
|
-
type: "tuple",
|
|
12484
|
-
},
|
|
12485
|
-
],
|
|
12486
|
-
name: "initializeBorrowingFeePerBlockCap",
|
|
12487
|
-
outputs: [],
|
|
12488
|
-
stateMutability: "nonpayable",
|
|
12489
|
-
type: "function",
|
|
12490
|
-
signature: "0x1a733ea0",
|
|
12491
|
-
},
|
|
12492
12304
|
{
|
|
12493
12305
|
inputs: [
|
|
12494
12306
|
{
|
|
@@ -12523,32 +12335,6 @@ const _abi = [
|
|
|
12523
12335
|
type: "function",
|
|
12524
12336
|
signature: "0x4fa72788",
|
|
12525
12337
|
},
|
|
12526
|
-
{
|
|
12527
|
-
inputs: [
|
|
12528
|
-
{
|
|
12529
|
-
components: [
|
|
12530
|
-
{
|
|
12531
|
-
internalType: "uint32",
|
|
12532
|
-
name: "minP",
|
|
12533
|
-
type: "uint32",
|
|
12534
|
-
},
|
|
12535
|
-
{
|
|
12536
|
-
internalType: "uint32",
|
|
12537
|
-
name: "maxP",
|
|
12538
|
-
type: "uint32",
|
|
12539
|
-
},
|
|
12540
|
-
],
|
|
12541
|
-
internalType: "struct IBorrowingFees.BorrowingFeePerBlockCap",
|
|
12542
|
-
name: "_feePerBlockCap",
|
|
12543
|
-
type: "tuple",
|
|
12544
|
-
},
|
|
12545
|
-
],
|
|
12546
|
-
name: "setBorrowingFeePerBlockCap",
|
|
12547
|
-
outputs: [],
|
|
12548
|
-
stateMutability: "nonpayable",
|
|
12549
|
-
type: "function",
|
|
12550
|
-
signature: "0x197b65a5",
|
|
12551
|
-
},
|
|
12552
12338
|
{
|
|
12553
12339
|
inputs: [
|
|
12554
12340
|
{
|
|
@@ -12631,42 +12417,6 @@ const _abi = [
|
|
|
12631
12417
|
type: "function",
|
|
12632
12418
|
signature: "0x02c4e7c1",
|
|
12633
12419
|
},
|
|
12634
|
-
{
|
|
12635
|
-
inputs: [
|
|
12636
|
-
{
|
|
12637
|
-
internalType: "uint8",
|
|
12638
|
-
name: "_collateralIndex",
|
|
12639
|
-
type: "uint8",
|
|
12640
|
-
},
|
|
12641
|
-
{
|
|
12642
|
-
internalType: "uint16[]",
|
|
12643
|
-
name: "_indices",
|
|
12644
|
-
type: "uint16[]",
|
|
12645
|
-
},
|
|
12646
|
-
{
|
|
12647
|
-
components: [
|
|
12648
|
-
{
|
|
12649
|
-
internalType: "uint32",
|
|
12650
|
-
name: "minP",
|
|
12651
|
-
type: "uint32",
|
|
12652
|
-
},
|
|
12653
|
-
{
|
|
12654
|
-
internalType: "uint32",
|
|
12655
|
-
name: "maxP",
|
|
12656
|
-
type: "uint32",
|
|
12657
|
-
},
|
|
12658
|
-
],
|
|
12659
|
-
internalType: "struct IBorrowingFees.BorrowingFeePerBlockCap[]",
|
|
12660
|
-
name: "_values",
|
|
12661
|
-
type: "tuple[]",
|
|
12662
|
-
},
|
|
12663
|
-
],
|
|
12664
|
-
name: "setBorrowingPairFeePerBlockCapArray",
|
|
12665
|
-
outputs: [],
|
|
12666
|
-
stateMutability: "nonpayable",
|
|
12667
|
-
type: "function",
|
|
12668
|
-
signature: "0x92748a7d",
|
|
12669
|
-
},
|
|
12670
12420
|
{
|
|
12671
12421
|
inputs: [
|
|
12672
12422
|
{
|
|
@@ -12911,20 +12661,6 @@ const _abi = [
|
|
|
12911
12661
|
type: "event",
|
|
12912
12662
|
signature: "0x764c19c693af0da42ec6c6bed68a2dd1a2fa93d24785fcfce58ffa29ae313606",
|
|
12913
12663
|
},
|
|
12914
|
-
{
|
|
12915
|
-
anonymous: false,
|
|
12916
|
-
inputs: [
|
|
12917
|
-
{
|
|
12918
|
-
indexed: false,
|
|
12919
|
-
internalType: "uint8",
|
|
12920
|
-
name: "limitJobCount",
|
|
12921
|
-
type: "uint8",
|
|
12922
|
-
},
|
|
12923
|
-
],
|
|
12924
|
-
name: "LimitJobCountUpdated",
|
|
12925
|
-
type: "event",
|
|
12926
|
-
signature: "0xe3fd233ab0f657acfa4eec07f6b1d79a510c3eef274d27d305c7fc47695a1e7f",
|
|
12927
|
-
},
|
|
12928
12664
|
{
|
|
12929
12665
|
anonymous: false,
|
|
12930
12666
|
inputs: [
|
|
@@ -13534,20 +13270,6 @@ const _abi = [
|
|
|
13534
13270
|
type: "function",
|
|
13535
13271
|
signature: "0x891e656c",
|
|
13536
13272
|
},
|
|
13537
|
-
{
|
|
13538
|
-
inputs: [],
|
|
13539
|
-
name: "getLimitJobCount",
|
|
13540
|
-
outputs: [
|
|
13541
|
-
{
|
|
13542
|
-
internalType: "uint8",
|
|
13543
|
-
name: "",
|
|
13544
|
-
type: "uint8",
|
|
13545
|
-
},
|
|
13546
|
-
],
|
|
13547
|
-
stateMutability: "view",
|
|
13548
|
-
type: "function",
|
|
13549
|
-
signature: "0x75d097a7",
|
|
13550
|
-
},
|
|
13551
13273
|
{
|
|
13552
13274
|
inputs: [],
|
|
13553
13275
|
name: "getLimitJobId",
|
|
@@ -13562,20 +13284,6 @@ const _abi = [
|
|
|
13562
13284
|
type: "function",
|
|
13563
13285
|
signature: "0xf4b0664d",
|
|
13564
13286
|
},
|
|
13565
|
-
{
|
|
13566
|
-
inputs: [],
|
|
13567
|
-
name: "getLimitJobIndex",
|
|
13568
|
-
outputs: [
|
|
13569
|
-
{
|
|
13570
|
-
internalType: "uint88",
|
|
13571
|
-
name: "",
|
|
13572
|
-
type: "uint88",
|
|
13573
|
-
},
|
|
13574
|
-
],
|
|
13575
|
-
stateMutability: "view",
|
|
13576
|
-
type: "function",
|
|
13577
|
-
signature: "0xdb461060",
|
|
13578
|
-
},
|
|
13579
13287
|
{
|
|
13580
13288
|
inputs: [
|
|
13581
13289
|
{
|
|
@@ -13934,20 +13642,6 @@ const _abi = [
|
|
|
13934
13642
|
type: "function",
|
|
13935
13643
|
signature: "0xbbad411a",
|
|
13936
13644
|
},
|
|
13937
|
-
{
|
|
13938
|
-
inputs: [
|
|
13939
|
-
{
|
|
13940
|
-
internalType: "uint8",
|
|
13941
|
-
name: "_limitJobCount",
|
|
13942
|
-
type: "uint8",
|
|
13943
|
-
},
|
|
13944
|
-
],
|
|
13945
|
-
name: "initializeLimitJobCount",
|
|
13946
|
-
outputs: [],
|
|
13947
|
-
stateMutability: "nonpayable",
|
|
13948
|
-
type: "function",
|
|
13949
|
-
signature: "0xc386f31b",
|
|
13950
|
-
},
|
|
13951
13645
|
{
|
|
13952
13646
|
inputs: [
|
|
13953
13647
|
{
|
|
@@ -14047,20 +13741,6 @@ const _abi = [
|
|
|
14047
13741
|
type: "function",
|
|
14048
13742
|
signature: "0x25e589cd",
|
|
14049
13743
|
},
|
|
14050
|
-
{
|
|
14051
|
-
inputs: [
|
|
14052
|
-
{
|
|
14053
|
-
internalType: "uint8",
|
|
14054
|
-
name: "_limitJobCount",
|
|
14055
|
-
type: "uint8",
|
|
14056
|
-
},
|
|
14057
|
-
],
|
|
14058
|
-
name: "setLimitJobCount",
|
|
14059
|
-
outputs: [],
|
|
14060
|
-
stateMutability: "nonpayable",
|
|
14061
|
-
type: "function",
|
|
14062
|
-
signature: "0x19a891e4",
|
|
14063
|
-
},
|
|
14064
13744
|
{
|
|
14065
13745
|
inputs: [
|
|
14066
13746
|
{
|
|
@@ -31,9 +31,7 @@ const getBorrowingGroupName = (groupIndex) => {
|
|
|
31
31
|
};
|
|
32
32
|
exports.getBorrowingGroupName = getBorrowingGroupName;
|
|
33
33
|
const fetchAllPairBorrowingFees = (contract, collateralIndex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
|
|
35
|
-
const feeCaps = yield contract.getBorrowingPairFeePerBlockCaps(collateralIndex, [...Array(pairs.length).keys()]);
|
|
36
|
-
return (0, trade_1.convertPairBorrowingFees)([pairs, pairOi, pairGroups, feeCaps]);
|
|
34
|
+
return (0, trade_1.convertPairBorrowingFees)(yield contract.getAllBorrowingPairs(collateralIndex));
|
|
37
35
|
});
|
|
38
36
|
exports.fetchAllPairBorrowingFees = fetchAllPairBorrowingFees;
|
|
39
37
|
const fetchGroupBorrowingFees = (contract, collateralIndex, groupIxs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -443,4 +443,8 @@ const PAIR_INDEX_TO_DESCRIPTION = {
|
|
|
443
443
|
[types_1.PairIndex.GRIFFAINUSD]: "GRIFFAIN to US Dollar",
|
|
444
444
|
[types_1.PairIndex.SWARMSUSD]: "Swarms to US Dollar",
|
|
445
445
|
[types_1.PairIndex.ANIMEUSD]: "Animecoin to US Dollar",
|
|
446
|
+
[types_1.PairIndex.PLUMEUSD]: "Plume to US Dollar",
|
|
447
|
+
[types_1.PairIndex.VVVUSD]: "Venice Token to US Dollar",
|
|
448
|
+
[types_1.PairIndex.VINEUSD]: "Vine coin to US Dollar",
|
|
449
|
+
[types_1.PairIndex.TOSHIUSD]: "Toshi to US Dollar",
|
|
446
450
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { IBorrowingFees } from "../../../contracts/types/generated/GNSMultiCollatDiamond";
|
|
2
2
|
import { BorrowingFee } from ".";
|
|
3
3
|
export declare const convertPairGroupBorrowingFee: (pairGroup: IBorrowingFees.BorrowingPairGroupStructOutput) => BorrowingFee.PairGroup;
|
|
4
|
-
export declare const convertPairBorrowingFee: (pair: IBorrowingFees.BorrowingDataStructOutput, pairOi: IBorrowingFees.OpenInterestStructOutput, pairGroup: IBorrowingFees.BorrowingPairGroupStructOutput[]
|
|
5
|
-
export declare const convertPairBorrowingFees: ([pairs, pairOi, pairGroups
|
|
4
|
+
export declare const convertPairBorrowingFee: (pair: IBorrowingFees.BorrowingDataStructOutput, pairOi: IBorrowingFees.OpenInterestStructOutput, pairGroup: IBorrowingFees.BorrowingPairGroupStructOutput[]) => BorrowingFee.Pair;
|
|
5
|
+
export declare const convertPairBorrowingFees: ([pairs, pairOi, pairGroups]: [
|
|
6
6
|
IBorrowingFees.BorrowingDataStructOutput[],
|
|
7
7
|
IBorrowingFees.OpenInterestStructOutput[],
|
|
8
|
-
IBorrowingFees.BorrowingPairGroupStructOutput[][]
|
|
9
|
-
IBorrowingFees.BorrowingFeePerBlockCapStructOutput[]
|
|
8
|
+
IBorrowingFees.BorrowingPairGroupStructOutput[][]
|
|
10
9
|
]) => BorrowingFee.Pair[];
|
|
11
10
|
export declare const convertGroupBorrowingFee: (group: IBorrowingFees.BorrowingDataStructOutput, groupOi: IBorrowingFees.OpenInterestStructOutput) => BorrowingFee.Group;
|
|
12
11
|
export declare const convertGroupBorrowingData: (obj: IBorrowingFees.BorrowingDataStructOutput, oi: IBorrowingFees.OpenInterestStructOutput) => BorrowingFee.BorrowingData & BorrowingFee.BorrowingOi;
|
|
@@ -14,4 +13,3 @@ export declare const convertGroupBorrowingFees: ([groups, groupOis]: [
|
|
|
14
13
|
IBorrowingFees.BorrowingDataStructOutput[],
|
|
15
14
|
IBorrowingFees.OpenInterestStructOutput[]
|
|
16
15
|
]) => BorrowingFee.Group[];
|
|
17
|
-
export declare const convertFeePerBlockCap: (feeCap: IBorrowingFees.BorrowingFeePerBlockCapStructOutput) => BorrowingFee.BorrowingFeePerBlockCap;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.convertGroupBorrowingFees = exports.convertGroupBorrowingData = exports.convertGroupBorrowingFee = exports.convertPairBorrowingFees = exports.convertPairBorrowingFee = exports.convertPairGroupBorrowingFee = void 0;
|
|
4
4
|
const borrowingFees_1 = require("../../../contracts/utils/borrowingFees");
|
|
5
5
|
const convertPairGroupBorrowingFee = (pairGroup) => ({
|
|
6
6
|
groupIndex: pairGroup.groupIndex,
|
|
@@ -14,9 +14,9 @@ const convertPairGroupBorrowingFee = (pairGroup) => ({
|
|
|
14
14
|
block: pairGroup.block,
|
|
15
15
|
});
|
|
16
16
|
exports.convertPairGroupBorrowingFee = convertPairGroupBorrowingFee;
|
|
17
|
-
const convertPairBorrowingFee = (pair, pairOi, pairGroup
|
|
17
|
+
const convertPairBorrowingFee = (pair, pairOi, pairGroup) => (Object.assign(Object.assign({}, (0, exports.convertGroupBorrowingData)(pair, pairOi)), { groups: pairGroup.map(value => (0, exports.convertPairGroupBorrowingFee)(value)) }));
|
|
18
18
|
exports.convertPairBorrowingFee = convertPairBorrowingFee;
|
|
19
|
-
const convertPairBorrowingFees = ([pairs, pairOi, pairGroups
|
|
19
|
+
const convertPairBorrowingFees = ([pairs, pairOi, pairGroups]) => pairs.map((value, ix) => (0, exports.convertPairBorrowingFee)(value, pairOi[ix], pairGroups[ix]));
|
|
20
20
|
exports.convertPairBorrowingFees = convertPairBorrowingFees;
|
|
21
21
|
const convertGroupBorrowingFee = (group, groupOi) => (0, exports.convertGroupBorrowingData)(group, groupOi);
|
|
22
22
|
exports.convertGroupBorrowingFee = convertGroupBorrowingFee;
|
|
@@ -35,8 +35,3 @@ const convertGroupBorrowingData = (obj, oi) => ({
|
|
|
35
35
|
exports.convertGroupBorrowingData = convertGroupBorrowingData;
|
|
36
36
|
const convertGroupBorrowingFees = ([groups, groupOis]) => groups.map((value, ix) => (0, exports.convertGroupBorrowingFee)(value, groupOis[ix]));
|
|
37
37
|
exports.convertGroupBorrowingFees = convertGroupBorrowingFees;
|
|
38
|
-
const convertFeePerBlockCap = (feeCap) => ({
|
|
39
|
-
minP: feeCap.minP ? parseFloat(feeCap.minP.toString()) / 1e3 / 100 : 0,
|
|
40
|
-
maxP: feeCap.maxP ? parseFloat(feeCap.maxP.toString()) / 1e3 / 100 : 1,
|
|
41
|
-
});
|
|
42
|
-
exports.convertFeePerBlockCap = convertFeePerBlockCap;
|
|
@@ -22,8 +22,7 @@ export declare const borrowingFeeUtils: {
|
|
|
22
22
|
}) => {
|
|
23
23
|
accFeeLong: number;
|
|
24
24
|
accFeeShort: number;
|
|
25
|
-
|
|
26
|
-
deltaShort: number;
|
|
25
|
+
delta: number;
|
|
27
26
|
};
|
|
28
27
|
getPairPendingAccFee: (pairIndex: PairIndex, currentBlock: number, long: boolean, context: {
|
|
29
28
|
pairs: BorrowingFee.Pair[];
|
|
@@ -34,25 +33,21 @@ export declare const borrowingFeeUtils: {
|
|
|
34
33
|
}) => {
|
|
35
34
|
accFeeLong: number;
|
|
36
35
|
accFeeShort: number;
|
|
37
|
-
|
|
38
|
-
deltaShort: number;
|
|
36
|
+
delta: number;
|
|
39
37
|
};
|
|
40
38
|
getGroupPendingAccFee: (groupIndex: number, currentBlock: number, long: boolean, context: {
|
|
41
39
|
groups: BorrowingFee.Group[];
|
|
42
40
|
}) => number;
|
|
43
|
-
getPendingAccFees: (accFeeLong: number, accFeeShort: number, oiLong: number, oiShort: number, feePerBlock: number, currentBlock: number, accLastUpdatedBlock: number, maxOi: number, feeExponent: number
|
|
41
|
+
getPendingAccFees: (accFeeLong: number, accFeeShort: number, oiLong: number, oiShort: number, feePerBlock: number, currentBlock: number, accLastUpdatedBlock: number, maxOi: number, feeExponent: number) => {
|
|
44
42
|
accFeeLong: number;
|
|
45
43
|
accFeeShort: number;
|
|
46
|
-
|
|
47
|
-
deltaShort: number;
|
|
44
|
+
delta: number;
|
|
48
45
|
};
|
|
49
46
|
getActiveFeePerBlock: (pair: BorrowingFee.Pair, group: BorrowingFee.Group | undefined) => number;
|
|
50
47
|
getBorrowingDataActiveFeePerBlock: (val: BorrowingFee.Pair | BorrowingFee.Group) => number;
|
|
51
48
|
getPairGroupIndex: (pairIndex: PairIndex, context: {
|
|
52
49
|
pairs: BorrowingFee.Pair[];
|
|
53
50
|
}) => number;
|
|
54
|
-
getPendingAccFeesDelta: (blockDistance: number, feePerBlock: number, netOi: number, maxOi: number, feeExponent: number) => number;
|
|
55
|
-
getFeePerBlockCaps: (cap?: BorrowingFee.BorrowingFeePerBlockCap) => BorrowingFee.BorrowingFeePerBlockCap;
|
|
56
51
|
};
|
|
57
52
|
export * as BorrowingFee from "./types";
|
|
58
53
|
export * from "./converter";
|
|
@@ -77,7 +77,7 @@ const getPairGroupIndex = (pairIndex, context) => {
|
|
|
77
77
|
const getPairPendingAccFees = (pairIndex, currentBlock, context) => {
|
|
78
78
|
const { pairs, openInterest: { long, short }, } = context;
|
|
79
79
|
const pair = pairs[pairIndex];
|
|
80
|
-
return getPendingAccFees(pair.accFeeLong, pair.accFeeShort, long, short, pair.feePerBlock, currentBlock, pair.accLastUpdatedBlock, pair.oi.max, pair.feeExponent
|
|
80
|
+
return getPendingAccFees(pair.accFeeLong, pair.accFeeShort, long, short, pair.feePerBlock, currentBlock, pair.accLastUpdatedBlock, pair.oi.max, pair.feeExponent);
|
|
81
81
|
};
|
|
82
82
|
const getPairPendingAccFee = (pairIndex, currentBlock, long, context) => {
|
|
83
83
|
const { accFeeLong, accFeeShort } = getPairPendingAccFees(pairIndex, currentBlock, context);
|
|
@@ -127,62 +127,22 @@ const getPairGroupAccFeesDeltas = (i, pairGroups, initialFees, pairIndex, long,
|
|
|
127
127
|
}
|
|
128
128
|
return { deltaGroup, deltaPair, beforeTradeOpen };
|
|
129
129
|
};
|
|
130
|
-
const getPendingAccFees = (accFeeLong, accFeeShort, oiLong, oiShort, feePerBlock, currentBlock, accLastUpdatedBlock, maxOi, feeExponent
|
|
131
|
-
) => {
|
|
130
|
+
const getPendingAccFees = (accFeeLong, accFeeShort, oiLong, oiShort, feePerBlock, currentBlock, accLastUpdatedBlock, maxOi, feeExponent) => {
|
|
132
131
|
const moreShorts = oiLong < oiShort;
|
|
133
|
-
const blockDistance = currentBlock > accLastUpdatedBlock ? currentBlock - accLastUpdatedBlock : 0;
|
|
134
|
-
// If block distance is zero nothing changes
|
|
135
|
-
if (blockDistance === 0) {
|
|
136
|
-
return {
|
|
137
|
-
accFeeLong,
|
|
138
|
-
accFeeShort,
|
|
139
|
-
deltaLong: 0,
|
|
140
|
-
deltaShort: 0,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
132
|
const netOi = Math.abs(oiLong - oiShort);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
// Calculate the minimum acc fee delta (applies to both sides)
|
|
149
|
-
const minDelta = minNetOi > 0
|
|
150
|
-
? getPendingAccFeesDelta(blockDistance, feePerBlock, netOi, maxOi, feeExponent)
|
|
151
|
-
: 0;
|
|
152
|
-
// Calculate the actual acc fee (using capped oi of 100% or less)
|
|
153
|
-
const delta = netOi > minNetOi
|
|
154
|
-
? getPendingAccFeesDelta(blockDistance, feePerBlock, Math.min(netOi, maxNetOi), // if netOi > cap, use cap
|
|
155
|
-
maxOi, feeExponent)
|
|
156
|
-
: minDelta;
|
|
157
|
-
const [deltaLong, deltaShort] = moreShorts
|
|
158
|
-
? [minDelta, delta]
|
|
159
|
-
: [delta, minDelta];
|
|
160
|
-
return {
|
|
161
|
-
accFeeLong: accFeeLong + deltaLong,
|
|
162
|
-
accFeeShort: accFeeShort + deltaShort,
|
|
163
|
-
deltaLong,
|
|
164
|
-
deltaShort,
|
|
165
|
-
};
|
|
166
|
-
};
|
|
167
|
-
const getPendingAccFeesDelta = (blockDistance, feePerBlock, netOi, maxOi, feeExponent) => {
|
|
168
|
-
return maxOi > 0 && feeExponent > 0
|
|
169
|
-
? feePerBlock * blockDistance * Math.pow((netOi / maxOi), feeExponent)
|
|
133
|
+
const delta = maxOi > 0 && feeExponent > 0
|
|
134
|
+
? feePerBlock *
|
|
135
|
+
(currentBlock - accLastUpdatedBlock) *
|
|
136
|
+
Math.pow((netOi / maxOi), feeExponent)
|
|
170
137
|
: 0;
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
return {
|
|
174
|
-
minP: (cap === null || cap === void 0 ? void 0 : cap.minP) || 0,
|
|
175
|
-
maxP: (cap === null || cap === void 0 ? void 0 : cap.maxP) && cap.maxP > 0 ? cap.maxP : 1,
|
|
176
|
-
};
|
|
138
|
+
const newAccFeeLong = moreShorts ? accFeeLong : accFeeLong + delta;
|
|
139
|
+
const newAccFeeShort = moreShorts ? accFeeShort + delta : accFeeShort;
|
|
140
|
+
return { accFeeLong: newAccFeeLong, accFeeShort: newAccFeeShort, delta };
|
|
177
141
|
};
|
|
178
142
|
const getBorrowingDataActiveFeePerBlock = (val) => {
|
|
179
143
|
const { long, short, max } = val.oi;
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
// If minP > 0 then netOi has to be at least minP * maxOi
|
|
183
|
-
// If maxP > 0 then netOi cannot be more than maxP * maxOi
|
|
184
|
-
const effectiveOi = Math.min(Math.max(Math.abs(long - short), max * minP), max * maxP);
|
|
185
|
-
return val.feePerBlock * Math.pow((effectiveOi / max), val.feeExponent);
|
|
144
|
+
const netOi = Math.abs(long - short);
|
|
145
|
+
return val.feePerBlock * Math.pow((netOi / max), val.feeExponent);
|
|
186
146
|
};
|
|
187
147
|
const getActiveFeePerBlock = (pair, group) => {
|
|
188
148
|
const pairFeePerBlock = getBorrowingDataActiveFeePerBlock(pair);
|
|
@@ -202,8 +162,6 @@ exports.borrowingFeeUtils = {
|
|
|
202
162
|
getActiveFeePerBlock,
|
|
203
163
|
getBorrowingDataActiveFeePerBlock,
|
|
204
164
|
getPairGroupIndex,
|
|
205
|
-
getPendingAccFeesDelta,
|
|
206
|
-
getFeePerBlockCaps,
|
|
207
165
|
};
|
|
208
166
|
exports.BorrowingFee = __importStar(require("./types"));
|
|
209
167
|
__exportStar(require("./converter"), exports);
|
|
@@ -20,13 +20,8 @@ export type PairGroup = {
|
|
|
20
20
|
export type BorrowingOi = {
|
|
21
21
|
oi: OpenInterest;
|
|
22
22
|
};
|
|
23
|
-
export type BorrowingFeePerBlockCap = {
|
|
24
|
-
minP: number;
|
|
25
|
-
maxP: number;
|
|
26
|
-
};
|
|
27
23
|
export type Pair = BorrowingData & BorrowingOi & {
|
|
28
24
|
groups: PairGroup[];
|
|
29
|
-
feePerBlockCap?: BorrowingFeePerBlockCap;
|
|
30
25
|
};
|
|
31
26
|
export type Group = BorrowingData & BorrowingOi;
|
|
32
27
|
export type InitialAccFees = {
|
package/lib/trade/types.d.ts
CHANGED
package/lib/trade/types.js
CHANGED
|
@@ -367,4 +367,8 @@ var PairIndex;
|
|
|
367
367
|
PairIndex[PairIndex["GRIFFAINUSD"] = 335] = "GRIFFAINUSD";
|
|
368
368
|
PairIndex[PairIndex["SWARMSUSD"] = 336] = "SWARMSUSD";
|
|
369
369
|
PairIndex[PairIndex["ANIMEUSD"] = 337] = "ANIMEUSD";
|
|
370
|
+
PairIndex[PairIndex["PLUMEUSD"] = 338] = "PLUMEUSD";
|
|
371
|
+
PairIndex[PairIndex["VVVUSD"] = 339] = "VVVUSD";
|
|
372
|
+
PairIndex[PairIndex["VINEUSD"] = 340] = "VINEUSD";
|
|
373
|
+
PairIndex[PairIndex["TOSHIUSD"] = 341] = "TOSHIUSD";
|
|
370
374
|
})(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
|