@oydual31/more-vaults-sdk 0.4.2 → 0.5.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/README.md +44 -0
- package/dist/{spokeRoutes-B8Lnk-t4.d.cts → curatorBridge-DTW1lPF7.d.cts} +130 -1
- package/dist/{spokeRoutes-B8Lnk-t4.d.ts → curatorBridge-DTW1lPF7.d.ts} +130 -1
- package/dist/ethers/index.cjs +73 -0
- package/dist/ethers/index.cjs.map +1 -1
- package/dist/ethers/index.d.cts +103 -1
- package/dist/ethers/index.d.ts +103 -1
- package/dist/ethers/index.js +71 -2
- package/dist/ethers/index.js.map +1 -1
- package/dist/react/index.cjs +163 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +214 -2
- package/dist/react/index.d.ts +214 -2
- package/dist/react/index.js +162 -1
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +91 -0
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +2 -2
- package/dist/viem/index.d.ts +2 -2
- package/dist/viem/index.js +88 -1
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ethers/curatorBridge.ts +235 -0
- package/src/ethers/index.ts +9 -0
- package/src/react/index.ts +4 -0
- package/src/react/useCuratorBridgeQuote.ts +43 -0
- package/src/react/useExecuteBridge.ts +50 -0
- package/src/viem/curatorBridge.ts +288 -0
- package/src/viem/index.ts +7 -0
package/dist/viem/index.cjs
CHANGED
|
@@ -3947,6 +3947,93 @@ function buildUniswapV3Swap(params) {
|
|
|
3947
3947
|
}
|
|
3948
3948
|
};
|
|
3949
3949
|
}
|
|
3950
|
+
function encodeBridgeParams(params) {
|
|
3951
|
+
return viem.encodeAbiParameters(
|
|
3952
|
+
[
|
|
3953
|
+
{ type: "address" },
|
|
3954
|
+
{ type: "uint32" },
|
|
3955
|
+
{ type: "uint256" },
|
|
3956
|
+
{ type: "address" },
|
|
3957
|
+
{ type: "address" }
|
|
3958
|
+
],
|
|
3959
|
+
[
|
|
3960
|
+
viem.getAddress(params.oftToken),
|
|
3961
|
+
params.dstEid,
|
|
3962
|
+
params.amount,
|
|
3963
|
+
viem.getAddress(params.dstVault),
|
|
3964
|
+
viem.getAddress(params.refundAddress)
|
|
3965
|
+
]
|
|
3966
|
+
);
|
|
3967
|
+
}
|
|
3968
|
+
function encodeBridgeParamsForQuote(params) {
|
|
3969
|
+
return viem.encodeAbiParameters(
|
|
3970
|
+
[
|
|
3971
|
+
{ type: "address" },
|
|
3972
|
+
{ type: "uint32" },
|
|
3973
|
+
{ type: "uint256" },
|
|
3974
|
+
{ type: "address" }
|
|
3975
|
+
],
|
|
3976
|
+
[
|
|
3977
|
+
viem.getAddress(params.oftToken),
|
|
3978
|
+
params.dstEid,
|
|
3979
|
+
params.amount,
|
|
3980
|
+
viem.getAddress(params.dstVault)
|
|
3981
|
+
]
|
|
3982
|
+
);
|
|
3983
|
+
}
|
|
3984
|
+
function findBridgeRoute(srcChainId, dstChainId, tokenAddress) {
|
|
3985
|
+
const normalizedToken = viem.getAddress(tokenAddress);
|
|
3986
|
+
for (const [symbol, chains] of Object.entries(OFT_ROUTES)) {
|
|
3987
|
+
const srcEntry = chains[srcChainId];
|
|
3988
|
+
const dstEntry = chains[dstChainId];
|
|
3989
|
+
if (!srcEntry || !dstEntry) continue;
|
|
3990
|
+
const srcToken = viem.getAddress(srcEntry.token);
|
|
3991
|
+
const srcOft = viem.getAddress(srcEntry.oft);
|
|
3992
|
+
if (srcToken === normalizedToken || srcOft === normalizedToken) {
|
|
3993
|
+
return {
|
|
3994
|
+
oftSrc: srcOft,
|
|
3995
|
+
oftDst: viem.getAddress(dstEntry.oft),
|
|
3996
|
+
symbol
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
return null;
|
|
4001
|
+
}
|
|
4002
|
+
async function quoteCuratorBridgeFee(publicClient, vault, params) {
|
|
4003
|
+
const status = await getCuratorVaultStatus(publicClient, vault);
|
|
4004
|
+
const lzAdapter = status.lzAdapter;
|
|
4005
|
+
const bridgeSpecificParams = encodeBridgeParamsForQuote(params);
|
|
4006
|
+
const nativeFee = await publicClient.readContract({
|
|
4007
|
+
address: lzAdapter,
|
|
4008
|
+
abi: LZ_ADAPTER_ABI,
|
|
4009
|
+
functionName: "quoteBridgeFee",
|
|
4010
|
+
args: [bridgeSpecificParams]
|
|
4011
|
+
});
|
|
4012
|
+
return nativeFee;
|
|
4013
|
+
}
|
|
4014
|
+
async function executeCuratorBridge(walletClient, publicClient, vault, token, params) {
|
|
4015
|
+
const account = walletClient.account;
|
|
4016
|
+
const v = viem.getAddress(vault);
|
|
4017
|
+
const status = await getCuratorVaultStatus(publicClient, vault);
|
|
4018
|
+
const lzAdapter = status.lzAdapter;
|
|
4019
|
+
const fee = await quoteCuratorBridgeFee(publicClient, vault, params);
|
|
4020
|
+
const bridgeSpecificParams = encodeBridgeParams(params);
|
|
4021
|
+
const txHash = await walletClient.writeContract({
|
|
4022
|
+
address: v,
|
|
4023
|
+
abi: BRIDGE_FACET_ABI,
|
|
4024
|
+
functionName: "executeBridging",
|
|
4025
|
+
args: [
|
|
4026
|
+
lzAdapter,
|
|
4027
|
+
viem.getAddress(token),
|
|
4028
|
+
params.amount,
|
|
4029
|
+
bridgeSpecificParams
|
|
4030
|
+
],
|
|
4031
|
+
value: fee,
|
|
4032
|
+
account,
|
|
4033
|
+
chain: walletClient.chain
|
|
4034
|
+
});
|
|
4035
|
+
return txHash;
|
|
4036
|
+
}
|
|
3950
4037
|
|
|
3951
4038
|
// src/viem/wagmiCompat.ts
|
|
3952
4039
|
function asSdkClient(client) {
|
|
@@ -4008,11 +4095,14 @@ exports.depositMultiAsset = depositMultiAsset;
|
|
|
4008
4095
|
exports.depositSimple = depositSimple;
|
|
4009
4096
|
exports.detectStargateOft = detectStargateOft;
|
|
4010
4097
|
exports.discoverVaultTopology = discoverVaultTopology;
|
|
4098
|
+
exports.encodeBridgeParams = encodeBridgeParams;
|
|
4011
4099
|
exports.encodeCuratorAction = encodeCuratorAction;
|
|
4012
4100
|
exports.encodeUniswapV3SwapCalldata = encodeUniswapV3SwapCalldata;
|
|
4013
4101
|
exports.ensureAllowance = ensureAllowance;
|
|
4014
4102
|
exports.executeActions = executeActions;
|
|
4015
4103
|
exports.executeCompose = executeCompose;
|
|
4104
|
+
exports.executeCuratorBridge = executeCuratorBridge;
|
|
4105
|
+
exports.findBridgeRoute = findBridgeRoute;
|
|
4016
4106
|
exports.getAllVaultChainIds = getAllVaultChainIds;
|
|
4017
4107
|
exports.getAsyncRequestStatus = getAsyncRequestStatus;
|
|
4018
4108
|
exports.getAsyncRequestStatusLabel = getAsyncRequestStatusLabel;
|
|
@@ -4047,6 +4137,7 @@ exports.preflightSync = preflightSync;
|
|
|
4047
4137
|
exports.previewDeposit = previewDeposit;
|
|
4048
4138
|
exports.previewRedeem = previewRedeem;
|
|
4049
4139
|
exports.quoteComposeFee = quoteComposeFee;
|
|
4140
|
+
exports.quoteCuratorBridgeFee = quoteCuratorBridgeFee;
|
|
4050
4141
|
exports.quoteDepositFromSpokeFee = quoteDepositFromSpokeFee;
|
|
4051
4142
|
exports.quoteLzFee = quoteLzFee;
|
|
4052
4143
|
exports.quoteRouteDepositFee = quoteRouteDepositFee;
|