@augustdigital/sdk 8.3.2 → 8.5.0
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/ERC20_Bytes32.d.ts +4 -0
- package/lib/abis/ERC20_Bytes32.js +4 -0
- package/lib/abis/ERC4626.d.ts +1 -0
- package/lib/abis/ERC4626.js +1 -0
- package/lib/abis/ERC721.d.ts +1 -0
- package/lib/abis/ERC721.js +1 -0
- package/lib/abis/FeeOracle.js +1 -0
- package/lib/abis/LendingPool.js +1 -0
- package/lib/abis/LendingPoolV2.js +1 -0
- package/lib/abis/Multicall3.js +3 -0
- package/lib/abis/OFT.d.ts +20 -0
- package/lib/abis/OFT.js +20 -0
- package/lib/abis/SmartAccount.d.ts +1 -0
- package/lib/abis/SmartAccount.js +3 -0
- package/lib/abis/SwapRouter.d.ts +1 -0
- package/lib/abis/SwapRouter.js +1 -0
- package/lib/abis/UniversalSignatureValidator.js +3 -0
- package/lib/abis/index.d.ts +5 -0
- package/lib/abis/index.js +5 -0
- package/lib/adapters/evm/getters.d.ts +17 -2
- package/lib/adapters/evm/getters.js +35 -3
- package/lib/adapters/evm/index.d.ts +262 -0
- package/lib/adapters/evm/index.js +268 -1
- package/lib/adapters/evm/utils.d.ts +6 -0
- package/lib/adapters/evm/utils.js +7 -0
- package/lib/adapters/solana/constants.js +4 -1
- package/lib/adapters/solana/getters.d.ts +8 -0
- package/lib/adapters/solana/getters.js +21 -0
- package/lib/adapters/solana/idl/vault-idl.js +9 -0
- package/lib/adapters/solana/index.d.ts +55 -0
- package/lib/adapters/solana/index.js +57 -0
- package/lib/adapters/solana/utils.d.ts +28 -0
- package/lib/adapters/solana/utils.js +79 -4
- package/lib/adapters/solana/vault.actions.d.ts +19 -0
- package/lib/adapters/solana/vault.actions.js +47 -3
- package/lib/adapters/stellar/actions.d.ts +25 -0
- package/lib/adapters/stellar/actions.js +33 -0
- package/lib/adapters/stellar/constants.d.ts +26 -0
- package/lib/adapters/stellar/constants.js +29 -0
- package/lib/adapters/stellar/getters.d.ts +56 -0
- package/lib/adapters/stellar/getters.js +81 -0
- package/lib/adapters/stellar/index.d.ts +48 -0
- package/lib/adapters/stellar/index.js +48 -0
- package/lib/adapters/stellar/soroban.d.ts +20 -0
- package/lib/adapters/stellar/soroban.js +46 -0
- package/lib/adapters/stellar/submit.d.ts +12 -0
- package/lib/adapters/stellar/submit.js +19 -0
- package/lib/adapters/stellar/types.d.ts +27 -0
- package/lib/adapters/stellar/types.js +3 -0
- package/lib/adapters/stellar/utils.d.ts +10 -0
- package/lib/adapters/stellar/utils.js +10 -0
- package/lib/adapters/sui/getters.d.ts +6 -0
- package/lib/adapters/sui/getters.js +6 -0
- package/lib/adapters/sui/index.d.ts +15 -0
- package/lib/adapters/sui/index.js +15 -0
- package/lib/adapters/sui/transformer.d.ts +6 -0
- package/lib/adapters/sui/transformer.js +6 -0
- package/lib/adapters/sui/utils.d.ts +6 -0
- package/lib/adapters/sui/utils.js +6 -0
- package/lib/core/analytics/chain-name.d.ts +8 -0
- package/lib/core/analytics/chain-name.js +8 -0
- package/lib/core/analytics/constants.d.ts +4 -0
- package/lib/core/analytics/constants.js +4 -0
- package/lib/core/analytics/env.d.ts +25 -0
- package/lib/core/analytics/env.js +26 -0
- package/lib/core/analytics/index.d.ts +26 -0
- package/lib/core/analytics/index.js +35 -0
- package/lib/core/analytics/instrumentation.d.ts +26 -0
- package/lib/core/analytics/instrumentation.js +66 -2
- package/lib/core/analytics/method-taxonomy.d.ts +16 -0
- package/lib/core/analytics/method-taxonomy.js +18 -0
- package/lib/core/analytics/metrics.d.ts +23 -0
- package/lib/core/analytics/metrics.js +40 -0
- package/lib/core/analytics/sanitize.d.ts +38 -0
- package/lib/core/analytics/sanitize.js +46 -0
- package/lib/core/analytics/sentry-runtime.d.ts +11 -0
- package/lib/core/analytics/sentry-runtime.js +19 -0
- package/lib/core/analytics/sentry.d.ts +45 -0
- package/lib/core/analytics/sentry.js +115 -2
- package/lib/core/analytics/types.d.ts +27 -0
- package/lib/core/analytics/user-identity.d.ts +34 -0
- package/lib/core/analytics/user-identity.js +42 -0
- package/lib/core/analytics/version.d.ts +6 -1
- package/lib/core/analytics/version.js +6 -1
- package/lib/core/auth/verify.js +5 -0
- package/lib/core/base.class.d.ts +75 -0
- package/lib/core/base.class.js +56 -0
- package/lib/core/cache.d.ts +5 -0
- package/lib/core/cache.js +6 -0
- package/lib/core/constants/adapters.d.ts +15 -0
- package/lib/core/constants/adapters.js +28 -8
- package/lib/core/constants/core.d.ts +12 -1
- package/lib/core/constants/core.js +12 -0
- package/lib/core/constants/swap-router.d.ts +46 -0
- package/lib/core/constants/swap-router.js +50 -0
- package/lib/core/constants/vaults.d.ts +56 -0
- package/lib/core/constants/vaults.js +66 -1
- package/lib/core/constants/web3.d.ts +3 -0
- package/lib/core/constants/web3.js +18 -5
- package/lib/core/errors/index.d.ts +36 -0
- package/lib/core/errors/index.js +29 -0
- package/lib/core/fetcher.d.ts +134 -0
- package/lib/core/fetcher.js +191 -5
- package/lib/core/helpers/adapters.d.ts +9 -0
- package/lib/core/helpers/adapters.js +11 -0
- package/lib/core/helpers/chain-address.d.ts +10 -0
- package/lib/core/helpers/chain-address.js +11 -0
- package/lib/core/helpers/core.d.ts +42 -0
- package/lib/core/helpers/core.js +66 -1
- package/lib/core/helpers/explorer-link.d.ts +14 -0
- package/lib/core/helpers/explorer-link.js +14 -0
- package/lib/core/helpers/signer.d.ts +26 -0
- package/lib/core/helpers/signer.js +39 -0
- package/lib/core/helpers/swap-router.d.ts +32 -0
- package/lib/core/helpers/swap-router.js +32 -0
- package/lib/core/helpers/vault-version.d.ts +1 -0
- package/lib/core/helpers/vault-version.js +2 -0
- package/lib/core/helpers/vaults.d.ts +8 -0
- package/lib/core/helpers/vaults.js +22 -8
- package/lib/core/helpers/web3.d.ts +152 -0
- package/lib/core/helpers/web3.js +183 -6
- package/lib/core/logger/index.d.ts +55 -0
- package/lib/core/logger/index.js +19 -0
- package/lib/core/logger/slack.d.ts +3 -0
- package/lib/core/logger/slack.js +3 -0
- package/lib/core/vault-metadata.d.ts +6 -0
- package/lib/core/vault-metadata.js +6 -0
- package/lib/core/version-check.d.ts +52 -0
- package/lib/core/version-check.js +81 -0
- package/lib/evm/methods/crossChainVault.d.ts +90 -0
- package/lib/evm/methods/crossChainVault.js +186 -1
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
- package/lib/evm/methods/index.d.ts +1 -0
- package/lib/evm/methods/index.js +1 -0
- package/lib/evm/types/crossChain.d.ts +202 -0
- package/lib/evm/types/crossChain.js +11 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +19 -0
- package/lib/main.d.ts +288 -5
- package/lib/main.js +305 -0
- package/lib/modules/api/index.d.ts +1 -0
- package/lib/modules/api/index.js +6 -0
- package/lib/modules/api/main.d.ts +52 -0
- package/lib/modules/api/main.js +130 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +15 -0
- package/lib/modules/sub-accounts/fetcher.js +15 -0
- package/lib/modules/sub-accounts/main.d.ts +33 -0
- package/lib/modules/sub-accounts/main.js +38 -0
- package/lib/modules/sub-accounts/utils.d.ts +3 -0
- package/lib/modules/sub-accounts/utils.js +3 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +18 -0
- package/lib/modules/vaults/adapter.helpers.js +34 -0
- package/lib/modules/vaults/fetcher.d.ts +20 -0
- package/lib/modules/vaults/fetcher.js +40 -3
- package/lib/modules/vaults/getters.d.ts +295 -0
- package/lib/modules/vaults/getters.js +552 -12
- package/lib/modules/vaults/index.d.ts +12 -0
- package/lib/modules/vaults/index.js +12 -0
- package/lib/modules/vaults/main.d.ts +292 -4
- package/lib/modules/vaults/main.js +379 -7
- package/lib/modules/vaults/read.actions.d.ts +168 -0
- package/lib/modules/vaults/read.actions.js +143 -0
- package/lib/modules/vaults/types.d.ts +34 -0
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +47 -0
- package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
- package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
- package/lib/modules/vaults/utils/date-utils.js +47 -1
- package/lib/modules/vaults/utils.d.ts +69 -0
- package/lib/modules/vaults/utils.js +104 -5
- package/lib/modules/vaults/write.actions.d.ts +363 -3
- package/lib/modules/vaults/write.actions.js +364 -2
- package/lib/polyfills.js +2 -0
- package/lib/sdk.d.ts +23705 -0
- package/lib/services/coingecko/fetcher.d.ts +13 -0
- package/lib/services/coingecko/fetcher.js +17 -0
- package/lib/services/debank/fetcher.d.ts +14 -0
- package/lib/services/debank/fetcher.js +12 -0
- package/lib/services/debank/utils.js +17 -0
- package/lib/services/layerzero/deposits.d.ts +11 -0
- package/lib/services/layerzero/deposits.js +34 -11
- package/lib/services/layerzero/redeems.d.ts +10 -0
- package/lib/services/layerzero/redeems.js +13 -0
- package/lib/services/layerzero/utils.d.ts +8 -0
- package/lib/services/layerzero/utils.js +11 -0
- package/lib/services/octavfi/fetcher.d.ts +7 -0
- package/lib/services/octavfi/fetcher.js +25 -0
- package/lib/services/octavfi/utils.d.ts +12 -0
- package/lib/services/octavfi/utils.js +44 -10
- package/lib/services/subgraph/fetcher.js +4 -2
- package/lib/services/subgraph/vaults.d.ts +12 -0
- package/lib/services/subgraph/vaults.js +43 -2
- package/lib/services/swap-quotes/index.d.ts +71 -0
- package/lib/services/swap-quotes/index.js +25 -0
- package/lib/services/swap-quotes/paraswap.d.ts +17 -0
- package/lib/services/swap-quotes/paraswap.js +14 -0
- package/lib/types/pools.d.ts +3 -0
- package/lib/types/typed-contract.d.ts +64 -0
- package/lib/types/vaults.d.ts +137 -2
- package/lib/types/vaults.js +10 -0
- package/lib/types/web3.d.ts +8 -0
- package/lib/types/web3.js +1 -0
- package/lib/types/webserver.d.ts +45 -0
- package/package.json +6 -5
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchSubaccountSummary = exports.fetchSubaccountOtcPositions = exports.fetchSubaccountCefiPositions = exports.fetchSubaccountLoans = exports.fetchSubaccountHeathFactor = void 0;
|
|
4
4
|
const core_1 = require("../../core");
|
|
5
|
+
/**
|
|
6
|
+
* Fetch subaccount health factor for a given subaccount address
|
|
7
|
+
*/
|
|
5
8
|
const fetchSubaccountHeathFactor = async (address, augustKey, headers) => {
|
|
6
9
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.health_factor(address), {
|
|
7
10
|
headers,
|
|
@@ -12,6 +15,9 @@ const fetchSubaccountHeathFactor = async (address, augustKey, headers) => {
|
|
|
12
15
|
return response.json();
|
|
13
16
|
};
|
|
14
17
|
exports.fetchSubaccountHeathFactor = fetchSubaccountHeathFactor;
|
|
18
|
+
/**
|
|
19
|
+
* Fetch subaccount loans details
|
|
20
|
+
*/
|
|
15
21
|
const fetchSubaccountLoans = async (payload, augustKey, headers) => {
|
|
16
22
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.loans(payload.address, payload.side, payload.active), {
|
|
17
23
|
headers,
|
|
@@ -22,6 +28,9 @@ const fetchSubaccountLoans = async (payload, augustKey, headers) => {
|
|
|
22
28
|
return response.json();
|
|
23
29
|
};
|
|
24
30
|
exports.fetchSubaccountLoans = fetchSubaccountLoans;
|
|
31
|
+
/**
|
|
32
|
+
* Fetch the subaccount CeFi positions
|
|
33
|
+
*/
|
|
25
34
|
const fetchSubaccountCefiPositions = async (address, augustKey, headers) => {
|
|
26
35
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.cefi(address), {
|
|
27
36
|
headers,
|
|
@@ -32,6 +41,9 @@ const fetchSubaccountCefiPositions = async (address, augustKey, headers) => {
|
|
|
32
41
|
return response.json();
|
|
33
42
|
};
|
|
34
43
|
exports.fetchSubaccountCefiPositions = fetchSubaccountCefiPositions;
|
|
44
|
+
/**
|
|
45
|
+
* Fetch the subaccount OTC positions
|
|
46
|
+
*/
|
|
35
47
|
const fetchSubaccountOtcPositions = async (address, augustKey, headers) => {
|
|
36
48
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.otc_positions(address), {
|
|
37
49
|
headers,
|
|
@@ -42,6 +54,9 @@ const fetchSubaccountOtcPositions = async (address, augustKey, headers) => {
|
|
|
42
54
|
return response.json();
|
|
43
55
|
};
|
|
44
56
|
exports.fetchSubaccountOtcPositions = fetchSubaccountOtcPositions;
|
|
57
|
+
/**
|
|
58
|
+
* Fetch the subaccount summary view
|
|
59
|
+
*/
|
|
45
60
|
const fetchSubaccountSummary = async (address, augustKey, headers) => {
|
|
46
61
|
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.summary(address), {
|
|
47
62
|
headers,
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { AugustBase, IAugustBase } from '../../core';
|
|
2
2
|
import { IAddress } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Subaccount operation class interacting with August Subaccounts
|
|
5
|
+
* Subaccount is a smart contract wallet that serves as the fundamental infrastructure for August's platform.
|
|
6
|
+
* It functions as a cross-margin account designed for optimal capital efficiency.
|
|
7
|
+
* Most of the operations require a August API key to perform
|
|
8
|
+
*/
|
|
3
9
|
export declare class AugustSubAccounts extends AugustBase {
|
|
4
10
|
private headers;
|
|
5
11
|
constructor(baseConfig: IAugustBase);
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the health factor for a subaccount.
|
|
14
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
15
|
+
* @returns The health factor data including collateral value, loan value, and health factor ratio
|
|
16
|
+
*/
|
|
6
17
|
getSubaccountHealthFactor(subaccountAddress: IAddress): Promise<{
|
|
7
18
|
id: `0x${string}`;
|
|
8
19
|
dateTime: string;
|
|
@@ -10,9 +21,31 @@ export declare class AugustSubAccounts extends AugustBase {
|
|
|
10
21
|
totalCollateral: number;
|
|
11
22
|
totalLoan: number;
|
|
12
23
|
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves loan positions for a subaccount.
|
|
26
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
27
|
+
* @param side - Filter by loan side: 'BOTH' for all loans, 'LENDER' for lent positions, 'BORROWER' for borrowed positions
|
|
28
|
+
* @param active - When true, returns only active loans; when false, returns all loans including closed ones
|
|
29
|
+
* @returns List of loan positions matching the specified filters
|
|
30
|
+
*/
|
|
13
31
|
getSubaccountLoans(subaccountAddress: IAddress, side: 'BOTH' | 'LENDER' | 'BORROWER', active: boolean): Promise<import("../../types").IWSSubaccountLoan[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves CeFi (Centralized Finance) positions for a subaccount.
|
|
34
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
35
|
+
* @returns List of CeFi positions held by the subaccount
|
|
36
|
+
*/
|
|
14
37
|
getSubaccountCefiPositions(subaccountAddress: IAddress): Promise<import("../../types").IWSSubaccountCefi[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves OTC (Over-The-Counter) positions for a subaccount.
|
|
40
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
41
|
+
* @returns List of OTC positions held by the subaccount
|
|
42
|
+
*/
|
|
15
43
|
getSubaccountOtcPositions(subaccountAddress: IAddress): Promise<import("../../types").IOTCPosition[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the summary view for a subaccount or EOA operator.
|
|
46
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
47
|
+
* @returns The full summary including portfolio, loanbook, tokens, and account values
|
|
48
|
+
*/
|
|
16
49
|
getSubaccountSummary(subaccountAddress: IAddress): Promise<{
|
|
17
50
|
address: `0x${string}`;
|
|
18
51
|
name: string;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AugustSubAccounts = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The August Sub Accounts Module.
|
|
6
|
+
*
|
|
7
|
+
* @module AugustSubAccounts
|
|
8
|
+
*/
|
|
4
9
|
const fetcher_1 = require("./fetcher");
|
|
5
10
|
const utils_1 = require("./utils");
|
|
6
11
|
const core_1 = require("../../core");
|
|
12
|
+
/**
|
|
13
|
+
* Subaccount operation class interacting with August Subaccounts
|
|
14
|
+
* Subaccount is a smart contract wallet that serves as the fundamental infrastructure for August's platform.
|
|
15
|
+
* It functions as a cross-margin account designed for optimal capital efficiency.
|
|
16
|
+
* Most of the operations require a August API key to perform
|
|
17
|
+
*/
|
|
7
18
|
class AugustSubAccounts extends core_1.AugustBase {
|
|
8
19
|
constructor(baseConfig) {
|
|
9
20
|
super(baseConfig);
|
|
@@ -13,6 +24,11 @@ class AugustSubAccounts extends core_1.AugustBase {
|
|
|
13
24
|
'x-user-id': this.monitoring?.['x-user-id'],
|
|
14
25
|
};
|
|
15
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the health factor for a subaccount.
|
|
29
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
30
|
+
* @returns The health factor data including collateral value, loan value, and health factor ratio
|
|
31
|
+
*/
|
|
16
32
|
async getSubaccountHealthFactor(subaccountAddress) {
|
|
17
33
|
const response = await (0, fetcher_1.fetchSubaccountHeathFactor)(subaccountAddress, this.keys.august, this.headers);
|
|
18
34
|
return {
|
|
@@ -23,18 +39,40 @@ class AugustSubAccounts extends core_1.AugustBase {
|
|
|
23
39
|
totalLoan: response.total_loan_value,
|
|
24
40
|
};
|
|
25
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves loan positions for a subaccount.
|
|
44
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
45
|
+
* @param side - Filter by loan side: 'BOTH' for all loans, 'LENDER' for lent positions, 'BORROWER' for borrowed positions
|
|
46
|
+
* @param active - When true, returns only active loans; when false, returns all loans including closed ones
|
|
47
|
+
* @returns List of loan positions matching the specified filters
|
|
48
|
+
*/
|
|
26
49
|
async getSubaccountLoans(subaccountAddress, side, active) {
|
|
27
50
|
const response = await (0, fetcher_1.fetchSubaccountLoans)({ address: subaccountAddress, active, side }, this.keys.august, this.headers);
|
|
28
51
|
return response;
|
|
29
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves CeFi (Centralized Finance) positions for a subaccount.
|
|
55
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
56
|
+
* @returns List of CeFi positions held by the subaccount
|
|
57
|
+
*/
|
|
30
58
|
async getSubaccountCefiPositions(subaccountAddress) {
|
|
31
59
|
const response = await (0, fetcher_1.fetchSubaccountCefiPositions)(subaccountAddress, this.keys.august, this.headers);
|
|
32
60
|
return response;
|
|
33
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves OTC (Over-The-Counter) positions for a subaccount.
|
|
64
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
65
|
+
* @returns List of OTC positions held by the subaccount
|
|
66
|
+
*/
|
|
34
67
|
async getSubaccountOtcPositions(subaccountAddress) {
|
|
35
68
|
const response = await (0, fetcher_1.fetchSubaccountOtcPositions)(subaccountAddress, this.keys.august, this.headers);
|
|
36
69
|
return response;
|
|
37
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves the summary view for a subaccount or EOA operator.
|
|
73
|
+
* @param subaccountAddress - The address of the subaccount to query
|
|
74
|
+
* @returns The full summary including portfolio, loanbook, tokens, and account values
|
|
75
|
+
*/
|
|
38
76
|
async getSubaccountSummary(subaccountAddress) {
|
|
39
77
|
const response = await (0, fetcher_1.fetchSubaccountSummary)(subaccountAddress, this.keys.august, this.headers);
|
|
40
78
|
return (0, utils_1.transformSubaccountSummary)(response);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformSubaccountSummary = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Transform the raw API response to camelCase
|
|
6
|
+
*/
|
|
4
7
|
const transformSubaccountSummary = (response) => {
|
|
5
8
|
return {
|
|
6
9
|
address: response.address,
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* Functions to support deposits with alternative tokens through swap adapters,
|
|
5
|
+
* wrapper contracts, and Paraswap integration.
|
|
6
|
+
*/
|
|
1
7
|
import { BaseContract, Signer, Wallet } from 'ethers';
|
|
2
8
|
import { IAddress } from '../../types';
|
|
3
9
|
import { IVaultAdapterConfig } from '../../types/vaults';
|
|
10
|
+
/**
|
|
11
|
+
* Get quote from Paraswap for token swap
|
|
12
|
+
*/
|
|
4
13
|
export declare function getParaswapQuote({ srcToken, destToken, amount, network, srcDecimals, destDecimals, }: {
|
|
5
14
|
srcToken: string;
|
|
6
15
|
destToken: string;
|
|
@@ -9,6 +18,9 @@ export declare function getParaswapQuote({ srcToken, destToken, amount, network,
|
|
|
9
18
|
srcDecimals: number;
|
|
10
19
|
destDecimals: number;
|
|
11
20
|
}): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Build swap and deposit transaction for Paraswap bridge
|
|
23
|
+
*/
|
|
12
24
|
export declare function buildSwapAndDepositTransaction({ signer, srcToken, srcDecimals, destToken, destDecimals, amount, network, adapterConfig, userAddress, }: {
|
|
13
25
|
signer: Signer | Wallet;
|
|
14
26
|
srcToken: IAddress;
|
|
@@ -20,6 +32,9 @@ export declare function buildSwapAndDepositTransaction({ signer, srcToken, srcDe
|
|
|
20
32
|
adapterConfig: IVaultAdapterConfig;
|
|
21
33
|
userAddress: IAddress;
|
|
22
34
|
}): Promise<BaseContract>;
|
|
35
|
+
/**
|
|
36
|
+
* Build native/wrapped token deposit transaction
|
|
37
|
+
*/
|
|
23
38
|
export declare function buildNativeDepositTransaction({ signer, srcToken, amount, poolName, adapterConfig, userAddress, }: {
|
|
24
39
|
signer: Signer | Wallet;
|
|
25
40
|
srcToken: IAddress;
|
|
@@ -33,6 +48,9 @@ export declare function buildNativeDepositTransaction({ signer, srcToken, amount
|
|
|
33
48
|
args: any[];
|
|
34
49
|
value?: bigint;
|
|
35
50
|
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Preview adapter deposit output
|
|
53
|
+
*/
|
|
36
54
|
export declare function previewAdapterDeposit({ signer, vaultAddress, srcToken, srcAmount, srcDecimals, destToken, destDecimals, adapterConfig, chainId, }: {
|
|
37
55
|
signer: Signer | Wallet;
|
|
38
56
|
vaultAddress: IAddress;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Adapter Helper Functions
|
|
4
|
+
*
|
|
5
|
+
* Functions to support deposits with alternative tokens through swap adapters,
|
|
6
|
+
* wrapper contracts, and Paraswap integration.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.getParaswapQuote = getParaswapQuote;
|
|
4
10
|
exports.buildSwapAndDepositTransaction = buildSwapAndDepositTransaction;
|
|
@@ -7,10 +13,19 @@ exports.previewAdapterDeposit = previewAdapterDeposit;
|
|
|
7
13
|
const adapters_1 = require("../../core/constants/adapters");
|
|
8
14
|
const abis_1 = require("../../abis");
|
|
9
15
|
const core_1 = require("../../core");
|
|
16
|
+
/**
|
|
17
|
+
* Paraswap API endpoints
|
|
18
|
+
*/
|
|
10
19
|
const PARASWAP_PRICES_API = 'https://api.paraswap.io/prices';
|
|
20
|
+
/**
|
|
21
|
+
* Paraswap partner configuration
|
|
22
|
+
*/
|
|
11
23
|
const PARASWAP_PARTNER = 'august';
|
|
12
24
|
const PARASWAP_PARTNER_ADDRESS = '0xb60ee0FA5B6bA917255A03e744967E0Bda531dD0';
|
|
13
25
|
const PARASWAP_VERSION = '6.2';
|
|
26
|
+
/**
|
|
27
|
+
* Get quote from Paraswap for token swap
|
|
28
|
+
*/
|
|
14
29
|
async function getParaswapQuote({ srcToken, destToken, amount, network, srcDecimals, destDecimals, }) {
|
|
15
30
|
const params = new URLSearchParams();
|
|
16
31
|
params.append('network', network);
|
|
@@ -32,7 +47,13 @@ async function getParaswapQuote({ srcToken, destToken, amount, network, srcDecim
|
|
|
32
47
|
const data = await response.json();
|
|
33
48
|
return data?.priceRoute || {};
|
|
34
49
|
}
|
|
50
|
+
// Note: buildParaswapTransaction is kept for potential future use
|
|
51
|
+
// Currently transaction building is handled directly in buildSwapAndDepositTransaction
|
|
52
|
+
/**
|
|
53
|
+
* Build swap and deposit transaction for Paraswap bridge
|
|
54
|
+
*/
|
|
35
55
|
async function buildSwapAndDepositTransaction({ signer, srcToken, srcDecimals, destToken, destDecimals, amount, network, adapterConfig, userAddress, }) {
|
|
56
|
+
// Get price quote from Paraswap
|
|
36
57
|
const priceRoute = await getParaswapQuote({
|
|
37
58
|
srcToken,
|
|
38
59
|
destToken,
|
|
@@ -44,6 +65,8 @@ async function buildSwapAndDepositTransaction({ signer, srcToken, srcDecimals, d
|
|
|
44
65
|
if (!priceRoute || !priceRoute.destAmount) {
|
|
45
66
|
throw new Error('No price route found from Paraswap');
|
|
46
67
|
}
|
|
68
|
+
// Create adapter contract
|
|
69
|
+
// Note: Transaction data will be built in the calling code
|
|
47
70
|
const adapterContract = (0, core_1.createContract)({
|
|
48
71
|
address: adapterConfig.wrapperAddress,
|
|
49
72
|
provider: signer,
|
|
@@ -51,6 +74,9 @@ async function buildSwapAndDepositTransaction({ signer, srcToken, srcDecimals, d
|
|
|
51
74
|
});
|
|
52
75
|
return adapterContract;
|
|
53
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Build native/wrapped token deposit transaction
|
|
79
|
+
*/
|
|
54
80
|
async function buildNativeDepositTransaction({ signer, srcToken, amount, poolName, adapterConfig, userAddress, }) {
|
|
55
81
|
const isNative = srcToken === '0x0000000000000000000000000000000000000000';
|
|
56
82
|
const wrapperContract = (0, core_1.createContract)({
|
|
@@ -59,6 +85,7 @@ async function buildNativeDepositTransaction({ signer, srcToken, amount, poolNam
|
|
|
59
85
|
abi: (adapterConfig.abi ||
|
|
60
86
|
abis_1.ABI_WRAPPER_ADAPTER),
|
|
61
87
|
});
|
|
88
|
+
// Handle different pool types
|
|
62
89
|
if (poolName === adapters_1.POOL_NAMES.ETH_TREEHOUSE_GROWTH) {
|
|
63
90
|
if (isNative) {
|
|
64
91
|
return {
|
|
@@ -101,6 +128,7 @@ async function buildNativeDepositTransaction({ signer, srcToken, amount, poolNam
|
|
|
101
128
|
],
|
|
102
129
|
};
|
|
103
130
|
}
|
|
131
|
+
// Default native deposit
|
|
104
132
|
if (isNative && adapterConfig.isNativeTokenDeposit) {
|
|
105
133
|
return {
|
|
106
134
|
contract: wrapperContract,
|
|
@@ -111,7 +139,11 @@ async function buildNativeDepositTransaction({ signer, srcToken, amount, poolNam
|
|
|
111
139
|
}
|
|
112
140
|
throw new Error('Unsupported deposit configuration');
|
|
113
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Preview adapter deposit output
|
|
144
|
+
*/
|
|
114
145
|
async function previewAdapterDeposit({ signer, vaultAddress, srcToken, srcAmount, srcDecimals, destToken, destDecimals, adapterConfig, chainId, }) {
|
|
146
|
+
// If using Paraswap bridge, get quote
|
|
115
147
|
if (adapterConfig.bridgeId === 2) {
|
|
116
148
|
const quote = await getParaswapQuote({
|
|
117
149
|
srcToken,
|
|
@@ -123,6 +155,7 @@ async function previewAdapterDeposit({ signer, vaultAddress, srcToken, srcAmount
|
|
|
123
155
|
});
|
|
124
156
|
return BigInt(quote.destAmount || 0);
|
|
125
157
|
}
|
|
158
|
+
// If view adapter is available, use it
|
|
126
159
|
if (adapterConfig.viewAdapter) {
|
|
127
160
|
const viewContract = (0, core_1.createContract)({
|
|
128
161
|
address: adapterConfig.viewAdapter,
|
|
@@ -145,6 +178,7 @@ async function previewAdapterDeposit({ signer, vaultAddress, srcToken, srcAmount
|
|
|
145
178
|
const output = await viewContract.getRsETHAmountToMint(srcToken, BigInt(srcAmount));
|
|
146
179
|
return BigInt(output);
|
|
147
180
|
}
|
|
181
|
+
// Default: assume 1:1 ratio
|
|
148
182
|
return BigInt(srcAmount);
|
|
149
183
|
}
|
|
150
184
|
//# sourceMappingURL=adapter.helpers.js.map
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specialized vault fetching with enhanced retry logic and fallback strategies
|
|
3
|
+
* This function attempts to fetch vault data with multiple fallback approaches
|
|
4
|
+
*
|
|
5
|
+
* The return shape is "success flag wins": when `success === true`, `data` is
|
|
6
|
+
* the resolved value (which may legitimately be falsy — `0`, `''`, `0n`,
|
|
7
|
+
* `null`); when `success === false`, `error` is populated. Callers must branch
|
|
8
|
+
* on `success`, not on the truthiness of `data`.
|
|
9
|
+
*/
|
|
1
10
|
export declare function fetchVaultWithFallback<T>(vaultAddress: string, fetchFn: () => Promise<T>, options?: {
|
|
2
11
|
maxRetries?: number;
|
|
3
12
|
baseDelay?: number;
|
|
@@ -9,6 +18,10 @@ export declare function fetchVaultWithFallback<T>(vaultAddress: string, fetchFn:
|
|
|
9
18
|
error?: Error;
|
|
10
19
|
strategy: string;
|
|
11
20
|
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Batch vault fetching with intelligent retry and fallback
|
|
23
|
+
* Ensures maximum vault coverage by trying multiple strategies
|
|
24
|
+
*/
|
|
12
25
|
export declare function fetchVaultsBatch<T>(vaults: Array<{
|
|
13
26
|
address: string;
|
|
14
27
|
fetchFn: () => Promise<T>;
|
|
@@ -31,6 +44,10 @@ export declare function fetchVaultsBatch<T>(vaults: Array<{
|
|
|
31
44
|
totalAttempted: number;
|
|
32
45
|
successRate: number;
|
|
33
46
|
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Comprehensive vault fetching that handles all failure points
|
|
49
|
+
* This function ensures maximum vault coverage by implementing multiple strategies
|
|
50
|
+
*/
|
|
34
51
|
export declare function fetchVaultsComprehensive<T>(vaults: Array<{
|
|
35
52
|
address: string;
|
|
36
53
|
chain: number;
|
|
@@ -73,6 +90,9 @@ export declare function fetchVaultsComprehensive<T>(vaults: Array<{
|
|
|
73
90
|
rpcFailures: Record<number, number>;
|
|
74
91
|
};
|
|
75
92
|
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Enhanced vault filtering that preserves more vaults while maintaining quality
|
|
95
|
+
*/
|
|
76
96
|
export declare function filterVaultsIntelligently<T extends {
|
|
77
97
|
status?: string;
|
|
78
98
|
isVisible?: boolean;
|
|
@@ -6,6 +6,7 @@ exports.fetchVaultsBatch = fetchVaultsBatch;
|
|
|
6
6
|
exports.fetchVaultsComprehensive = fetchVaultsComprehensive;
|
|
7
7
|
exports.filterVaultsIntelligently = filterVaultsIntelligently;
|
|
8
8
|
const core_1 = require("../../core");
|
|
9
|
+
/** @internal */
|
|
9
10
|
async function runWithConcurrency(tasks, limit) {
|
|
10
11
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
11
12
|
throw new Error(`runWithConcurrency: limit must be a positive finite number, got ${limit}`);
|
|
@@ -13,6 +14,8 @@ async function runWithConcurrency(tasks, limit) {
|
|
|
13
14
|
const results = new Array(tasks.length);
|
|
14
15
|
let nextIndex = 0;
|
|
15
16
|
const workerCount = Math.min(Math.floor(limit), tasks.length);
|
|
17
|
+
// `nextIndex++` is safe across workers — JS is single-threaded and the
|
|
18
|
+
// increment runs to completion before any worker yields at `await`.
|
|
16
19
|
const workers = Array.from({ length: workerCount }, async () => {
|
|
17
20
|
while (true) {
|
|
18
21
|
const i = nextIndex++;
|
|
@@ -24,6 +27,15 @@ async function runWithConcurrency(tasks, limit) {
|
|
|
24
27
|
await Promise.all(workers);
|
|
25
28
|
return results;
|
|
26
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Specialized vault fetching with enhanced retry logic and fallback strategies
|
|
32
|
+
* This function attempts to fetch vault data with multiple fallback approaches
|
|
33
|
+
*
|
|
34
|
+
* The return shape is "success flag wins": when `success === true`, `data` is
|
|
35
|
+
* the resolved value (which may legitimately be falsy — `0`, `''`, `0n`,
|
|
36
|
+
* `null`); when `success === false`, `error` is populated. Callers must branch
|
|
37
|
+
* on `success`, not on the truthiness of `data`.
|
|
38
|
+
*/
|
|
27
39
|
async function fetchVaultWithFallback(vaultAddress, fetchFn, options = {}) {
|
|
28
40
|
const { maxRetries = 3, baseDelay = 1000 } = options;
|
|
29
41
|
try {
|
|
@@ -42,6 +54,10 @@ async function fetchVaultWithFallback(vaultAddress, fetchFn, options = {}) {
|
|
|
42
54
|
strategy: 'all-failed',
|
|
43
55
|
};
|
|
44
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Batch vault fetching with intelligent retry and fallback
|
|
59
|
+
* Ensures maximum vault coverage by trying multiple strategies
|
|
60
|
+
*/
|
|
45
61
|
async function fetchVaultsBatch(vaults, options = {}) {
|
|
46
62
|
const { maxRetries = 3, baseDelay = 1000, batchSize = 10, parallelLimit = batchSize, } = options;
|
|
47
63
|
const successful = [];
|
|
@@ -57,6 +73,10 @@ async function fetchVaultsBatch(vaults, options = {}) {
|
|
|
57
73
|
maxRetries,
|
|
58
74
|
baseDelay,
|
|
59
75
|
});
|
|
76
|
+
// Branch on `result.success` only — not on truthiness of `result.data`.
|
|
77
|
+
// A successful fetch can legitimately resolve to a falsy value
|
|
78
|
+
// (`0`, `''`, `0n`, `null`); the cast respects the function's
|
|
79
|
+
// documented contract that `data` is present on the success branch.
|
|
60
80
|
if (result.success) {
|
|
61
81
|
successful.push({
|
|
62
82
|
index: globalIndex,
|
|
@@ -81,6 +101,7 @@ async function fetchVaultsBatch(vaults, options = {}) {
|
|
|
81
101
|
}
|
|
82
102
|
});
|
|
83
103
|
await runWithConcurrency(batchTasks, parallelLimit);
|
|
104
|
+
// Small delay between batches to be respectful to RPC endpoints
|
|
84
105
|
if (i + batchSize < vaults.length) {
|
|
85
106
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
86
107
|
}
|
|
@@ -93,8 +114,14 @@ async function fetchVaultsBatch(vaults, options = {}) {
|
|
|
93
114
|
successRate,
|
|
94
115
|
};
|
|
95
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Comprehensive vault fetching that handles all failure points
|
|
119
|
+
* This function ensures maximum vault coverage by implementing multiple strategies
|
|
120
|
+
*/
|
|
96
121
|
async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
|
|
97
|
-
const { maxRetries = 5, baseDelay = 2000, batchSize = 10, parallelLimit = batchSize, includeClosed: _includeClosed = false,
|
|
122
|
+
const { maxRetries = 5, baseDelay = 2000, batchSize = 10, parallelLimit = batchSize, includeClosed: _includeClosed = false, // Reserved for future filtering
|
|
123
|
+
includeInvisible: _includeInvisible = false, // Reserved for future filtering
|
|
124
|
+
fallbackRpcUrls = {}, timeout = 60000, } = options;
|
|
98
125
|
const successful = [];
|
|
99
126
|
const failed = [];
|
|
100
127
|
const rpcFailures = {};
|
|
@@ -106,6 +133,7 @@ async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
|
|
|
106
133
|
totalAttempted++;
|
|
107
134
|
let attempts = 0;
|
|
108
135
|
let lastError;
|
|
136
|
+
// Strategy 1: Primary fetch with retry
|
|
109
137
|
for (attempts = 1; attempts <= maxRetries; attempts++) {
|
|
110
138
|
try {
|
|
111
139
|
const data = await Promise.race([
|
|
@@ -129,6 +157,7 @@ async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
|
|
|
129
157
|
}
|
|
130
158
|
}
|
|
131
159
|
}
|
|
160
|
+
// Strategy 2: Try with fallback RPC endpoints
|
|
132
161
|
if (fallbackRpcUrls[vault.chain] &&
|
|
133
162
|
fallbackRpcUrls[vault.chain].length > 0) {
|
|
134
163
|
for (const fallbackRpc of fallbackRpcUrls[vault.chain]) {
|
|
@@ -154,6 +183,7 @@ async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
|
|
|
154
183
|
}
|
|
155
184
|
}
|
|
156
185
|
}
|
|
186
|
+
// Strategy 3: Try with minimal data fetching (if fetchFn supports it)
|
|
157
187
|
try {
|
|
158
188
|
const data = await Promise.race([
|
|
159
189
|
fetchFn({ ...vault, minimal: true }),
|
|
@@ -173,6 +203,7 @@ async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
|
|
|
173
203
|
error: error instanceof Error ? error.message : String(error),
|
|
174
204
|
});
|
|
175
205
|
}
|
|
206
|
+
// Strategy 4: Extended retry with longer delays
|
|
176
207
|
try {
|
|
177
208
|
const extendedDelay = baseDelay * 3;
|
|
178
209
|
await new Promise((resolve) => setTimeout(resolve, extendedDelay));
|
|
@@ -194,6 +225,7 @@ async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
|
|
|
194
225
|
error: error instanceof Error ? error.message : String(error),
|
|
195
226
|
});
|
|
196
227
|
}
|
|
228
|
+
// All strategies failed
|
|
197
229
|
failed.push({
|
|
198
230
|
index: globalIndex,
|
|
199
231
|
error: lastError || new Error('All strategies failed'),
|
|
@@ -201,9 +233,11 @@ async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
|
|
|
201
233
|
chain: vault.chain,
|
|
202
234
|
attempts: attempts + 2,
|
|
203
235
|
});
|
|
236
|
+
// Track RPC failures by chain
|
|
204
237
|
rpcFailures[vault.chain] = (rpcFailures[vault.chain] || 0) + 1;
|
|
205
238
|
});
|
|
206
239
|
await runWithConcurrency(batchTasks, parallelLimit);
|
|
240
|
+
// Small delay between batches to be respectful to RPC endpoints
|
|
207
241
|
if (i + batchSize < vaults.length) {
|
|
208
242
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
209
243
|
}
|
|
@@ -218,12 +252,15 @@ async function fetchVaultsComprehensive(vaults, fetchFn, options = {}) {
|
|
|
218
252
|
totalVaults: vaults.length,
|
|
219
253
|
successfulVaults: successful.length,
|
|
220
254
|
failedVaults: failed.length,
|
|
221
|
-
closedVaults: 0,
|
|
222
|
-
invisibleVaults: 0,
|
|
255
|
+
closedVaults: 0, // Will be calculated by the calling code
|
|
256
|
+
invisibleVaults: 0, // Will be calculated by the calling code
|
|
223
257
|
rpcFailures,
|
|
224
258
|
},
|
|
225
259
|
};
|
|
226
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Enhanced vault filtering that preserves more vaults while maintaining quality
|
|
263
|
+
*/
|
|
227
264
|
function filterVaultsIntelligently(vaults, options = {}) {
|
|
228
265
|
const { includeClosed = true, includeInvisible = true, includeNull = false, minStatus = ['active', 'closed'], } = options;
|
|
229
266
|
const active = [];
|