@augustdigital/sdk 9.13.1 → 9.13.3
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/adapters/evm/getters.js +2 -2
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/helpers/chain-error.js +15 -0
- package/lib/core/helpers/signer.d.ts +11 -3
- package/lib/core/helpers/signer.js +55 -18
- package/lib/core/helpers/web3.js +2 -2
- package/lib/modules/vaults/getters.js +9 -5
- package/lib/sdk.d.ts +11 -3
- package/lib/services/subgraph/vaults.js +5 -5
- package/package.json +1 -1
|
@@ -90,7 +90,7 @@ const getEvmVaultV1 = async (tokenizedVault, options) => {
|
|
|
90
90
|
return (0, core_1.getSymbol)(provider, vault);
|
|
91
91
|
}
|
|
92
92
|
if (f === 'decimals') {
|
|
93
|
-
return (0, core_1.
|
|
93
|
+
return (0, core_1.getDecimalsOrThrow)(provider, vault, 'getEvmVaultV1');
|
|
94
94
|
}
|
|
95
95
|
return vaultContract[f]();
|
|
96
96
|
}));
|
|
@@ -188,7 +188,7 @@ const getEvmVaultV2 = async (tokenizedVault, options) => {
|
|
|
188
188
|
return (0, core_1.getSymbol)(provider, receiptAddress, false);
|
|
189
189
|
}
|
|
190
190
|
if (f === 'decimals') {
|
|
191
|
-
return (0, core_1.
|
|
191
|
+
return (0, core_1.getDecimalsOrThrow)(provider, receiptAddress, 'getEvmVaultV2');
|
|
192
192
|
}
|
|
193
193
|
return reciptContract[f]();
|
|
194
194
|
})),
|
|
@@ -467,6 +467,21 @@ const ARGUMENT_FREE_VIEW_SELECTORS = new Set([
|
|
|
467
467
|
'0x06fdde03', // name()
|
|
468
468
|
'0x18160ddd', // totalSupply()
|
|
469
469
|
exports.LP_TOKEN_ADDRESS_SELECTOR, // lpTokenAddress()
|
|
470
|
+
// The vault views `getEvmVaultV1` / `getEvmVaultV2` read in one fan-out.
|
|
471
|
+
// Same caveat as `lpTokenAddress()`: each exists on one vault generation, so
|
|
472
|
+
// a misrouted vault answers empty deterministically and must still surface
|
|
473
|
+
// once the bounded retry is spent.
|
|
474
|
+
'0x38d52e0f', // asset()
|
|
475
|
+
'0x01e1d114', // totalAssets()
|
|
476
|
+
'0xd5abeb01', // maxSupply()
|
|
477
|
+
'0x8bc7e8c4', // withdrawalFee()
|
|
478
|
+
'0x24e86d67', // lagDuration()
|
|
479
|
+
'0xe9f2838e', // withdrawalsPaused()
|
|
480
|
+
'0x60da3e83', // depositsPaused()
|
|
481
|
+
'0x8ed83271', // maxDepositAmount()
|
|
482
|
+
'0xcdb1fb2b', // assetsWhitelistAddress()
|
|
483
|
+
'0x6e07302b', // getTotalAssets()
|
|
484
|
+
'0xdbd5edc7', // depositCap()
|
|
470
485
|
]);
|
|
471
486
|
/**
|
|
472
487
|
* Extract the 4-byte selector of the call an ethers `CALL_EXCEPTION` describes.
|
|
@@ -12,9 +12,17 @@ import { type Signer, type Wallet } from 'ethers';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function isViemWalletClient(signer: any): boolean;
|
|
14
14
|
/**
|
|
15
|
-
* Convert a viem WalletClient to an ethers-compatible Signer
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* Convert a viem WalletClient to an ethers-compatible Signer.
|
|
16
|
+
*
|
|
17
|
+
* The account and chain are answered from the client itself, and
|
|
18
|
+
* transactions, personal messages and EIP-712 typed data are signed through
|
|
19
|
+
* the client's own `sendTransaction` / `signMessage` / `signTypedData`, so a
|
|
20
|
+
* local account (for example an embedded wallet built with
|
|
21
|
+
* `createWalletClient({ account, transport: http() })`) signs locally and
|
|
22
|
+
* broadcasts the raw transaction. Every other request goes to the client's
|
|
23
|
+
* transport.
|
|
24
|
+
*
|
|
25
|
+
* @param walletClient - Viem WalletClient from wagmi or viem
|
|
18
26
|
* @returns Ethers Signer that can be used with the SDK
|
|
19
27
|
*/
|
|
20
28
|
export declare function viemToEthersSigner(walletClient: any): Promise<Signer | Wallet>;
|
|
@@ -26,39 +26,76 @@ function isViemWalletClient(signer) {
|
|
|
26
26
|
'transport' in signer &&
|
|
27
27
|
typeof signer.writeContract === 'function');
|
|
28
28
|
}
|
|
29
|
+
function toBigInt(value) {
|
|
30
|
+
return value == null ? undefined : BigInt(value);
|
|
31
|
+
}
|
|
32
|
+
function toViemTransaction(tx) {
|
|
33
|
+
return {
|
|
34
|
+
to: tx.to ?? undefined,
|
|
35
|
+
data: tx.data,
|
|
36
|
+
accessList: tx.accessList,
|
|
37
|
+
value: toBigInt(tx.value),
|
|
38
|
+
gas: toBigInt(tx.gas),
|
|
39
|
+
gasPrice: toBigInt(tx.gasPrice),
|
|
40
|
+
maxFeePerGas: toBigInt(tx.maxFeePerGas),
|
|
41
|
+
maxPriorityFeePerGas: toBigInt(tx.maxPriorityFeePerGas),
|
|
42
|
+
nonce: tx.nonce == null ? undefined : Number(tx.nonce),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
29
45
|
/**
|
|
30
|
-
* Convert a viem WalletClient to an ethers-compatible Signer
|
|
31
|
-
*
|
|
32
|
-
*
|
|
46
|
+
* Convert a viem WalletClient to an ethers-compatible Signer.
|
|
47
|
+
*
|
|
48
|
+
* The account and chain are answered from the client itself, and
|
|
49
|
+
* transactions, personal messages and EIP-712 typed data are signed through
|
|
50
|
+
* the client's own `sendTransaction` / `signMessage` / `signTypedData`, so a
|
|
51
|
+
* local account (for example an embedded wallet built with
|
|
52
|
+
* `createWalletClient({ account, transport: http() })`) signs locally and
|
|
53
|
+
* broadcasts the raw transaction. Every other request goes to the client's
|
|
54
|
+
* transport.
|
|
55
|
+
*
|
|
56
|
+
* @param walletClient - Viem WalletClient from wagmi or viem
|
|
33
57
|
* @returns Ethers Signer that can be used with the SDK
|
|
34
58
|
*/
|
|
35
59
|
async function viemToEthersSigner(walletClient) {
|
|
36
60
|
if (!walletClient) {
|
|
37
61
|
throw new Error('WalletClient is required');
|
|
38
62
|
}
|
|
39
|
-
// Create an EIP-1193 provider from the wallet client
|
|
40
63
|
const { account, chain, transport } = walletClient;
|
|
41
64
|
if (!account) {
|
|
42
65
|
throw new Error('WalletClient must have an account');
|
|
43
66
|
}
|
|
44
|
-
// Create a custom transport that uses the walletClient
|
|
45
67
|
const provider = new ethers_1.BrowserProvider({
|
|
46
|
-
request: async ({ method, params }) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
request: async ({ method, params = [] }) => {
|
|
69
|
+
switch (method) {
|
|
70
|
+
case 'eth_accounts':
|
|
71
|
+
case 'eth_requestAccounts':
|
|
72
|
+
return [account.address];
|
|
73
|
+
case 'eth_chainId':
|
|
74
|
+
if (chain)
|
|
75
|
+
return (0, ethers_1.toQuantity)(chain.id);
|
|
76
|
+
break;
|
|
77
|
+
case 'eth_sendTransaction':
|
|
78
|
+
return walletClient.sendTransaction({
|
|
79
|
+
...toViemTransaction(params[0]),
|
|
80
|
+
account,
|
|
81
|
+
chain,
|
|
82
|
+
});
|
|
83
|
+
case 'personal_sign':
|
|
84
|
+
return walletClient.signMessage({
|
|
85
|
+
account,
|
|
86
|
+
message: { raw: params[0] },
|
|
87
|
+
});
|
|
88
|
+
case 'eth_signTypedData_v4':
|
|
89
|
+
return walletClient.signTypedData({
|
|
90
|
+
account,
|
|
91
|
+
...(typeof params[1] === 'string'
|
|
92
|
+
? JSON.parse(params[1])
|
|
93
|
+
: params[1]),
|
|
94
|
+
});
|
|
56
95
|
}
|
|
57
|
-
|
|
58
|
-
return transport({ chain }).request({ method, params });
|
|
96
|
+
return transport.request({ method, params });
|
|
59
97
|
},
|
|
60
98
|
}, chain?.id);
|
|
61
|
-
// Get the signer from the provider
|
|
62
99
|
return provider.getSigner(account.address);
|
|
63
100
|
}
|
|
64
101
|
/**
|
package/lib/core/helpers/web3.js
CHANGED
|
@@ -382,7 +382,7 @@ function sharedDecimalsRequest(key, fetch) {
|
|
|
382
382
|
async function fetchDecimals(runner, address, isVault) {
|
|
383
383
|
let realAddress = address;
|
|
384
384
|
if (isVault) {
|
|
385
|
-
const tokenizedVault = (await (0, fetcher_1.fetchTokenizedVault)(address))?.[0];
|
|
385
|
+
const tokenizedVault = (await (0, fetcher_1.fetchTokenizedVault)(address, undefined, false, false))?.[0];
|
|
386
386
|
const version = (0, vault_version_1.getVaultVersionV2)(tokenizedVault);
|
|
387
387
|
if (version === 'evm-2') {
|
|
388
388
|
realAddress = await (0, exports.getReceiptTokenAddress)(runner, address);
|
|
@@ -716,7 +716,7 @@ const getSymbol = async (provider, address, isVault = true) => {
|
|
|
716
716
|
const fetchPromise = (async () => {
|
|
717
717
|
try {
|
|
718
718
|
if (isVault) {
|
|
719
|
-
const tokenizedVault = (await (0, fetcher_1.fetchTokenizedVault)(address))?.[0];
|
|
719
|
+
const tokenizedVault = (await (0, fetcher_1.fetchTokenizedVault)(address, undefined, false, false))?.[0];
|
|
720
720
|
const version = (0, vault_version_1.getVaultVersionV2)(tokenizedVault);
|
|
721
721
|
let realAddress = address;
|
|
722
722
|
if (version === 'evm-2') {
|
|
@@ -169,7 +169,11 @@ async function getVault({ vault, loans = false, allocations = false, options, lo
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
catch (err) {
|
|
172
|
-
|
|
172
|
+
// A provider fault (rate limit, socket reset, an empty response to one of
|
|
173
|
+
// the vault's argument-free views) is not an SDK or caller defect: the
|
|
174
|
+
// caller sees the same throw either way, so it is recorded as a breadcrumb
|
|
175
|
+
// rather than a billed Sentry issue. Everything else stays at error.
|
|
176
|
+
(0, core_1.logChainError)('getVault', err, (0, core_1.isRetryableRpcError)(err) || (0, core_1.isEmptyViewResponse)(err), { vault });
|
|
173
177
|
throw new Error(`#getVault::${vault}: ${err?.message}`);
|
|
174
178
|
}
|
|
175
179
|
// Loans enrichment stays EVM-only — there is no non-EVM loan book to read.
|
|
@@ -1625,7 +1629,7 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
|
|
|
1625
1629
|
// get vault metadata and balance based on version
|
|
1626
1630
|
let bal = BigInt(0);
|
|
1627
1631
|
if (version === 'evm-2') {
|
|
1628
|
-
const receiptAddress = await (0, core_1.getReceiptTokenAddress)(provider,
|
|
1632
|
+
const receiptAddress = await (0, core_1.getReceiptTokenAddress)(provider, v.address);
|
|
1629
1633
|
decimals = await (0, core_1.getDecimals)(provider, receiptAddress, false);
|
|
1630
1634
|
if (wallet && (0, ethers_1.isAddress)(wallet)) {
|
|
1631
1635
|
if (typeof prefetched?.balance === 'bigint') {
|
|
@@ -1642,7 +1646,7 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
|
|
|
1642
1646
|
}
|
|
1643
1647
|
}
|
|
1644
1648
|
else {
|
|
1645
|
-
decimals = await (0, core_1.getDecimals)(provider,
|
|
1649
|
+
decimals = await (0, core_1.getDecimals)(provider, v.address);
|
|
1646
1650
|
if (wallet && (0, ethers_1.isAddress)(wallet)) {
|
|
1647
1651
|
bal =
|
|
1648
1652
|
typeof prefetched?.balance === 'bigint'
|
|
@@ -1675,7 +1679,7 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
|
|
|
1675
1679
|
const aggregateAvailableRedemptions = availableRedemptions.reduce((acc, curr) => acc + BigInt(curr.amount.raw), BigInt(0));
|
|
1676
1680
|
// return obj
|
|
1677
1681
|
return {
|
|
1678
|
-
vault,
|
|
1682
|
+
vault: v.address,
|
|
1679
1683
|
status: renderStatus(availableRedemptions, balance),
|
|
1680
1684
|
availableRedemptions,
|
|
1681
1685
|
pendingRedemptions,
|
|
@@ -1686,7 +1690,7 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
|
|
|
1686
1690
|
catch (vaultError) {
|
|
1687
1691
|
core_1.Logger.log.error(`getVaultPositions`, `Error processing vault ${v.address}: ${vaultError}`);
|
|
1688
1692
|
return {
|
|
1689
|
-
vault,
|
|
1693
|
+
vault: v.address,
|
|
1690
1694
|
status: 'PENDING',
|
|
1691
1695
|
availableRedemptions: [],
|
|
1692
1696
|
pendingRedemptions: [],
|
package/lib/sdk.d.ts
CHANGED
|
@@ -29785,9 +29785,17 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
29785
29785
|
export declare function verifyInfuraKey(key: string): Promise<boolean>;
|
|
29786
29786
|
|
|
29787
29787
|
/**
|
|
29788
|
-
* Convert a viem WalletClient to an ethers-compatible Signer
|
|
29789
|
-
*
|
|
29790
|
-
*
|
|
29788
|
+
* Convert a viem WalletClient to an ethers-compatible Signer.
|
|
29789
|
+
*
|
|
29790
|
+
* The account and chain are answered from the client itself, and
|
|
29791
|
+
* transactions, personal messages and EIP-712 typed data are signed through
|
|
29792
|
+
* the client's own `sendTransaction` / `signMessage` / `signTypedData`, so a
|
|
29793
|
+
* local account (for example an embedded wallet built with
|
|
29794
|
+
* `createWalletClient({ account, transport: http() })`) signs locally and
|
|
29795
|
+
* broadcasts the raw transaction. Every other request goes to the client's
|
|
29796
|
+
* transport.
|
|
29797
|
+
*
|
|
29798
|
+
* @param walletClient - Viem WalletClient from wagmi or viem
|
|
29791
29799
|
* @returns Ethers Signer that can be used with the SDK
|
|
29792
29800
|
*/
|
|
29793
29801
|
export declare function viemToEthersSigner(walletClient: any): Promise<Signer | Wallet>;
|
|
@@ -405,7 +405,7 @@ async function getSubgraphWithdrawRequests(pool, provider, slackWebookUrl = (0,
|
|
|
405
405
|
});
|
|
406
406
|
return [];
|
|
407
407
|
}
|
|
408
|
-
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool))?.[0];
|
|
408
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool, undefined, false, false))?.[0];
|
|
409
409
|
const version = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
410
410
|
// Probe the deployed subgraph to learn its actual field schema (cached per
|
|
411
411
|
// URL) instead of guessing from the vault symbol. See resolveSubgraphSchema —
|
|
@@ -479,7 +479,7 @@ async function getSubgraphWithdrawProccessed(pool, provider, slackWebookUrl = (0
|
|
|
479
479
|
});
|
|
480
480
|
return [];
|
|
481
481
|
}
|
|
482
|
-
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool))?.[0];
|
|
482
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool, undefined, false, false))?.[0];
|
|
483
483
|
const version = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
484
484
|
// Probe the deployed subgraph's actual field schema (cached per URL) rather
|
|
485
485
|
// than guessing from the vault symbol — see resolveSubgraphSchema (AUGUST-6568).
|
|
@@ -566,7 +566,7 @@ async function getSubgraphAllWithdrawals(pool, provider, slackWebookUrl = (0, sl
|
|
|
566
566
|
});
|
|
567
567
|
return errorReturnObj;
|
|
568
568
|
}
|
|
569
|
-
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool))?.[0];
|
|
569
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool, undefined, false, false))?.[0];
|
|
570
570
|
const version = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
571
571
|
// Probe the deployed subgraph's actual field schema (cached per URL) rather
|
|
572
572
|
// than guessing from the vault symbol — see resolveSubgraphSchema (AUGUST-6568).
|
|
@@ -748,7 +748,7 @@ async function getSubgraphUserHistory(user, provider, pool, slackWebookUrl = (0,
|
|
|
748
748
|
});
|
|
749
749
|
return requests;
|
|
750
750
|
}
|
|
751
|
-
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool))?.[0];
|
|
751
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool, undefined, false, false))?.[0];
|
|
752
752
|
const version = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
753
753
|
// Probe the deployed subgraph's actual field schema (cached per URL) rather
|
|
754
754
|
// than guessing from the vault symbol — see resolveSubgraphSchema (AUGUST-6568).
|
|
@@ -881,7 +881,7 @@ async function getSubgraphVaultHistory(provider, pool, slackWebookUrl = (0, slac
|
|
|
881
881
|
});
|
|
882
882
|
return requests;
|
|
883
883
|
}
|
|
884
|
-
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool))?.[0];
|
|
884
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(pool, undefined, false, false))?.[0];
|
|
885
885
|
const version = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
886
886
|
// Probe the deployed subgraph's actual field schema (cached per URL) rather
|
|
887
887
|
// than guessing from the vault symbol — see resolveSubgraphSchema (AUGUST-6568).
|