@augustdigital/sdk 4.24.1 → 4.24.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/lib/modules/sub-accounts/fetcher.d.ts +2 -1
- package/lib/modules/sub-accounts/fetcher.js +23 -1
- package/lib/modules/sub-accounts/fetcher.js.map +1 -1
- package/lib/modules/sub-accounts/main.d.ts +102 -0
- package/lib/modules/sub-accounts/main.js +5 -0
- package/lib/modules/sub-accounts/main.js.map +1 -1
- package/lib/modules/sub-accounts/utils.d.ts +103 -0
- package/lib/modules/sub-accounts/utils.js +109 -0
- package/lib/modules/sub-accounts/utils.js.map +1 -0
- package/lib/types/sub-accounts.d.ts +96 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFetchAugustOptions } from '../../core';
|
|
2
|
-
import { IAddress, IOTCPosition, IWSSubaccountCefi, IWSSubAccountHealthFactor, IWSSubaccountLoan } from '../../types';
|
|
2
|
+
import { IAddress, IOTCPosition, IWSSubaccountCefi, IWSSubAccountHealthFactor, IWSSubaccountLoan, IWSSubaccountSummary } from '../../types';
|
|
3
3
|
export declare const fetchSubaccountHeathFactor: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubAccountHealthFactor>;
|
|
4
4
|
export declare const fetchSubaccountLoans: (payload: {
|
|
5
5
|
address: IAddress;
|
|
@@ -8,3 +8,4 @@ export declare const fetchSubaccountLoans: (payload: {
|
|
|
8
8
|
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountLoan[]>;
|
|
9
9
|
export declare const fetchSubaccountCefiPositions: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountCefi[]>;
|
|
10
10
|
export declare const fetchSubaccountOtcPositions: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IOTCPosition[]>;
|
|
11
|
+
export declare const fetchSubaccountSummary: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountSummary>;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchSubaccountOtcPositions = exports.fetchSubaccountCefiPositions = exports.fetchSubaccountLoans = exports.fetchSubaccountHeathFactor = void 0;
|
|
3
|
+
exports.fetchSubaccountSummary = exports.fetchSubaccountOtcPositions = exports.fetchSubaccountCefiPositions = exports.fetchSubaccountLoans = exports.fetchSubaccountHeathFactor = void 0;
|
|
4
4
|
const core_1 = require("../../core");
|
|
5
5
|
const fetchSubaccountHeathFactor = async (address, augustKey, headers) => {
|
|
6
6
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.health_factor(address), {
|
|
7
7
|
headers,
|
|
8
8
|
});
|
|
9
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
10
|
+
throw new Error(`Failed to fetch subaccount health factor: ${response.statusText || 'Unknown error'}`);
|
|
11
|
+
}
|
|
9
12
|
return response.json();
|
|
10
13
|
};
|
|
11
14
|
exports.fetchSubaccountHeathFactor = fetchSubaccountHeathFactor;
|
|
@@ -13,6 +16,9 @@ const fetchSubaccountLoans = async (payload, augustKey, headers) => {
|
|
|
13
16
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.loans(payload.address, payload.side, payload.active), {
|
|
14
17
|
headers,
|
|
15
18
|
});
|
|
19
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
20
|
+
throw new Error(`Failed to fetch subaccount loans: ${response.statusText || 'Unknown error'}`);
|
|
21
|
+
}
|
|
16
22
|
return response.json();
|
|
17
23
|
};
|
|
18
24
|
exports.fetchSubaccountLoans = fetchSubaccountLoans;
|
|
@@ -20,6 +26,9 @@ const fetchSubaccountCefiPositions = async (address, augustKey, headers) => {
|
|
|
20
26
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.cefi(address), {
|
|
21
27
|
headers,
|
|
22
28
|
});
|
|
29
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
30
|
+
throw new Error(`Failed to fetch subaccount CeFi positions: ${response.statusText || 'Unknown error'}`);
|
|
31
|
+
}
|
|
23
32
|
return response.json();
|
|
24
33
|
};
|
|
25
34
|
exports.fetchSubaccountCefiPositions = fetchSubaccountCefiPositions;
|
|
@@ -27,7 +36,20 @@ const fetchSubaccountOtcPositions = async (address, augustKey, headers) => {
|
|
|
27
36
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.otc_positions(address), {
|
|
28
37
|
headers,
|
|
29
38
|
});
|
|
39
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
40
|
+
throw new Error(`Failed to fetch subaccount OTC positions: ${response.statusText || 'Unknown error'}`);
|
|
41
|
+
}
|
|
30
42
|
return response.json();
|
|
31
43
|
};
|
|
32
44
|
exports.fetchSubaccountOtcPositions = fetchSubaccountOtcPositions;
|
|
45
|
+
const fetchSubaccountSummary = async (address, augustKey, headers) => {
|
|
46
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.summary(address), {
|
|
47
|
+
headers,
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
50
|
+
throw new Error(`Failed to fetch subaccount summary: ${response.statusText || 'Unknown error'}`);
|
|
51
|
+
}
|
|
52
|
+
return response.json();
|
|
53
|
+
};
|
|
54
|
+
exports.fetchSubaccountSummary = fetchSubaccountSummary;
|
|
33
55
|
//# sourceMappingURL=fetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.js","sourceRoot":"","sources":["../../../src.ts/modules/sub-accounts/fetcher.ts"],"names":[],"mappings":";;;AAAA,qCAIoB;
|
|
1
|
+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EAAE,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CACb,uCAAuC,QAAQ,CAAC,UAAU,IAAI,eAAe,EAAE,CAChF,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAC;AApBW,QAAA,sBAAsB,0BAoBjC"}
|
|
@@ -13,4 +13,106 @@ export declare class AugustSubAccounts extends AugustBase {
|
|
|
13
13
|
getSubaccountLoans(subaccountAddress: IAddress, side: 'BOTH' | 'LENDER' | 'BORROWER', active: boolean): Promise<import("../../types").IWSSubaccountLoan[]>;
|
|
14
14
|
getSubaccountCefiPositions(subaccountAddress: IAddress): Promise<import("../../types").IWSSubaccountCefi[]>;
|
|
15
15
|
getSubaccountOtcPositions(subaccountAddress: IAddress): Promise<import("../../types").IOTCPosition[]>;
|
|
16
|
+
getSubaccountSummary(subaccountAddress: IAddress): Promise<{
|
|
17
|
+
address: `0x${string}`;
|
|
18
|
+
name: string;
|
|
19
|
+
type: "eoa" | "subaccount";
|
|
20
|
+
portfolio: {
|
|
21
|
+
tokens: {
|
|
22
|
+
value: number;
|
|
23
|
+
balance: number;
|
|
24
|
+
token: {
|
|
25
|
+
type: string;
|
|
26
|
+
name: string;
|
|
27
|
+
address: string;
|
|
28
|
+
chain: number;
|
|
29
|
+
symbol: string;
|
|
30
|
+
decimals: number;
|
|
31
|
+
imgUrl: string;
|
|
32
|
+
};
|
|
33
|
+
}[];
|
|
34
|
+
marginBalances: unknown[];
|
|
35
|
+
collateralBalances: unknown[];
|
|
36
|
+
cefiPositions: unknown[];
|
|
37
|
+
defiPositions: unknown[];
|
|
38
|
+
trsPositions: unknown[];
|
|
39
|
+
strategyContractPositions: unknown[];
|
|
40
|
+
legacyHedgerPositions: unknown[];
|
|
41
|
+
otcPositions: unknown[];
|
|
42
|
+
totalValue: number;
|
|
43
|
+
discountedValue: number;
|
|
44
|
+
};
|
|
45
|
+
loanbook: {
|
|
46
|
+
loans: {
|
|
47
|
+
subaccountAddress: `0x${string}`;
|
|
48
|
+
book: {
|
|
49
|
+
address: `0x${string}`;
|
|
50
|
+
lender: `0x${string}`;
|
|
51
|
+
borrower: `0x${string}`;
|
|
52
|
+
state: string;
|
|
53
|
+
totalRepaid: number;
|
|
54
|
+
principalToken: {
|
|
55
|
+
type: string;
|
|
56
|
+
name: string;
|
|
57
|
+
address: string;
|
|
58
|
+
chain: number;
|
|
59
|
+
symbol: string;
|
|
60
|
+
decimals: number;
|
|
61
|
+
imgUrl: string;
|
|
62
|
+
tokenType: number;
|
|
63
|
+
discountFactor: number;
|
|
64
|
+
price: number;
|
|
65
|
+
};
|
|
66
|
+
principalAmount: number;
|
|
67
|
+
interestAmount: number;
|
|
68
|
+
upcomingPayment: {
|
|
69
|
+
amount: number;
|
|
70
|
+
dueDate: string;
|
|
71
|
+
};
|
|
72
|
+
apr: number;
|
|
73
|
+
initialPrincipalAmount: number;
|
|
74
|
+
deployedDate: string;
|
|
75
|
+
paymentInterval: number;
|
|
76
|
+
totalInterestPaymentFees: number;
|
|
77
|
+
};
|
|
78
|
+
isBorrow: boolean;
|
|
79
|
+
debtInfo: {
|
|
80
|
+
interestOwed: number;
|
|
81
|
+
principalDebtOwed: number;
|
|
82
|
+
interestRepaid: number;
|
|
83
|
+
};
|
|
84
|
+
creditInfo: {
|
|
85
|
+
netInterestOwed: number;
|
|
86
|
+
principalDebtOwed: number;
|
|
87
|
+
netInterestRepaid: number;
|
|
88
|
+
};
|
|
89
|
+
}[];
|
|
90
|
+
totalDebt: number;
|
|
91
|
+
totalCredit: number;
|
|
92
|
+
aggregatesByToken: unknown[];
|
|
93
|
+
};
|
|
94
|
+
chains: {
|
|
95
|
+
name: string;
|
|
96
|
+
chainId: number;
|
|
97
|
+
}[];
|
|
98
|
+
tokens: {
|
|
99
|
+
type: string;
|
|
100
|
+
name: string;
|
|
101
|
+
address: string;
|
|
102
|
+
chain: number;
|
|
103
|
+
symbol: string;
|
|
104
|
+
decimals: number;
|
|
105
|
+
imgUrl: string;
|
|
106
|
+
price: number;
|
|
107
|
+
rawBalance: number;
|
|
108
|
+
balance: number;
|
|
109
|
+
value: number;
|
|
110
|
+
}[];
|
|
111
|
+
totalAccountValue: number;
|
|
112
|
+
totalCollateralValue: number;
|
|
113
|
+
totalLoanValue: number;
|
|
114
|
+
healthFactor: number;
|
|
115
|
+
netAccountValue: number;
|
|
116
|
+
totalEquityValue: number;
|
|
117
|
+
}>;
|
|
16
118
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AugustSubAccounts = void 0;
|
|
4
4
|
const fetcher_1 = require("./fetcher");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
5
6
|
const core_1 = require("../../core");
|
|
6
7
|
class AugustSubAccounts extends core_1.AugustBase {
|
|
7
8
|
constructor(baseConfig) {
|
|
@@ -34,6 +35,10 @@ class AugustSubAccounts extends core_1.AugustBase {
|
|
|
34
35
|
const response = await (0, fetcher_1.fetchSubaccountOtcPositions)(subaccountAddress, this.keys.august, this.headers);
|
|
35
36
|
return response;
|
|
36
37
|
}
|
|
38
|
+
async getSubaccountSummary(subaccountAddress) {
|
|
39
|
+
const response = await (0, fetcher_1.fetchSubaccountSummary)(subaccountAddress, this.keys.august, this.headers);
|
|
40
|
+
return (0, utils_1.transformSubaccountSummary)(response);
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
exports.AugustSubAccounts = AugustSubAccounts;
|
|
39
44
|
//# sourceMappingURL=main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src.ts/modules/sub-accounts/main.ts"],"names":[],"mappings":";;;AAKA,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src.ts/modules/sub-accounts/main.ts"],"names":[],"mappings":";;;AAKA,uCAMmB;AACnB,mCAAqD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B,CAAC,iBAA2B;QACzD,MAAM,QAAQ,GAAG,MAAM,IAAA,qCAA2B,EAChD,iBAAiB,EACjB,IAAI,CAAC,IAAI,CAAC,MAAM,EAChB,IAAI,CAAC,OAAO,CACb,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAOD,KAAK,CAAC,oBAAoB,CAAC,iBAA2B;QACpD,MAAM,QAAQ,GAAG,MAAM,IAAA,gCAAsB,EAC3C,iBAAiB,EACjB,IAAI,CAAC,IAAI,CAAC,MAAM,EAChB,IAAI,CAAC,OAAO,CACb,CAAC;QACF,OAAO,IAAA,kCAA0B,EAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;CACF;AA5FD,8CA4FC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { IWSSubaccountSummary } from '../../types';
|
|
2
|
+
export declare const transformSubaccountSummary: (response: IWSSubaccountSummary) => {
|
|
3
|
+
address: `0x${string}`;
|
|
4
|
+
name: string;
|
|
5
|
+
type: "eoa" | "subaccount";
|
|
6
|
+
portfolio: {
|
|
7
|
+
tokens: {
|
|
8
|
+
value: number;
|
|
9
|
+
balance: number;
|
|
10
|
+
token: {
|
|
11
|
+
type: string;
|
|
12
|
+
name: string;
|
|
13
|
+
address: string;
|
|
14
|
+
chain: number;
|
|
15
|
+
symbol: string;
|
|
16
|
+
decimals: number;
|
|
17
|
+
imgUrl: string;
|
|
18
|
+
};
|
|
19
|
+
}[];
|
|
20
|
+
marginBalances: unknown[];
|
|
21
|
+
collateralBalances: unknown[];
|
|
22
|
+
cefiPositions: unknown[];
|
|
23
|
+
defiPositions: unknown[];
|
|
24
|
+
trsPositions: unknown[];
|
|
25
|
+
strategyContractPositions: unknown[];
|
|
26
|
+
legacyHedgerPositions: unknown[];
|
|
27
|
+
otcPositions: unknown[];
|
|
28
|
+
totalValue: number;
|
|
29
|
+
discountedValue: number;
|
|
30
|
+
};
|
|
31
|
+
loanbook: {
|
|
32
|
+
loans: {
|
|
33
|
+
subaccountAddress: `0x${string}`;
|
|
34
|
+
book: {
|
|
35
|
+
address: `0x${string}`;
|
|
36
|
+
lender: `0x${string}`;
|
|
37
|
+
borrower: `0x${string}`;
|
|
38
|
+
state: string;
|
|
39
|
+
totalRepaid: number;
|
|
40
|
+
principalToken: {
|
|
41
|
+
type: string;
|
|
42
|
+
name: string;
|
|
43
|
+
address: string;
|
|
44
|
+
chain: number;
|
|
45
|
+
symbol: string;
|
|
46
|
+
decimals: number;
|
|
47
|
+
imgUrl: string;
|
|
48
|
+
tokenType: number;
|
|
49
|
+
discountFactor: number;
|
|
50
|
+
price: number;
|
|
51
|
+
};
|
|
52
|
+
principalAmount: number;
|
|
53
|
+
interestAmount: number;
|
|
54
|
+
upcomingPayment: {
|
|
55
|
+
amount: number;
|
|
56
|
+
dueDate: string;
|
|
57
|
+
};
|
|
58
|
+
apr: number;
|
|
59
|
+
initialPrincipalAmount: number;
|
|
60
|
+
deployedDate: string;
|
|
61
|
+
paymentInterval: number;
|
|
62
|
+
totalInterestPaymentFees: number;
|
|
63
|
+
};
|
|
64
|
+
isBorrow: boolean;
|
|
65
|
+
debtInfo: {
|
|
66
|
+
interestOwed: number;
|
|
67
|
+
principalDebtOwed: number;
|
|
68
|
+
interestRepaid: number;
|
|
69
|
+
};
|
|
70
|
+
creditInfo: {
|
|
71
|
+
netInterestOwed: number;
|
|
72
|
+
principalDebtOwed: number;
|
|
73
|
+
netInterestRepaid: number;
|
|
74
|
+
};
|
|
75
|
+
}[];
|
|
76
|
+
totalDebt: number;
|
|
77
|
+
totalCredit: number;
|
|
78
|
+
aggregatesByToken: unknown[];
|
|
79
|
+
};
|
|
80
|
+
chains: {
|
|
81
|
+
name: string;
|
|
82
|
+
chainId: number;
|
|
83
|
+
}[];
|
|
84
|
+
tokens: {
|
|
85
|
+
type: string;
|
|
86
|
+
name: string;
|
|
87
|
+
address: string;
|
|
88
|
+
chain: number;
|
|
89
|
+
symbol: string;
|
|
90
|
+
decimals: number;
|
|
91
|
+
imgUrl: string;
|
|
92
|
+
price: number;
|
|
93
|
+
rawBalance: number;
|
|
94
|
+
balance: number;
|
|
95
|
+
value: number;
|
|
96
|
+
}[];
|
|
97
|
+
totalAccountValue: number;
|
|
98
|
+
totalCollateralValue: number;
|
|
99
|
+
totalLoanValue: number;
|
|
100
|
+
healthFactor: number;
|
|
101
|
+
netAccountValue: number;
|
|
102
|
+
totalEquityValue: number;
|
|
103
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformSubaccountSummary = void 0;
|
|
4
|
+
const transformSubaccountSummary = (response) => {
|
|
5
|
+
return {
|
|
6
|
+
address: response.address,
|
|
7
|
+
name: response.name,
|
|
8
|
+
type: response.type,
|
|
9
|
+
portfolio: {
|
|
10
|
+
tokens: response.portfolio.tokens.map((t) => ({
|
|
11
|
+
value: t.value,
|
|
12
|
+
balance: t.balance,
|
|
13
|
+
token: {
|
|
14
|
+
type: t.token.type,
|
|
15
|
+
name: t.token.name,
|
|
16
|
+
address: t.token.address,
|
|
17
|
+
chain: t.token.chain,
|
|
18
|
+
symbol: t.token.symbol,
|
|
19
|
+
decimals: t.token.decimals,
|
|
20
|
+
imgUrl: t.token.img_url,
|
|
21
|
+
},
|
|
22
|
+
})),
|
|
23
|
+
marginBalances: response.portfolio.margin_balances,
|
|
24
|
+
collateralBalances: response.portfolio.collateral_balances,
|
|
25
|
+
cefiPositions: response.portfolio.cefi_positions,
|
|
26
|
+
defiPositions: response.portfolio.defi_positions,
|
|
27
|
+
trsPositions: response.portfolio.trs_positions,
|
|
28
|
+
strategyContractPositions: response.portfolio.strategy_contract_positions,
|
|
29
|
+
legacyHedgerPositions: response.portfolio.legacy_hedger_positions,
|
|
30
|
+
otcPositions: response.portfolio.otc_positions,
|
|
31
|
+
totalValue: response.portfolio.total_value,
|
|
32
|
+
discountedValue: response.portfolio.discounted_value,
|
|
33
|
+
},
|
|
34
|
+
loanbook: {
|
|
35
|
+
loans: response.loanbook.loans.map((loan) => ({
|
|
36
|
+
subaccountAddress: loan.subaccount_address,
|
|
37
|
+
book: {
|
|
38
|
+
address: loan.book.address,
|
|
39
|
+
lender: loan.book.lender,
|
|
40
|
+
borrower: loan.book.borrower,
|
|
41
|
+
state: loan.book.state,
|
|
42
|
+
totalRepaid: loan.book.total_repaid,
|
|
43
|
+
principalToken: {
|
|
44
|
+
type: loan.book.principal_token.type,
|
|
45
|
+
name: loan.book.principal_token.name,
|
|
46
|
+
address: loan.book.principal_token.address,
|
|
47
|
+
chain: loan.book.principal_token.chain,
|
|
48
|
+
symbol: loan.book.principal_token.symbol,
|
|
49
|
+
decimals: loan.book.principal_token.decimals,
|
|
50
|
+
imgUrl: loan.book.principal_token.img_url,
|
|
51
|
+
tokenType: loan.book.principal_token.token_type,
|
|
52
|
+
discountFactor: loan.book.principal_token.discount_factor,
|
|
53
|
+
price: loan.book.principal_token.price,
|
|
54
|
+
},
|
|
55
|
+
principalAmount: loan.book.principal_amount,
|
|
56
|
+
interestAmount: loan.book.interest_amount,
|
|
57
|
+
upcomingPayment: {
|
|
58
|
+
amount: loan.book.upcoming_payment.amount,
|
|
59
|
+
dueDate: loan.book.upcoming_payment.due_date,
|
|
60
|
+
},
|
|
61
|
+
apr: loan.book.apr,
|
|
62
|
+
initialPrincipalAmount: loan.book.initial_principal_amount,
|
|
63
|
+
deployedDate: loan.book.deployed_date,
|
|
64
|
+
paymentInterval: loan.book.payment_interval,
|
|
65
|
+
totalInterestPaymentFees: loan.book.total_interest_payment_fees,
|
|
66
|
+
},
|
|
67
|
+
isBorrow: loan.is_borrow,
|
|
68
|
+
debtInfo: {
|
|
69
|
+
interestOwed: loan.debt_info.interest_owed,
|
|
70
|
+
principalDebtOwed: loan.debt_info.principal_debt_owed,
|
|
71
|
+
interestRepaid: loan.debt_info.interest_repaid,
|
|
72
|
+
},
|
|
73
|
+
creditInfo: {
|
|
74
|
+
netInterestOwed: loan.credit_info.net_interest_owed,
|
|
75
|
+
principalDebtOwed: loan.credit_info.principal_debt_owed,
|
|
76
|
+
netInterestRepaid: loan.credit_info.net_interest_repaid,
|
|
77
|
+
},
|
|
78
|
+
})),
|
|
79
|
+
totalDebt: response.loanbook.total_debt,
|
|
80
|
+
totalCredit: response.loanbook.total_credit,
|
|
81
|
+
aggregatesByToken: response.loanbook.aggregates_by_token,
|
|
82
|
+
},
|
|
83
|
+
chains: response.chains.map((c) => ({
|
|
84
|
+
name: c.name,
|
|
85
|
+
chainId: c.chain_id,
|
|
86
|
+
})),
|
|
87
|
+
tokens: response.tokens.map((t) => ({
|
|
88
|
+
type: t.type,
|
|
89
|
+
name: t.name,
|
|
90
|
+
address: t.address,
|
|
91
|
+
chain: t.chain,
|
|
92
|
+
symbol: t.symbol,
|
|
93
|
+
decimals: t.decimals,
|
|
94
|
+
imgUrl: t.img_url,
|
|
95
|
+
price: t.price,
|
|
96
|
+
rawBalance: t.raw_balance,
|
|
97
|
+
balance: t.balance,
|
|
98
|
+
value: t.value,
|
|
99
|
+
})),
|
|
100
|
+
totalAccountValue: response.total_account_value,
|
|
101
|
+
totalCollateralValue: response.total_collateral_value,
|
|
102
|
+
totalLoanValue: response.total_loan_value,
|
|
103
|
+
healthFactor: response.health_factor,
|
|
104
|
+
netAccountValue: response.net_account_value,
|
|
105
|
+
totalEquityValue: response.total_equity_value,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
exports.transformSubaccountSummary = transformSubaccountSummary;
|
|
109
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src.ts/modules/sub-accounts/utils.ts"],"names":[],"mappings":";;;AAKO,MAAM,0BAA0B,GAAG,CAAC,QAA8B,EAAE,EAAE;IAC3E,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,IAAI,EA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YAClB,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,MAAM,EAAE,CAAC,CAAC,OAAO;YACjB,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,UAAU,EAAE,CAAC,CAAC,WAAW;YACzB,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,KAAK,EAAE,CAAC,CAAC,KAAK;SACf,CAAC,CAAC;QACH,iBAAiB,EAAE,QAAQ,CAAC,mBAAmB;QAC/C,oBAAoB,EAAE,QAAQ,CAAC,sBAAsB;QACrD,cAAc,EAAE,QAAQ,CAAC,gBAAgB;QACzC,YAAY,EAAE,QAAQ,CAAC,aAAa;QACpC,eAAe,EAAE,QAAQ,CAAC,iBAAiB;QAC3C,gBAAgB,EAAE,QAAQ,CAAC,kBAAkB;KAC9C,CAAC;AACJ,CAAC,CAAC;AAvGW,QAAA,0BAA0B,8BAuGrC"}
|
|
@@ -6,3 +6,99 @@ export interface IWSSubAccountHealthFactor {
|
|
|
6
6
|
total_collateral_value: number;
|
|
7
7
|
total_loan_value: number;
|
|
8
8
|
}
|
|
9
|
+
export interface IWSSubaccountSummaryToken {
|
|
10
|
+
type: string;
|
|
11
|
+
name: string;
|
|
12
|
+
address: string;
|
|
13
|
+
chain: number;
|
|
14
|
+
symbol: string;
|
|
15
|
+
decimals: number;
|
|
16
|
+
img_url: string;
|
|
17
|
+
}
|
|
18
|
+
export interface IWSSubaccountSummaryPortfolioToken {
|
|
19
|
+
value: number;
|
|
20
|
+
balance: number;
|
|
21
|
+
token: IWSSubaccountSummaryToken;
|
|
22
|
+
}
|
|
23
|
+
export interface IWSSubaccountSummaryFullToken extends IWSSubaccountSummaryToken {
|
|
24
|
+
price: number;
|
|
25
|
+
raw_balance: number;
|
|
26
|
+
balance: number;
|
|
27
|
+
value: number;
|
|
28
|
+
}
|
|
29
|
+
export interface IWSSubaccountSummaryChain {
|
|
30
|
+
name: string;
|
|
31
|
+
chain_id: number;
|
|
32
|
+
}
|
|
33
|
+
export interface IWSSubaccountSummaryLoanBook {
|
|
34
|
+
address: IAddress;
|
|
35
|
+
lender: IAddress;
|
|
36
|
+
borrower: IAddress;
|
|
37
|
+
state: string;
|
|
38
|
+
total_repaid: number;
|
|
39
|
+
principal_token: IWSSubaccountSummaryToken & {
|
|
40
|
+
token_type: number;
|
|
41
|
+
discount_factor: number;
|
|
42
|
+
price: number;
|
|
43
|
+
};
|
|
44
|
+
principal_amount: number;
|
|
45
|
+
interest_amount: number;
|
|
46
|
+
upcoming_payment: {
|
|
47
|
+
amount: number;
|
|
48
|
+
due_date: string;
|
|
49
|
+
};
|
|
50
|
+
apr: number;
|
|
51
|
+
initial_principal_amount: number;
|
|
52
|
+
deployed_date: string;
|
|
53
|
+
payment_interval: number;
|
|
54
|
+
total_interest_payment_fees: number;
|
|
55
|
+
}
|
|
56
|
+
export interface IWSSubaccountSummaryLoan {
|
|
57
|
+
subaccount_address: IAddress;
|
|
58
|
+
book: IWSSubaccountSummaryLoanBook;
|
|
59
|
+
is_borrow: boolean;
|
|
60
|
+
debt_info: {
|
|
61
|
+
interest_owed: number;
|
|
62
|
+
principal_debt_owed: number;
|
|
63
|
+
interest_repaid: number;
|
|
64
|
+
};
|
|
65
|
+
credit_info: {
|
|
66
|
+
net_interest_owed: number;
|
|
67
|
+
principal_debt_owed: number;
|
|
68
|
+
net_interest_repaid: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface IWSSubaccountSummaryLoanbook {
|
|
72
|
+
loans: IWSSubaccountSummaryLoan[];
|
|
73
|
+
total_debt: number;
|
|
74
|
+
total_credit: number;
|
|
75
|
+
aggregates_by_token: unknown[];
|
|
76
|
+
}
|
|
77
|
+
export interface IWSSubaccountSummaryPortfolio {
|
|
78
|
+
tokens: IWSSubaccountSummaryPortfolioToken[];
|
|
79
|
+
margin_balances: unknown[];
|
|
80
|
+
collateral_balances: unknown[];
|
|
81
|
+
cefi_positions: unknown[];
|
|
82
|
+
defi_positions: unknown[];
|
|
83
|
+
trs_positions: unknown[];
|
|
84
|
+
strategy_contract_positions: unknown[];
|
|
85
|
+
legacy_hedger_positions: unknown[];
|
|
86
|
+
otc_positions: unknown[];
|
|
87
|
+
total_value: number;
|
|
88
|
+
discounted_value: number;
|
|
89
|
+
}
|
|
90
|
+
export interface IWSSubaccountSummary {
|
|
91
|
+
address: IAddress;
|
|
92
|
+
name: string;
|
|
93
|
+
type: 'subaccount' | 'eoa';
|
|
94
|
+
portfolio: IWSSubaccountSummaryPortfolio;
|
|
95
|
+
loanbook: IWSSubaccountSummaryLoanbook;
|
|
96
|
+
chains: IWSSubaccountSummaryChain[];
|
|
97
|
+
tokens: IWSSubaccountSummaryFullToken[];
|
|
98
|
+
total_account_value: number;
|
|
99
|
+
total_collateral_value: number;
|
|
100
|
+
total_loan_value: number;
|
|
101
|
+
health_factor: number | null;
|
|
102
|
+
net_account_value: number;
|
|
103
|
+
total_equity_value: number;
|
|
104
|
+
}
|