@augustdigital/sdk 4.21.0-alpha.0 → 4.22.0-alpha1
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/abis/RwaRedeem.d.ts +76 -0
- package/lib/abis/RwaRedeem.js +55 -0
- package/lib/abis/RwaRedeem.js.map +1 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js.map +1 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js.map +1 -0
- package/lib/abis/TokenizedVaultV2WithDepositWithPermit.d.ts +85 -0
- package/lib/abis/TokenizedVaultV2WithDepositWithPermit.js +1878 -0
- package/lib/abis/TokenizedVaultV2WithDepositWithPermit.js.map +1 -0
- package/lib/abis/index.d.ts +2 -0
- package/lib/abis/index.js +2 -0
- package/lib/abis/index.js.map +1 -1
- package/lib/adapters/evm/index.d.ts +20 -1
- package/lib/adapters/evm/index.js +16 -0
- package/lib/adapters/evm/index.js.map +1 -1
- package/lib/adapters/solana/getters.js +2 -1
- package/lib/adapters/solana/getters.js.map +1 -1
- package/lib/adapters/solana/index.js.map +1 -1
- package/lib/adapters/sui/index.js.map +1 -1
- package/lib/adapters/sui/transformer.js +4 -1
- package/lib/adapters/sui/transformer.js.map +1 -1
- package/lib/core/constants/core.js +4 -4
- package/lib/core/constants/core.js.map +1 -1
- package/lib/core/constants/hardcoded-vaults.d.ts +7 -0
- package/lib/core/constants/hardcoded-vaults.js +171 -0
- package/lib/core/constants/hardcoded-vaults.js.map +1 -0
- package/lib/core/constants/rwa-vaults.d.ts +4 -0
- package/lib/core/constants/rwa-vaults.js +27 -0
- package/lib/core/constants/rwa-vaults.js.map +1 -0
- package/lib/core/constants/vaults.d.ts +2 -0
- package/lib/core/constants/vaults.js +3 -1
- package/lib/core/constants/vaults.js.map +1 -1
- package/lib/core/constants/web3.js +6 -0
- package/lib/core/constants/web3.js.map +1 -1
- package/lib/core/constants.adapters.d.ts +117 -0
- package/lib/core/constants.adapters.js +160 -0
- package/lib/core/constants.adapters.js.map +1 -0
- package/lib/core/constants.core.d.ts +78 -0
- package/lib/core/constants.core.js +75 -0
- package/lib/core/constants.core.js.map +1 -0
- package/lib/core/constants.vaults.d.ts +64 -0
- package/lib/core/constants.vaults.js +156 -0
- package/lib/core/constants.vaults.js.map +1 -0
- package/lib/core/constants.web3.d.ts +31 -0
- package/lib/core/constants.web3.js +100 -0
- package/lib/core/constants.web3.js.map +1 -0
- package/lib/core/fetcher.js +1 -1
- package/lib/core/fetcher.js.map +1 -1
- package/lib/core/helpers/address-utils.d.ts +3 -0
- package/lib/core/helpers/address-utils.js +18 -0
- package/lib/core/helpers/address-utils.js.map +1 -0
- package/lib/core/helpers/vaults.d.ts +1 -0
- package/lib/core/helpers/vaults.js +19 -1
- package/lib/core/helpers/vaults.js.map +1 -1
- package/lib/core/helpers.adapters.d.ts +9 -0
- package/lib/core/helpers.adapters.js +28 -0
- package/lib/core/helpers.adapters.js.map +1 -0
- package/lib/core/helpers.core.d.ts +48 -0
- package/lib/core/helpers.core.js +210 -0
- package/lib/core/helpers.core.js.map +1 -0
- package/lib/core/helpers.signer.d.ts +9 -0
- package/lib/core/helpers.signer.js +54 -0
- package/lib/core/helpers.signer.js.map +1 -0
- package/lib/core/helpers.vaults.d.ts +36 -0
- package/lib/core/helpers.vaults.js +145 -0
- package/lib/core/helpers.vaults.js.map +1 -0
- package/lib/core/helpers.web3.d.ts +95 -0
- package/lib/core/helpers.web3.js +376 -0
- package/lib/core/helpers.web3.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/main.d.ts +4 -0
- package/lib/main.js +47 -0
- package/lib/main.js.map +1 -1
- 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/modules/vaults/getters.js +84 -24
- package/lib/modules/vaults/getters.js.map +1 -1
- package/lib/modules/vaults/main.js +29 -15
- package/lib/modules/vaults/main.js.map +1 -1
- package/lib/modules/vaults/read.actions.d.ts +21 -3
- package/lib/modules/vaults/read.actions.js +128 -0
- package/lib/modules/vaults/read.actions.js.map +1 -1
- package/lib/modules/vaults/utils.js +9 -3
- package/lib/modules/vaults/utils.js.map +1 -1
- package/lib/services/layerzero/deposits.d.ts +25 -0
- package/lib/services/layerzero/deposits.js +111 -0
- package/lib/services/layerzero/deposits.js.map +1 -0
- package/lib/types/rwa-redemption.d.ts +12 -0
- package/lib/types/rwa-redemption.js +3 -0
- package/lib/types/rwa-redemption.js.map +1 -0
- package/lib/types/sub-accounts.d.ts +96 -0
- package/lib/types/vaults.d.ts +2 -0
- package/lib/types/vaults.js.map +1 -1
- package/lib/types/webserver.d.ts +2 -0
- package/lib/verify.d.ts +2 -0
- package/lib/verify.js +33 -0
- package/lib/verify.js.map +1 -0
- package/package.json +2 -2
- package/lib/core/analytics/version.d.ts +0 -1
- package/lib/core/analytics/version.js +0 -5
- package/lib/core/analytics/version.js.map +0 -1
|
@@ -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;AACrD,qCAAqD;AASrD,MAAa,iBAAkB,SAAQ,iBAAU;IAG/C,YAAY,UAAuB;QACjC,KAAK,CAAC,UAAU,CAAC,CAAC;QAHZ,YAAO,GAAkC,IAAI,CAAC;QAIpD,IAAI,CAAC,OAAO,GAAG;YACb,eAAe,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,eAAe,CAAC;YACnD,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC;SAC5C,CAAC;IACJ,CAAC;IAOD,KAAK,CAAC,yBAAyB,CAAC,iBAA2B;QACzD,MAAM,QAAQ,GAAG,MAAM,IAAA,oCAA0B,EAC/C,iBAAiB,EACjB,IAAI,CAAC,IAAI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"}
|
|
@@ -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,EAAE,QAAQ,CAAC,IAAI;QACnB,SAAS,EAAE;YACT,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC5C,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,KAAK,EAAE;oBACL,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI;oBAClB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI;oBAClB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO;oBACxB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK;oBACpB,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,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"}
|
|
@@ -237,7 +237,7 @@ async function getVaultAllocations(vault, options) {
|
|
|
237
237
|
catch (e) {
|
|
238
238
|
core_1.Logger.log.error('getVaultAllocations:borrowers', e);
|
|
239
239
|
}
|
|
240
|
-
const hardcodedSubaccount = Object.values(core_1.VAULT_ALLOCATION_SUBACCOUNTS).find((entry) => entry.address.toLowerCase() === vault.toLowerCase());
|
|
240
|
+
const hardcodedSubaccount = Object.values(core_1.VAULT_ALLOCATION_SUBACCOUNTS).find((entry) => entry.address.toLowerCase() === vault.toLowerCase() && !entry.useDebank);
|
|
241
241
|
if (hardcodedSubaccount) {
|
|
242
242
|
const debankRes = await (0, debank_1.fetchDebankResponse)(hardcodedSubaccount.subaccount);
|
|
243
243
|
if (debankRes === false) {
|
|
@@ -1208,7 +1208,7 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1208
1208
|
wallet,
|
|
1209
1209
|
options,
|
|
1210
1210
|
}),
|
|
1211
|
-
(0, core_1.fetchTokenizedVault)(vault, options?.headers),
|
|
1211
|
+
(0, core_1.fetchTokenizedVault)(vault, options?.headers, false, false),
|
|
1212
1212
|
]);
|
|
1213
1213
|
const tokenizedVault = tokenizedVaultResult?.[0];
|
|
1214
1214
|
if (!tokenizedVault) {
|
|
@@ -1247,19 +1247,62 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1247
1247
|
}
|
|
1248
1248
|
return { underlyingTokenSymbol, underlyingAssetAddress };
|
|
1249
1249
|
})();
|
|
1250
|
-
|
|
1251
|
-
let
|
|
1250
|
+
const depositsByAsset = new Map();
|
|
1251
|
+
let totalWithdrawalsInShares = BigInt(0);
|
|
1252
|
+
let totalWithdrawalsInAssets = BigInt(0);
|
|
1252
1253
|
for (const historyItem of userHistory) {
|
|
1253
1254
|
const amount = BigInt(historyItem.amount);
|
|
1255
|
+
if ((0, core_1.isBadTransaction)(historyItem.transactionHash_, tokenizedVault.chain)) {
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1254
1258
|
if (historyItem.type === 'deposit') {
|
|
1255
|
-
|
|
1259
|
+
const assetKey = 'assetIn' in historyItem && typeof historyItem.assetIn === 'string'
|
|
1260
|
+
? historyItem.assetIn.toLowerCase()
|
|
1261
|
+
: 'default';
|
|
1262
|
+
const current = depositsByAsset.get(assetKey) ?? BigInt(0);
|
|
1263
|
+
depositsByAsset.set(assetKey, current + amount);
|
|
1264
|
+
}
|
|
1265
|
+
else if (historyItem.type === 'withdraw-request') {
|
|
1266
|
+
totalWithdrawalsInShares += amount;
|
|
1256
1267
|
}
|
|
1257
|
-
else if (historyItem.type === 'withdraw-
|
|
1258
|
-
|
|
1259
|
-
|
|
1268
|
+
else if (historyItem.type === 'withdraw-processed' &&
|
|
1269
|
+
historyItem.isInstant) {
|
|
1270
|
+
totalWithdrawalsInAssets += amount;
|
|
1260
1271
|
}
|
|
1261
1272
|
}
|
|
1262
|
-
const
|
|
1273
|
+
const assetDecimals = new Map();
|
|
1274
|
+
await Promise.all(Array.from(depositsByAsset.keys()).map(async (assetAddress) => {
|
|
1275
|
+
if (assetAddress === 'default') {
|
|
1276
|
+
assetDecimals.set(assetAddress, decimals);
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
const dec = await (0, core_1.getDecimals)(provider, assetAddress, false);
|
|
1280
|
+
assetDecimals.set(assetAddress, dec);
|
|
1281
|
+
}
|
|
1282
|
+
}));
|
|
1283
|
+
const totalDepositedRaw = new Map();
|
|
1284
|
+
for (const [assetAddress, rawAmount] of depositsByAsset) {
|
|
1285
|
+
const assetDec = assetDecimals.get(assetAddress) ?? decimals;
|
|
1286
|
+
totalDepositedRaw.set(assetAddress, (0, core_1.toNormalizedBn)(rawAmount, assetDec));
|
|
1287
|
+
}
|
|
1288
|
+
const assetPrices = new Map();
|
|
1289
|
+
if (tokenizedVault.chain) {
|
|
1290
|
+
await Promise.all(Array.from(depositsByAsset.keys()).map(async (assetAddress) => {
|
|
1291
|
+
if (assetAddress === 'default') {
|
|
1292
|
+
assetPrices.set(assetAddress, 0);
|
|
1293
|
+
}
|
|
1294
|
+
else {
|
|
1295
|
+
try {
|
|
1296
|
+
const price = await (0, core_1.fetchTokenPriceByAddress)(assetAddress, tokenizedVault.chain, options?.headers);
|
|
1297
|
+
assetPrices.set(assetAddress, price);
|
|
1298
|
+
}
|
|
1299
|
+
catch (error) {
|
|
1300
|
+
core_1.Logger.log.warn('getVaultUserLifetimePnl:fetchAssetPrice', `Failed to fetch price for ${assetAddress}: ${error}`);
|
|
1301
|
+
assetPrices.set(assetAddress, 0);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}));
|
|
1305
|
+
}
|
|
1263
1306
|
const { underlyingTokenSymbol, underlyingAssetAddress } = await underlyingSymbolPromise;
|
|
1264
1307
|
let currentPositionValue = (0, core_1.toNormalizedBn)(0, decimals);
|
|
1265
1308
|
const pricePromise = underlyingAssetAddress && tokenizedVault.chain
|
|
@@ -1311,25 +1354,42 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1311
1354
|
currentPositionValue = currentPosition.walletBalance;
|
|
1312
1355
|
}
|
|
1313
1356
|
}
|
|
1314
|
-
let
|
|
1357
|
+
let totalWithdrawnRaw = totalWithdrawalsInAssets;
|
|
1315
1358
|
if (version === 'evm-2' && sharePriceRaw > BigInt(0)) {
|
|
1316
|
-
|
|
1317
|
-
(
|
|
1359
|
+
totalWithdrawnRaw +=
|
|
1360
|
+
(totalWithdrawalsInShares * sharePriceRaw) / BigInt(10 ** decimals);
|
|
1361
|
+
}
|
|
1362
|
+
else {
|
|
1363
|
+
totalWithdrawnRaw += totalWithdrawalsInShares;
|
|
1318
1364
|
}
|
|
1319
|
-
const tokenPriceUsd = await pricePromise;
|
|
1320
|
-
const totalWithdrawnRaw = totalWithdrawalsRequestedInAssetsRaw;
|
|
1321
1365
|
const totalWithdrawn = (0, core_1.toNormalizedBn)(totalWithdrawnRaw, decimals);
|
|
1322
|
-
const
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1366
|
+
const tokenPriceUsd = await pricePromise;
|
|
1367
|
+
const effectiveTokenPrice = tokenPriceUsd > 0 ? tokenPriceUsd : 1;
|
|
1368
|
+
if (tokenPriceUsd <= 0) {
|
|
1369
|
+
core_1.Logger.log.warn('getVaultUserLifetimePnl:tokenPrice', `Invalid underlying token price: ${tokenPriceUsd}, using fallback of 1`);
|
|
1370
|
+
}
|
|
1371
|
+
let totalDepositedUsd = 0;
|
|
1372
|
+
for (const [assetAddress, normalizedAmount] of totalDepositedRaw) {
|
|
1373
|
+
const assetPrice = assetAddress === 'default'
|
|
1374
|
+
? effectiveTokenPrice
|
|
1375
|
+
: assetPrices.get(assetAddress) || effectiveTokenPrice;
|
|
1376
|
+
totalDepositedUsd += Number(normalizedAmount.normalized) * assetPrice;
|
|
1377
|
+
}
|
|
1378
|
+
const totalWithdrawnUsd = Number(totalWithdrawn.normalized) * effectiveTokenPrice;
|
|
1379
|
+
const currentPositionValueUsd = Number(currentPositionValue.normalized) * effectiveTokenPrice;
|
|
1380
|
+
const lifetimePnlUsd = currentPositionValueUsd + totalWithdrawnUsd - totalDepositedUsd;
|
|
1381
|
+
const scaleFactor = BigInt(10 ** 18);
|
|
1382
|
+
const tokenPriceScaled = BigInt(Math.round(effectiveTokenPrice * Number(scaleFactor)));
|
|
1383
|
+
const totalDepositedUsdScaled = BigInt(Math.round(totalDepositedUsd * Number(scaleFactor)));
|
|
1384
|
+
const totalDepositedNativeRaw = tokenPriceScaled > BigInt(0)
|
|
1385
|
+
? (totalDepositedUsdScaled * BigInt(10 ** decimals)) / tokenPriceScaled
|
|
1386
|
+
: BigInt(0);
|
|
1387
|
+
const totalDeposited = (0, core_1.toNormalizedBn)(totalDepositedNativeRaw, decimals);
|
|
1388
|
+
const lifetimePnlUsdScaled = BigInt(Math.round(lifetimePnlUsd * Number(scaleFactor)));
|
|
1389
|
+
const lifetimePnlRaw = tokenPriceScaled > BigInt(0)
|
|
1390
|
+
? (lifetimePnlUsdScaled * BigInt(10 ** decimals)) / tokenPriceScaled
|
|
1391
|
+
: BigInt(0);
|
|
1329
1392
|
const lifetimePnl = (0, core_1.toNormalizedBn)(lifetimePnlRaw, decimals);
|
|
1330
|
-
const lifetimePnlUsd = currentPositionValueUsd +
|
|
1331
|
-
Number(totalWithdrawalsRequestedInAssets.normalized) * tokenPriceUsd -
|
|
1332
|
-
totalDepositedUsd;
|
|
1333
1393
|
const pnlPercentage = totalDepositedUsd > 0
|
|
1334
1394
|
? Number.parseFloat(((lifetimePnlUsd / totalDepositedUsd) * 100).toFixed(2))
|
|
1335
1395
|
: 0;
|