@oydual31/more-vaults-sdk 0.3.0 → 0.3.2
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/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/{spokeRoutes-FgKCJQYa.d.cts → spokeRoutes-DK7cIW4z.d.cts} +4 -0
- package/dist/{spokeRoutes-FgKCJQYa.d.ts → spokeRoutes-DK7cIW4z.d.ts} +4 -0
- package/dist/viem/index.cjs +450 -5
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +396 -3
- package/dist/viem/index.d.ts +396 -3
- package/dist/viem/index.js +438 -7
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/abis.ts +51 -0
- package/src/viem/chains.ts +17 -0
- package/src/viem/curatorMulticall.ts +299 -0
- package/src/viem/curatorStatus.ts +197 -2
- package/src/viem/curatorSwaps.ts +239 -0
- package/src/viem/index.ts +22 -1
- package/src/viem/types.ts +38 -0
- package/src/viem/userHelpers.ts +22 -6
|
@@ -241,6 +241,10 @@ type DepositBlockReason = 'paused' | 'capacity-full' | 'not-whitelisted' | 'ok';
|
|
|
241
241
|
interface DepositEligibility {
|
|
242
242
|
allowed: boolean;
|
|
243
243
|
reason: DepositBlockReason;
|
|
244
|
+
/** Max deposit amount for this user (0n if capacity full or not whitelisted) */
|
|
245
|
+
maxDeposit?: bigint;
|
|
246
|
+
/** Whether the vault restricts deposits to whitelisted addresses */
|
|
247
|
+
whitelistEnabled?: boolean;
|
|
244
248
|
}
|
|
245
249
|
/**
|
|
246
250
|
* Check whether a user is eligible to deposit into the vault right now.
|
|
@@ -241,6 +241,10 @@ type DepositBlockReason = 'paused' | 'capacity-full' | 'not-whitelisted' | 'ok';
|
|
|
241
241
|
interface DepositEligibility {
|
|
242
242
|
allowed: boolean;
|
|
243
243
|
reason: DepositBlockReason;
|
|
244
|
+
/** Max deposit amount for this user (0n if capacity full or not whitelisted) */
|
|
245
|
+
maxDeposit?: bigint;
|
|
246
|
+
/** Whether the vault restricts deposits to whitelisted addresses */
|
|
247
|
+
whitelistEnabled?: boolean;
|
|
244
248
|
}
|
|
245
249
|
/**
|
|
246
250
|
* Check whether a user is eligible to deposit into the vault right now.
|
package/dist/viem/index.cjs
CHANGED
|
@@ -387,6 +387,18 @@ var LZ_TIMEOUTS = {
|
|
|
387
387
|
FULL_SPOKE_REDEEM: 36e5
|
|
388
388
|
// 60 min
|
|
389
389
|
};
|
|
390
|
+
var UNISWAP_V3_ROUTERS = {
|
|
391
|
+
[8453]: "0x2626664c2603336E57B271c5C0b26F421741e481",
|
|
392
|
+
// Base — SwapRouter02 (no deadline)
|
|
393
|
+
[1]: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
|
|
394
|
+
// Ethereum — SwapRouter
|
|
395
|
+
[42161]: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
|
|
396
|
+
// Arbitrum — SwapRouter
|
|
397
|
+
[10]: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
|
|
398
|
+
// Optimism — SwapRouter
|
|
399
|
+
[747]: "0xeEDC6Ff75e1b10B903D9013c358e446a73d35341"
|
|
400
|
+
// Flow EVM — FlowSwap V3 SwapRouter
|
|
401
|
+
};
|
|
390
402
|
var USDC_STARGATE_OFT = Object.fromEntries(
|
|
391
403
|
Object.entries(OFT_ROUTES.stgUSDC).map(([k, v]) => [k, v.oft])
|
|
392
404
|
);
|
|
@@ -1077,6 +1089,45 @@ var LZ_ADAPTER_ABI = [
|
|
|
1077
1089
|
stateMutability: "view"
|
|
1078
1090
|
}
|
|
1079
1091
|
];
|
|
1092
|
+
var ERC4626_FACET_ABI = [
|
|
1093
|
+
{
|
|
1094
|
+
type: "function",
|
|
1095
|
+
name: "erc4626Deposit",
|
|
1096
|
+
inputs: [
|
|
1097
|
+
{ name: "vault", type: "address" },
|
|
1098
|
+
{ name: "assets", type: "uint256" }
|
|
1099
|
+
],
|
|
1100
|
+
outputs: [{ name: "shares", type: "uint256" }],
|
|
1101
|
+
stateMutability: "nonpayable"
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
type: "function",
|
|
1105
|
+
name: "erc4626Redeem",
|
|
1106
|
+
inputs: [
|
|
1107
|
+
{ name: "vault", type: "address" },
|
|
1108
|
+
{ name: "shares", type: "uint256" }
|
|
1109
|
+
],
|
|
1110
|
+
outputs: [{ name: "assets", type: "uint256" }],
|
|
1111
|
+
stateMutability: "nonpayable"
|
|
1112
|
+
}
|
|
1113
|
+
];
|
|
1114
|
+
var VAULT_ANALYSIS_ABI = [
|
|
1115
|
+
// Asset management reads
|
|
1116
|
+
{ type: "function", name: "getAvailableAssets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" },
|
|
1117
|
+
{ type: "function", name: "getDepositableAssets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" },
|
|
1118
|
+
{ type: "function", name: "isAssetAvailable", inputs: [{ name: "asset", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1119
|
+
{ type: "function", name: "isAssetDepositable", inputs: [{ name: "asset", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1120
|
+
// Deposit whitelist
|
|
1121
|
+
{ type: "function", name: "isDepositWhitelistEnabled", inputs: [], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1122
|
+
{ type: "function", name: "getAvailableToDeposit", inputs: [{ name: "depositor", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "view" },
|
|
1123
|
+
// Registry
|
|
1124
|
+
{ type: "function", name: "moreVaultsRegistry", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" }
|
|
1125
|
+
];
|
|
1126
|
+
var REGISTRY_ABI = [
|
|
1127
|
+
{ type: "function", name: "isWhitelisted", inputs: [{ name: "protocol", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1128
|
+
{ type: "function", name: "isBridgeAllowed", inputs: [{ name: "bridge", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1129
|
+
{ type: "function", name: "getAllowedFacets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" }
|
|
1130
|
+
];
|
|
1080
1131
|
var LZ_ENDPOINT_ABI = [
|
|
1081
1132
|
{
|
|
1082
1133
|
type: "function",
|
|
@@ -3086,12 +3137,21 @@ async function canDeposit(publicClient, vault, user) {
|
|
|
3086
3137
|
],
|
|
3087
3138
|
allowFailure: false
|
|
3088
3139
|
});
|
|
3140
|
+
let whitelistEnabled = false;
|
|
3141
|
+
try {
|
|
3142
|
+
whitelistEnabled = await publicClient.readContract({
|
|
3143
|
+
address: v,
|
|
3144
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3145
|
+
functionName: "isDepositWhitelistEnabled"
|
|
3146
|
+
});
|
|
3147
|
+
} catch {
|
|
3148
|
+
}
|
|
3089
3149
|
if (isPaused) {
|
|
3090
|
-
return { allowed: false, reason: "paused" };
|
|
3150
|
+
return { allowed: false, reason: "paused", whitelistEnabled };
|
|
3091
3151
|
}
|
|
3092
3152
|
const isCrossChainAsync = isHub && !oraclesEnabled;
|
|
3093
3153
|
if (isCrossChainAsync) {
|
|
3094
|
-
return { allowed: true, reason: "ok" };
|
|
3154
|
+
return { allowed: true, reason: "ok", whitelistEnabled };
|
|
3095
3155
|
}
|
|
3096
3156
|
let maxDepositAmount;
|
|
3097
3157
|
try {
|
|
@@ -3102,12 +3162,12 @@ async function canDeposit(publicClient, vault, user) {
|
|
|
3102
3162
|
args: [viem.getAddress(user)]
|
|
3103
3163
|
});
|
|
3104
3164
|
} catch {
|
|
3105
|
-
return { allowed: false, reason: "not-whitelisted" };
|
|
3165
|
+
return { allowed: false, reason: "not-whitelisted", maxDeposit: 0n, whitelistEnabled };
|
|
3106
3166
|
}
|
|
3107
3167
|
if (maxDepositAmount === 0n) {
|
|
3108
|
-
return { allowed: false, reason: "capacity-full" };
|
|
3168
|
+
return { allowed: false, reason: "capacity-full", maxDeposit: 0n, whitelistEnabled };
|
|
3109
3169
|
}
|
|
3110
|
-
return { allowed: true, reason: "ok" };
|
|
3170
|
+
return { allowed: true, reason: "ok", maxDeposit: maxDepositAmount, whitelistEnabled };
|
|
3111
3171
|
}
|
|
3112
3172
|
async function getVaultMetadata(publicClient, vault) {
|
|
3113
3173
|
const v = viem.getAddress(vault);
|
|
@@ -3511,6 +3571,377 @@ async function isCurator(publicClient, vault, address) {
|
|
|
3511
3571
|
});
|
|
3512
3572
|
return viem.getAddress(curatorAddress) === viem.getAddress(address);
|
|
3513
3573
|
}
|
|
3574
|
+
async function getVaultAnalysis(publicClient, vault) {
|
|
3575
|
+
const v = viem.getAddress(vault);
|
|
3576
|
+
const [availableRaw, depositableRaw, depositWhitelistEnabled, registryResult] = await Promise.all([
|
|
3577
|
+
publicClient.readContract({
|
|
3578
|
+
address: v,
|
|
3579
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3580
|
+
functionName: "getAvailableAssets"
|
|
3581
|
+
}),
|
|
3582
|
+
publicClient.readContract({
|
|
3583
|
+
address: v,
|
|
3584
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3585
|
+
functionName: "getDepositableAssets"
|
|
3586
|
+
}),
|
|
3587
|
+
publicClient.readContract({
|
|
3588
|
+
address: v,
|
|
3589
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3590
|
+
functionName: "isDepositWhitelistEnabled"
|
|
3591
|
+
}),
|
|
3592
|
+
publicClient.readContract({
|
|
3593
|
+
address: v,
|
|
3594
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3595
|
+
functionName: "moreVaultsRegistry"
|
|
3596
|
+
}).catch(() => null)
|
|
3597
|
+
]);
|
|
3598
|
+
const availableAddresses = availableRaw.map(viem.getAddress);
|
|
3599
|
+
const depositableAddresses = depositableRaw.map(viem.getAddress);
|
|
3600
|
+
const allAddresses = Array.from(/* @__PURE__ */ new Set([...availableAddresses, ...depositableAddresses]));
|
|
3601
|
+
const metadataCalls = allAddresses.flatMap((addr) => [
|
|
3602
|
+
{ address: addr, abi: METADATA_ABI, functionName: "name" },
|
|
3603
|
+
{ address: addr, abi: METADATA_ABI, functionName: "symbol" },
|
|
3604
|
+
{ address: addr, abi: METADATA_ABI, functionName: "decimals" }
|
|
3605
|
+
]);
|
|
3606
|
+
const metadataResults = allAddresses.length > 0 ? await publicClient.multicall({ contracts: metadataCalls, allowFailure: true }) : [];
|
|
3607
|
+
const assetInfoMap = /* @__PURE__ */ new Map();
|
|
3608
|
+
for (let i = 0; i < allAddresses.length; i++) {
|
|
3609
|
+
const addr = allAddresses[i];
|
|
3610
|
+
const nameResult = metadataResults[i * 3];
|
|
3611
|
+
const symbolResult = metadataResults[i * 3 + 1];
|
|
3612
|
+
const decimalsResult = metadataResults[i * 3 + 2];
|
|
3613
|
+
assetInfoMap.set(addr, {
|
|
3614
|
+
address: addr,
|
|
3615
|
+
name: nameResult?.status === "success" ? nameResult.result : "",
|
|
3616
|
+
symbol: symbolResult?.status === "success" ? symbolResult.result : "",
|
|
3617
|
+
decimals: decimalsResult?.status === "success" ? decimalsResult.result : 18
|
|
3618
|
+
});
|
|
3619
|
+
}
|
|
3620
|
+
const registryAddress = registryResult ? viem.getAddress(registryResult) : null;
|
|
3621
|
+
return {
|
|
3622
|
+
availableAssets: availableAddresses.map((a) => assetInfoMap.get(a)),
|
|
3623
|
+
depositableAssets: depositableAddresses.map((a) => assetInfoMap.get(a)),
|
|
3624
|
+
depositWhitelistEnabled,
|
|
3625
|
+
registryAddress
|
|
3626
|
+
};
|
|
3627
|
+
}
|
|
3628
|
+
async function checkProtocolWhitelist(publicClient, vault, protocols) {
|
|
3629
|
+
const v = viem.getAddress(vault);
|
|
3630
|
+
const registryRaw = await publicClient.readContract({
|
|
3631
|
+
address: v,
|
|
3632
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3633
|
+
functionName: "moreVaultsRegistry"
|
|
3634
|
+
});
|
|
3635
|
+
const registry = viem.getAddress(registryRaw);
|
|
3636
|
+
if (protocols.length === 0) return {};
|
|
3637
|
+
const results = await publicClient.multicall({
|
|
3638
|
+
contracts: protocols.map((protocol) => ({
|
|
3639
|
+
address: registry,
|
|
3640
|
+
abi: REGISTRY_ABI,
|
|
3641
|
+
functionName: "isWhitelisted",
|
|
3642
|
+
args: [viem.getAddress(protocol)]
|
|
3643
|
+
})),
|
|
3644
|
+
allowFailure: true
|
|
3645
|
+
});
|
|
3646
|
+
const out = {};
|
|
3647
|
+
for (let i = 0; i < protocols.length; i++) {
|
|
3648
|
+
const r = results[i];
|
|
3649
|
+
out[viem.getAddress(protocols[i])] = r?.status === "success" ? r.result : false;
|
|
3650
|
+
}
|
|
3651
|
+
return out;
|
|
3652
|
+
}
|
|
3653
|
+
async function getVaultAssetBreakdown(publicClient, vault) {
|
|
3654
|
+
const v = viem.getAddress(vault);
|
|
3655
|
+
const availableRaw = await publicClient.readContract({
|
|
3656
|
+
address: v,
|
|
3657
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3658
|
+
functionName: "getAvailableAssets"
|
|
3659
|
+
});
|
|
3660
|
+
const addresses = availableRaw.map(viem.getAddress);
|
|
3661
|
+
const results = await publicClient.multicall({
|
|
3662
|
+
contracts: [
|
|
3663
|
+
// Per-asset: balanceOf, name, symbol, decimals
|
|
3664
|
+
...addresses.flatMap((addr) => [
|
|
3665
|
+
{ address: addr, abi: ERC20_ABI, functionName: "balanceOf", args: [v] },
|
|
3666
|
+
{ address: addr, abi: METADATA_ABI, functionName: "name" },
|
|
3667
|
+
{ address: addr, abi: METADATA_ABI, functionName: "symbol" },
|
|
3668
|
+
{ address: addr, abi: METADATA_ABI, functionName: "decimals" }
|
|
3669
|
+
]),
|
|
3670
|
+
// Vault totals
|
|
3671
|
+
{ address: v, abi: VAULT_ABI, functionName: "totalAssets" },
|
|
3672
|
+
{ address: v, abi: VAULT_ABI, functionName: "totalSupply" },
|
|
3673
|
+
{ address: v, abi: METADATA_ABI, functionName: "decimals" }
|
|
3674
|
+
],
|
|
3675
|
+
allowFailure: true
|
|
3676
|
+
});
|
|
3677
|
+
const perAssetFields = 4;
|
|
3678
|
+
const assets = addresses.map((addr, i) => {
|
|
3679
|
+
const base = i * perAssetFields;
|
|
3680
|
+
const balance = results[base]?.status === "success" ? results[base].result : 0n;
|
|
3681
|
+
const name = results[base + 1]?.status === "success" ? results[base + 1].result : "";
|
|
3682
|
+
const symbol = results[base + 2]?.status === "success" ? results[base + 2].result : "";
|
|
3683
|
+
const decimals = results[base + 3]?.status === "success" ? results[base + 3].result : 18;
|
|
3684
|
+
return { address: addr, name, symbol, decimals, balance };
|
|
3685
|
+
});
|
|
3686
|
+
const totalsBase = addresses.length * perAssetFields;
|
|
3687
|
+
const totalAssets = results[totalsBase]?.status === "success" ? results[totalsBase].result : 0n;
|
|
3688
|
+
const totalSupply = results[totalsBase + 1]?.status === "success" ? results[totalsBase + 1].result : 0n;
|
|
3689
|
+
const underlyingDecimals = results[totalsBase + 2]?.status === "success" ? results[totalsBase + 2].result : 6;
|
|
3690
|
+
return { assets, totalAssets, totalSupply, underlyingDecimals };
|
|
3691
|
+
}
|
|
3692
|
+
function encodeCuratorAction(action) {
|
|
3693
|
+
switch (action.type) {
|
|
3694
|
+
case "swap":
|
|
3695
|
+
return viem.encodeFunctionData({
|
|
3696
|
+
abi: DEX_ABI,
|
|
3697
|
+
functionName: "executeSwap",
|
|
3698
|
+
args: [
|
|
3699
|
+
{
|
|
3700
|
+
targetContract: viem.getAddress(action.params.targetContract),
|
|
3701
|
+
tokenIn: viem.getAddress(action.params.tokenIn),
|
|
3702
|
+
tokenOut: viem.getAddress(action.params.tokenOut),
|
|
3703
|
+
maxAmountIn: action.params.maxAmountIn,
|
|
3704
|
+
minAmountOut: action.params.minAmountOut,
|
|
3705
|
+
swapCallData: action.params.swapCallData
|
|
3706
|
+
}
|
|
3707
|
+
]
|
|
3708
|
+
});
|
|
3709
|
+
case "batchSwap":
|
|
3710
|
+
return viem.encodeFunctionData({
|
|
3711
|
+
abi: DEX_ABI,
|
|
3712
|
+
functionName: "executeBatchSwap",
|
|
3713
|
+
args: [
|
|
3714
|
+
{
|
|
3715
|
+
swaps: action.params.swaps.map((s) => ({
|
|
3716
|
+
targetContract: viem.getAddress(s.targetContract),
|
|
3717
|
+
tokenIn: viem.getAddress(s.tokenIn),
|
|
3718
|
+
tokenOut: viem.getAddress(s.tokenOut),
|
|
3719
|
+
maxAmountIn: s.maxAmountIn,
|
|
3720
|
+
minAmountOut: s.minAmountOut,
|
|
3721
|
+
swapCallData: s.swapCallData
|
|
3722
|
+
}))
|
|
3723
|
+
}
|
|
3724
|
+
]
|
|
3725
|
+
});
|
|
3726
|
+
case "erc4626Deposit":
|
|
3727
|
+
return viem.encodeFunctionData({
|
|
3728
|
+
abi: ERC4626_FACET_ABI,
|
|
3729
|
+
functionName: "erc4626Deposit",
|
|
3730
|
+
args: [viem.getAddress(action.vault), action.assets]
|
|
3731
|
+
});
|
|
3732
|
+
case "erc4626Redeem":
|
|
3733
|
+
return viem.encodeFunctionData({
|
|
3734
|
+
abi: ERC4626_FACET_ABI,
|
|
3735
|
+
functionName: "erc4626Redeem",
|
|
3736
|
+
args: [viem.getAddress(action.vault), action.shares]
|
|
3737
|
+
});
|
|
3738
|
+
case "erc7540RequestDeposit":
|
|
3739
|
+
return viem.encodeFunctionData({
|
|
3740
|
+
abi: ERC7540_FACET_ABI,
|
|
3741
|
+
functionName: "erc7540RequestDeposit",
|
|
3742
|
+
args: [viem.getAddress(action.vault), action.assets]
|
|
3743
|
+
});
|
|
3744
|
+
case "erc7540Deposit":
|
|
3745
|
+
return viem.encodeFunctionData({
|
|
3746
|
+
abi: ERC7540_FACET_ABI,
|
|
3747
|
+
functionName: "erc7540Deposit",
|
|
3748
|
+
args: [viem.getAddress(action.vault), action.assets]
|
|
3749
|
+
});
|
|
3750
|
+
case "erc7540RequestRedeem":
|
|
3751
|
+
return viem.encodeFunctionData({
|
|
3752
|
+
abi: ERC7540_FACET_ABI,
|
|
3753
|
+
functionName: "erc7540RequestRedeem",
|
|
3754
|
+
args: [viem.getAddress(action.vault), action.shares]
|
|
3755
|
+
});
|
|
3756
|
+
case "erc7540Redeem":
|
|
3757
|
+
return viem.encodeFunctionData({
|
|
3758
|
+
abi: ERC7540_FACET_ABI,
|
|
3759
|
+
functionName: "erc7540Redeem",
|
|
3760
|
+
args: [viem.getAddress(action.vault), action.shares]
|
|
3761
|
+
});
|
|
3762
|
+
default: {
|
|
3763
|
+
const _exhaustive = action;
|
|
3764
|
+
throw new Error(`[MoreVaults] Unknown CuratorAction type: ${_exhaustive.type}`);
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
function buildCuratorBatch(actions) {
|
|
3769
|
+
return actions.map(encodeCuratorAction);
|
|
3770
|
+
}
|
|
3771
|
+
async function submitActions(walletClient, publicClient, vault, actions) {
|
|
3772
|
+
const account = walletClient.account;
|
|
3773
|
+
const v = viem.getAddress(vault);
|
|
3774
|
+
await publicClient.simulateContract({
|
|
3775
|
+
address: v,
|
|
3776
|
+
abi: MULTICALL_ABI,
|
|
3777
|
+
functionName: "submitActions",
|
|
3778
|
+
args: [actions],
|
|
3779
|
+
account: account.address
|
|
3780
|
+
});
|
|
3781
|
+
const txHash = await walletClient.writeContract({
|
|
3782
|
+
address: v,
|
|
3783
|
+
abi: MULTICALL_ABI,
|
|
3784
|
+
functionName: "submitActions",
|
|
3785
|
+
args: [actions],
|
|
3786
|
+
account,
|
|
3787
|
+
chain: walletClient.chain
|
|
3788
|
+
});
|
|
3789
|
+
const nextNonce = await publicClient.readContract({
|
|
3790
|
+
address: v,
|
|
3791
|
+
abi: MULTICALL_ABI,
|
|
3792
|
+
functionName: "getCurrentNonce"
|
|
3793
|
+
});
|
|
3794
|
+
const nonce = nextNonce - 1n;
|
|
3795
|
+
return { txHash, nonce };
|
|
3796
|
+
}
|
|
3797
|
+
async function executeActions(walletClient, publicClient, vault, nonce) {
|
|
3798
|
+
const account = walletClient.account;
|
|
3799
|
+
const v = viem.getAddress(vault);
|
|
3800
|
+
await publicClient.simulateContract({
|
|
3801
|
+
address: v,
|
|
3802
|
+
abi: MULTICALL_ABI,
|
|
3803
|
+
functionName: "executeActions",
|
|
3804
|
+
args: [nonce],
|
|
3805
|
+
account: account.address
|
|
3806
|
+
});
|
|
3807
|
+
const txHash = await walletClient.writeContract({
|
|
3808
|
+
address: v,
|
|
3809
|
+
abi: MULTICALL_ABI,
|
|
3810
|
+
functionName: "executeActions",
|
|
3811
|
+
args: [nonce],
|
|
3812
|
+
account,
|
|
3813
|
+
chain: walletClient.chain
|
|
3814
|
+
});
|
|
3815
|
+
return { txHash };
|
|
3816
|
+
}
|
|
3817
|
+
async function vetoActions(walletClient, publicClient, vault, nonces) {
|
|
3818
|
+
const account = walletClient.account;
|
|
3819
|
+
const v = viem.getAddress(vault);
|
|
3820
|
+
await publicClient.simulateContract({
|
|
3821
|
+
address: v,
|
|
3822
|
+
abi: MULTICALL_ABI,
|
|
3823
|
+
functionName: "vetoActions",
|
|
3824
|
+
args: [nonces],
|
|
3825
|
+
account: account.address
|
|
3826
|
+
});
|
|
3827
|
+
const txHash = await walletClient.writeContract({
|
|
3828
|
+
address: v,
|
|
3829
|
+
abi: MULTICALL_ABI,
|
|
3830
|
+
functionName: "vetoActions",
|
|
3831
|
+
args: [nonces],
|
|
3832
|
+
account,
|
|
3833
|
+
chain: walletClient.chain
|
|
3834
|
+
});
|
|
3835
|
+
return { txHash };
|
|
3836
|
+
}
|
|
3837
|
+
var UNISWAP_V3_SWAP_ROUTER_ABI = [
|
|
3838
|
+
{
|
|
3839
|
+
type: "function",
|
|
3840
|
+
name: "exactInputSingle",
|
|
3841
|
+
inputs: [
|
|
3842
|
+
{
|
|
3843
|
+
type: "tuple",
|
|
3844
|
+
name: "params",
|
|
3845
|
+
components: [
|
|
3846
|
+
{ name: "tokenIn", type: "address" },
|
|
3847
|
+
{ name: "tokenOut", type: "address" },
|
|
3848
|
+
{ name: "fee", type: "uint24" },
|
|
3849
|
+
{ name: "recipient", type: "address" },
|
|
3850
|
+
{ name: "deadline", type: "uint256" },
|
|
3851
|
+
{ name: "amountIn", type: "uint256" },
|
|
3852
|
+
{ name: "amountOutMinimum", type: "uint256" },
|
|
3853
|
+
{ name: "sqrtPriceLimitX96", type: "uint160" }
|
|
3854
|
+
]
|
|
3855
|
+
}
|
|
3856
|
+
],
|
|
3857
|
+
outputs: [{ name: "amountOut", type: "uint256" }],
|
|
3858
|
+
stateMutability: "payable"
|
|
3859
|
+
}
|
|
3860
|
+
];
|
|
3861
|
+
var UNISWAP_V3_SWAP_ROUTER02_ABI = [
|
|
3862
|
+
{
|
|
3863
|
+
type: "function",
|
|
3864
|
+
name: "exactInputSingle",
|
|
3865
|
+
inputs: [
|
|
3866
|
+
{
|
|
3867
|
+
type: "tuple",
|
|
3868
|
+
name: "params",
|
|
3869
|
+
components: [
|
|
3870
|
+
{ name: "tokenIn", type: "address" },
|
|
3871
|
+
{ name: "tokenOut", type: "address" },
|
|
3872
|
+
{ name: "fee", type: "uint24" },
|
|
3873
|
+
{ name: "recipient", type: "address" },
|
|
3874
|
+
{ name: "amountIn", type: "uint256" },
|
|
3875
|
+
{ name: "amountOutMinimum", type: "uint256" },
|
|
3876
|
+
{ name: "sqrtPriceLimitX96", type: "uint160" }
|
|
3877
|
+
]
|
|
3878
|
+
}
|
|
3879
|
+
],
|
|
3880
|
+
outputs: [{ name: "amountOut", type: "uint256" }],
|
|
3881
|
+
stateMutability: "payable"
|
|
3882
|
+
}
|
|
3883
|
+
];
|
|
3884
|
+
var SWAP_ROUTER02_CHAINS = /* @__PURE__ */ new Set([8453]);
|
|
3885
|
+
function encodeUniswapV3SwapCalldata(params) {
|
|
3886
|
+
const { chainId, tokenIn, tokenOut, fee, amountIn, minAmountOut, recipient } = params;
|
|
3887
|
+
const router = UNISWAP_V3_ROUTERS[chainId];
|
|
3888
|
+
if (!router) {
|
|
3889
|
+
throw new Error(
|
|
3890
|
+
`[MoreVaults] No Uniswap V3 router configured for chainId ${chainId}. Supported chains: ${Object.keys(UNISWAP_V3_ROUTERS).join(", ")}`
|
|
3891
|
+
);
|
|
3892
|
+
}
|
|
3893
|
+
let swapCallData;
|
|
3894
|
+
if (SWAP_ROUTER02_CHAINS.has(chainId)) {
|
|
3895
|
+
swapCallData = viem.encodeFunctionData({
|
|
3896
|
+
abi: UNISWAP_V3_SWAP_ROUTER02_ABI,
|
|
3897
|
+
functionName: "exactInputSingle",
|
|
3898
|
+
args: [
|
|
3899
|
+
{
|
|
3900
|
+
tokenIn,
|
|
3901
|
+
tokenOut,
|
|
3902
|
+
fee,
|
|
3903
|
+
recipient,
|
|
3904
|
+
amountIn,
|
|
3905
|
+
amountOutMinimum: minAmountOut,
|
|
3906
|
+
sqrtPriceLimitX96: 0n
|
|
3907
|
+
}
|
|
3908
|
+
]
|
|
3909
|
+
});
|
|
3910
|
+
} else {
|
|
3911
|
+
const deadline = BigInt(Math.floor(Date.now() / 1e3) + 1200);
|
|
3912
|
+
swapCallData = viem.encodeFunctionData({
|
|
3913
|
+
abi: UNISWAP_V3_SWAP_ROUTER_ABI,
|
|
3914
|
+
functionName: "exactInputSingle",
|
|
3915
|
+
args: [
|
|
3916
|
+
{
|
|
3917
|
+
tokenIn,
|
|
3918
|
+
tokenOut,
|
|
3919
|
+
fee,
|
|
3920
|
+
recipient,
|
|
3921
|
+
deadline,
|
|
3922
|
+
amountIn,
|
|
3923
|
+
amountOutMinimum: minAmountOut,
|
|
3924
|
+
sqrtPriceLimitX96: 0n
|
|
3925
|
+
}
|
|
3926
|
+
]
|
|
3927
|
+
});
|
|
3928
|
+
}
|
|
3929
|
+
return { targetContract: router, swapCallData };
|
|
3930
|
+
}
|
|
3931
|
+
function buildUniswapV3Swap(params) {
|
|
3932
|
+
const { targetContract, swapCallData } = encodeUniswapV3SwapCalldata(params);
|
|
3933
|
+
return {
|
|
3934
|
+
type: "swap",
|
|
3935
|
+
params: {
|
|
3936
|
+
targetContract,
|
|
3937
|
+
tokenIn: params.tokenIn,
|
|
3938
|
+
tokenOut: params.tokenOut,
|
|
3939
|
+
maxAmountIn: params.amountIn,
|
|
3940
|
+
minAmountOut: params.minAmountOut,
|
|
3941
|
+
swapCallData
|
|
3942
|
+
}
|
|
3943
|
+
};
|
|
3944
|
+
}
|
|
3514
3945
|
|
|
3515
3946
|
// src/viem/wagmiCompat.ts
|
|
3516
3947
|
function asSdkClient(client) {
|
|
@@ -3530,6 +3961,7 @@ exports.CapacityFullError = CapacityFullError;
|
|
|
3530
3961
|
exports.DEX_ABI = DEX_ABI;
|
|
3531
3962
|
exports.EID_TO_CHAIN_ID = EID_TO_CHAIN_ID;
|
|
3532
3963
|
exports.ERC20_ABI = ERC20_ABI;
|
|
3964
|
+
exports.ERC4626_FACET_ABI = ERC4626_FACET_ABI;
|
|
3533
3965
|
exports.ERC7540_FACET_ABI = ERC7540_FACET_ABI;
|
|
3534
3966
|
exports.EscrowNotConfiguredError = EscrowNotConfiguredError;
|
|
3535
3967
|
exports.InsufficientLiquidityError = InsufficientLiquidityError;
|
|
@@ -3547,16 +3979,22 @@ exports.NotWhitelistedError = NotWhitelistedError;
|
|
|
3547
3979
|
exports.OFT_ABI = OFT_ABI;
|
|
3548
3980
|
exports.OFT_ROUTES = OFT_ROUTES;
|
|
3549
3981
|
exports.OMNI_FACTORY_ADDRESS = OMNI_FACTORY_ADDRESS;
|
|
3982
|
+
exports.REGISTRY_ABI = REGISTRY_ABI;
|
|
3550
3983
|
exports.STARGATE_TAXI_CMD = STARGATE_TAXI_CMD;
|
|
3984
|
+
exports.UNISWAP_V3_ROUTERS = UNISWAP_V3_ROUTERS;
|
|
3551
3985
|
exports.USDC_STARGATE_OFT = USDC_STARGATE_OFT;
|
|
3552
3986
|
exports.USDC_TOKEN = USDC_TOKEN;
|
|
3553
3987
|
exports.VAULT_ABI = VAULT_ABI;
|
|
3988
|
+
exports.VAULT_ANALYSIS_ABI = VAULT_ANALYSIS_ABI;
|
|
3554
3989
|
exports.VaultPausedError = VaultPausedError;
|
|
3555
3990
|
exports.WrongChainError = WrongChainError;
|
|
3556
3991
|
exports.asSdkClient = asSdkClient;
|
|
3557
3992
|
exports.bridgeAssetsToSpoke = bridgeAssetsToSpoke;
|
|
3558
3993
|
exports.bridgeSharesToHub = bridgeSharesToHub;
|
|
3994
|
+
exports.buildCuratorBatch = buildCuratorBatch;
|
|
3995
|
+
exports.buildUniswapV3Swap = buildUniswapV3Swap;
|
|
3559
3996
|
exports.canDeposit = canDeposit;
|
|
3997
|
+
exports.checkProtocolWhitelist = checkProtocolWhitelist;
|
|
3560
3998
|
exports.depositAsync = depositAsync;
|
|
3561
3999
|
exports.depositCrossChainOracleOn = depositSimple;
|
|
3562
4000
|
exports.depositFromSpoke = depositFromSpoke;
|
|
@@ -3564,7 +4002,10 @@ exports.depositFromSpokeAsync = depositFromSpoke;
|
|
|
3564
4002
|
exports.depositMultiAsset = depositMultiAsset;
|
|
3565
4003
|
exports.depositSimple = depositSimple;
|
|
3566
4004
|
exports.discoverVaultTopology = discoverVaultTopology;
|
|
4005
|
+
exports.encodeCuratorAction = encodeCuratorAction;
|
|
4006
|
+
exports.encodeUniswapV3SwapCalldata = encodeUniswapV3SwapCalldata;
|
|
3567
4007
|
exports.ensureAllowance = ensureAllowance;
|
|
4008
|
+
exports.executeActions = executeActions;
|
|
3568
4009
|
exports.executeCompose = executeCompose;
|
|
3569
4010
|
exports.getAllVaultChainIds = getAllVaultChainIds;
|
|
3570
4011
|
exports.getAsyncRequestStatus = getAsyncRequestStatus;
|
|
@@ -3579,6 +4020,8 @@ exports.getUserBalances = getUserBalances;
|
|
|
3579
4020
|
exports.getUserBalancesForRoutes = getUserBalancesForRoutes;
|
|
3580
4021
|
exports.getUserPosition = getUserPosition;
|
|
3581
4022
|
exports.getUserPositionMultiChain = getUserPositionMultiChain;
|
|
4023
|
+
exports.getVaultAnalysis = getVaultAnalysis;
|
|
4024
|
+
exports.getVaultAssetBreakdown = getVaultAssetBreakdown;
|
|
3582
4025
|
exports.getVaultDistribution = getVaultDistribution;
|
|
3583
4026
|
exports.getVaultDistributionWithTopology = getVaultDistributionWithTopology;
|
|
3584
4027
|
exports.getVaultMetadata = getVaultMetadata;
|
|
@@ -3608,6 +4051,8 @@ exports.requestRedeem = requestRedeem;
|
|
|
3608
4051
|
exports.resolveRedeemAddresses = resolveRedeemAddresses;
|
|
3609
4052
|
exports.smartDeposit = smartDeposit;
|
|
3610
4053
|
exports.smartRedeem = smartRedeem;
|
|
4054
|
+
exports.submitActions = submitActions;
|
|
4055
|
+
exports.vetoActions = vetoActions;
|
|
3611
4056
|
exports.waitForAsyncRequest = waitForAsyncRequest;
|
|
3612
4057
|
exports.waitForCompose = waitForCompose;
|
|
3613
4058
|
exports.waitForTx = waitForTx;
|