@augustdigital/sdk 9.3.0 → 9.4.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/adapters/evm/getters.js +40 -0
- package/lib/adapters/evm/index.d.ts +106 -2
- package/lib/adapters/evm/index.js +125 -0
- package/lib/adapters/solana/index.d.ts +12 -5
- package/lib/adapters/solana/index.js +12 -4
- package/lib/adapters/solana/pricing.d.ts +173 -0
- package/lib/adapters/solana/pricing.js +223 -0
- package/lib/adapters/solana/types.d.ts +45 -0
- package/lib/adapters/solana/vault.actions.d.ts +33 -8
- package/lib/adapters/solana/vault.actions.js +185 -28
- package/lib/adapters/stellar/actions.d.ts +2 -2
- package/lib/adapters/stellar/actions.js +2 -2
- package/lib/adapters/stellar/getters.d.ts +1 -1
- package/lib/adapters/stellar/getters.js +2 -2
- package/lib/adapters/stellar/index.d.ts +1 -1
- package/lib/adapters/stellar/index.js +1 -1
- package/lib/adapters/stellar/types.d.ts +1 -2
- package/lib/core/analytics/method-taxonomy.js +7 -0
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/base.class.d.ts +2 -2
- package/lib/core/base.class.js +2 -2
- package/lib/core/constants/core.d.ts +17 -3
- package/lib/core/constants/core.js +17 -3
- package/lib/core/constants/vaults.js +4 -0
- package/lib/core/fetcher.js +112 -45
- package/lib/core/helpers/concurrency.d.ts +37 -0
- package/lib/core/helpers/concurrency.js +58 -0
- package/lib/core/helpers/core.d.ts +9 -0
- package/lib/core/helpers/core.js +47 -0
- package/lib/core/helpers/vaults.d.ts +1 -1
- package/lib/core/helpers/vaults.js +1 -1
- package/lib/core/helpers/web3.js +14 -1
- package/lib/core/logger/curator-alert.d.ts +2 -2
- package/lib/core/logger/curator-alert.js +2 -2
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +2 -3
- package/lib/evm/methods/crossChainVaultRegistry.js +2 -3
- package/lib/evm/types/crossChain.d.ts +1 -1
- package/lib/main.d.ts +7 -5
- package/lib/main.js +7 -5
- package/lib/modules/vaults/getters.d.ts +10 -3
- package/lib/modules/vaults/getters.js +205 -71
- package/lib/modules/vaults/main.d.ts +4 -4
- package/lib/modules/vaults/main.js +7 -4
- package/lib/modules/vaults/read.actions.d.ts +181 -0
- package/lib/modules/vaults/read.actions.js +331 -36
- package/lib/modules/vaults/types.d.ts +13 -0
- package/lib/modules/vaults/utils.js +5 -1
- package/lib/modules/vaults/write.actions.d.ts +74 -6
- package/lib/modules/vaults/write.actions.js +133 -23
- package/lib/sdk.d.ts +9827 -9342
- package/lib/services/subgraph/schema.d.ts +1 -1
- package/lib/services/subgraph/schema.js +1 -1
- package/lib/types/pools.d.ts +1 -1
- package/lib/types/vaults.d.ts +4 -4
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ exports.approve = approve;
|
|
|
13
13
|
exports.vaultDeposit = vaultDeposit;
|
|
14
14
|
exports.vaultRequestRedeem = vaultRequestRedeem;
|
|
15
15
|
exports.vaultRedeem = vaultRedeem;
|
|
16
|
+
exports.claimWithdrawal = claimWithdrawal;
|
|
16
17
|
exports.depositNative = depositNative;
|
|
17
18
|
exports.rwaRedeemAsset = rwaRedeemAsset;
|
|
18
19
|
exports.swapAndDeposit = swapAndDeposit;
|
|
@@ -861,12 +862,14 @@ async function vaultDeposit(signer, options) {
|
|
|
861
862
|
}
|
|
862
863
|
/**
|
|
863
864
|
* Request to redeem vault shares. For EVM-1 vaults this queues a standard
|
|
864
|
-
* redemption (claimable later via `vaultRedeem`)
|
|
865
|
-
*
|
|
866
|
-
*
|
|
865
|
+
* redemption (claimable later via `vaultRedeem`). For EVM-2 vaults the queued
|
|
866
|
+
* `requestRedeem` escrows the shares in the vault via `transferFrom`, so this
|
|
867
|
+
* also approves the receipt token when its allowance is short; the instant
|
|
868
|
+
* path (`isInstantRedeem: true`) burns the caller's shares directly and sends
|
|
869
|
+
* no approval.
|
|
867
870
|
*
|
|
868
|
-
*
|
|
869
|
-
* redeem call, regardless of the caller's `wait` flag.
|
|
871
|
+
* The receipt-token approval (EVM-2 queued path) is always waited on before
|
|
872
|
+
* the redeem call, regardless of the caller's `wait` flag.
|
|
870
873
|
*
|
|
871
874
|
* @param signer ethers Signer / Wallet (or viem WalletClient via {@link setSigner})
|
|
872
875
|
* @param options Vault address, wallet, amount, optional `isInstantRedeem`,
|
|
@@ -932,25 +935,26 @@ async function vaultRequestRedeem(signer, options) {
|
|
|
932
935
|
// misroute (a non-evm-2 vault reaching this branch) still throws the
|
|
933
936
|
// original error. See getReceiptTokenAddressOrThrow.
|
|
934
937
|
const receiptTokenAddr = await (0, core_1.getReceiptTokenAddressOrThrow)(signer, target, 'vaultRequestRedeem:receiptToken');
|
|
935
|
-
const receiptContract = (0, core_1.createContract)({
|
|
936
|
-
address: receiptTokenAddr,
|
|
937
|
-
provider: signer,
|
|
938
|
-
abi: abis_1.ABI_ERC20,
|
|
939
|
-
});
|
|
940
938
|
decimals = await (0, core_1.getDecimalsOrThrow)(signer, receiptTokenAddr, 'vaultRequestRedeem:receiptDecimals');
|
|
941
|
-
//
|
|
942
|
-
|
|
943
|
-
//
|
|
944
|
-
//
|
|
945
|
-
//
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
939
|
+
// Queued requestRedeem escrows the shares in the vault through
|
|
940
|
+
// receipt.transferFrom(user → vault): the vault is the spender, so it
|
|
941
|
+
// needs an explicit allowance even on self-redeem (without it the call
|
|
942
|
+
// reverts with ERC20InsufficientAllowance). instantRedeem burns the
|
|
943
|
+
// caller's shares directly and needs none.
|
|
944
|
+
if (!options.isInstantRedeem) {
|
|
945
|
+
const receiptContract = (0, core_1.createContract)({
|
|
946
|
+
address: receiptTokenAddr,
|
|
947
|
+
provider: signer,
|
|
948
|
+
abi: abis_1.ABI_ERC20,
|
|
949
|
+
});
|
|
950
|
+
const sharesRaw = (0, core_1.toNormalizedBn)(amount, decimals).raw;
|
|
951
|
+
const allowance = await receiptContract.allowance(wallet, target);
|
|
952
|
+
if (safeBigInt(allowance, 'vaultRequestRedeem:allowance') <
|
|
953
|
+
BigInt(sharesRaw)) {
|
|
954
|
+
const { hash: approveHash } = await safeSendTx(() => receiptContract.connect(signer).approve(target, sharesRaw), signer, true);
|
|
955
|
+
core_1.Logger.log.info('approve:receipt_token:tx_hash', approveHash);
|
|
956
|
+
}
|
|
951
957
|
}
|
|
952
|
-
// For evm-2, use vaultContract for both instant and standard redeem
|
|
953
|
-
// ABI_TOKENIZED_VAULT_V2 has both instantRedeem (2 params) and requestRedeem
|
|
954
958
|
poolContract = vaultContract;
|
|
955
959
|
}
|
|
956
960
|
else {
|
|
@@ -1026,7 +1030,6 @@ async function vaultRequestRedeem(signer, options) {
|
|
|
1026
1030
|
}
|
|
1027
1031
|
}
|
|
1028
1032
|
/**
|
|
1029
|
-
* @TODO
|
|
1030
1033
|
* @description withdraw funds from the specified pool including accrued rewards
|
|
1031
1034
|
* @param signer signer / wallet object
|
|
1032
1035
|
* @param options object including pool contract address, user wallet address, and more
|
|
@@ -1090,6 +1093,113 @@ async function vaultRedeem(signer, options) {
|
|
|
1090
1093
|
});
|
|
1091
1094
|
}
|
|
1092
1095
|
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Claim a previously-requested queued withdrawal on an EVM-2 (Tokenized
|
|
1098
|
+
* Vault V2) vault, once its withdrawal epoch has passed.
|
|
1099
|
+
*
|
|
1100
|
+
* EVM-2 only — v1/v0 vaults use a different claim path ({@link vaultRedeem}).
|
|
1101
|
+
* The vault's on-chain `claim(year, month, day, receiverAddr)` reverts if the
|
|
1102
|
+
* epoch has not yet elapsed, or if the vault's idle reserve has not been
|
|
1103
|
+
* refilled from subaccounts to cover the queue for that date; neither
|
|
1104
|
+
* condition is checked client-side before sending.
|
|
1105
|
+
*
|
|
1106
|
+
* @param signer ethers Signer / Wallet.
|
|
1107
|
+
* @param options.target EVM-2 vault contract address.
|
|
1108
|
+
* @param options.wallet Wallet initiating the claim; receives the withdrawn assets unless `receiver` is set.
|
|
1109
|
+
* @param options.year Withdrawal-epoch year from `requestRedeem`.
|
|
1110
|
+
* @param options.month Withdrawal-epoch month from `requestRedeem`.
|
|
1111
|
+
* @param options.day Withdrawal-epoch day from `requestRedeem`.
|
|
1112
|
+
* @param options.receiver Address receiving the withdrawn assets. Defaults to `wallet`.
|
|
1113
|
+
* @param options.wait Wait for transaction confirmation.
|
|
1114
|
+
* @returns Claim transaction hash.
|
|
1115
|
+
* @throws AugustValidationError on invalid address input, missing or non-integer date fields, or a non-EVM-2 vault.
|
|
1116
|
+
* @throws AugustSDKError when the on-chain claim call fails.
|
|
1117
|
+
*
|
|
1118
|
+
* @worstCaseRpcCalls 2 — one vault-version lookup, one claim transaction.
|
|
1119
|
+
*
|
|
1120
|
+
* @example
|
|
1121
|
+
* ```ts
|
|
1122
|
+
* const { year, month, day } = await augustSdk.evm.vaultRequestRedeem({
|
|
1123
|
+
* target: vaultAddress,
|
|
1124
|
+
* wallet: walletAddress,
|
|
1125
|
+
* amount: '10',
|
|
1126
|
+
* });
|
|
1127
|
+
* // ...after the withdrawal epoch has elapsed...
|
|
1128
|
+
* await augustSdk.evm.claimWithdrawal({
|
|
1129
|
+
* target: vaultAddress,
|
|
1130
|
+
* wallet: walletAddress,
|
|
1131
|
+
* year,
|
|
1132
|
+
* month,
|
|
1133
|
+
* day,
|
|
1134
|
+
* wait: true,
|
|
1135
|
+
* });
|
|
1136
|
+
* ```
|
|
1137
|
+
*/
|
|
1138
|
+
async function claimWithdrawal(signer, options) {
|
|
1139
|
+
const { wallet, target, wait, year, month, day, receiver } = options;
|
|
1140
|
+
const [goodWallet, goodTarget] = [
|
|
1141
|
+
(0, core_1.checkAddress)(wallet, console, 'wallet'),
|
|
1142
|
+
(0, core_1.checkAddress)(target, console),
|
|
1143
|
+
];
|
|
1144
|
+
if (!goodWallet || !goodTarget) {
|
|
1145
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', `claimWithdrawal: invalid ${!goodWallet ? 'wallet' : 'target'} address`);
|
|
1146
|
+
}
|
|
1147
|
+
if (receiver !== undefined && !(0, core_1.checkAddress)(receiver, console, 'wallet')) {
|
|
1148
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', 'claimWithdrawal: invalid receiver address');
|
|
1149
|
+
}
|
|
1150
|
+
if (year === undefined || month === undefined || day === undefined) {
|
|
1151
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', 'claimWithdrawal: year, month, and day are required');
|
|
1152
|
+
}
|
|
1153
|
+
const yearRaw = (0, core_1.toRawBigInt)(year, 'claimWithdrawal', 'year');
|
|
1154
|
+
const monthRaw = (0, core_1.toRawBigInt)(month, 'claimWithdrawal', 'month');
|
|
1155
|
+
const dayRaw = (0, core_1.toRawBigInt)(day, 'claimWithdrawal', 'day');
|
|
1156
|
+
try {
|
|
1157
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(target))?.[0];
|
|
1158
|
+
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
1159
|
+
if (vaultVersion !== 'evm-2') {
|
|
1160
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `claimWithdrawal: only EVM-2 (Tokenized Vault V2) vaults expose claim() — ${target} resolved to ${vaultVersion}`);
|
|
1161
|
+
}
|
|
1162
|
+
const vaultContract = (0, core_1.createContract)({
|
|
1163
|
+
address: target,
|
|
1164
|
+
provider: signer,
|
|
1165
|
+
abi: abis_1.ABI_TOKENIZED_VAULT_V2,
|
|
1166
|
+
});
|
|
1167
|
+
const { hash: claimHash } = await safeSendTx(() => vaultContract
|
|
1168
|
+
.connect(signer)
|
|
1169
|
+
.claim(yearRaw, monthRaw, dayRaw, receiver ?? wallet), signer, wait);
|
|
1170
|
+
core_1.Logger.log.info('claim:tx_hash', claimHash);
|
|
1171
|
+
return claimHash;
|
|
1172
|
+
}
|
|
1173
|
+
catch (e) {
|
|
1174
|
+
const recovered = await tryRecoverTxHash(e, signer, wait);
|
|
1175
|
+
if (recovered) {
|
|
1176
|
+
core_1.Logger.log.warn('claim:nonce-fallback', { hash: recovered });
|
|
1177
|
+
return recovered;
|
|
1178
|
+
}
|
|
1179
|
+
if (e instanceof core_1.AugustSDKError)
|
|
1180
|
+
throw e;
|
|
1181
|
+
const broadcast = errorTxBroadcastContext(e);
|
|
1182
|
+
const insufficientFunds = (0, core_1.isInsufficientFundsError)(e);
|
|
1183
|
+
(0, core_1.logChainError)('claim', e, (0, core_1.isUserRejectionError)(e) || insufficientFunds, {
|
|
1184
|
+
target,
|
|
1185
|
+
year,
|
|
1186
|
+
month,
|
|
1187
|
+
day,
|
|
1188
|
+
...broadcast,
|
|
1189
|
+
});
|
|
1190
|
+
throwIfInsufficientFunds(insufficientFunds, 'Claim withdrawal', e, {
|
|
1191
|
+
target,
|
|
1192
|
+
year,
|
|
1193
|
+
month,
|
|
1194
|
+
day,
|
|
1195
|
+
...broadcast,
|
|
1196
|
+
});
|
|
1197
|
+
throw new core_1.AugustSDKError('UNKNOWN', `Claim withdrawal failed: ${e instanceof Error ? e.message : 'Unknown error'}`, {
|
|
1198
|
+
cause: e,
|
|
1199
|
+
context: { target, year, month, day, ...broadcast },
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1093
1203
|
/**
|
|
1094
1204
|
* Deposit a native token (ETH / AVAX / etc.) into a vault via the
|
|
1095
1205
|
* `MultiAssetNativeDepositWrapper`. The wrapper forwards `msg.value` to
|