@oydual31/more-vaults-sdk 1.1.16 → 1.1.18
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/dist/{curatorBridge-BMSgDsUE.d.cts → curatorBridge-PVqdHUEp.d.cts} +14 -1
- package/dist/{curatorBridge-BMSgDsUE.d.ts → curatorBridge-PVqdHUEp.d.ts} +14 -1
- package/dist/ethers/index.cjs +106 -4
- package/dist/ethers/index.cjs.map +1 -1
- package/dist/ethers/index.d.cts +32 -1
- package/dist/ethers/index.d.ts +32 -1
- package/dist/ethers/index.js +105 -5
- package/dist/ethers/index.js.map +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +138 -10
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +21 -3
- package/dist/viem/index.d.ts +21 -3
- package/dist/viem/index.js +137 -11
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ethers/crossChainFlows.ts +15 -5
- package/src/ethers/errors.ts +7 -0
- package/src/ethers/index.ts +3 -0
- package/src/ethers/redeemFlows.ts +117 -0
- package/src/ethers/types.ts +11 -0
- package/src/viem/crossChainFlows.ts +31 -14
- package/src/viem/errors.ts +7 -0
- package/src/viem/index.ts +3 -0
- package/src/viem/redeemFlows.ts +138 -0
- package/src/viem/types.ts +11 -0
|
@@ -29,6 +29,19 @@ interface AsyncRequestResult {
|
|
|
29
29
|
/** Cross-chain request GUID to track via getRequestInfo / getFinalizationResult */
|
|
30
30
|
guid: `0x${string}`;
|
|
31
31
|
}
|
|
32
|
+
interface RedeemCostEstimate {
|
|
33
|
+
/** Which redeem flow will be used based on vault configuration */
|
|
34
|
+
flow: 'direct' | 'queue-no-timelock' | 'queue-timelock' | 'async';
|
|
35
|
+
/** Gas estimate per transaction step */
|
|
36
|
+
steps: {
|
|
37
|
+
label: string;
|
|
38
|
+
gasEstimate: bigint;
|
|
39
|
+
}[];
|
|
40
|
+
/** Sum of gasEstimate across all steps */
|
|
41
|
+
totalGasEstimate: bigint;
|
|
42
|
+
/** LayerZero fee in native token wei (0 for non-async vaults) */
|
|
43
|
+
lzFee: bigint;
|
|
44
|
+
}
|
|
32
45
|
/**
|
|
33
46
|
* ActionType enum values matching MoreVaultsLib.ActionType on-chain.
|
|
34
47
|
* DEPOSIT=0, MINT=1, WITHDRAW=2, REDEEM=3, MULTI_ASSETS_DEPOSIT=4, ACCRUE_FEES=5
|
|
@@ -1266,4 +1279,4 @@ declare function quoteCuratorBridgeFee(publicClient: PublicClient, vault: Addres
|
|
|
1266
1279
|
*/
|
|
1267
1280
|
declare function executeCuratorBridge(walletClient: WalletClient, publicClient: PublicClient, vault: Address, token: Address, params: CuratorBridgeParams): Promise<Hash>;
|
|
1268
1281
|
|
|
1269
|
-
export {
|
|
1282
|
+
export { canDeposit as $, type AsyncRequestResult as A, type BatchSwapParams as B, type ComposeData as C, type DepositResult as D, type ERC7540RequestStatus as E, type FlowStorage as F, type MultiChainUserPosition as G, type OutboundRoute as H, type InboundRoute as I, type SpokeBalance as J, type SwapParams as K, LocalStorageAdapter as L, type MultiChainPortfolio as M, NATIVE_SYMBOL as N, OMNI_FACTORY_ADDRESS as O, type PendingAction as P, type UserPosition as Q, type RedeemCostEstimate as R, type SpokeDepositResult as S, type VaultDistribution as T, type UserBalances as U, type VaultAddresses as V, type VaultMetadata as W, type VaultMode as X, type VaultStatus as Y, type VaultSummary as Z, type VaultTopology as _, type RedeemResult as a, clearDepositFlow as a0, detectStargateOft as a1, discoverVaultTopology as a2, encodeBridgeParams as a3, ensureAllowance as a4, executeCuratorBridge as a5, findBridgeRoute as a6, getAllVaultChainIds as a7, getAsyncRequestStatus as a8, getAsyncRequestStatusLabel as a9, getDefaultStorage as aa, getFullVaultTopology as ab, getInboundRoutes as ac, getMaxWithdrawable as ad, getOutboundRoutes as ae, getUserBalances as af, getUserBalancesForRoutes as ag, getUserPosition as ah, getUserPositionMultiChain as ai, getVaultDistribution as aj, getVaultDistributionWithTopology as ak, getVaultMetadata as al, getVaultStatus as am, getVaultSummary as an, getVaultTopology as ao, isAsyncMode as ap, isOnHubChain as aq, loadDepositFlow as ar, previewDeposit as as, previewRedeem as at, quoteCuratorBridgeFee as au, quoteLzFee as av, quoteRouteDepositFee as aw, saveDepositFlow as ax, waitForAsyncRequest as ay, waitForTx as az, type CuratorVaultStatus as b, type VaultAnalysis as c, type VaultAssetBreakdown as d, type CuratorAction as e, type SubmitActionsResult as f, type VaultConfiguration as g, type SubVaultInfo as h, type SubVaultPosition as i, type VaultPortfolio as j, ActionType as k, type ActionTypeValue as l, type AssetBalance as m, type AssetInfo as n, type AsyncRequestFinalResult as o, type AsyncRequestStatus as p, type AsyncRequestStatusInfo as q, type BridgeParams as r, type ChainPortfolio as s, type CrossChainRequestInfo as t, type CuratorBridgeParams as u, type DepositBlockReason as v, type DepositEligibility as w, type DepositFlowState as x, type InboundRouteWithBalance as y, type MaxWithdrawable as z };
|
|
@@ -29,6 +29,19 @@ interface AsyncRequestResult {
|
|
|
29
29
|
/** Cross-chain request GUID to track via getRequestInfo / getFinalizationResult */
|
|
30
30
|
guid: `0x${string}`;
|
|
31
31
|
}
|
|
32
|
+
interface RedeemCostEstimate {
|
|
33
|
+
/** Which redeem flow will be used based on vault configuration */
|
|
34
|
+
flow: 'direct' | 'queue-no-timelock' | 'queue-timelock' | 'async';
|
|
35
|
+
/** Gas estimate per transaction step */
|
|
36
|
+
steps: {
|
|
37
|
+
label: string;
|
|
38
|
+
gasEstimate: bigint;
|
|
39
|
+
}[];
|
|
40
|
+
/** Sum of gasEstimate across all steps */
|
|
41
|
+
totalGasEstimate: bigint;
|
|
42
|
+
/** LayerZero fee in native token wei (0 for non-async vaults) */
|
|
43
|
+
lzFee: bigint;
|
|
44
|
+
}
|
|
32
45
|
/**
|
|
33
46
|
* ActionType enum values matching MoreVaultsLib.ActionType on-chain.
|
|
34
47
|
* DEPOSIT=0, MINT=1, WITHDRAW=2, REDEEM=3, MULTI_ASSETS_DEPOSIT=4, ACCRUE_FEES=5
|
|
@@ -1266,4 +1279,4 @@ declare function quoteCuratorBridgeFee(publicClient: PublicClient, vault: Addres
|
|
|
1266
1279
|
*/
|
|
1267
1280
|
declare function executeCuratorBridge(walletClient: WalletClient, publicClient: PublicClient, vault: Address, token: Address, params: CuratorBridgeParams): Promise<Hash>;
|
|
1268
1281
|
|
|
1269
|
-
export {
|
|
1282
|
+
export { canDeposit as $, type AsyncRequestResult as A, type BatchSwapParams as B, type ComposeData as C, type DepositResult as D, type ERC7540RequestStatus as E, type FlowStorage as F, type MultiChainUserPosition as G, type OutboundRoute as H, type InboundRoute as I, type SpokeBalance as J, type SwapParams as K, LocalStorageAdapter as L, type MultiChainPortfolio as M, NATIVE_SYMBOL as N, OMNI_FACTORY_ADDRESS as O, type PendingAction as P, type UserPosition as Q, type RedeemCostEstimate as R, type SpokeDepositResult as S, type VaultDistribution as T, type UserBalances as U, type VaultAddresses as V, type VaultMetadata as W, type VaultMode as X, type VaultStatus as Y, type VaultSummary as Z, type VaultTopology as _, type RedeemResult as a, clearDepositFlow as a0, detectStargateOft as a1, discoverVaultTopology as a2, encodeBridgeParams as a3, ensureAllowance as a4, executeCuratorBridge as a5, findBridgeRoute as a6, getAllVaultChainIds as a7, getAsyncRequestStatus as a8, getAsyncRequestStatusLabel as a9, getDefaultStorage as aa, getFullVaultTopology as ab, getInboundRoutes as ac, getMaxWithdrawable as ad, getOutboundRoutes as ae, getUserBalances as af, getUserBalancesForRoutes as ag, getUserPosition as ah, getUserPositionMultiChain as ai, getVaultDistribution as aj, getVaultDistributionWithTopology as ak, getVaultMetadata as al, getVaultStatus as am, getVaultSummary as an, getVaultTopology as ao, isAsyncMode as ap, isOnHubChain as aq, loadDepositFlow as ar, previewDeposit as as, previewRedeem as at, quoteCuratorBridgeFee as au, quoteLzFee as av, quoteRouteDepositFee as aw, saveDepositFlow as ax, waitForAsyncRequest as ay, waitForTx as az, type CuratorVaultStatus as b, type VaultAnalysis as c, type VaultAssetBreakdown as d, type CuratorAction as e, type SubmitActionsResult as f, type VaultConfiguration as g, type SubVaultInfo as h, type SubVaultPosition as i, type VaultPortfolio as j, ActionType as k, type ActionTypeValue as l, type AssetBalance as m, type AssetInfo as n, type AsyncRequestFinalResult as o, type AsyncRequestStatus as p, type AsyncRequestStatusInfo as q, type BridgeParams as r, type ChainPortfolio as s, type CrossChainRequestInfo as t, type CuratorBridgeParams as u, type DepositBlockReason as v, type DepositEligibility as w, type DepositFlowState as x, type InboundRouteWithBalance as y, type MaxWithdrawable as z };
|
package/dist/ethers/index.cjs
CHANGED
|
@@ -742,6 +742,12 @@ var ComposeTimeoutError = class extends MoreVaultsError {
|
|
|
742
742
|
this.guid = guid;
|
|
743
743
|
}
|
|
744
744
|
};
|
|
745
|
+
var ComposeAlreadyExecutedError = class extends MoreVaultsError {
|
|
746
|
+
constructor() {
|
|
747
|
+
super("[MoreVaults] Compose already executed \u2014 deposit is complete, no action needed.");
|
|
748
|
+
this.name = "ComposeAlreadyExecutedError";
|
|
749
|
+
}
|
|
750
|
+
};
|
|
745
751
|
var WithdrawalTimelockActiveError = class extends MoreVaultsError {
|
|
746
752
|
timelockEndsAt;
|
|
747
753
|
requestTxHash;
|
|
@@ -1186,7 +1192,11 @@ async function waitForCompose(hubProvider, composeData, receiver, pollIntervalMs
|
|
|
1186
1192
|
logGuid,
|
|
1187
1193
|
logIndex
|
|
1188
1194
|
);
|
|
1189
|
-
if (hash
|
|
1195
|
+
if (hash === RECEIVED_HASH) {
|
|
1196
|
+
console.log(`[more-vaults-sdk] waitForCompose compose already executed (RECEIVED_HASH) \u2014 signaling done`);
|
|
1197
|
+
throw new ComposeAlreadyExecutedError();
|
|
1198
|
+
}
|
|
1199
|
+
if (hash !== EMPTY_HASH) {
|
|
1190
1200
|
console.log(`[${elapsed}s] Poll #${attempt} \u2014 compose found! (block ${log.blockNumber})`);
|
|
1191
1201
|
return {
|
|
1192
1202
|
...composeData,
|
|
@@ -1198,16 +1208,19 @@ async function waitForCompose(hubProvider, composeData, receiver, pollIntervalMs
|
|
|
1198
1208
|
};
|
|
1199
1209
|
}
|
|
1200
1210
|
}
|
|
1201
|
-
} catch {
|
|
1211
|
+
} catch (e) {
|
|
1212
|
+
if (e instanceof ComposeAlreadyExecutedError) throw e;
|
|
1202
1213
|
}
|
|
1203
1214
|
}
|
|
1204
|
-
} catch {
|
|
1215
|
+
} catch (e) {
|
|
1216
|
+
if (e instanceof ComposeAlreadyExecutedError) throw e;
|
|
1205
1217
|
break;
|
|
1206
1218
|
}
|
|
1207
1219
|
from = chunkEnd + 1n;
|
|
1208
1220
|
}
|
|
1209
1221
|
scannedUpTo = currentBlock;
|
|
1210
|
-
} catch {
|
|
1222
|
+
} catch (e) {
|
|
1223
|
+
if (e instanceof ComposeAlreadyExecutedError) throw e;
|
|
1211
1224
|
}
|
|
1212
1225
|
let guidMatchFound = false;
|
|
1213
1226
|
for (const fromAddr of knownFromAddresses) {
|
|
@@ -1869,6 +1882,93 @@ async function bridgeSharesToHub(signer, shareOFT, hubChainEid, shares, receiver
|
|
|
1869
1882
|
const receipt = await tx.wait();
|
|
1870
1883
|
return { receipt };
|
|
1871
1884
|
}
|
|
1885
|
+
async function estimateRedeemCost(provider, addresses, shares, receiver, owner, extraOptions = "0x") {
|
|
1886
|
+
const vault = addresses.vault;
|
|
1887
|
+
const status = await getVaultStatus(provider, vault);
|
|
1888
|
+
if (status.mode === "paused") throw new VaultPausedError(vault);
|
|
1889
|
+
if (status.recommendedDepositFlow === "depositAsync") {
|
|
1890
|
+
const lzFee = await quoteLzFee(provider, vault, extraOptions);
|
|
1891
|
+
const abiCoder = ethers.AbiCoder.defaultAbiCoder();
|
|
1892
|
+
const actionCallData = abiCoder.encode(
|
|
1893
|
+
["uint256", "address", "address"],
|
|
1894
|
+
[shares, receiver, owner]
|
|
1895
|
+
);
|
|
1896
|
+
const vaultContract2 = new ethers.Contract(vault, BRIDGE_ABI, provider);
|
|
1897
|
+
let requestGas = 0n;
|
|
1898
|
+
try {
|
|
1899
|
+
const raw = await vaultContract2.initVaultActionRequest.estimateGas(
|
|
1900
|
+
ActionType.REDEEM,
|
|
1901
|
+
actionCallData,
|
|
1902
|
+
0n,
|
|
1903
|
+
extraOptions,
|
|
1904
|
+
{ value: lzFee, from: owner }
|
|
1905
|
+
);
|
|
1906
|
+
requestGas = BigInt(raw.toString()) * 130n / 100n;
|
|
1907
|
+
} catch {
|
|
1908
|
+
}
|
|
1909
|
+
const approveGas = 60000n;
|
|
1910
|
+
return {
|
|
1911
|
+
flow: "async",
|
|
1912
|
+
steps: [
|
|
1913
|
+
{ label: "approve shares to escrow", gasEstimate: approveGas },
|
|
1914
|
+
{ label: "initVaultActionRequest", gasEstimate: requestGas }
|
|
1915
|
+
],
|
|
1916
|
+
totalGasEstimate: approveGas + requestGas,
|
|
1917
|
+
lzFee
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
if (status.withdrawalQueueEnabled) {
|
|
1921
|
+
const vaultNew = new ethers.Contract(vault, VAULT_ABI, provider);
|
|
1922
|
+
let requestGas = 0n;
|
|
1923
|
+
try {
|
|
1924
|
+
const raw = await vaultNew.requestRedeem.estimateGas(shares, owner, { from: owner });
|
|
1925
|
+
requestGas = BigInt(raw.toString());
|
|
1926
|
+
} catch {
|
|
1927
|
+
try {
|
|
1928
|
+
const vaultLegacy = new ethers.Contract(vault, VAULT_REQUEST_REDEEM_LEGACY_ABI, provider);
|
|
1929
|
+
const raw = await vaultLegacy.requestRedeem.estimateGas(shares, { from: owner });
|
|
1930
|
+
requestGas = BigInt(raw.toString());
|
|
1931
|
+
} catch {
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
if (status.withdrawalTimelockSeconds === 0n) {
|
|
1935
|
+
let redeemGas2 = 0n;
|
|
1936
|
+
try {
|
|
1937
|
+
const raw = await vaultNew.redeem.estimateGas(shares, receiver, owner, { from: owner });
|
|
1938
|
+
redeemGas2 = BigInt(raw.toString());
|
|
1939
|
+
} catch {
|
|
1940
|
+
}
|
|
1941
|
+
return {
|
|
1942
|
+
flow: "queue-no-timelock",
|
|
1943
|
+
steps: [
|
|
1944
|
+
{ label: "requestRedeem", gasEstimate: requestGas },
|
|
1945
|
+
{ label: "redeemShares", gasEstimate: redeemGas2 }
|
|
1946
|
+
],
|
|
1947
|
+
totalGasEstimate: requestGas + redeemGas2,
|
|
1948
|
+
lzFee: 0n
|
|
1949
|
+
};
|
|
1950
|
+
}
|
|
1951
|
+
return {
|
|
1952
|
+
flow: "queue-timelock",
|
|
1953
|
+
steps: [{ label: "requestRedeem", gasEstimate: requestGas }],
|
|
1954
|
+
totalGasEstimate: requestGas,
|
|
1955
|
+
lzFee: 0n
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
const vaultContract = new ethers.Contract(vault, VAULT_ABI, provider);
|
|
1959
|
+
let redeemGas = 0n;
|
|
1960
|
+
try {
|
|
1961
|
+
const raw = await vaultContract.redeem.estimateGas(shares, receiver, owner, { from: owner });
|
|
1962
|
+
redeemGas = BigInt(raw.toString());
|
|
1963
|
+
} catch {
|
|
1964
|
+
}
|
|
1965
|
+
return {
|
|
1966
|
+
flow: "direct",
|
|
1967
|
+
steps: [{ label: "redeemShares", gasEstimate: redeemGas }],
|
|
1968
|
+
totalGasEstimate: redeemGas,
|
|
1969
|
+
lzFee: 0n
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1872
1972
|
async function smartRedeem(signer, addresses, shares, receiver, owner, extraOptions = "0x") {
|
|
1873
1973
|
const provider = signer.provider;
|
|
1874
1974
|
const vault = addresses.vault;
|
|
@@ -3603,6 +3703,7 @@ exports.CHAIN_ID_TO_EID = CHAIN_ID_TO_EID;
|
|
|
3603
3703
|
exports.CONFIG_ABI = CONFIG_ABI;
|
|
3604
3704
|
exports.CURATOR_CONFIG_ABI = CURATOR_CONFIG_ABI;
|
|
3605
3705
|
exports.CapacityFullError = CapacityFullError;
|
|
3706
|
+
exports.ComposeAlreadyExecutedError = ComposeAlreadyExecutedError;
|
|
3606
3707
|
exports.ComposeTimeoutError = ComposeTimeoutError;
|
|
3607
3708
|
exports.ComposerNotConfiguredError = ComposerNotConfiguredError;
|
|
3608
3709
|
exports.DEX_ABI = DEX_ABI;
|
|
@@ -3669,6 +3770,7 @@ exports.encodeBridgeParams = encodeBridgeParams;
|
|
|
3669
3770
|
exports.encodeCuratorAction = encodeCuratorAction;
|
|
3670
3771
|
exports.encodeUniswapV3SwapCalldata = encodeUniswapV3SwapCalldata;
|
|
3671
3772
|
exports.ensureAllowance = ensureAllowance;
|
|
3773
|
+
exports.estimateRedeemCost = estimateRedeemCost;
|
|
3672
3774
|
exports.executeActions = executeActions;
|
|
3673
3775
|
exports.executeCompose = executeCompose;
|
|
3674
3776
|
exports.executeCuratorBridge = executeCuratorBridge;
|