@defisaver/positions-sdk 2.1.137-audit-dev → 2.1.138
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/cjs/aaveV4/index.js +26 -10
- package/cjs/contracts.d.ts +2129 -1886
- package/cjs/savings/morphoVaults/index.js +2 -19
- package/cjs/services/utils.d.ts +1 -0
- package/cjs/services/utils.js +3 -1
- package/cjs/services/viem.d.ts +2679 -918
- package/cjs/types/aaveV4.d.ts +5 -0
- package/esm/aaveV4/index.js +27 -11
- package/esm/contracts.d.ts +2129 -1886
- package/esm/savings/morphoVaults/index.js +2 -19
- package/esm/services/utils.d.ts +1 -0
- package/esm/services/utils.js +1 -0
- package/esm/services/viem.d.ts +2667 -916
- package/esm/types/aaveV4.d.ts +5 -0
- package/package.json +2 -9
- package/src/aaveV4/index.ts +29 -11
- package/src/contracts.ts +2 -2
- package/src/savings/morphoVaults/index.ts +2 -18
- package/src/services/utils.ts +2 -0
- package/src/types/aaveV4.ts +5 -0
|
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
|
+
import { request as graphqlRequest } from 'graphql-request';
|
|
11
12
|
import { assetAmountInEth } from '@defisaver/tokens';
|
|
12
13
|
import * as morphoVaultsOptions from './options';
|
|
13
|
-
import { LONGER_TIMEOUT } from '../../services/utils';
|
|
14
14
|
import { getViemProvider } from '../../services/viem';
|
|
15
15
|
import { getMorphoVaultContractViem } from '../../contracts';
|
|
16
16
|
export { morphoVaultsOptions, };
|
|
@@ -30,23 +30,6 @@ const vaultDataQuery = `
|
|
|
30
30
|
}
|
|
31
31
|
}`;
|
|
32
32
|
const MORPHO_BLUE_API = 'https://api.morpho.org/graphql';
|
|
33
|
-
const fetchVaultData = (address, chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
const res = yield fetch(MORPHO_BLUE_API, {
|
|
35
|
-
method: 'POST',
|
|
36
|
-
headers: { 'Content-Type': 'application/json' },
|
|
37
|
-
body: JSON.stringify({
|
|
38
|
-
query: vaultDataQuery,
|
|
39
|
-
variables: { address, chainId },
|
|
40
|
-
}),
|
|
41
|
-
signal: AbortSignal.timeout(LONGER_TIMEOUT),
|
|
42
|
-
});
|
|
43
|
-
if (!res.ok)
|
|
44
|
-
throw new Error(`Morpho vault request failed: ${res.status}`);
|
|
45
|
-
const body = yield res.json();
|
|
46
|
-
if (!(body === null || body === void 0 ? void 0 : body.data))
|
|
47
|
-
throw new Error('Morpho vault response missing data');
|
|
48
|
-
return body.data;
|
|
49
|
-
});
|
|
50
33
|
export const _getMorphoVaultData = (provider, network, morphoVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
34
|
const morphoVaultContract = getMorphoVaultContractViem(provider, morphoVault.address);
|
|
52
35
|
const shares = {};
|
|
@@ -55,7 +38,7 @@ export const _getMorphoVaultData = (provider, network, morphoVault, accounts) =>
|
|
|
55
38
|
morphoVaultContract.read.totalSupply(),
|
|
56
39
|
morphoVaultContract.read.decimals(),
|
|
57
40
|
morphoVaultContract.read.DECIMALS_OFFSET(),
|
|
58
|
-
|
|
41
|
+
graphqlRequest(MORPHO_BLUE_API, vaultDataQuery, { address: morphoVault.address, chainId: network }),
|
|
59
42
|
...accounts.map((account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
43
|
const share = yield morphoVaultContract.read.balanceOf([account]);
|
|
61
44
|
shares[account] = share;
|
package/esm/services/utils.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const getAbiItem: (abi: any, methodName: string) => any;
|
|
|
8
8
|
export declare const ADDRESS_REGEX: RegExp;
|
|
9
9
|
export declare const isAddress: (address: string) => boolean;
|
|
10
10
|
export declare const compareAddresses: (addr1?: string, addr2?: string) => boolean;
|
|
11
|
+
export declare const shortenAddress: (address?: string, start?: number, end?: number) => string;
|
|
11
12
|
export declare const getWeiAmountForDecimals: (amount: string | number, decimals: number) => string;
|
|
12
13
|
export declare const getEthAmountForDecimals: (amount: string | number, decimals: string | number) => string;
|
|
13
14
|
export declare const handleWbtcLegacy: (asset: string) => string;
|
package/esm/services/utils.js
CHANGED
|
@@ -10,6 +10,7 @@ export const getAbiItem = (abi, methodName) => abi.find((i) => i.name === method
|
|
|
10
10
|
export const ADDRESS_REGEX = /0x[0-9a-fA-F]{40}/;
|
|
11
11
|
export const isAddress = (address) => typeof address === 'string' && (new RegExp(ADDRESS_REGEX).test(address));
|
|
12
12
|
export const compareAddresses = (addr1 = '', addr2 = '') => addr1.toLowerCase() === addr2.toLowerCase();
|
|
13
|
+
export const shortenAddress = (address = '', start = 8, end = 4) => `${address.substring(0, start)}...${address.slice(-end)}`;
|
|
13
14
|
export const getWeiAmountForDecimals = (amount, decimals) => new Dec(amount).mul(Math.pow(10, decimals)).floor().toString();
|
|
14
15
|
export const getEthAmountForDecimals = (amount, decimals) => new Dec(amount).div(Math.pow(10, +decimals)).toString();
|
|
15
16
|
export const handleWbtcLegacy = (asset) => (asset === 'WBTC Legacy' ? 'WBTC' : asset);
|