@kehtus/proportion-sdk 0.1.0 → 0.1.2
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/arch.md +15 -8
- package/dist/__tests__/reads.test.js +0 -1
- package/dist/abi/factory.d.ts +14 -0
- package/dist/abi/factory.js +18 -0
- package/dist/abi/forwarder.d.ts +287 -0
- package/dist/abi/forwarder.js +373 -0
- package/dist/abi/fundedAccount.d.ts +38 -99
- package/dist/abi/fundedAccount.js +47 -124
- package/dist/abi/mainVault.d.ts +0 -10
- package/dist/abi/mainVault.js +0 -13
- package/dist/account.d.ts +1 -3
- package/dist/account.js +23 -36
- package/dist/constants.d.ts +3 -3
- package/dist/constants.js +6 -5
- package/dist/indexer.js +1 -1
- package/dist/types.d.ts +1 -6
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/src/__tests__/reads.test.ts +0 -1
- package/src/abi/factory.ts +18 -0
- package/src/abi/forwarder.ts +373 -0
- package/src/abi/fundedAccount.ts +47 -124
- package/src/abi/mainVault.ts +0 -13
- package/src/account.ts +26 -40
- package/src/constants.ts +6 -5
- package/src/indexer.ts +1 -1
- package/src/types.ts +1 -6
- package/src/utils.ts +1 -1
- package/SDK_IMPROVEMENT_PLAN.md +0 -197
|
@@ -75,13 +75,13 @@ export const fundedAccountAbi = [
|
|
|
75
75
|
"anonymous": false,
|
|
76
76
|
"inputs": [
|
|
77
77
|
{
|
|
78
|
-
"indexed":
|
|
79
|
-
"internalType": "
|
|
80
|
-
"name": "
|
|
81
|
-
"type": "
|
|
78
|
+
"indexed": false,
|
|
79
|
+
"internalType": "uint64",
|
|
80
|
+
"name": "amount",
|
|
81
|
+
"type": "uint64"
|
|
82
82
|
}
|
|
83
83
|
],
|
|
84
|
-
"name": "
|
|
84
|
+
"name": "BridgedToEvm",
|
|
85
85
|
"type": "event"
|
|
86
86
|
},
|
|
87
87
|
{
|
|
@@ -210,31 +210,6 @@ export const fundedAccountAbi = [
|
|
|
210
210
|
"name": "Initialized",
|
|
211
211
|
"type": "event"
|
|
212
212
|
},
|
|
213
|
-
{
|
|
214
|
-
"anonymous": false,
|
|
215
|
-
"inputs": [
|
|
216
|
-
{
|
|
217
|
-
"indexed": true,
|
|
218
|
-
"internalType": "address",
|
|
219
|
-
"name": "owner",
|
|
220
|
-
"type": "address"
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
"indexed": false,
|
|
224
|
-
"internalType": "uint64",
|
|
225
|
-
"name": "ntlPos",
|
|
226
|
-
"type": "uint64"
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
"indexed": false,
|
|
230
|
-
"internalType": "int64",
|
|
231
|
-
"name": "accountValue",
|
|
232
|
-
"type": "int64"
|
|
233
|
-
}
|
|
234
|
-
],
|
|
235
|
-
"name": "LeverageBreached",
|
|
236
|
-
"type": "event"
|
|
237
|
-
},
|
|
238
213
|
{
|
|
239
214
|
"anonymous": false,
|
|
240
215
|
"inputs": [
|
|
@@ -260,19 +235,6 @@ export const fundedAccountAbi = [
|
|
|
260
235
|
"name": "PositionLeverageBreached",
|
|
261
236
|
"type": "event"
|
|
262
237
|
},
|
|
263
|
-
{
|
|
264
|
-
"anonymous": false,
|
|
265
|
-
"inputs": [
|
|
266
|
-
{
|
|
267
|
-
"indexed": true,
|
|
268
|
-
"internalType": "address",
|
|
269
|
-
"name": "wallet",
|
|
270
|
-
"type": "address"
|
|
271
|
-
}
|
|
272
|
-
],
|
|
273
|
-
"name": "RiskEngineWalletSet",
|
|
274
|
-
"type": "event"
|
|
275
|
-
},
|
|
276
238
|
{
|
|
277
239
|
"anonymous": false,
|
|
278
240
|
"inputs": [
|
|
@@ -426,25 +388,6 @@ export const fundedAccountAbi = [
|
|
|
426
388
|
"name": "VaultReturnInitiated",
|
|
427
389
|
"type": "event"
|
|
428
390
|
},
|
|
429
|
-
{
|
|
430
|
-
"anonymous": false,
|
|
431
|
-
"inputs": [
|
|
432
|
-
{
|
|
433
|
-
"indexed": true,
|
|
434
|
-
"internalType": "address",
|
|
435
|
-
"name": "owner",
|
|
436
|
-
"type": "address"
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
"indexed": false,
|
|
440
|
-
"internalType": "uint256",
|
|
441
|
-
"name": "profit",
|
|
442
|
-
"type": "uint256"
|
|
443
|
-
}
|
|
444
|
-
],
|
|
445
|
-
"name": "WithdrawalCancelled",
|
|
446
|
-
"type": "event"
|
|
447
|
-
},
|
|
448
391
|
{
|
|
449
392
|
"anonymous": false,
|
|
450
393
|
"inputs": [
|
|
@@ -639,7 +582,7 @@ export const fundedAccountAbi = [
|
|
|
639
582
|
},
|
|
640
583
|
{
|
|
641
584
|
"inputs": [],
|
|
642
|
-
"name": "
|
|
585
|
+
"name": "PERP_DEX_COUNT",
|
|
643
586
|
"outputs": [
|
|
644
587
|
{
|
|
645
588
|
"internalType": "uint32",
|
|
@@ -715,19 +658,6 @@ export const fundedAccountAbi = [
|
|
|
715
658
|
"stateMutability": "view",
|
|
716
659
|
"type": "function"
|
|
717
660
|
},
|
|
718
|
-
{
|
|
719
|
-
"inputs": [],
|
|
720
|
-
"name": "WITHDRAWAL_TIMEOUT",
|
|
721
|
-
"outputs": [
|
|
722
|
-
{
|
|
723
|
-
"internalType": "uint256",
|
|
724
|
-
"name": "",
|
|
725
|
-
"type": "uint256"
|
|
726
|
-
}
|
|
727
|
-
],
|
|
728
|
-
"stateMutability": "view",
|
|
729
|
-
"type": "function"
|
|
730
|
-
},
|
|
731
661
|
{
|
|
732
662
|
"inputs": [],
|
|
733
663
|
"name": "accountSize",
|
|
@@ -769,20 +699,14 @@ export const fundedAccountAbi = [
|
|
|
769
699
|
},
|
|
770
700
|
{
|
|
771
701
|
"inputs": [],
|
|
772
|
-
"name": "
|
|
773
|
-
"outputs": [
|
|
774
|
-
|
|
775
|
-
"internalType": "address",
|
|
776
|
-
"name": "",
|
|
777
|
-
"type": "address"
|
|
778
|
-
}
|
|
779
|
-
],
|
|
780
|
-
"stateMutability": "view",
|
|
702
|
+
"name": "bridgeToEvm",
|
|
703
|
+
"outputs": [],
|
|
704
|
+
"stateMutability": "nonpayable",
|
|
781
705
|
"type": "function"
|
|
782
706
|
},
|
|
783
707
|
{
|
|
784
708
|
"inputs": [],
|
|
785
|
-
"name": "
|
|
709
|
+
"name": "builder",
|
|
786
710
|
"outputs": [
|
|
787
711
|
{
|
|
788
712
|
"internalType": "address",
|
|
@@ -806,13 +730,6 @@ export const fundedAccountAbi = [
|
|
|
806
730
|
"stateMutability": "view",
|
|
807
731
|
"type": "function"
|
|
808
732
|
},
|
|
809
|
-
{
|
|
810
|
-
"inputs": [],
|
|
811
|
-
"name": "cancelStuckWithdrawal",
|
|
812
|
-
"outputs": [],
|
|
813
|
-
"stateMutability": "nonpayable",
|
|
814
|
-
"type": "function"
|
|
815
|
-
},
|
|
816
733
|
{
|
|
817
734
|
"inputs": [],
|
|
818
735
|
"name": "cancelSubscription",
|
|
@@ -962,6 +879,19 @@ export const fundedAccountAbi = [
|
|
|
962
879
|
"stateMutability": "nonpayable",
|
|
963
880
|
"type": "function"
|
|
964
881
|
},
|
|
882
|
+
{
|
|
883
|
+
"inputs": [],
|
|
884
|
+
"name": "forwarder",
|
|
885
|
+
"outputs": [
|
|
886
|
+
{
|
|
887
|
+
"internalType": "address",
|
|
888
|
+
"name": "",
|
|
889
|
+
"type": "address"
|
|
890
|
+
}
|
|
891
|
+
],
|
|
892
|
+
"stateMutability": "view",
|
|
893
|
+
"type": "function"
|
|
894
|
+
},
|
|
965
895
|
{
|
|
966
896
|
"inputs": [],
|
|
967
897
|
"name": "getAllCheckpoints",
|
|
@@ -1066,6 +996,11 @@ export const fundedAccountAbi = [
|
|
|
1066
996
|
"name": "_builder",
|
|
1067
997
|
"type": "address"
|
|
1068
998
|
},
|
|
999
|
+
{
|
|
1000
|
+
"internalType": "address",
|
|
1001
|
+
"name": "_forwarder",
|
|
1002
|
+
"type": "address"
|
|
1003
|
+
},
|
|
1069
1004
|
{
|
|
1070
1005
|
"internalType": "uint96",
|
|
1071
1006
|
"name": "_accountSize",
|
|
@@ -1139,6 +1074,25 @@ export const fundedAccountAbi = [
|
|
|
1139
1074
|
"stateMutability": "view",
|
|
1140
1075
|
"type": "function"
|
|
1141
1076
|
},
|
|
1077
|
+
{
|
|
1078
|
+
"inputs": [
|
|
1079
|
+
{
|
|
1080
|
+
"internalType": "address",
|
|
1081
|
+
"name": "_forwarder",
|
|
1082
|
+
"type": "address"
|
|
1083
|
+
}
|
|
1084
|
+
],
|
|
1085
|
+
"name": "isTrustedForwarder",
|
|
1086
|
+
"outputs": [
|
|
1087
|
+
{
|
|
1088
|
+
"internalType": "bool",
|
|
1089
|
+
"name": "",
|
|
1090
|
+
"type": "bool"
|
|
1091
|
+
}
|
|
1092
|
+
],
|
|
1093
|
+
"stateMutability": "view",
|
|
1094
|
+
"type": "function"
|
|
1095
|
+
},
|
|
1142
1096
|
{
|
|
1143
1097
|
"inputs": [],
|
|
1144
1098
|
"name": "lastCheckpointDay",
|
|
@@ -1186,11 +1140,6 @@ export const fundedAccountAbi = [
|
|
|
1186
1140
|
"internalType": "uint256",
|
|
1187
1141
|
"name": "profit",
|
|
1188
1142
|
"type": "uint256"
|
|
1189
|
-
},
|
|
1190
|
-
{
|
|
1191
|
-
"internalType": "uint48",
|
|
1192
|
-
"name": "requestedAt",
|
|
1193
|
-
"type": "uint48"
|
|
1194
1143
|
}
|
|
1195
1144
|
],
|
|
1196
1145
|
"stateMutability": "view",
|
|
@@ -1236,19 +1185,6 @@ export const fundedAccountAbi = [
|
|
|
1236
1185
|
"stateMutability": "view",
|
|
1237
1186
|
"type": "function"
|
|
1238
1187
|
},
|
|
1239
|
-
{
|
|
1240
|
-
"inputs": [],
|
|
1241
|
-
"name": "riskEngineWallet",
|
|
1242
|
-
"outputs": [
|
|
1243
|
-
{
|
|
1244
|
-
"internalType": "address",
|
|
1245
|
-
"name": "",
|
|
1246
|
-
"type": "address"
|
|
1247
|
-
}
|
|
1248
|
-
],
|
|
1249
|
-
"stateMutability": "view",
|
|
1250
|
-
"type": "function"
|
|
1251
|
-
},
|
|
1252
1188
|
{
|
|
1253
1189
|
"inputs": [
|
|
1254
1190
|
{
|
|
@@ -1262,19 +1198,6 @@ export const fundedAccountAbi = [
|
|
|
1262
1198
|
"stateMutability": "nonpayable",
|
|
1263
1199
|
"type": "function"
|
|
1264
1200
|
},
|
|
1265
|
-
{
|
|
1266
|
-
"inputs": [
|
|
1267
|
-
{
|
|
1268
|
-
"internalType": "address",
|
|
1269
|
-
"name": "_wallet",
|
|
1270
|
-
"type": "address"
|
|
1271
|
-
}
|
|
1272
|
-
],
|
|
1273
|
-
"name": "setRiskEngineWallet",
|
|
1274
|
-
"outputs": [],
|
|
1275
|
-
"stateMutability": "nonpayable",
|
|
1276
|
-
"type": "function"
|
|
1277
|
-
},
|
|
1278
1201
|
{
|
|
1279
1202
|
"inputs": [],
|
|
1280
1203
|
"name": "state",
|
package/dist/abi/mainVault.d.ts
CHANGED
|
@@ -642,16 +642,6 @@ export declare const mainVaultAbi: readonly [{
|
|
|
642
642
|
}];
|
|
643
643
|
readonly stateMutability: "view";
|
|
644
644
|
readonly type: "function";
|
|
645
|
-
}, {
|
|
646
|
-
readonly inputs: readonly [];
|
|
647
|
-
readonly name: "HYPERCORE_NEW_ACCOUNT_FEE";
|
|
648
|
-
readonly outputs: readonly [{
|
|
649
|
-
readonly internalType: "uint256";
|
|
650
|
-
readonly name: "";
|
|
651
|
-
readonly type: "uint256";
|
|
652
|
-
}];
|
|
653
|
-
readonly stateMutability: "view";
|
|
654
|
-
readonly type: "function";
|
|
655
645
|
}, {
|
|
656
646
|
readonly inputs: readonly [];
|
|
657
647
|
readonly name: "MAX_ACCOUNT_SIZE";
|
package/dist/abi/mainVault.js
CHANGED
|
@@ -812,19 +812,6 @@ export const mainVaultAbi = [
|
|
|
812
812
|
"stateMutability": "view",
|
|
813
813
|
"type": "function"
|
|
814
814
|
},
|
|
815
|
-
{
|
|
816
|
-
"inputs": [],
|
|
817
|
-
"name": "HYPERCORE_NEW_ACCOUNT_FEE",
|
|
818
|
-
"outputs": [
|
|
819
|
-
{
|
|
820
|
-
"internalType": "uint256",
|
|
821
|
-
"name": "",
|
|
822
|
-
"type": "uint256"
|
|
823
|
-
}
|
|
824
|
-
],
|
|
825
|
-
"stateMutability": "view",
|
|
826
|
-
"type": "function"
|
|
827
|
-
},
|
|
828
815
|
{
|
|
829
816
|
"inputs": [],
|
|
830
817
|
"name": "MAX_ACCOUNT_SIZE",
|
package/dist/account.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ export declare class AccountModule {
|
|
|
28
28
|
}>>;
|
|
29
29
|
getPendingWithdrawal(account: Address): Promise<{
|
|
30
30
|
profit: bigint;
|
|
31
|
-
requestedAt: number;
|
|
32
31
|
}>;
|
|
33
32
|
getAccountConfig(account: Address): Promise<{
|
|
34
33
|
usdc: Address;
|
|
@@ -40,16 +39,15 @@ export declare class AccountModule {
|
|
|
40
39
|
setApiWallet(account: Address, wallet: Address): Promise<Hash>;
|
|
41
40
|
requestWithdrawProfit(account: Address): Promise<Hash>;
|
|
42
41
|
cancelSubscription(account: Address): Promise<Hash>;
|
|
43
|
-
cancelStuckWithdrawal(account: Address): Promise<Hash>;
|
|
44
42
|
checkpoint(account: Address): Promise<Hash>;
|
|
45
43
|
initiateClose(account: Address): Promise<Hash>;
|
|
46
44
|
initiateCloseForPerp(account: Address, perpIndex: number): Promise<Hash>;
|
|
47
45
|
initiateCloseAdmin(account: Address): Promise<Hash>;
|
|
48
46
|
closeAndReturn(account: Address): Promise<Hash>;
|
|
47
|
+
bridgeToEvm(account: Address): Promise<Hash>;
|
|
49
48
|
finalizeReturn(account: Address): Promise<Hash>;
|
|
50
49
|
claimWithdrawal(account: Address): Promise<Hash>;
|
|
51
50
|
claimSubscriptionFee(account: Address): Promise<Hash>;
|
|
52
51
|
rescueStuckFunds(account: Address): Promise<Hash>;
|
|
53
|
-
setRiskEngineWallet(account: Address, wallet: Address): Promise<Hash>;
|
|
54
52
|
}
|
|
55
53
|
export {};
|
package/dist/account.js
CHANGED
|
@@ -38,8 +38,6 @@ export class AccountModule {
|
|
|
38
38
|
{ ...contract, functionName: "subscriptionCancelled" },
|
|
39
39
|
{ ...contract, functionName: "pendingSubscriptionFee" },
|
|
40
40
|
{ ...contract, functionName: "apiWallet" },
|
|
41
|
-
{ ...contract, functionName: "riskEngineWallet" },
|
|
42
|
-
{ ...contract, functionName: "builderRiskEngineWallet" },
|
|
43
41
|
{ ...contract, functionName: "checkpointIndex" },
|
|
44
42
|
{ ...contract, functionName: "profitableDaysCount" },
|
|
45
43
|
{ ...contract, functionName: "totalCheckpoints" },
|
|
@@ -55,10 +53,10 @@ export class AccountModule {
|
|
|
55
53
|
{ ...contract, functionName: "getAllCheckpoints" },
|
|
56
54
|
],
|
|
57
55
|
});
|
|
58
|
-
const checkpointIndex = results[
|
|
59
|
-
const totalCp = results[
|
|
60
|
-
const
|
|
61
|
-
const rawCheckpoints = results[
|
|
56
|
+
const checkpointIndex = results[14].result;
|
|
57
|
+
const totalCp = results[16].result;
|
|
58
|
+
const profit = results[20].result;
|
|
59
|
+
const rawCheckpoints = results[26].result;
|
|
62
60
|
const checkpoints = normalizeCheckpoints(rawCheckpoints, totalCp, checkpointIndex);
|
|
63
61
|
return {
|
|
64
62
|
address: account,
|
|
@@ -76,20 +74,18 @@ export class AccountModule {
|
|
|
76
74
|
subscriptionCancelled: results[11].result,
|
|
77
75
|
pendingSubscriptionFee: results[12].result,
|
|
78
76
|
apiWallet: results[13].result,
|
|
79
|
-
riskEngineWallet: results[14].result,
|
|
80
|
-
builderRiskEngineWallet: results[15].result,
|
|
81
77
|
checkpointIndex,
|
|
82
|
-
profitableDaysCount: results[
|
|
78
|
+
profitableDaysCount: results[15].result,
|
|
83
79
|
totalCheckpoints: totalCp,
|
|
84
|
-
lastCheckpointDay: results[
|
|
85
|
-
closingInitiatedAt: Number(results[
|
|
86
|
-
returnInitiatedAt: Number(results[
|
|
87
|
-
pendingWithdrawal: { profit
|
|
88
|
-
trailingFloor: results[
|
|
89
|
-
dailyFloor: results[
|
|
90
|
-
subscriptionFee: results[
|
|
91
|
-
isSubscriptionActive: results[
|
|
92
|
-
canWithdrawProfit: results[
|
|
80
|
+
lastCheckpointDay: results[17].result,
|
|
81
|
+
closingInitiatedAt: Number(results[18].result),
|
|
82
|
+
returnInitiatedAt: Number(results[19].result),
|
|
83
|
+
pendingWithdrawal: { profit },
|
|
84
|
+
trailingFloor: results[21].result,
|
|
85
|
+
dailyFloor: results[22].result,
|
|
86
|
+
subscriptionFee: results[23].result,
|
|
87
|
+
isSubscriptionActive: results[24].result,
|
|
88
|
+
canWithdrawProfit: results[25].result,
|
|
93
89
|
checkpoints,
|
|
94
90
|
};
|
|
95
91
|
}
|
|
@@ -150,12 +146,12 @@ export class AccountModule {
|
|
|
150
146
|
return normalizeCheckpoints(all, Number(total), Number(checkpointIndex));
|
|
151
147
|
}
|
|
152
148
|
async getPendingWithdrawal(account) {
|
|
153
|
-
const
|
|
149
|
+
const profit = await this.publicClient.readContract({
|
|
154
150
|
address: account,
|
|
155
151
|
abi: fundedAccountAbi,
|
|
156
152
|
functionName: "pendingWithdrawal",
|
|
157
153
|
});
|
|
158
|
-
return { profit
|
|
154
|
+
return { profit };
|
|
159
155
|
}
|
|
160
156
|
async getAccountConfig(account) {
|
|
161
157
|
const contract = { address: account, abi: fundedAccountAbi };
|
|
@@ -206,13 +202,6 @@ export class AccountModule {
|
|
|
206
202
|
functionName: "cancelSubscription",
|
|
207
203
|
});
|
|
208
204
|
}
|
|
209
|
-
async cancelStuckWithdrawal(account) {
|
|
210
|
-
return this.write({
|
|
211
|
-
address: account,
|
|
212
|
-
abi: fundedAccountAbi,
|
|
213
|
-
functionName: "cancelStuckWithdrawal",
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
205
|
// ── PERMISSIONLESS WRITES ───────────────────────────
|
|
217
206
|
async checkpoint(account) {
|
|
218
207
|
return this.write({
|
|
@@ -250,6 +239,13 @@ export class AccountModule {
|
|
|
250
239
|
functionName: "closeAndReturn",
|
|
251
240
|
});
|
|
252
241
|
}
|
|
242
|
+
async bridgeToEvm(account) {
|
|
243
|
+
return this.write({
|
|
244
|
+
address: account,
|
|
245
|
+
abi: fundedAccountAbi,
|
|
246
|
+
functionName: "bridgeToEvm",
|
|
247
|
+
});
|
|
248
|
+
}
|
|
253
249
|
async finalizeReturn(account) {
|
|
254
250
|
return this.write({
|
|
255
251
|
address: account,
|
|
@@ -278,13 +274,4 @@ export class AccountModule {
|
|
|
278
274
|
functionName: "rescueStuckFunds",
|
|
279
275
|
});
|
|
280
276
|
}
|
|
281
|
-
// ── RISK ENGINE WRITES ──────────────────────────────
|
|
282
|
-
async setRiskEngineWallet(account, wallet) {
|
|
283
|
-
return this.write({
|
|
284
|
-
address: account,
|
|
285
|
-
abi: fundedAccountAbi,
|
|
286
|
-
functionName: "setRiskEngineWallet",
|
|
287
|
-
args: [wallet],
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
277
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -19,8 +19,9 @@ export declare const hyperEvm: {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
export declare const ADDRESSES: {
|
|
22
|
-
readonly MAIN_VAULT: "
|
|
23
|
-
readonly FACTORY: "
|
|
22
|
+
readonly MAIN_VAULT: "0x3A8cD3feb02959B2AB622Fcebe40A477c73f9488";
|
|
23
|
+
readonly FACTORY: "0x04B71DC7414Bfa940D1c11f839011B6a11031D2E";
|
|
24
|
+
readonly FORWARDER: "0x5961880B2C461F9733EC71720528461840881f4E";
|
|
24
25
|
readonly USDC: "0xb88339CB7199b77E23DB6E890353E22632Ba630f";
|
|
25
26
|
};
|
|
26
27
|
export declare const BPS = 10000n;
|
|
@@ -38,7 +39,6 @@ export declare const USDC_DECIMALS = 6;
|
|
|
38
39
|
export declare const ACCOUNT_VALUE_DECIMALS = 8;
|
|
39
40
|
export declare const DECIMALS_MULTIPLIER = 100n;
|
|
40
41
|
export declare const SUBSCRIPTION_PERIOD: number;
|
|
41
|
-
export declare const WITHDRAWAL_TIMEOUT: number;
|
|
42
42
|
export declare const BRIDGE_DELAY = 30;
|
|
43
43
|
export declare const CLOSING_TIMEOUT: number;
|
|
44
44
|
export declare const CHECKPOINT_INTERVAL = 86400;
|
package/dist/constants.js
CHANGED
|
@@ -9,8 +9,9 @@ export const hyperEvm = {
|
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
11
|
export const ADDRESSES = {
|
|
12
|
-
MAIN_VAULT: "
|
|
13
|
-
FACTORY: "
|
|
12
|
+
MAIN_VAULT: "0x3A8cD3feb02959B2AB622Fcebe40A477c73f9488",
|
|
13
|
+
FACTORY: "0x04B71DC7414Bfa940D1c11f839011B6a11031D2E",
|
|
14
|
+
FORWARDER: "0x5961880B2C461F9733EC71720528461840881f4E",
|
|
14
15
|
USDC: "0xb88339CB7199b77E23DB6E890353E22632Ba630f",
|
|
15
16
|
};
|
|
16
17
|
// BPS
|
|
@@ -27,11 +28,11 @@ export const MAX_SINGLE_ACCOUNT_BPS = 1000n;
|
|
|
27
28
|
export const HYPE_FOR_GAS = 1000000000000000n; // 0.001 ether
|
|
28
29
|
// Decimals
|
|
29
30
|
export const USDC_DECIMALS = 6;
|
|
30
|
-
export const ACCOUNT_VALUE_DECIMALS = 8;
|
|
31
|
-
export const DECIMALS_MULTIPLIER = 100n; //
|
|
31
|
+
export const ACCOUNT_VALUE_DECIMALS = 8; // spotBalance, spotSend
|
|
32
|
+
export const DECIMALS_MULTIPLIER = 100n; // 6dec→8dec (used for spotSend conversion)
|
|
33
|
+
// Note: accountValue, HWM, dayStartValue, floors are all 6dec (accountMarginSummary returns 6dec)
|
|
32
34
|
// Time (seconds)
|
|
33
35
|
export const SUBSCRIPTION_PERIOD = 30 * 86400;
|
|
34
|
-
export const WITHDRAWAL_TIMEOUT = 7 * 86400;
|
|
35
36
|
export const BRIDGE_DELAY = 30;
|
|
36
37
|
export const CLOSING_TIMEOUT = 3 * 86400;
|
|
37
38
|
export const CHECKPOINT_INTERVAL = 86400;
|
package/dist/indexer.js
CHANGED
|
@@ -14,7 +14,7 @@ export class IndexerModule {
|
|
|
14
14
|
}
|
|
15
15
|
static PAGE_SIZE = 1000;
|
|
16
16
|
static VAULT_FIELDS = `id address totalDeposits totalWithdrawals totalActivationFees cumulativeActivationFeesToVault totalAllocated totalShares cumulativeProfitShares cumulativeCancelledProfit cumulativeSubscriptionFees cumulativeProtocolFeesRouted cumulativeHypercoreFees cumulativeAccountGains cumulativeAccountLosses cumulativeRescuedFunds totalAccountsActivated totalAccountsActive totalAccountsClosed paused subscriptionFeeMultiplier protocolFeeBps protocolFeeReceiver updatedAt`;
|
|
17
|
-
static ACCOUNT_FIELDS = `id owner builder { id address vaultAddress } vaultAddress factoryAddress state accountSize drawdownBps dailyDrawdownEnabled activationFee highWaterMark profitableDaysCount lastCheckpointDay totalCheckpoints subscriptionPaidUntil subscriptionCancelled pendingSubscriptionFee subscriptionFeeMultiplier dayStartValue apiWallet
|
|
17
|
+
static ACCOUNT_FIELDS = `id owner builder { id address vaultAddress } vaultAddress factoryAddress state accountSize drawdownBps dailyDrawdownEnabled activationFee highWaterMark profitableDaysCount lastCheckpointDay totalCheckpoints subscriptionPaidUntil subscriptionCancelled pendingSubscriptionFee subscriptionFeeMultiplier dayStartValue apiWallet createdAt activatedAt closingInitiatedAt returnInitiatedAt closedAt returnedAmount breachType breachValue breachFloor closePendingSubFee closePendingProfit lastWithdrawalId updatedAt`;
|
|
18
18
|
static MAIN_VAULT_CONFIG_FIELDS = `id vaultAddress factoryAddress owner pendingOwner relayer paused protocolFeeReceiver feeMultiplier subscriptionFeeMultiplier dailyDdDiscountBps minBuilderShares builderLeverage protocolFeeBps minAccountSize maxAccountSize minDrawdownBps maxDrawdownBps maxUtilizationBps maxSingleAccountBps hypeForSpot maxCap createdAt updatedAt`;
|
|
19
19
|
static FACTORY_CONFIG_FIELDS = `id factoryAddress vaultAddress owner pendingOwner createdAt updatedAt`;
|
|
20
20
|
static CONFIG_CHANGE_FIELDS = `id contractAddress contractType field oldValue newValue blockNumber timestamp txHash`;
|
package/dist/types.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare enum AccountState {
|
|
|
35
35
|
}
|
|
36
36
|
export type AccountStateLabel = "UNINITIALIZED" | "INITIALIZED" | "ACTIVE" | "WITHDRAWAL_PENDING" | "CLOSING" | "RETURNING" | "CLOSED";
|
|
37
37
|
export type IndexerAccountStateLabel = "INITIALIZED" | "ACTIVE" | "WITHDRAWAL_PENDING" | "CLOSING" | "RETURNING" | "CLOSED";
|
|
38
|
-
export type BreachType = "TRAILING_DRAWDOWN" | "DAILY_DRAWDOWN" | "
|
|
38
|
+
export type BreachType = "TRAILING_DRAWDOWN" | "DAILY_DRAWDOWN" | "POSITION_LEVERAGE" | "UNAUTHORIZED_ASSET" | "SUBSCRIPTION_EXPIRED";
|
|
39
39
|
export interface VaultStats {
|
|
40
40
|
totalAssets: bigint;
|
|
41
41
|
sharePrice: bigint;
|
|
@@ -92,8 +92,6 @@ export interface AccountDetails {
|
|
|
92
92
|
subscriptionCancelled: boolean;
|
|
93
93
|
pendingSubscriptionFee: bigint;
|
|
94
94
|
apiWallet: Address;
|
|
95
|
-
riskEngineWallet: Address;
|
|
96
|
-
builderRiskEngineWallet: Address;
|
|
97
95
|
checkpointIndex: number;
|
|
98
96
|
totalCheckpoints: number;
|
|
99
97
|
profitableDaysCount: number;
|
|
@@ -102,7 +100,6 @@ export interface AccountDetails {
|
|
|
102
100
|
returnInitiatedAt: number;
|
|
103
101
|
pendingWithdrawal: {
|
|
104
102
|
profit: bigint;
|
|
105
|
-
requestedAt: number;
|
|
106
103
|
};
|
|
107
104
|
trailingFloor: bigint;
|
|
108
105
|
dailyFloor: bigint;
|
|
@@ -185,8 +182,6 @@ export interface GqlAccount {
|
|
|
185
182
|
subscriptionFeeMultiplier: number;
|
|
186
183
|
dayStartValue: string;
|
|
187
184
|
apiWallet: string | null;
|
|
188
|
-
riskEngineWallet: string | null;
|
|
189
|
-
builderRiskEngineWallet: string | null;
|
|
190
185
|
createdAt: string;
|
|
191
186
|
activatedAt: string | null;
|
|
192
187
|
closingInitiatedAt: string | null;
|
package/dist/utils.js
CHANGED
|
@@ -20,7 +20,7 @@ export function formatUsd(amount, dec = USDC_DECIMALS) {
|
|
|
20
20
|
const num = Number(amount) / 10 ** dec;
|
|
21
21
|
return "$" + num.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
22
22
|
}
|
|
23
|
-
// ── Drawdown
|
|
23
|
+
// ── Drawdown (all values in 6dec — matching on-chain HWM/dayStartValue) ──
|
|
24
24
|
export function trailingFloor(hwm, drawdownBps) {
|
|
25
25
|
return hwm - (hwm * BigInt(drawdownBps)) / BPS;
|
|
26
26
|
}
|
package/package.json
CHANGED
package/src/abi/factory.ts
CHANGED
|
@@ -10,6 +10,11 @@ export const factoryAbi = [
|
|
|
10
10
|
"internalType": "address",
|
|
11
11
|
"name": "_implementation",
|
|
12
12
|
"type": "address"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"internalType": "address",
|
|
16
|
+
"name": "_forwarder",
|
|
17
|
+
"type": "address"
|
|
13
18
|
}
|
|
14
19
|
],
|
|
15
20
|
"stateMutability": "nonpayable",
|
|
@@ -244,6 +249,19 @@ export const factoryAbi = [
|
|
|
244
249
|
"stateMutability": "nonpayable",
|
|
245
250
|
"type": "function"
|
|
246
251
|
},
|
|
252
|
+
{
|
|
253
|
+
"inputs": [],
|
|
254
|
+
"name": "forwarder",
|
|
255
|
+
"outputs": [
|
|
256
|
+
{
|
|
257
|
+
"internalType": "address",
|
|
258
|
+
"name": "",
|
|
259
|
+
"type": "address"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"stateMutability": "view",
|
|
263
|
+
"type": "function"
|
|
264
|
+
},
|
|
247
265
|
{
|
|
248
266
|
"inputs": [],
|
|
249
267
|
"name": "implementation",
|