@oydual31/more-vaults-sdk 0.2.9 → 0.3.1
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/README.md +25 -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/{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 +604 -5
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +721 -3
- package/dist/viem/index.d.ts +721 -3
- package/dist/viem/index.js +587 -7
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/abis.ts +329 -0
- package/src/viem/curatorMulticall.ts +299 -0
- package/src/viem/curatorStatus.ts +255 -0
- package/src/viem/index.ts +34 -0
- package/src/viem/types.ts +79 -0
- package/src/viem/userHelpers.ts +22 -6
package/dist/viem/index.cjs
CHANGED
|
@@ -829,6 +829,293 @@ var OFT_ABI = [
|
|
|
829
829
|
stateMutability: "view"
|
|
830
830
|
}
|
|
831
831
|
];
|
|
832
|
+
var MULTICALL_ABI = [
|
|
833
|
+
{
|
|
834
|
+
type: "function",
|
|
835
|
+
name: "submitActions",
|
|
836
|
+
inputs: [
|
|
837
|
+
{ name: "actionsData", type: "bytes[]" }
|
|
838
|
+
],
|
|
839
|
+
outputs: [{ name: "nonce", type: "uint256" }],
|
|
840
|
+
stateMutability: "nonpayable"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
type: "function",
|
|
844
|
+
name: "executeActions",
|
|
845
|
+
inputs: [
|
|
846
|
+
{ name: "actionsNonce", type: "uint256" }
|
|
847
|
+
],
|
|
848
|
+
outputs: [],
|
|
849
|
+
stateMutability: "nonpayable"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
type: "function",
|
|
853
|
+
name: "getPendingActions",
|
|
854
|
+
inputs: [
|
|
855
|
+
{ name: "actionsNonce", type: "uint256" }
|
|
856
|
+
],
|
|
857
|
+
outputs: [
|
|
858
|
+
{ name: "actionsData", type: "bytes[]" },
|
|
859
|
+
{ name: "pendingUntil", type: "uint256" }
|
|
860
|
+
],
|
|
861
|
+
stateMutability: "view"
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
type: "function",
|
|
865
|
+
name: "getCurrentNonce",
|
|
866
|
+
inputs: [],
|
|
867
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
868
|
+
stateMutability: "view"
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
type: "function",
|
|
872
|
+
name: "vetoActions",
|
|
873
|
+
inputs: [
|
|
874
|
+
{ name: "actionsNonces", type: "uint256[]" }
|
|
875
|
+
],
|
|
876
|
+
outputs: [],
|
|
877
|
+
stateMutability: "nonpayable"
|
|
878
|
+
}
|
|
879
|
+
];
|
|
880
|
+
var DEX_ABI = [
|
|
881
|
+
{
|
|
882
|
+
type: "function",
|
|
883
|
+
name: "executeSwap",
|
|
884
|
+
inputs: [
|
|
885
|
+
{
|
|
886
|
+
name: "params",
|
|
887
|
+
type: "tuple",
|
|
888
|
+
components: [
|
|
889
|
+
{ name: "targetContract", type: "address" },
|
|
890
|
+
{ name: "tokenIn", type: "address" },
|
|
891
|
+
{ name: "tokenOut", type: "address" },
|
|
892
|
+
{ name: "maxAmountIn", type: "uint256" },
|
|
893
|
+
{ name: "minAmountOut", type: "uint256" },
|
|
894
|
+
{ name: "swapCallData", type: "bytes" }
|
|
895
|
+
]
|
|
896
|
+
}
|
|
897
|
+
],
|
|
898
|
+
outputs: [{ name: "amountOut", type: "uint256" }],
|
|
899
|
+
stateMutability: "nonpayable"
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
type: "function",
|
|
903
|
+
name: "executeBatchSwap",
|
|
904
|
+
inputs: [
|
|
905
|
+
{
|
|
906
|
+
name: "params",
|
|
907
|
+
type: "tuple",
|
|
908
|
+
components: [
|
|
909
|
+
{
|
|
910
|
+
name: "swaps",
|
|
911
|
+
type: "tuple[]",
|
|
912
|
+
components: [
|
|
913
|
+
{ name: "targetContract", type: "address" },
|
|
914
|
+
{ name: "tokenIn", type: "address" },
|
|
915
|
+
{ name: "tokenOut", type: "address" },
|
|
916
|
+
{ name: "maxAmountIn", type: "uint256" },
|
|
917
|
+
{ name: "minAmountOut", type: "uint256" },
|
|
918
|
+
{ name: "swapCallData", type: "bytes" }
|
|
919
|
+
]
|
|
920
|
+
}
|
|
921
|
+
]
|
|
922
|
+
}
|
|
923
|
+
],
|
|
924
|
+
outputs: [{ name: "amountsOut", type: "uint256[]" }],
|
|
925
|
+
stateMutability: "nonpayable"
|
|
926
|
+
}
|
|
927
|
+
];
|
|
928
|
+
var BRIDGE_FACET_ABI = [
|
|
929
|
+
{
|
|
930
|
+
type: "function",
|
|
931
|
+
name: "executeBridging",
|
|
932
|
+
inputs: [
|
|
933
|
+
{ name: "adapter", type: "address" },
|
|
934
|
+
{ name: "token", type: "address" },
|
|
935
|
+
{ name: "amount", type: "uint256" },
|
|
936
|
+
{ name: "bridgeSpecificParams", type: "bytes" }
|
|
937
|
+
],
|
|
938
|
+
outputs: [],
|
|
939
|
+
stateMutability: "payable"
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
type: "function",
|
|
943
|
+
name: "initVaultActionRequest",
|
|
944
|
+
inputs: [
|
|
945
|
+
{ name: "actionType", type: "uint8" },
|
|
946
|
+
{ name: "actionCallData", type: "bytes" },
|
|
947
|
+
{ name: "amountLimit", type: "uint256" },
|
|
948
|
+
{ name: "extraOptions", type: "bytes" }
|
|
949
|
+
],
|
|
950
|
+
outputs: [{ name: "guid", type: "bytes32" }],
|
|
951
|
+
stateMutability: "payable"
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
type: "function",
|
|
955
|
+
name: "executeRequest",
|
|
956
|
+
inputs: [
|
|
957
|
+
{ name: "guid", type: "bytes32" }
|
|
958
|
+
],
|
|
959
|
+
outputs: [],
|
|
960
|
+
stateMutability: "nonpayable"
|
|
961
|
+
}
|
|
962
|
+
];
|
|
963
|
+
var ERC7540_FACET_ABI = [
|
|
964
|
+
{
|
|
965
|
+
type: "function",
|
|
966
|
+
name: "erc7540RequestDeposit",
|
|
967
|
+
inputs: [
|
|
968
|
+
{ name: "vault", type: "address" },
|
|
969
|
+
{ name: "assets", type: "uint256" }
|
|
970
|
+
],
|
|
971
|
+
outputs: [{ name: "requestId", type: "uint256" }],
|
|
972
|
+
stateMutability: "nonpayable"
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
type: "function",
|
|
976
|
+
name: "erc7540RequestRedeem",
|
|
977
|
+
inputs: [
|
|
978
|
+
{ name: "vault", type: "address" },
|
|
979
|
+
{ name: "shares", type: "uint256" }
|
|
980
|
+
],
|
|
981
|
+
outputs: [{ name: "requestId", type: "uint256" }],
|
|
982
|
+
stateMutability: "nonpayable"
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
type: "function",
|
|
986
|
+
name: "erc7540Deposit",
|
|
987
|
+
inputs: [
|
|
988
|
+
{ name: "vault", type: "address" },
|
|
989
|
+
{ name: "assets", type: "uint256" }
|
|
990
|
+
],
|
|
991
|
+
outputs: [{ name: "shares", type: "uint256" }],
|
|
992
|
+
stateMutability: "nonpayable"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
type: "function",
|
|
996
|
+
name: "erc7540Redeem",
|
|
997
|
+
inputs: [
|
|
998
|
+
{ name: "vault", type: "address" },
|
|
999
|
+
{ name: "shares", type: "uint256" }
|
|
1000
|
+
],
|
|
1001
|
+
outputs: [{ name: "assets", type: "uint256" }],
|
|
1002
|
+
stateMutability: "nonpayable"
|
|
1003
|
+
}
|
|
1004
|
+
];
|
|
1005
|
+
var CURATOR_CONFIG_ABI = [
|
|
1006
|
+
{
|
|
1007
|
+
type: "function",
|
|
1008
|
+
name: "curator",
|
|
1009
|
+
inputs: [],
|
|
1010
|
+
outputs: [{ name: "", type: "address" }],
|
|
1011
|
+
stateMutability: "view"
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
type: "function",
|
|
1015
|
+
name: "timeLockPeriod",
|
|
1016
|
+
inputs: [],
|
|
1017
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
1018
|
+
stateMutability: "view"
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
type: "function",
|
|
1022
|
+
name: "getAvailableAssets",
|
|
1023
|
+
inputs: [],
|
|
1024
|
+
outputs: [{ name: "", type: "address[]" }],
|
|
1025
|
+
stateMutability: "view"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
type: "function",
|
|
1029
|
+
name: "getMaxSlippagePercent",
|
|
1030
|
+
inputs: [],
|
|
1031
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
1032
|
+
stateMutability: "view"
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
type: "function",
|
|
1036
|
+
name: "getCrossChainAccountingManager",
|
|
1037
|
+
inputs: [],
|
|
1038
|
+
outputs: [{ name: "", type: "address" }],
|
|
1039
|
+
stateMutability: "view"
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
type: "function",
|
|
1043
|
+
name: "paused",
|
|
1044
|
+
inputs: [],
|
|
1045
|
+
outputs: [{ name: "", type: "bool" }],
|
|
1046
|
+
stateMutability: "view"
|
|
1047
|
+
}
|
|
1048
|
+
];
|
|
1049
|
+
var LZ_ADAPTER_ABI = [
|
|
1050
|
+
{
|
|
1051
|
+
type: "function",
|
|
1052
|
+
name: "quoteBridgeFee",
|
|
1053
|
+
inputs: [
|
|
1054
|
+
{ name: "bridgeSpecificParams", type: "bytes" }
|
|
1055
|
+
],
|
|
1056
|
+
outputs: [{ name: "nativeFee", type: "uint256" }],
|
|
1057
|
+
stateMutability: "view"
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
type: "function",
|
|
1061
|
+
name: "quoteReadFee",
|
|
1062
|
+
inputs: [
|
|
1063
|
+
{ name: "vaults", type: "address[]" },
|
|
1064
|
+
{ name: "eids", type: "uint32[]" },
|
|
1065
|
+
{ name: "_extraOptions", type: "bytes" }
|
|
1066
|
+
],
|
|
1067
|
+
outputs: [
|
|
1068
|
+
{
|
|
1069
|
+
name: "fee",
|
|
1070
|
+
type: "tuple",
|
|
1071
|
+
components: [
|
|
1072
|
+
{ name: "nativeFee", type: "uint256" },
|
|
1073
|
+
{ name: "lzTokenFee", type: "uint256" }
|
|
1074
|
+
]
|
|
1075
|
+
}
|
|
1076
|
+
],
|
|
1077
|
+
stateMutability: "view"
|
|
1078
|
+
}
|
|
1079
|
+
];
|
|
1080
|
+
var ERC4626_FACET_ABI = [
|
|
1081
|
+
{
|
|
1082
|
+
type: "function",
|
|
1083
|
+
name: "erc4626Deposit",
|
|
1084
|
+
inputs: [
|
|
1085
|
+
{ name: "vault", type: "address" },
|
|
1086
|
+
{ name: "assets", type: "uint256" }
|
|
1087
|
+
],
|
|
1088
|
+
outputs: [{ name: "shares", type: "uint256" }],
|
|
1089
|
+
stateMutability: "nonpayable"
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
type: "function",
|
|
1093
|
+
name: "erc4626Redeem",
|
|
1094
|
+
inputs: [
|
|
1095
|
+
{ name: "vault", type: "address" },
|
|
1096
|
+
{ name: "shares", type: "uint256" }
|
|
1097
|
+
],
|
|
1098
|
+
outputs: [{ name: "assets", type: "uint256" }],
|
|
1099
|
+
stateMutability: "nonpayable"
|
|
1100
|
+
}
|
|
1101
|
+
];
|
|
1102
|
+
var VAULT_ANALYSIS_ABI = [
|
|
1103
|
+
// Asset management reads
|
|
1104
|
+
{ type: "function", name: "getAvailableAssets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" },
|
|
1105
|
+
{ type: "function", name: "getDepositableAssets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" },
|
|
1106
|
+
{ type: "function", name: "isAssetAvailable", inputs: [{ name: "asset", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1107
|
+
{ type: "function", name: "isAssetDepositable", inputs: [{ name: "asset", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1108
|
+
// Deposit whitelist
|
|
1109
|
+
{ type: "function", name: "isDepositWhitelistEnabled", inputs: [], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1110
|
+
{ type: "function", name: "getAvailableToDeposit", inputs: [{ name: "depositor", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "view" },
|
|
1111
|
+
// Registry
|
|
1112
|
+
{ type: "function", name: "moreVaultsRegistry", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" }
|
|
1113
|
+
];
|
|
1114
|
+
var REGISTRY_ABI = [
|
|
1115
|
+
{ type: "function", name: "isWhitelisted", inputs: [{ name: "protocol", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1116
|
+
{ type: "function", name: "isBridgeAllowed", inputs: [{ name: "bridge", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1117
|
+
{ type: "function", name: "getAllowedFacets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" }
|
|
1118
|
+
];
|
|
832
1119
|
var LZ_ENDPOINT_ABI = [
|
|
833
1120
|
{
|
|
834
1121
|
type: "function",
|
|
@@ -2838,12 +3125,21 @@ async function canDeposit(publicClient, vault, user) {
|
|
|
2838
3125
|
],
|
|
2839
3126
|
allowFailure: false
|
|
2840
3127
|
});
|
|
3128
|
+
let whitelistEnabled = false;
|
|
3129
|
+
try {
|
|
3130
|
+
whitelistEnabled = await publicClient.readContract({
|
|
3131
|
+
address: v,
|
|
3132
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3133
|
+
functionName: "isDepositWhitelistEnabled"
|
|
3134
|
+
});
|
|
3135
|
+
} catch {
|
|
3136
|
+
}
|
|
2841
3137
|
if (isPaused) {
|
|
2842
|
-
return { allowed: false, reason: "paused" };
|
|
3138
|
+
return { allowed: false, reason: "paused", whitelistEnabled };
|
|
2843
3139
|
}
|
|
2844
3140
|
const isCrossChainAsync = isHub && !oraclesEnabled;
|
|
2845
3141
|
if (isCrossChainAsync) {
|
|
2846
|
-
return { allowed: true, reason: "ok" };
|
|
3142
|
+
return { allowed: true, reason: "ok", whitelistEnabled };
|
|
2847
3143
|
}
|
|
2848
3144
|
let maxDepositAmount;
|
|
2849
3145
|
try {
|
|
@@ -2854,12 +3150,12 @@ async function canDeposit(publicClient, vault, user) {
|
|
|
2854
3150
|
args: [viem.getAddress(user)]
|
|
2855
3151
|
});
|
|
2856
3152
|
} catch {
|
|
2857
|
-
return { allowed: false, reason: "not-whitelisted" };
|
|
3153
|
+
return { allowed: false, reason: "not-whitelisted", maxDeposit: 0n, whitelistEnabled };
|
|
2858
3154
|
}
|
|
2859
3155
|
if (maxDepositAmount === 0n) {
|
|
2860
|
-
return { allowed: false, reason: "capacity-full" };
|
|
3156
|
+
return { allowed: false, reason: "capacity-full", maxDeposit: 0n, whitelistEnabled };
|
|
2861
3157
|
}
|
|
2862
|
-
return { allowed: true, reason: "ok" };
|
|
3158
|
+
return { allowed: true, reason: "ok", maxDeposit: maxDepositAmount, whitelistEnabled };
|
|
2863
3159
|
}
|
|
2864
3160
|
async function getVaultMetadata(publicClient, vault) {
|
|
2865
3161
|
const v = viem.getAddress(vault);
|
|
@@ -3203,6 +3499,290 @@ async function getVaultDistributionWithTopology(hubClient, vault) {
|
|
|
3203
3499
|
spokeChainIds: topology.spokeChainIds
|
|
3204
3500
|
};
|
|
3205
3501
|
}
|
|
3502
|
+
async function getCuratorVaultStatus(publicClient, vault) {
|
|
3503
|
+
const v = viem.getAddress(vault);
|
|
3504
|
+
const [
|
|
3505
|
+
curator,
|
|
3506
|
+
timeLockPeriod,
|
|
3507
|
+
maxSlippagePercent,
|
|
3508
|
+
currentNonce,
|
|
3509
|
+
availableAssets,
|
|
3510
|
+
lzAdapter,
|
|
3511
|
+
paused
|
|
3512
|
+
] = await publicClient.multicall({
|
|
3513
|
+
contracts: [
|
|
3514
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "curator" },
|
|
3515
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "timeLockPeriod" },
|
|
3516
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "getMaxSlippagePercent" },
|
|
3517
|
+
{ address: v, abi: MULTICALL_ABI, functionName: "getCurrentNonce" },
|
|
3518
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "getAvailableAssets" },
|
|
3519
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "getCrossChainAccountingManager" },
|
|
3520
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "paused" }
|
|
3521
|
+
],
|
|
3522
|
+
allowFailure: false
|
|
3523
|
+
});
|
|
3524
|
+
return {
|
|
3525
|
+
curator: viem.getAddress(curator),
|
|
3526
|
+
timeLockPeriod,
|
|
3527
|
+
maxSlippagePercent,
|
|
3528
|
+
currentNonce,
|
|
3529
|
+
availableAssets: availableAssets.map(viem.getAddress),
|
|
3530
|
+
lzAdapter: viem.getAddress(lzAdapter),
|
|
3531
|
+
paused
|
|
3532
|
+
};
|
|
3533
|
+
}
|
|
3534
|
+
async function getPendingActions(publicClient, vault, nonce) {
|
|
3535
|
+
const v = viem.getAddress(vault);
|
|
3536
|
+
const [actionsResult, block] = await Promise.all([
|
|
3537
|
+
publicClient.readContract({
|
|
3538
|
+
address: v,
|
|
3539
|
+
abi: MULTICALL_ABI,
|
|
3540
|
+
functionName: "getPendingActions",
|
|
3541
|
+
args: [nonce]
|
|
3542
|
+
}),
|
|
3543
|
+
publicClient.getBlock()
|
|
3544
|
+
]);
|
|
3545
|
+
const [actionsData, pendingUntil] = actionsResult;
|
|
3546
|
+
const isExecutable = pendingUntil > 0n && block.timestamp >= pendingUntil;
|
|
3547
|
+
return {
|
|
3548
|
+
nonce,
|
|
3549
|
+
actionsData,
|
|
3550
|
+
pendingUntil,
|
|
3551
|
+
isExecutable
|
|
3552
|
+
};
|
|
3553
|
+
}
|
|
3554
|
+
async function isCurator(publicClient, vault, address) {
|
|
3555
|
+
const curatorAddress = await publicClient.readContract({
|
|
3556
|
+
address: viem.getAddress(vault),
|
|
3557
|
+
abi: CURATOR_CONFIG_ABI,
|
|
3558
|
+
functionName: "curator"
|
|
3559
|
+
});
|
|
3560
|
+
return viem.getAddress(curatorAddress) === viem.getAddress(address);
|
|
3561
|
+
}
|
|
3562
|
+
async function getVaultAnalysis(publicClient, vault) {
|
|
3563
|
+
const v = viem.getAddress(vault);
|
|
3564
|
+
const [availableRaw, depositableRaw, depositWhitelistEnabled, registryResult] = await Promise.all([
|
|
3565
|
+
publicClient.readContract({
|
|
3566
|
+
address: v,
|
|
3567
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3568
|
+
functionName: "getAvailableAssets"
|
|
3569
|
+
}),
|
|
3570
|
+
publicClient.readContract({
|
|
3571
|
+
address: v,
|
|
3572
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3573
|
+
functionName: "getDepositableAssets"
|
|
3574
|
+
}),
|
|
3575
|
+
publicClient.readContract({
|
|
3576
|
+
address: v,
|
|
3577
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3578
|
+
functionName: "isDepositWhitelistEnabled"
|
|
3579
|
+
}),
|
|
3580
|
+
publicClient.readContract({
|
|
3581
|
+
address: v,
|
|
3582
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3583
|
+
functionName: "moreVaultsRegistry"
|
|
3584
|
+
}).catch(() => null)
|
|
3585
|
+
]);
|
|
3586
|
+
const availableAddresses = availableRaw.map(viem.getAddress);
|
|
3587
|
+
const depositableAddresses = depositableRaw.map(viem.getAddress);
|
|
3588
|
+
const allAddresses = Array.from(/* @__PURE__ */ new Set([...availableAddresses, ...depositableAddresses]));
|
|
3589
|
+
const metadataCalls = allAddresses.flatMap((addr) => [
|
|
3590
|
+
{ address: addr, abi: METADATA_ABI, functionName: "name" },
|
|
3591
|
+
{ address: addr, abi: METADATA_ABI, functionName: "symbol" },
|
|
3592
|
+
{ address: addr, abi: METADATA_ABI, functionName: "decimals" }
|
|
3593
|
+
]);
|
|
3594
|
+
const metadataResults = allAddresses.length > 0 ? await publicClient.multicall({ contracts: metadataCalls, allowFailure: true }) : [];
|
|
3595
|
+
const assetInfoMap = /* @__PURE__ */ new Map();
|
|
3596
|
+
for (let i = 0; i < allAddresses.length; i++) {
|
|
3597
|
+
const addr = allAddresses[i];
|
|
3598
|
+
const nameResult = metadataResults[i * 3];
|
|
3599
|
+
const symbolResult = metadataResults[i * 3 + 1];
|
|
3600
|
+
const decimalsResult = metadataResults[i * 3 + 2];
|
|
3601
|
+
assetInfoMap.set(addr, {
|
|
3602
|
+
address: addr,
|
|
3603
|
+
name: nameResult?.status === "success" ? nameResult.result : "",
|
|
3604
|
+
symbol: symbolResult?.status === "success" ? symbolResult.result : "",
|
|
3605
|
+
decimals: decimalsResult?.status === "success" ? decimalsResult.result : 18
|
|
3606
|
+
});
|
|
3607
|
+
}
|
|
3608
|
+
const registryAddress = registryResult ? viem.getAddress(registryResult) : null;
|
|
3609
|
+
return {
|
|
3610
|
+
availableAssets: availableAddresses.map((a) => assetInfoMap.get(a)),
|
|
3611
|
+
depositableAssets: depositableAddresses.map((a) => assetInfoMap.get(a)),
|
|
3612
|
+
depositWhitelistEnabled,
|
|
3613
|
+
registryAddress
|
|
3614
|
+
};
|
|
3615
|
+
}
|
|
3616
|
+
async function checkProtocolWhitelist(publicClient, vault, protocols) {
|
|
3617
|
+
const v = viem.getAddress(vault);
|
|
3618
|
+
const registryRaw = await publicClient.readContract({
|
|
3619
|
+
address: v,
|
|
3620
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3621
|
+
functionName: "moreVaultsRegistry"
|
|
3622
|
+
});
|
|
3623
|
+
const registry = viem.getAddress(registryRaw);
|
|
3624
|
+
if (protocols.length === 0) return {};
|
|
3625
|
+
const results = await publicClient.multicall({
|
|
3626
|
+
contracts: protocols.map((protocol) => ({
|
|
3627
|
+
address: registry,
|
|
3628
|
+
abi: REGISTRY_ABI,
|
|
3629
|
+
functionName: "isWhitelisted",
|
|
3630
|
+
args: [viem.getAddress(protocol)]
|
|
3631
|
+
})),
|
|
3632
|
+
allowFailure: true
|
|
3633
|
+
});
|
|
3634
|
+
const out = {};
|
|
3635
|
+
for (let i = 0; i < protocols.length; i++) {
|
|
3636
|
+
const r = results[i];
|
|
3637
|
+
out[viem.getAddress(protocols[i])] = r?.status === "success" ? r.result : false;
|
|
3638
|
+
}
|
|
3639
|
+
return out;
|
|
3640
|
+
}
|
|
3641
|
+
function encodeCuratorAction(action) {
|
|
3642
|
+
switch (action.type) {
|
|
3643
|
+
case "swap":
|
|
3644
|
+
return viem.encodeFunctionData({
|
|
3645
|
+
abi: DEX_ABI,
|
|
3646
|
+
functionName: "executeSwap",
|
|
3647
|
+
args: [
|
|
3648
|
+
{
|
|
3649
|
+
targetContract: viem.getAddress(action.params.targetContract),
|
|
3650
|
+
tokenIn: viem.getAddress(action.params.tokenIn),
|
|
3651
|
+
tokenOut: viem.getAddress(action.params.tokenOut),
|
|
3652
|
+
maxAmountIn: action.params.maxAmountIn,
|
|
3653
|
+
minAmountOut: action.params.minAmountOut,
|
|
3654
|
+
swapCallData: action.params.swapCallData
|
|
3655
|
+
}
|
|
3656
|
+
]
|
|
3657
|
+
});
|
|
3658
|
+
case "batchSwap":
|
|
3659
|
+
return viem.encodeFunctionData({
|
|
3660
|
+
abi: DEX_ABI,
|
|
3661
|
+
functionName: "executeBatchSwap",
|
|
3662
|
+
args: [
|
|
3663
|
+
{
|
|
3664
|
+
swaps: action.params.swaps.map((s) => ({
|
|
3665
|
+
targetContract: viem.getAddress(s.targetContract),
|
|
3666
|
+
tokenIn: viem.getAddress(s.tokenIn),
|
|
3667
|
+
tokenOut: viem.getAddress(s.tokenOut),
|
|
3668
|
+
maxAmountIn: s.maxAmountIn,
|
|
3669
|
+
minAmountOut: s.minAmountOut,
|
|
3670
|
+
swapCallData: s.swapCallData
|
|
3671
|
+
}))
|
|
3672
|
+
}
|
|
3673
|
+
]
|
|
3674
|
+
});
|
|
3675
|
+
case "erc4626Deposit":
|
|
3676
|
+
return viem.encodeFunctionData({
|
|
3677
|
+
abi: ERC4626_FACET_ABI,
|
|
3678
|
+
functionName: "erc4626Deposit",
|
|
3679
|
+
args: [viem.getAddress(action.vault), action.assets]
|
|
3680
|
+
});
|
|
3681
|
+
case "erc4626Redeem":
|
|
3682
|
+
return viem.encodeFunctionData({
|
|
3683
|
+
abi: ERC4626_FACET_ABI,
|
|
3684
|
+
functionName: "erc4626Redeem",
|
|
3685
|
+
args: [viem.getAddress(action.vault), action.shares]
|
|
3686
|
+
});
|
|
3687
|
+
case "erc7540RequestDeposit":
|
|
3688
|
+
return viem.encodeFunctionData({
|
|
3689
|
+
abi: ERC7540_FACET_ABI,
|
|
3690
|
+
functionName: "erc7540RequestDeposit",
|
|
3691
|
+
args: [viem.getAddress(action.vault), action.assets]
|
|
3692
|
+
});
|
|
3693
|
+
case "erc7540Deposit":
|
|
3694
|
+
return viem.encodeFunctionData({
|
|
3695
|
+
abi: ERC7540_FACET_ABI,
|
|
3696
|
+
functionName: "erc7540Deposit",
|
|
3697
|
+
args: [viem.getAddress(action.vault), action.assets]
|
|
3698
|
+
});
|
|
3699
|
+
case "erc7540RequestRedeem":
|
|
3700
|
+
return viem.encodeFunctionData({
|
|
3701
|
+
abi: ERC7540_FACET_ABI,
|
|
3702
|
+
functionName: "erc7540RequestRedeem",
|
|
3703
|
+
args: [viem.getAddress(action.vault), action.shares]
|
|
3704
|
+
});
|
|
3705
|
+
case "erc7540Redeem":
|
|
3706
|
+
return viem.encodeFunctionData({
|
|
3707
|
+
abi: ERC7540_FACET_ABI,
|
|
3708
|
+
functionName: "erc7540Redeem",
|
|
3709
|
+
args: [viem.getAddress(action.vault), action.shares]
|
|
3710
|
+
});
|
|
3711
|
+
default: {
|
|
3712
|
+
const _exhaustive = action;
|
|
3713
|
+
throw new Error(`[MoreVaults] Unknown CuratorAction type: ${_exhaustive.type}`);
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
function buildCuratorBatch(actions) {
|
|
3718
|
+
return actions.map(encodeCuratorAction);
|
|
3719
|
+
}
|
|
3720
|
+
async function submitActions(walletClient, publicClient, vault, actions) {
|
|
3721
|
+
const account = walletClient.account;
|
|
3722
|
+
const v = viem.getAddress(vault);
|
|
3723
|
+
await publicClient.simulateContract({
|
|
3724
|
+
address: v,
|
|
3725
|
+
abi: MULTICALL_ABI,
|
|
3726
|
+
functionName: "submitActions",
|
|
3727
|
+
args: [actions],
|
|
3728
|
+
account: account.address
|
|
3729
|
+
});
|
|
3730
|
+
const txHash = await walletClient.writeContract({
|
|
3731
|
+
address: v,
|
|
3732
|
+
abi: MULTICALL_ABI,
|
|
3733
|
+
functionName: "submitActions",
|
|
3734
|
+
args: [actions],
|
|
3735
|
+
account,
|
|
3736
|
+
chain: walletClient.chain
|
|
3737
|
+
});
|
|
3738
|
+
const nextNonce = await publicClient.readContract({
|
|
3739
|
+
address: v,
|
|
3740
|
+
abi: MULTICALL_ABI,
|
|
3741
|
+
functionName: "getCurrentNonce"
|
|
3742
|
+
});
|
|
3743
|
+
const nonce = nextNonce - 1n;
|
|
3744
|
+
return { txHash, nonce };
|
|
3745
|
+
}
|
|
3746
|
+
async function executeActions(walletClient, publicClient, vault, nonce) {
|
|
3747
|
+
const account = walletClient.account;
|
|
3748
|
+
const v = viem.getAddress(vault);
|
|
3749
|
+
await publicClient.simulateContract({
|
|
3750
|
+
address: v,
|
|
3751
|
+
abi: MULTICALL_ABI,
|
|
3752
|
+
functionName: "executeActions",
|
|
3753
|
+
args: [nonce],
|
|
3754
|
+
account: account.address
|
|
3755
|
+
});
|
|
3756
|
+
const txHash = await walletClient.writeContract({
|
|
3757
|
+
address: v,
|
|
3758
|
+
abi: MULTICALL_ABI,
|
|
3759
|
+
functionName: "executeActions",
|
|
3760
|
+
args: [nonce],
|
|
3761
|
+
account,
|
|
3762
|
+
chain: walletClient.chain
|
|
3763
|
+
});
|
|
3764
|
+
return { txHash };
|
|
3765
|
+
}
|
|
3766
|
+
async function vetoActions(walletClient, publicClient, vault, nonces) {
|
|
3767
|
+
const account = walletClient.account;
|
|
3768
|
+
const v = viem.getAddress(vault);
|
|
3769
|
+
await publicClient.simulateContract({
|
|
3770
|
+
address: v,
|
|
3771
|
+
abi: MULTICALL_ABI,
|
|
3772
|
+
functionName: "vetoActions",
|
|
3773
|
+
args: [nonces],
|
|
3774
|
+
account: account.address
|
|
3775
|
+
});
|
|
3776
|
+
const txHash = await walletClient.writeContract({
|
|
3777
|
+
address: v,
|
|
3778
|
+
abi: MULTICALL_ABI,
|
|
3779
|
+
functionName: "vetoActions",
|
|
3780
|
+
args: [nonces],
|
|
3781
|
+
account,
|
|
3782
|
+
chain: walletClient.chain
|
|
3783
|
+
});
|
|
3784
|
+
return { txHash };
|
|
3785
|
+
}
|
|
3206
3786
|
|
|
3207
3787
|
// src/viem/wagmiCompat.ts
|
|
3208
3788
|
function asSdkClient(client) {
|
|
@@ -3212,19 +3792,26 @@ function asSdkClient(client) {
|
|
|
3212
3792
|
|
|
3213
3793
|
exports.ActionType = ActionType;
|
|
3214
3794
|
exports.BRIDGE_ABI = BRIDGE_ABI;
|
|
3795
|
+
exports.BRIDGE_FACET_ABI = BRIDGE_FACET_ABI;
|
|
3215
3796
|
exports.CCManagerNotConfiguredError = CCManagerNotConfiguredError;
|
|
3216
3797
|
exports.CHAIN_IDS = CHAIN_IDS;
|
|
3217
3798
|
exports.CHAIN_ID_TO_EID = CHAIN_ID_TO_EID;
|
|
3218
3799
|
exports.CONFIG_ABI = CONFIG_ABI;
|
|
3800
|
+
exports.CURATOR_CONFIG_ABI = CURATOR_CONFIG_ABI;
|
|
3219
3801
|
exports.CapacityFullError = CapacityFullError;
|
|
3802
|
+
exports.DEX_ABI = DEX_ABI;
|
|
3220
3803
|
exports.EID_TO_CHAIN_ID = EID_TO_CHAIN_ID;
|
|
3221
3804
|
exports.ERC20_ABI = ERC20_ABI;
|
|
3805
|
+
exports.ERC4626_FACET_ABI = ERC4626_FACET_ABI;
|
|
3806
|
+
exports.ERC7540_FACET_ABI = ERC7540_FACET_ABI;
|
|
3222
3807
|
exports.EscrowNotConfiguredError = EscrowNotConfiguredError;
|
|
3223
3808
|
exports.InsufficientLiquidityError = InsufficientLiquidityError;
|
|
3809
|
+
exports.LZ_ADAPTER_ABI = LZ_ADAPTER_ABI;
|
|
3224
3810
|
exports.LZ_EIDS = LZ_EIDS;
|
|
3225
3811
|
exports.LZ_ENDPOINT_ABI = LZ_ENDPOINT_ABI;
|
|
3226
3812
|
exports.LZ_TIMEOUTS = LZ_TIMEOUTS;
|
|
3227
3813
|
exports.METADATA_ABI = METADATA_ABI;
|
|
3814
|
+
exports.MULTICALL_ABI = MULTICALL_ABI;
|
|
3228
3815
|
exports.MissingEscrowAddressError = MissingEscrowAddressError;
|
|
3229
3816
|
exports.MoreVaultsError = MoreVaultsError;
|
|
3230
3817
|
exports.NATIVE_SYMBOL = NATIVE_SYMBOL;
|
|
@@ -3233,16 +3820,20 @@ exports.NotWhitelistedError = NotWhitelistedError;
|
|
|
3233
3820
|
exports.OFT_ABI = OFT_ABI;
|
|
3234
3821
|
exports.OFT_ROUTES = OFT_ROUTES;
|
|
3235
3822
|
exports.OMNI_FACTORY_ADDRESS = OMNI_FACTORY_ADDRESS;
|
|
3823
|
+
exports.REGISTRY_ABI = REGISTRY_ABI;
|
|
3236
3824
|
exports.STARGATE_TAXI_CMD = STARGATE_TAXI_CMD;
|
|
3237
3825
|
exports.USDC_STARGATE_OFT = USDC_STARGATE_OFT;
|
|
3238
3826
|
exports.USDC_TOKEN = USDC_TOKEN;
|
|
3239
3827
|
exports.VAULT_ABI = VAULT_ABI;
|
|
3828
|
+
exports.VAULT_ANALYSIS_ABI = VAULT_ANALYSIS_ABI;
|
|
3240
3829
|
exports.VaultPausedError = VaultPausedError;
|
|
3241
3830
|
exports.WrongChainError = WrongChainError;
|
|
3242
3831
|
exports.asSdkClient = asSdkClient;
|
|
3243
3832
|
exports.bridgeAssetsToSpoke = bridgeAssetsToSpoke;
|
|
3244
3833
|
exports.bridgeSharesToHub = bridgeSharesToHub;
|
|
3834
|
+
exports.buildCuratorBatch = buildCuratorBatch;
|
|
3245
3835
|
exports.canDeposit = canDeposit;
|
|
3836
|
+
exports.checkProtocolWhitelist = checkProtocolWhitelist;
|
|
3246
3837
|
exports.depositAsync = depositAsync;
|
|
3247
3838
|
exports.depositCrossChainOracleOn = depositSimple;
|
|
3248
3839
|
exports.depositFromSpoke = depositFromSpoke;
|
|
@@ -3250,19 +3841,24 @@ exports.depositFromSpokeAsync = depositFromSpoke;
|
|
|
3250
3841
|
exports.depositMultiAsset = depositMultiAsset;
|
|
3251
3842
|
exports.depositSimple = depositSimple;
|
|
3252
3843
|
exports.discoverVaultTopology = discoverVaultTopology;
|
|
3844
|
+
exports.encodeCuratorAction = encodeCuratorAction;
|
|
3253
3845
|
exports.ensureAllowance = ensureAllowance;
|
|
3846
|
+
exports.executeActions = executeActions;
|
|
3254
3847
|
exports.executeCompose = executeCompose;
|
|
3255
3848
|
exports.getAllVaultChainIds = getAllVaultChainIds;
|
|
3256
3849
|
exports.getAsyncRequestStatus = getAsyncRequestStatus;
|
|
3257
3850
|
exports.getAsyncRequestStatusLabel = getAsyncRequestStatusLabel;
|
|
3851
|
+
exports.getCuratorVaultStatus = getCuratorVaultStatus;
|
|
3258
3852
|
exports.getFullVaultTopology = getFullVaultTopology;
|
|
3259
3853
|
exports.getInboundRoutes = getInboundRoutes;
|
|
3260
3854
|
exports.getMaxWithdrawable = getMaxWithdrawable;
|
|
3261
3855
|
exports.getOutboundRoutes = getOutboundRoutes;
|
|
3856
|
+
exports.getPendingActions = getPendingActions;
|
|
3262
3857
|
exports.getUserBalances = getUserBalances;
|
|
3263
3858
|
exports.getUserBalancesForRoutes = getUserBalancesForRoutes;
|
|
3264
3859
|
exports.getUserPosition = getUserPosition;
|
|
3265
3860
|
exports.getUserPositionMultiChain = getUserPositionMultiChain;
|
|
3861
|
+
exports.getVaultAnalysis = getVaultAnalysis;
|
|
3266
3862
|
exports.getVaultDistribution = getVaultDistribution;
|
|
3267
3863
|
exports.getVaultDistributionWithTopology = getVaultDistributionWithTopology;
|
|
3268
3864
|
exports.getVaultMetadata = getVaultMetadata;
|
|
@@ -3271,6 +3867,7 @@ exports.getVaultSummary = getVaultSummary;
|
|
|
3271
3867
|
exports.getVaultTopology = getVaultTopology;
|
|
3272
3868
|
exports.getWithdrawalRequest = getWithdrawalRequest;
|
|
3273
3869
|
exports.isAsyncMode = isAsyncMode;
|
|
3870
|
+
exports.isCurator = isCurator;
|
|
3274
3871
|
exports.isOnHubChain = isOnHubChain;
|
|
3275
3872
|
exports.mintAsync = mintAsync;
|
|
3276
3873
|
exports.preflightAsync = preflightAsync;
|
|
@@ -3291,6 +3888,8 @@ exports.requestRedeem = requestRedeem;
|
|
|
3291
3888
|
exports.resolveRedeemAddresses = resolveRedeemAddresses;
|
|
3292
3889
|
exports.smartDeposit = smartDeposit;
|
|
3293
3890
|
exports.smartRedeem = smartRedeem;
|
|
3891
|
+
exports.submitActions = submitActions;
|
|
3892
|
+
exports.vetoActions = vetoActions;
|
|
3294
3893
|
exports.waitForAsyncRequest = waitForAsyncRequest;
|
|
3295
3894
|
exports.waitForCompose = waitForCompose;
|
|
3296
3895
|
exports.waitForTx = waitForTx;
|