@paxoslabs/amplify-sdk 0.0.1 → 0.1.0-alpha.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/CHANGELOG.md +22 -1
- package/README.md +5 -480
- package/dist/{amplify-sdk-api-DPrRhynk.d.mts → amplify-sdk-api-Biol0OIp.d.mts} +1 -1
- package/dist/{amplify-sdk-api-B5hBTGrB.d.ts → amplify-sdk-api-DGRgEybp.d.ts} +1 -1
- package/dist/{chunk-IBNTWZ4S.js → chunk-B2QCI6ET.js} +13 -35
- package/dist/chunk-B2QCI6ET.js.map +1 -0
- package/dist/{chunk-WFCHKDDG.mjs → chunk-CUGK4ZBJ.mjs} +13 -35
- package/dist/chunk-CUGK4ZBJ.mjs.map +1 -0
- package/dist/{chunk-BXUG3WDV.js → chunk-DTFLXAZJ.js} +27 -52
- package/dist/chunk-DTFLXAZJ.js.map +1 -0
- package/dist/{chunk-AIBI7ZQM.js → chunk-GS7TDQXA.js} +8 -8
- package/dist/{chunk-AIBI7ZQM.js.map → chunk-GS7TDQXA.js.map} +1 -1
- package/dist/{chunk-GBWBO6ZF.mjs → chunk-HI44AMLC.mjs} +8 -8
- package/dist/chunk-HI44AMLC.mjs.map +1 -0
- package/dist/{chunk-ZCVMGIMV.js → chunk-KYR6BFAE.js} +24 -24
- package/dist/chunk-KYR6BFAE.js.map +1 -0
- package/dist/{chunk-K4DL2AII.js → chunk-LSNRG5Z2.js} +4 -4
- package/dist/{chunk-K4DL2AII.js.map → chunk-LSNRG5Z2.js.map} +1 -1
- package/dist/{chunk-OPOYGPSS.mjs → chunk-REKEQLQA.mjs} +3 -3
- package/dist/{chunk-OPOYGPSS.mjs.map → chunk-REKEQLQA.mjs.map} +1 -1
- package/dist/{chunk-ZLS2AAMI.mjs → chunk-VIULRHK6.mjs} +3 -3
- package/dist/{chunk-ZLS2AAMI.mjs.map → chunk-VIULRHK6.mjs.map} +1 -1
- package/dist/{chunk-YP2TR5RP.mjs → chunk-ZILA73XN.mjs} +25 -50
- package/dist/chunk-ZILA73XN.mjs.map +1 -0
- package/dist/core.d.mts +6 -6
- package/dist/core.d.ts +6 -6
- package/dist/core.js +16 -16
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +6 -6
- package/dist/core.mjs.map +1 -1
- package/dist/display.d.mts +3 -3
- package/dist/display.d.ts +3 -3
- package/dist/display.js +16 -16
- package/dist/display.js.map +1 -1
- package/dist/display.mjs +8 -8
- package/dist/display.mjs.map +1 -1
- package/dist/{exchange-rate-CRA_CMaX.d.mts → exchange-rate-BfPH_fQt.d.mts} +4 -4
- package/dist/{exchange-rate-D3_FVgqa.d.ts → exchange-rate-Cp1ddpw4.d.ts} +4 -4
- package/dist/index.d.mts +245 -15
- package/dist/index.d.ts +245 -15
- package/dist/index.js +341 -145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +249 -53
- package/dist/index.mjs.map +1 -1
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +5 -5
- package/dist/utils.mjs +2 -2
- package/package.json +7 -7
- package/dist/chunk-BXUG3WDV.js.map +0 -1
- package/dist/chunk-GBWBO6ZF.mjs.map +0 -1
- package/dist/chunk-IBNTWZ4S.js.map +0 -1
- package/dist/chunk-WFCHKDDG.mjs.map +0 -1
- package/dist/chunk-YP2TR5RP.mjs.map +0 -1
- package/dist/chunk-ZCVMGIMV.js.map +0 -1
package/dist/display.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-
|
|
1
|
+
export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-BfPH_fQt.mjs';
|
|
2
2
|
import { Address } from 'viem';
|
|
3
3
|
import { C as ChainId } from './vault-config-BjSE7oL8.mjs';
|
|
4
4
|
import { V as VaultKey } from './config-BQynVNDC.mjs';
|
|
@@ -9,10 +9,10 @@ interface GetPreviewFeeParams {
|
|
|
9
9
|
bridgeAmount: bigint;
|
|
10
10
|
sourceChainId: ChainId;
|
|
11
11
|
destinationChainId: ChainId;
|
|
12
|
-
|
|
12
|
+
recipientAddress: Address;
|
|
13
13
|
nativeTokenForBridgeFee?: Address;
|
|
14
14
|
}
|
|
15
|
-
declare const getBridgeFee: ({ vaultKey, bridgeAmount, sourceChainId, destinationChainId,
|
|
15
|
+
declare const getBridgeFee: ({ vaultKey, bridgeAmount, sourceChainId, destinationChainId, recipientAddress, nativeTokenForBridgeFee, }: GetPreviewFeeParams) => Promise<bigint>;
|
|
16
16
|
|
|
17
17
|
type VaultStatusParams = {
|
|
18
18
|
vaultKey: VaultKey;
|
package/dist/display.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-
|
|
1
|
+
export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-Cp1ddpw4.js';
|
|
2
2
|
import { Address } from 'viem';
|
|
3
3
|
import { C as ChainId } from './vault-config-BNzhv3QV.js';
|
|
4
4
|
import { V as VaultKey } from './config-BQynVNDC.js';
|
|
@@ -9,10 +9,10 @@ interface GetPreviewFeeParams {
|
|
|
9
9
|
bridgeAmount: bigint;
|
|
10
10
|
sourceChainId: ChainId;
|
|
11
11
|
destinationChainId: ChainId;
|
|
12
|
-
|
|
12
|
+
recipientAddress: Address;
|
|
13
13
|
nativeTokenForBridgeFee?: Address;
|
|
14
14
|
}
|
|
15
|
-
declare const getBridgeFee: ({ vaultKey, bridgeAmount, sourceChainId, destinationChainId,
|
|
15
|
+
declare const getBridgeFee: ({ vaultKey, bridgeAmount, sourceChainId, destinationChainId, recipientAddress, nativeTokenForBridgeFee, }: GetPreviewFeeParams) => Promise<bigint>;
|
|
16
16
|
|
|
17
17
|
type VaultStatusParams = {
|
|
18
18
|
vaultKey: VaultKey;
|
package/dist/display.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunkKYR6BFAE_js = require('./chunk-KYR6BFAE.js');
|
|
4
|
+
var chunkGS7TDQXA_js = require('./chunk-GS7TDQXA.js');
|
|
5
|
+
require('./chunk-DTFLXAZJ.js');
|
|
6
6
|
var chunkICKDAKVS_js = require('./chunk-ICKDAKVS.js');
|
|
7
7
|
require('./chunk-RUIAH5HY.js');
|
|
8
8
|
require('./chunk-3I3PYX2F.js');
|
|
9
|
-
var
|
|
9
|
+
var chunkB2QCI6ET_js = require('./chunk-B2QCI6ET.js');
|
|
10
10
|
|
|
11
11
|
// src/vaults/bridge.ts
|
|
12
12
|
var prepareBridgeContractArg = ({
|
|
13
13
|
bridgeChainIdentifier,
|
|
14
|
-
|
|
15
|
-
nativeTokenForBridgeFee =
|
|
14
|
+
recipientAddress,
|
|
15
|
+
nativeTokenForBridgeFee = chunkB2QCI6ET_js.NATIVE_TOKEN_FOR_BRIDGE_FEE
|
|
16
16
|
}) => {
|
|
17
17
|
return {
|
|
18
18
|
chainSelector: bridgeChainIdentifier,
|
|
19
|
-
destinationChainReceiver:
|
|
19
|
+
destinationChainReceiver: recipientAddress,
|
|
20
20
|
bridgeFeeToken: nativeTokenForBridgeFee,
|
|
21
21
|
messageGas: BigInt(1e5),
|
|
22
22
|
data: "0x"
|
|
@@ -29,8 +29,8 @@ var getBridgeFee = async ({
|
|
|
29
29
|
bridgeAmount,
|
|
30
30
|
sourceChainId,
|
|
31
31
|
destinationChainId,
|
|
32
|
-
|
|
33
|
-
nativeTokenForBridgeFee =
|
|
32
|
+
recipientAddress,
|
|
33
|
+
nativeTokenForBridgeFee = chunkB2QCI6ET_js.NATIVE_TOKEN_FOR_BRIDGE_FEE
|
|
34
34
|
}) => {
|
|
35
35
|
const vault = await chunkICKDAKVS_js.getVaultByKey(vaultKey);
|
|
36
36
|
if (!vault) {
|
|
@@ -61,10 +61,10 @@ var getBridgeFee = async ({
|
|
|
61
61
|
const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;
|
|
62
62
|
const bridgeContractArg = prepareBridgeContractArg({
|
|
63
63
|
bridgeChainIdentifier,
|
|
64
|
-
|
|
64
|
+
recipientAddress,
|
|
65
65
|
nativeTokenForBridgeFee
|
|
66
66
|
});
|
|
67
|
-
const previewFee = await
|
|
67
|
+
const previewFee = await chunkGS7TDQXA_js.getPreviewFee({
|
|
68
68
|
shareAmount: bridgeAmount,
|
|
69
69
|
bridgeData: bridgeContractArg,
|
|
70
70
|
contractAddress: vault.contracts.teller,
|
|
@@ -81,7 +81,7 @@ var getVaultStatus = async ({ vaultKey, chainId }) => {
|
|
|
81
81
|
}
|
|
82
82
|
const tellerAddress = vault.contracts.teller;
|
|
83
83
|
const accountantAddress = vault.contracts.accountant;
|
|
84
|
-
const [tellerStatus, accountantStatus] = await
|
|
84
|
+
const [tellerStatus, accountantStatus] = await chunkGS7TDQXA_js.getPausedStates({
|
|
85
85
|
accountantAddress,
|
|
86
86
|
tellerAddress,
|
|
87
87
|
chainId
|
|
@@ -104,19 +104,19 @@ var getVaultStatus = async ({ vaultKey, chainId }) => {
|
|
|
104
104
|
|
|
105
105
|
Object.defineProperty(exports, "getDepositExchangeRate", {
|
|
106
106
|
enumerable: true,
|
|
107
|
-
get: function () { return
|
|
107
|
+
get: function () { return chunkKYR6BFAE_js.getDepositExchangeRate; }
|
|
108
108
|
});
|
|
109
109
|
Object.defineProperty(exports, "getWithdrawExchangeRate", {
|
|
110
110
|
enumerable: true,
|
|
111
|
-
get: function () { return
|
|
111
|
+
get: function () { return chunkKYR6BFAE_js.getWithdrawExchangeRate; }
|
|
112
112
|
});
|
|
113
113
|
Object.defineProperty(exports, "isDepositSpendApproved", {
|
|
114
114
|
enumerable: true,
|
|
115
|
-
get: function () { return
|
|
115
|
+
get: function () { return chunkKYR6BFAE_js.isDepositSpendApproved; }
|
|
116
116
|
});
|
|
117
117
|
Object.defineProperty(exports, "isWithdrawalSpendApproved", {
|
|
118
118
|
enumerable: true,
|
|
119
|
-
get: function () { return
|
|
119
|
+
get: function () { return chunkKYR6BFAE_js.isWithdrawalSpendApproved; }
|
|
120
120
|
});
|
|
121
121
|
exports.getBridgeFee = getBridgeFee;
|
|
122
122
|
exports.getVaultStatus = getVaultStatus;
|
package/dist/display.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vaults/bridge.ts","../src/display/bridge-fees.ts","../src/display/vault-status.ts"],"names":["NATIVE_TOKEN_FOR_BRIDGE_FEE","getVaultByKey","getPreviewFee","getPausedStates"],"mappings":";;;;;;;;;;;AA6BA,IAAM,2BAA2B,CAAC;AAAA,EAChC,qBAAA;AAAA,EACA,WAAA;AAAA,EACA,uBAAA,GAA0BA;AAC5B,CAAA,KAAkD;AAChD,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,qBAAA;AAAA,IACf,wBAAA,EAA0B,WAAA;AAAA,IAC1B,cAAA,EAAgB,uBAAA;AAAA,IAChB,UAAA,EAAY,OAAO,GAAM,CAAA;AAAA,IACzB,IAAA,EAAM;AAAA,GACR;AACF,CAAA;;;ACxBA,IAAM,eAAe,OAAO;AAAA,EAC1B,QAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,kBAAA;AAAA,EACA,WAAA;AAAA,EACA,uBAAA,GAA0BA;AAC5B,CAAA,KAA2B;AACzB,EAAA,MAAM,KAAA,GAAQ,MAAMC,8BAAA,CAAc,QAAQ,CAAA;AAC1C,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsB,QAAQ,CAAA,CAAE,CAAA;AAAA,EAClD;AAEA,EAAA,I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type { Address } from \"viem\";\nimport { getVaultByKey } from \".\";\nimport { TellerAbi } from \"../abi/teller-abi\";\nimport type { BridgeData } from \"../api/teller\";\nimport { getPreviewFee } from \"../api/teller\";\nimport { type ChainId, toChainId } from \"../api/vault-config\";\nimport { NATIVE_TOKEN_FOR_BRIDGE_FEE } from \"../constants\";\nimport type { VaultKey } from \"./config\";\n\n/**\n * Parameters for preparing bridge contract arguments\n * @interface PrepareBridgeContractArgParams\n * @property {number} bridgeChainIdentifier - Chain identifier for the bridge protocol\n * @property {Address} userAddress - Ethereum address of the user initiating the bridge\n * @property {Address} [nativeTokenForBridgeFee] - Optional address of the native token used for bridge fees\n */\ninterface PrepareBridgeContractArgParams {\n bridgeChainIdentifier: number;\n userAddress: Address;\n nativeTokenForBridgeFee?: Address;\n}\n\n// Creates a standardized bridge data object for cross-chain transactions\n// with default values for gas limits and other bridge protocol parameters\nconst prepareBridgeContractArg = ({\n bridgeChainIdentifier,\n userAddress,\n nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE,\n}: PrepareBridgeContractArgParams): BridgeData => {\n return {\n chainSelector: bridgeChainIdentifier,\n destinationChainReceiver: userAddress,\n bridgeFeeToken: nativeTokenForBridgeFee,\n messageGas: BigInt(100000),\n data: \"0x\" as never,\n };\n};\n\n/**\n * Parameters for preparing a cross-chain bridge transaction\n * @interface PrepareBridgeTransactionParams\n * @property {VaultKey} vaultKey - Unique identifier for the vault\n * @property {bigint} bridgeAmount - Amount of shares to bridge (in base units)\n * @property {ChainId} sourceChainId - Chain ID where shares currently exist\n * @property {ChainId} destinationChainId - Chain ID where shares will be bridged to\n * @property {Address} userAddress - Ethereum address of the user initiating the bridge\n */\ninterface PrepareBridgeTransactionParams {\n vaultKey: VaultKey;\n bridgeAmount: bigint;\n sourceChainId: ChainId;\n destinationChainId: ChainId;\n userAddress: Address;\n}\n\n/**\n * Transaction data for executing a cross-chain bridge operation\n * @interface BridgeTransactionData\n * @property {typeof TellerAbi} abi - ABI for the CrossChainTeller contract\n * @property {Address} address - Address of the CrossChainTeller contract\n * @property {string} functionName - Name of the function to call on the contract\n * @property {[bigint, BridgeData]} args - Arguments for the bridge function:\n * [amount, bridgeArgs]\n * @property {number} chainId - ID of the chain where the transaction should be executed\n * @property {bigint} value - Amount of native token to send with the transaction\n */\ninterface BridgeTransactionData {\n abi: typeof TellerAbi;\n address: Address;\n functionName: \"bridge\";\n args: [bigint, BridgeData];\n chainId: number;\n value: bigint;\n}\n\n// Example usage:\n// const bridgeData = await prepareBridgeData({\n// vaultKey: 'bobaeth',\n// bridgeAmount: BigInt('1000000000000000000'), // 1 token\n// sourceChainId: 288, // Boba network\n// userAddress: '0x1234...',\n// });\nconst prepareBridgeTransactionData = async ({\n vaultKey,\n bridgeAmount,\n sourceChainId,\n destinationChainId,\n userAddress,\n}: PrepareBridgeTransactionParams): Promise<BridgeTransactionData> => {\n const nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE;\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Invalid vault key: ${vaultKey}`);\n }\n\n if (!vault.contracts) {\n throw new Error(`Contracts not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.boringVault) {\n throw new Error(\n `BoringVault contract not configured for vault ${vaultKey}`\n );\n }\n\n if (!vault.contracts.accountant) {\n throw new Error(`Accountant contract not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.teller) {\n throw new Error(`Teller contract not configured for vault ${vaultKey}`);\n }\n\n const normalizedSourceChainId = toChainId(sourceChainId);\n const sourceChain = vault.withdraw.sourceChains[normalizedSourceChainId];\n if (!sourceChain) {\n throw new Error(`Source chain not configured for vault ${vaultKey}`);\n }\n\n const normalizedDestinationChainId = toChainId(destinationChainId);\n const destinationChain =\n sourceChain.destinationChains[normalizedDestinationChainId];\n if (!destinationChain) {\n throw new Error(`Destination chain not configured for vault ${vaultKey}`);\n }\n\n const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;\n\n const bridgeContractArg = prepareBridgeContractArg({\n bridgeChainIdentifier,\n userAddress,\n nativeTokenForBridgeFee,\n });\n\n const previewFee = await getPreviewFee({\n shareAmount: bridgeAmount,\n bridgeData: bridgeContractArg,\n contractAddress: vault.contracts.teller,\n chainId: normalizedSourceChainId,\n });\n\n return {\n abi: TellerAbi,\n address: vault.contracts.teller,\n functionName: \"bridge\",\n args: [bridgeAmount, bridgeContractArg],\n chainId: normalizedSourceChainId,\n value: previewFee,\n };\n};\n\nexport { prepareBridgeContractArg, prepareBridgeTransactionData };\nexport type { BridgeTransactionData };\n","import type { Address } from \"viem\";\nimport { getPreviewFee } from \"../api/teller\";\nimport type { ChainId } from \"../api/vault-config\";\nimport { NATIVE_TOKEN_FOR_BRIDGE_FEE } from \"../constants\";\nimport { getVaultByKey } from \"../vaults\";\nimport { prepareBridgeContractArg } from \"../vaults/bridge\";\nimport type { VaultKey } from \"../vaults/config\";\n\ninterface GetPreviewFeeParams {\n vaultKey: VaultKey;\n bridgeAmount: bigint;\n sourceChainId: ChainId;\n destinationChainId: ChainId;\n userAddress: Address;\n nativeTokenForBridgeFee?: Address;\n}\n\nconst getBridgeFee = async ({\n vaultKey,\n bridgeAmount,\n sourceChainId,\n destinationChainId,\n userAddress,\n nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE,\n}: GetPreviewFeeParams) => {\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Invalid vault key: ${vaultKey}`);\n }\n\n if (!vault.contracts) {\n throw new Error(`Contracts not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.boringVault) {\n throw new Error(\n `BoringVault contract not configured for vault ${vaultKey}`\n );\n }\n\n if (!vault.contracts.accountant) {\n throw new Error(`Accountant contract not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.teller) {\n throw new Error(`Teller contract not configured for vault ${vaultKey}`);\n }\n\n const sourceChain = vault.withdraw.sourceChains[sourceChainId];\n if (!sourceChain) {\n throw new Error(`Source chain not configured for vault ${vaultKey}`);\n }\n\n const destinationChain = sourceChain.destinationChains[destinationChainId];\n if (!destinationChain) {\n throw new Error(`Destination chain not configured for vault ${vaultKey}`);\n }\n\n const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;\n\n const bridgeContractArg = prepareBridgeContractArg({\n bridgeChainIdentifier,\n userAddress,\n nativeTokenForBridgeFee,\n });\n\n const previewFee = await getPreviewFee({\n shareAmount: bridgeAmount,\n bridgeData: bridgeContractArg,\n contractAddress: vault.contracts.teller,\n chainId: sourceChainId,\n });\n\n // TODO: use native currency from chains object returned from API\n return previewFee;\n};\n\nexport { getBridgeFee };\n","import { getPausedStates } from \"../api/multi-call\";\nimport type { ChainId } from \"../api/vault-config\";\nimport { getVaultByKey } from \"../vaults\";\nimport type { VaultKey } from \"../vaults/config\";\n\ntype VaultStatusParams = {\n vaultKey: VaultKey;\n chainId: ChainId;\n};\n\nconst getVaultStatus = async ({ vaultKey, chainId }: VaultStatusParams) => {\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Vault not found: ${vaultKey}`);\n }\n\n const tellerAddress = vault.contracts.teller;\n const accountantAddress = vault.contracts.accountant;\n\n const [tellerStatus, accountantStatus] = await getPausedStates({\n accountantAddress,\n tellerAddress,\n chainId,\n });\n\n if (tellerStatus.status === \"failure\") {\n throw new Error(tellerStatus.error.message);\n }\n\n if (accountantStatus.status === \"failure\") {\n throw new Error(accountantStatus.error.message);\n }\n\n if (tellerStatus.result === true || accountantStatus.result[7] === true) {\n return {\n isPaused: true,\n };\n }\n\n return {\n isPaused: false,\n };\n};\n\nexport { getVaultStatus };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/vaults/bridge.ts","../src/display/bridge-fees.ts","../src/display/vault-status.ts"],"names":["NATIVE_TOKEN_FOR_BRIDGE_FEE","getVaultByKey","getPreviewFee","getPausedStates"],"mappings":";;;;;;;;;;;AA6BA,IAAM,2BAA2B,CAAC;AAAA,EAChC,qBAA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I,MAAME,gCAAA,CAAgB;AAAA,IAC7D,iBAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,IAAI,YAAA,CAAa,WAAW,SAAA,EAAW;AACrC,IAAA,MAAM,IAAI,KAAA,CAAM,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAAA,EAC5C;AAEA,EAAA,IAAI,gBAAA,CAAiB,WAAW,SAAA,EAAW;AACzC,IAAA,MAAM,IAAI,KAAA,CAAM,gBAAA,CAAiB,KAAA,CAAM,OAAO,CAAA;AAAA,EAChD;AAEA,EAAA,IAAI,aAAa,MAAA,KAAW,IAAA,IAAQ,iBAAiB,MAAA,CAAO,CAAC,MAAM,IAAA,EAAM;AACvE,IAAA,OAAO;AAAA,MACL,QAAA,EAAU;AAAA,KACZ;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,QAAA,EAAU;AAAA,GACZ;AACF","file":"display.js","sourcesContent":["/**\n * @file Bridge functionality for cross-chain operations\n * @module vaults/bridge\n */\n\nimport type { Address } from \"viem\";\nimport { getVaultByKey } from \".\";\nimport { TellerAbi } from \"../abi/teller-abi\";\nimport type { BridgeData } from \"../api/teller\";\nimport { getPreviewFee } from \"../api/teller\";\nimport { type ChainId, toChainId } from \"../api/vault-config\";\nimport { NATIVE_TOKEN_FOR_BRIDGE_FEE } from \"../constants\";\nimport type { VaultKey } from \"./config\";\n\n/**\n * Parameters for preparing bridge contract arguments\n * @interface PrepareBridgeContractArgParams\n * @property {number} bridgeChainIdentifier - Chain identifier for the bridge protocol\n * @property {Address} recipientAddress - Ethereum address that will receive the bridged assets on the destination chain\n * @property {Address} [nativeTokenForBridgeFee] - Optional address of the native token used for bridge fees\n */\ninterface PrepareBridgeContractArgParams {\n bridgeChainIdentifier: number;\n recipientAddress: Address;\n nativeTokenForBridgeFee?: Address;\n}\n\n// Creates a standardized bridge data object for cross-chain transactions\n// with default values for gas limits and other bridge protocol parameters\nconst prepareBridgeContractArg = ({\n bridgeChainIdentifier,\n recipientAddress,\n nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE,\n}: PrepareBridgeContractArgParams): BridgeData => {\n return {\n chainSelector: bridgeChainIdentifier,\n destinationChainReceiver: recipientAddress,\n bridgeFeeToken: nativeTokenForBridgeFee,\n messageGas: BigInt(100000),\n data: \"0x\" as never,\n };\n};\n\n/**\n * Parameters for preparing a cross-chain bridge transaction\n * @interface PrepareBridgeTransactionParams\n * @property {VaultKey} vaultKey - Unique identifier for the vault\n * @property {bigint} bridgeAmount - Amount of shares to bridge (in base units)\n * @property {ChainId} sourceChainId - Chain ID where shares currently exist\n * @property {ChainId} destinationChainId - Chain ID where shares will be bridged to\n * @property {Address} recipientAddress - Ethereum address that will receive the bridged assets on the destination chain\n */\ninterface PrepareBridgeTransactionParams {\n vaultKey: VaultKey;\n bridgeAmount: bigint;\n sourceChainId: ChainId;\n destinationChainId: ChainId;\n recipientAddress: Address;\n}\n\n/**\n * Transaction data for executing a cross-chain bridge operation\n * @interface BridgeTransactionData\n * @property {typeof TellerAbi} abi - ABI for the CrossChainTeller contract\n * @property {Address} address - Address of the CrossChainTeller contract\n * @property {string} functionName - Name of the function to call on the contract\n * @property {[bigint, BridgeData]} args - Arguments for the bridge function:\n * [amount, bridgeArgs]\n * @property {number} chainId - ID of the chain where the transaction should be executed\n * @property {bigint} value - Amount of native token to send with the transaction\n */\ninterface BridgeTransactionData {\n abi: typeof TellerAbi;\n address: Address;\n functionName: \"bridge\";\n args: [bigint, BridgeData];\n chainId: number;\n value: bigint;\n}\n\n// Example usage:\n// const bridgeData = await prepareBridgeData({\n// vaultKey: 'bobaeth',\n// bridgeAmount: BigInt('1000000000000000000'), // 1 token\n// sourceChainId: 288, // Boba network\n// recipientAddress: '0x1234...',\n// });\nconst prepareBridgeTransactionData = async ({\n vaultKey,\n bridgeAmount,\n sourceChainId,\n destinationChainId,\n recipientAddress,\n}: PrepareBridgeTransactionParams): Promise<BridgeTransactionData> => {\n const nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE;\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Invalid vault key: ${vaultKey}`);\n }\n\n if (!vault.contracts) {\n throw new Error(`Contracts not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.boringVault) {\n throw new Error(\n `BoringVault contract not configured for vault ${vaultKey}`\n );\n }\n\n if (!vault.contracts.accountant) {\n throw new Error(`Accountant contract not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.teller) {\n throw new Error(`Teller contract not configured for vault ${vaultKey}`);\n }\n\n const normalizedSourceChainId = toChainId(sourceChainId);\n const sourceChain = vault.withdraw.sourceChains[normalizedSourceChainId];\n if (!sourceChain) {\n throw new Error(`Source chain not configured for vault ${vaultKey}`);\n }\n\n const normalizedDestinationChainId = toChainId(destinationChainId);\n const destinationChain =\n sourceChain.destinationChains[normalizedDestinationChainId];\n if (!destinationChain) {\n throw new Error(`Destination chain not configured for vault ${vaultKey}`);\n }\n\n const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;\n\n const bridgeContractArg = prepareBridgeContractArg({\n bridgeChainIdentifier,\n recipientAddress,\n nativeTokenForBridgeFee,\n });\n\n const previewFee = await getPreviewFee({\n shareAmount: bridgeAmount,\n bridgeData: bridgeContractArg,\n contractAddress: vault.contracts.teller,\n chainId: normalizedSourceChainId,\n });\n\n return {\n abi: TellerAbi,\n address: vault.contracts.teller,\n functionName: \"bridge\",\n args: [bridgeAmount, bridgeContractArg],\n chainId: normalizedSourceChainId,\n value: previewFee,\n };\n};\n\nexport { prepareBridgeContractArg, prepareBridgeTransactionData };\nexport type { BridgeTransactionData };\n","import type { Address } from \"viem\";\nimport { getPreviewFee } from \"../api/teller\";\nimport type { ChainId } from \"../api/vault-config\";\nimport { NATIVE_TOKEN_FOR_BRIDGE_FEE } from \"../constants\";\nimport { getVaultByKey } from \"../vaults\";\nimport { prepareBridgeContractArg } from \"../vaults/bridge\";\nimport type { VaultKey } from \"../vaults/config\";\n\ninterface GetPreviewFeeParams {\n vaultKey: VaultKey;\n bridgeAmount: bigint;\n sourceChainId: ChainId;\n destinationChainId: ChainId;\n recipientAddress: Address;\n nativeTokenForBridgeFee?: Address;\n}\n\nconst getBridgeFee = async ({\n vaultKey,\n bridgeAmount,\n sourceChainId,\n destinationChainId,\n recipientAddress,\n nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE,\n}: GetPreviewFeeParams) => {\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Invalid vault key: ${vaultKey}`);\n }\n\n if (!vault.contracts) {\n throw new Error(`Contracts not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.boringVault) {\n throw new Error(\n `BoringVault contract not configured for vault ${vaultKey}`\n );\n }\n\n if (!vault.contracts.accountant) {\n throw new Error(`Accountant contract not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.teller) {\n throw new Error(`Teller contract not configured for vault ${vaultKey}`);\n }\n\n const sourceChain = vault.withdraw.sourceChains[sourceChainId];\n if (!sourceChain) {\n throw new Error(`Source chain not configured for vault ${vaultKey}`);\n }\n\n const destinationChain = sourceChain.destinationChains[destinationChainId];\n if (!destinationChain) {\n throw new Error(`Destination chain not configured for vault ${vaultKey}`);\n }\n\n const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;\n\n const bridgeContractArg = prepareBridgeContractArg({\n bridgeChainIdentifier,\n recipientAddress,\n nativeTokenForBridgeFee,\n });\n\n const previewFee = await getPreviewFee({\n shareAmount: bridgeAmount,\n bridgeData: bridgeContractArg,\n contractAddress: vault.contracts.teller,\n chainId: sourceChainId,\n });\n\n // TODO: use native currency from chains object returned from API\n return previewFee;\n};\n\nexport { getBridgeFee };\n","import { getPausedStates } from \"../api/multi-call\";\nimport type { ChainId } from \"../api/vault-config\";\nimport { getVaultByKey } from \"../vaults\";\nimport type { VaultKey } from \"../vaults/config\";\n\ntype VaultStatusParams = {\n vaultKey: VaultKey;\n chainId: ChainId;\n};\n\nconst getVaultStatus = async ({ vaultKey, chainId }: VaultStatusParams) => {\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Vault not found: ${vaultKey}`);\n }\n\n const tellerAddress = vault.contracts.teller;\n const accountantAddress = vault.contracts.accountant;\n\n const [tellerStatus, accountantStatus] = await getPausedStates({\n accountantAddress,\n tellerAddress,\n chainId,\n });\n\n if (tellerStatus.status === \"failure\") {\n throw new Error(tellerStatus.error.message);\n }\n\n if (accountantStatus.status === \"failure\") {\n throw new Error(accountantStatus.error.message);\n }\n\n if (tellerStatus.result === true || accountantStatus.result[7] === true) {\n return {\n isPaused: true,\n };\n }\n\n return {\n isPaused: false,\n };\n};\n\nexport { getVaultStatus };\n"]}
|
package/dist/display.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { getDepositExchangeRate, getWithdrawExchangeRate, isDepositSpendApproved, isWithdrawalSpendApproved } from './chunk-
|
|
2
|
-
import { getPreviewFee, getPausedStates } from './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { getDepositExchangeRate, getWithdrawExchangeRate, isDepositSpendApproved, isWithdrawalSpendApproved } from './chunk-HI44AMLC.mjs';
|
|
2
|
+
import { getPreviewFee, getPausedStates } from './chunk-VIULRHK6.mjs';
|
|
3
|
+
import './chunk-ZILA73XN.mjs';
|
|
4
4
|
import { getVaultByKey } from './chunk-R663BFAZ.mjs';
|
|
5
5
|
import './chunk-J3662HYT.mjs';
|
|
6
6
|
import './chunk-7RWWVUHP.mjs';
|
|
7
|
-
import { NATIVE_TOKEN_FOR_BRIDGE_FEE } from './chunk-
|
|
7
|
+
import { NATIVE_TOKEN_FOR_BRIDGE_FEE } from './chunk-CUGK4ZBJ.mjs';
|
|
8
8
|
|
|
9
9
|
// src/vaults/bridge.ts
|
|
10
10
|
var prepareBridgeContractArg = ({
|
|
11
11
|
bridgeChainIdentifier,
|
|
12
|
-
|
|
12
|
+
recipientAddress,
|
|
13
13
|
nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE
|
|
14
14
|
}) => {
|
|
15
15
|
return {
|
|
16
16
|
chainSelector: bridgeChainIdentifier,
|
|
17
|
-
destinationChainReceiver:
|
|
17
|
+
destinationChainReceiver: recipientAddress,
|
|
18
18
|
bridgeFeeToken: nativeTokenForBridgeFee,
|
|
19
19
|
messageGas: BigInt(1e5),
|
|
20
20
|
data: "0x"
|
|
@@ -27,7 +27,7 @@ var getBridgeFee = async ({
|
|
|
27
27
|
bridgeAmount,
|
|
28
28
|
sourceChainId,
|
|
29
29
|
destinationChainId,
|
|
30
|
-
|
|
30
|
+
recipientAddress,
|
|
31
31
|
nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE
|
|
32
32
|
}) => {
|
|
33
33
|
const vault = await getVaultByKey(vaultKey);
|
|
@@ -59,7 +59,7 @@ var getBridgeFee = async ({
|
|
|
59
59
|
const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;
|
|
60
60
|
const bridgeContractArg = prepareBridgeContractArg({
|
|
61
61
|
bridgeChainIdentifier,
|
|
62
|
-
|
|
62
|
+
recipientAddress,
|
|
63
63
|
nativeTokenForBridgeFee
|
|
64
64
|
});
|
|
65
65
|
const previewFee = await getPreviewFee({
|
package/dist/display.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vaults/bridge.ts","../src/display/bridge-fees.ts","../src/display/vault-status.ts"],"names":[],"mappings":";;;;;;;;;AA6BA,IAAM,2BAA2B,CAAC;AAAA,EAChC,qBAAA;AAAA,EACA,WAAA;AAAA,EACA,uBAAA,GAA0B;AAC5B,CAAA,KAAkD;AAChD,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,qBAAA;AAAA,IACf,wBAAA,EAA0B,WAAA;AAAA,IAC1B,cAAA,EAAgB,uBAAA;AAAA,IAChB,UAAA,EAAY,OAAO,GAAM,CAAA;AAAA,IACzB,I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iB,WAAW,SAAA,EAAW;AACzC,IAAA,MAAM,IAAI,KAAA,CAAM,gBAAA,CAAiB,KAAA,CAAM,OAAO,CAAA;AAAA,EAChD;AAEA,EAAA,IAAI,aAAa,MAAA,KAAW,IAAA,IAAQ,iBAAiB,MAAA,CAAO,CAAC,MAAM,IAAA,EAAM;AACvE,IAAA,OAAO;AAAA,MACL,QAAA,EAAU;AAAA,KACZ;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,QAAA,EAAU;AAAA,GACZ;AACF","file":"display.mjs","sourcesContent":["/**\n * @file Bridge functionality for cross-chain operations\n * @module vaults/bridge\n */\n\nimport type { Address } from \"viem\";\nimport { getVaultByKey } from \".\";\nimport { TellerAbi } from \"../abi/teller-abi\";\nimport type { BridgeData } from \"../api/teller\";\nimport { getPreviewFee } from \"../api/teller\";\nimport { type ChainId, toChainId } from \"../api/vault-config\";\nimport { NATIVE_TOKEN_FOR_BRIDGE_FEE } from \"../constants\";\nimport type { VaultKey } from \"./config\";\n\n/**\n * Parameters for preparing bridge contract arguments\n * @interface PrepareBridgeContractArgParams\n * @property {number} bridgeChainIdentifier - Chain identifier for the bridge protocol\n * @property {Address} userAddress - Ethereum address of the user initiating the bridge\n * @property {Address} [nativeTokenForBridgeFee] - Optional address of the native token used for bridge fees\n */\ninterface PrepareBridgeContractArgParams {\n bridgeChainIdentifier: number;\n userAddress: Address;\n nativeTokenForBridgeFee?: Address;\n}\n\n// Creates a standardized bridge data object for cross-chain transactions\n// with default values for gas limits and other bridge protocol parameters\nconst prepareBridgeContractArg = ({\n bridgeChainIdentifier,\n userAddress,\n nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE,\n}: PrepareBridgeContractArgParams): BridgeData => {\n return {\n chainSelector: bridgeChainIdentifier,\n destinationChainReceiver: userAddress,\n bridgeFeeToken: nativeTokenForBridgeFee,\n messageGas: BigInt(100000),\n data: \"0x\" as never,\n };\n};\n\n/**\n * Parameters for preparing a cross-chain bridge transaction\n * @interface PrepareBridgeTransactionParams\n * @property {VaultKey} vaultKey - Unique identifier for the vault\n * @property {bigint} bridgeAmount - Amount of shares to bridge (in base units)\n * @property {ChainId} sourceChainId - Chain ID where shares currently exist\n * @property {ChainId} destinationChainId - Chain ID where shares will be bridged to\n * @property {Address} userAddress - Ethereum address of the user initiating the bridge\n */\ninterface PrepareBridgeTransactionParams {\n vaultKey: VaultKey;\n bridgeAmount: bigint;\n sourceChainId: ChainId;\n destinationChainId: ChainId;\n userAddress: Address;\n}\n\n/**\n * Transaction data for executing a cross-chain bridge operation\n * @interface BridgeTransactionData\n * @property {typeof TellerAbi} abi - ABI for the CrossChainTeller contract\n * @property {Address} address - Address of the CrossChainTeller contract\n * @property {string} functionName - Name of the function to call on the contract\n * @property {[bigint, BridgeData]} args - Arguments for the bridge function:\n * [amount, bridgeArgs]\n * @property {number} chainId - ID of the chain where the transaction should be executed\n * @property {bigint} value - Amount of native token to send with the transaction\n */\ninterface BridgeTransactionData {\n abi: typeof TellerAbi;\n address: Address;\n functionName: \"bridge\";\n args: [bigint, BridgeData];\n chainId: number;\n value: bigint;\n}\n\n// Example usage:\n// const bridgeData = await prepareBridgeData({\n// vaultKey: 'bobaeth',\n// bridgeAmount: BigInt('1000000000000000000'), // 1 token\n// sourceChainId: 288, // Boba network\n// userAddress: '0x1234...',\n// });\nconst prepareBridgeTransactionData = async ({\n vaultKey,\n bridgeAmount,\n sourceChainId,\n destinationChainId,\n userAddress,\n}: PrepareBridgeTransactionParams): Promise<BridgeTransactionData> => {\n const nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE;\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Invalid vault key: ${vaultKey}`);\n }\n\n if (!vault.contracts) {\n throw new Error(`Contracts not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.boringVault) {\n throw new Error(\n `BoringVault contract not configured for vault ${vaultKey}`\n );\n }\n\n if (!vault.contracts.accountant) {\n throw new Error(`Accountant contract not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.teller) {\n throw new Error(`Teller contract not configured for vault ${vaultKey}`);\n }\n\n const normalizedSourceChainId = toChainId(sourceChainId);\n const sourceChain = vault.withdraw.sourceChains[normalizedSourceChainId];\n if (!sourceChain) {\n throw new Error(`Source chain not configured for vault ${vaultKey}`);\n }\n\n const normalizedDestinationChainId = toChainId(destinationChainId);\n const destinationChain =\n sourceChain.destinationChains[normalizedDestinationChainId];\n if (!destinationChain) {\n throw new Error(`Destination chain not configured for vault ${vaultKey}`);\n }\n\n const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;\n\n const bridgeContractArg = prepareBridgeContractArg({\n bridgeChainIdentifier,\n userAddress,\n nativeTokenForBridgeFee,\n });\n\n const previewFee = await getPreviewFee({\n shareAmount: bridgeAmount,\n bridgeData: bridgeContractArg,\n contractAddress: vault.contracts.teller,\n chainId: normalizedSourceChainId,\n });\n\n return {\n abi: TellerAbi,\n address: vault.contracts.teller,\n functionName: \"bridge\",\n args: [bridgeAmount, bridgeContractArg],\n chainId: normalizedSourceChainId,\n value: previewFee,\n };\n};\n\nexport { prepareBridgeContractArg, prepareBridgeTransactionData };\nexport type { BridgeTransactionData };\n","import type { Address } from \"viem\";\nimport { getPreviewFee } from \"../api/teller\";\nimport type { ChainId } from \"../api/vault-config\";\nimport { NATIVE_TOKEN_FOR_BRIDGE_FEE } from \"../constants\";\nimport { getVaultByKey } from \"../vaults\";\nimport { prepareBridgeContractArg } from \"../vaults/bridge\";\nimport type { VaultKey } from \"../vaults/config\";\n\ninterface GetPreviewFeeParams {\n vaultKey: VaultKey;\n bridgeAmount: bigint;\n sourceChainId: ChainId;\n destinationChainId: ChainId;\n userAddress: Address;\n nativeTokenForBridgeFee?: Address;\n}\n\nconst getBridgeFee = async ({\n vaultKey,\n bridgeAmount,\n sourceChainId,\n destinationChainId,\n userAddress,\n nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE,\n}: GetPreviewFeeParams) => {\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Invalid vault key: ${vaultKey}`);\n }\n\n if (!vault.contracts) {\n throw new Error(`Contracts not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.boringVault) {\n throw new Error(\n `BoringVault contract not configured for vault ${vaultKey}`\n );\n }\n\n if (!vault.contracts.accountant) {\n throw new Error(`Accountant contract not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.teller) {\n throw new Error(`Teller contract not configured for vault ${vaultKey}`);\n }\n\n const sourceChain = vault.withdraw.sourceChains[sourceChainId];\n if (!sourceChain) {\n throw new Error(`Source chain not configured for vault ${vaultKey}`);\n }\n\n const destinationChain = sourceChain.destinationChains[destinationChainId];\n if (!destinationChain) {\n throw new Error(`Destination chain not configured for vault ${vaultKey}`);\n }\n\n const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;\n\n const bridgeContractArg = prepareBridgeContractArg({\n bridgeChainIdentifier,\n userAddress,\n nativeTokenForBridgeFee,\n });\n\n const previewFee = await getPreviewFee({\n shareAmount: bridgeAmount,\n bridgeData: bridgeContractArg,\n contractAddress: vault.contracts.teller,\n chainId: sourceChainId,\n });\n\n // TODO: use native currency from chains object returned from API\n return previewFee;\n};\n\nexport { getBridgeFee };\n","import { getPausedStates } from \"../api/multi-call\";\nimport type { ChainId } from \"../api/vault-config\";\nimport { getVaultByKey } from \"../vaults\";\nimport type { VaultKey } from \"../vaults/config\";\n\ntype VaultStatusParams = {\n vaultKey: VaultKey;\n chainId: ChainId;\n};\n\nconst getVaultStatus = async ({ vaultKey, chainId }: VaultStatusParams) => {\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Vault not found: ${vaultKey}`);\n }\n\n const tellerAddress = vault.contracts.teller;\n const accountantAddress = vault.contracts.accountant;\n\n const [tellerStatus, accountantStatus] = await getPausedStates({\n accountantAddress,\n tellerAddress,\n chainId,\n });\n\n if (tellerStatus.status === \"failure\") {\n throw new Error(tellerStatus.error.message);\n }\n\n if (accountantStatus.status === \"failure\") {\n throw new Error(accountantStatus.error.message);\n }\n\n if (tellerStatus.result === true || accountantStatus.result[7] === true) {\n return {\n isPaused: true,\n };\n }\n\n return {\n isPaused: false,\n };\n};\n\nexport { getVaultStatus };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/vaults/bridge.ts","../src/display/bridge-fees.ts","../src/display/vault-status.ts"],"names":[],"mappings":";;;;;;;;;AA6BA,IAAM,2BAA2B,CAAC;AAAA,EAChC,qBAAA;AAAA,EACA,gBAAA;AAAA,EACA,uBAAA,GAA0B;AAC5B,CAAA,KAAkD;AAChD,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,qBAAA;AAAA,IACf,wBAAA,EAA0B,gBAAA;AAAA,IAC1B,cAAA,EAAgB,uBAAA;AAAA,IAChB,UAAA,EAAY,OAAO,GAAM,CAAA;AAAA,IACzB,IAAA,EAAM;AAAA,GACR;AACF,CAAA;;;ACxBA,IAAM,eAAe,OAAO;AAAA,EAC1B,QAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,uBAAA,GAA0B;AAC5B,CAAA,KAA2B;AACzB,EAAA,MAAM,KAAA,GAAQ,MAAM,aAAA,CAAc,QAAQ,CAAA;AAC1C,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsB,QAAQ,CAAA,CAAE,CAAA;AAAA,EAClD;AAEA,EAAA,IAAI,CAAC,MAAM,SAAA,EAAW;AACpB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mCAAA,EAAsC,QAAQ,CAAA,CAAE,CAAA;AAAA,EAClE;AAEA,EAAA,IAAI,CAAC,KAAA,CAAM,SAAA,CAAU,WAAA,EAAa;AAChC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,iDAAiD,QAAQ,CAAA;AAAA,KAC3D;AAA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,aAAA,CAAc,QAAQ,CAAA;AAC1C,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,QAAQ,CAAA,CAAE,CAAA;AAAA,EAChD;AAEA,EAAA,MAAM,aAAA,GAAgB,MAAM,SAAA,CAAU,MAAA;AACtC,EAAA,MAAM,iBAAA,GAAoB,MAAM,SAAA,CAAU,UAAA;AAE1C,EAAA,MAAM,CAAC,YAAA,EAAc,gBAAgB,CAAA,GAAI,MAAM,eAAA,CAAgB;AAAA,IAC7D,iBAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,IAAI,YAAA,CAAa,WAAW,SAAA,EAAW;AACrC,IAAA,MAAM,IAAI,KAAA,CAAM,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAAA,EAC5C;AAEA,EAAA,IAAI,gBAAA,CAAiB,WAAW,SAAA,EAAW;AACzC,IAAA,MAAM,IAAI,KAAA,CAAM,gBAAA,CAAiB,KAAA,CAAM,OAAO,CAAA;AAAA,EAChD;AAEA,EAAA,IAAI,aAAa,MAAA,KAAW,IAAA,IAAQ,iBAAiB,MAAA,CAAO,CAAC,MAAM,IAAA,EAAM;AACvE,IAAA,OAAO;AAAA,MACL,QAAA,EAAU;AAAA,KACZ;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,QAAA,EAAU;AAAA,GACZ;AACF","file":"display.mjs","sourcesContent":["/**\n * @file Bridge functionality for cross-chain operations\n * @module vaults/bridge\n */\n\nimport type { Address } from \"viem\";\nimport { getVaultByKey } from \".\";\nimport { TellerAbi } from \"../abi/teller-abi\";\nimport type { BridgeData } from \"../api/teller\";\nimport { getPreviewFee } from \"../api/teller\";\nimport { type ChainId, toChainId } from \"../api/vault-config\";\nimport { NATIVE_TOKEN_FOR_BRIDGE_FEE } from \"../constants\";\nimport type { VaultKey } from \"./config\";\n\n/**\n * Parameters for preparing bridge contract arguments\n * @interface PrepareBridgeContractArgParams\n * @property {number} bridgeChainIdentifier - Chain identifier for the bridge protocol\n * @property {Address} recipientAddress - Ethereum address that will receive the bridged assets on the destination chain\n * @property {Address} [nativeTokenForBridgeFee] - Optional address of the native token used for bridge fees\n */\ninterface PrepareBridgeContractArgParams {\n bridgeChainIdentifier: number;\n recipientAddress: Address;\n nativeTokenForBridgeFee?: Address;\n}\n\n// Creates a standardized bridge data object for cross-chain transactions\n// with default values for gas limits and other bridge protocol parameters\nconst prepareBridgeContractArg = ({\n bridgeChainIdentifier,\n recipientAddress,\n nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE,\n}: PrepareBridgeContractArgParams): BridgeData => {\n return {\n chainSelector: bridgeChainIdentifier,\n destinationChainReceiver: recipientAddress,\n bridgeFeeToken: nativeTokenForBridgeFee,\n messageGas: BigInt(100000),\n data: \"0x\" as never,\n };\n};\n\n/**\n * Parameters for preparing a cross-chain bridge transaction\n * @interface PrepareBridgeTransactionParams\n * @property {VaultKey} vaultKey - Unique identifier for the vault\n * @property {bigint} bridgeAmount - Amount of shares to bridge (in base units)\n * @property {ChainId} sourceChainId - Chain ID where shares currently exist\n * @property {ChainId} destinationChainId - Chain ID where shares will be bridged to\n * @property {Address} recipientAddress - Ethereum address that will receive the bridged assets on the destination chain\n */\ninterface PrepareBridgeTransactionParams {\n vaultKey: VaultKey;\n bridgeAmount: bigint;\n sourceChainId: ChainId;\n destinationChainId: ChainId;\n recipientAddress: Address;\n}\n\n/**\n * Transaction data for executing a cross-chain bridge operation\n * @interface BridgeTransactionData\n * @property {typeof TellerAbi} abi - ABI for the CrossChainTeller contract\n * @property {Address} address - Address of the CrossChainTeller contract\n * @property {string} functionName - Name of the function to call on the contract\n * @property {[bigint, BridgeData]} args - Arguments for the bridge function:\n * [amount, bridgeArgs]\n * @property {number} chainId - ID of the chain where the transaction should be executed\n * @property {bigint} value - Amount of native token to send with the transaction\n */\ninterface BridgeTransactionData {\n abi: typeof TellerAbi;\n address: Address;\n functionName: \"bridge\";\n args: [bigint, BridgeData];\n chainId: number;\n value: bigint;\n}\n\n// Example usage:\n// const bridgeData = await prepareBridgeData({\n// vaultKey: 'bobaeth',\n// bridgeAmount: BigInt('1000000000000000000'), // 1 token\n// sourceChainId: 288, // Boba network\n// recipientAddress: '0x1234...',\n// });\nconst prepareBridgeTransactionData = async ({\n vaultKey,\n bridgeAmount,\n sourceChainId,\n destinationChainId,\n recipientAddress,\n}: PrepareBridgeTransactionParams): Promise<BridgeTransactionData> => {\n const nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE;\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Invalid vault key: ${vaultKey}`);\n }\n\n if (!vault.contracts) {\n throw new Error(`Contracts not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.boringVault) {\n throw new Error(\n `BoringVault contract not configured for vault ${vaultKey}`\n );\n }\n\n if (!vault.contracts.accountant) {\n throw new Error(`Accountant contract not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.teller) {\n throw new Error(`Teller contract not configured for vault ${vaultKey}`);\n }\n\n const normalizedSourceChainId = toChainId(sourceChainId);\n const sourceChain = vault.withdraw.sourceChains[normalizedSourceChainId];\n if (!sourceChain) {\n throw new Error(`Source chain not configured for vault ${vaultKey}`);\n }\n\n const normalizedDestinationChainId = toChainId(destinationChainId);\n const destinationChain =\n sourceChain.destinationChains[normalizedDestinationChainId];\n if (!destinationChain) {\n throw new Error(`Destination chain not configured for vault ${vaultKey}`);\n }\n\n const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;\n\n const bridgeContractArg = prepareBridgeContractArg({\n bridgeChainIdentifier,\n recipientAddress,\n nativeTokenForBridgeFee,\n });\n\n const previewFee = await getPreviewFee({\n shareAmount: bridgeAmount,\n bridgeData: bridgeContractArg,\n contractAddress: vault.contracts.teller,\n chainId: normalizedSourceChainId,\n });\n\n return {\n abi: TellerAbi,\n address: vault.contracts.teller,\n functionName: \"bridge\",\n args: [bridgeAmount, bridgeContractArg],\n chainId: normalizedSourceChainId,\n value: previewFee,\n };\n};\n\nexport { prepareBridgeContractArg, prepareBridgeTransactionData };\nexport type { BridgeTransactionData };\n","import type { Address } from \"viem\";\nimport { getPreviewFee } from \"../api/teller\";\nimport type { ChainId } from \"../api/vault-config\";\nimport { NATIVE_TOKEN_FOR_BRIDGE_FEE } from \"../constants\";\nimport { getVaultByKey } from \"../vaults\";\nimport { prepareBridgeContractArg } from \"../vaults/bridge\";\nimport type { VaultKey } from \"../vaults/config\";\n\ninterface GetPreviewFeeParams {\n vaultKey: VaultKey;\n bridgeAmount: bigint;\n sourceChainId: ChainId;\n destinationChainId: ChainId;\n recipientAddress: Address;\n nativeTokenForBridgeFee?: Address;\n}\n\nconst getBridgeFee = async ({\n vaultKey,\n bridgeAmount,\n sourceChainId,\n destinationChainId,\n recipientAddress,\n nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE,\n}: GetPreviewFeeParams) => {\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Invalid vault key: ${vaultKey}`);\n }\n\n if (!vault.contracts) {\n throw new Error(`Contracts not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.boringVault) {\n throw new Error(\n `BoringVault contract not configured for vault ${vaultKey}`\n );\n }\n\n if (!vault.contracts.accountant) {\n throw new Error(`Accountant contract not configured for vault ${vaultKey}`);\n }\n\n if (!vault.contracts.teller) {\n throw new Error(`Teller contract not configured for vault ${vaultKey}`);\n }\n\n const sourceChain = vault.withdraw.sourceChains[sourceChainId];\n if (!sourceChain) {\n throw new Error(`Source chain not configured for vault ${vaultKey}`);\n }\n\n const destinationChain = sourceChain.destinationChains[destinationChainId];\n if (!destinationChain) {\n throw new Error(`Destination chain not configured for vault ${vaultKey}`);\n }\n\n const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;\n\n const bridgeContractArg = prepareBridgeContractArg({\n bridgeChainIdentifier,\n recipientAddress,\n nativeTokenForBridgeFee,\n });\n\n const previewFee = await getPreviewFee({\n shareAmount: bridgeAmount,\n bridgeData: bridgeContractArg,\n contractAddress: vault.contracts.teller,\n chainId: sourceChainId,\n });\n\n // TODO: use native currency from chains object returned from API\n return previewFee;\n};\n\nexport { getBridgeFee };\n","import { getPausedStates } from \"../api/multi-call\";\nimport type { ChainId } from \"../api/vault-config\";\nimport { getVaultByKey } from \"../vaults\";\nimport type { VaultKey } from \"../vaults/config\";\n\ntype VaultStatusParams = {\n vaultKey: VaultKey;\n chainId: ChainId;\n};\n\nconst getVaultStatus = async ({ vaultKey, chainId }: VaultStatusParams) => {\n const vault = await getVaultByKey(vaultKey);\n if (!vault) {\n throw new Error(`Vault not found: ${vaultKey}`);\n }\n\n const tellerAddress = vault.contracts.teller;\n const accountantAddress = vault.contracts.accountant;\n\n const [tellerStatus, accountantStatus] = await getPausedStates({\n accountantAddress,\n tellerAddress,\n chainId,\n });\n\n if (tellerStatus.status === \"failure\") {\n throw new Error(tellerStatus.error.message);\n }\n\n if (accountantStatus.status === \"failure\") {\n throw new Error(accountantStatus.error.message);\n }\n\n if (tellerStatus.result === true || accountantStatus.result[7] === true) {\n return {\n isPaused: true,\n };\n }\n\n return {\n isPaused: false,\n };\n};\n\nexport { getVaultStatus };\n"]}
|
|
@@ -3,11 +3,11 @@ import { C as ChainId } from './vault-config-BjSE7oL8.mjs';
|
|
|
3
3
|
import { Y as YieldType } from './config-B-u3VqEX.mjs';
|
|
4
4
|
import { V as VaultKey } from './config-BQynVNDC.mjs';
|
|
5
5
|
|
|
6
|
-
declare const isDepositSpendApproved: ({ yieldType, chainId, depositAssetAddress,
|
|
6
|
+
declare const isDepositSpendApproved: ({ yieldType, chainId, depositAssetAddress, recipientAddress, }: {
|
|
7
7
|
yieldType: YieldType;
|
|
8
8
|
chainId: ChainId;
|
|
9
9
|
depositAssetAddress: Address;
|
|
10
|
-
|
|
10
|
+
recipientAddress: Address;
|
|
11
11
|
}) => Promise<{
|
|
12
12
|
isApproved: boolean;
|
|
13
13
|
allowance: string;
|
|
@@ -15,11 +15,11 @@ declare const isDepositSpendApproved: ({ yieldType, chainId, depositAssetAddress
|
|
|
15
15
|
decimals: number;
|
|
16
16
|
error: null;
|
|
17
17
|
}>;
|
|
18
|
-
declare const isWithdrawalSpendApproved: ({ yieldType, chainId, wantAssetAddress,
|
|
18
|
+
declare const isWithdrawalSpendApproved: ({ yieldType, chainId, wantAssetAddress, recipientAddress, }: {
|
|
19
19
|
yieldType: YieldType;
|
|
20
20
|
chainId: ChainId;
|
|
21
21
|
wantAssetAddress: Address;
|
|
22
|
-
|
|
22
|
+
recipientAddress: Address;
|
|
23
23
|
}) => Promise<{
|
|
24
24
|
isApproved: boolean;
|
|
25
25
|
allowance: string;
|
|
@@ -3,11 +3,11 @@ import { C as ChainId } from './vault-config-BNzhv3QV.js';
|
|
|
3
3
|
import { Y as YieldType } from './config-B-u3VqEX.js';
|
|
4
4
|
import { V as VaultKey } from './config-BQynVNDC.js';
|
|
5
5
|
|
|
6
|
-
declare const isDepositSpendApproved: ({ yieldType, chainId, depositAssetAddress,
|
|
6
|
+
declare const isDepositSpendApproved: ({ yieldType, chainId, depositAssetAddress, recipientAddress, }: {
|
|
7
7
|
yieldType: YieldType;
|
|
8
8
|
chainId: ChainId;
|
|
9
9
|
depositAssetAddress: Address;
|
|
10
|
-
|
|
10
|
+
recipientAddress: Address;
|
|
11
11
|
}) => Promise<{
|
|
12
12
|
isApproved: boolean;
|
|
13
13
|
allowance: string;
|
|
@@ -15,11 +15,11 @@ declare const isDepositSpendApproved: ({ yieldType, chainId, depositAssetAddress
|
|
|
15
15
|
decimals: number;
|
|
16
16
|
error: null;
|
|
17
17
|
}>;
|
|
18
|
-
declare const isWithdrawalSpendApproved: ({ yieldType, chainId, wantAssetAddress,
|
|
18
|
+
declare const isWithdrawalSpendApproved: ({ yieldType, chainId, wantAssetAddress, recipientAddress, }: {
|
|
19
19
|
yieldType: YieldType;
|
|
20
20
|
chainId: ChainId;
|
|
21
21
|
wantAssetAddress: Address;
|
|
22
|
-
|
|
22
|
+
recipientAddress: Address;
|
|
23
23
|
}) => Promise<{
|
|
24
24
|
isApproved: boolean;
|
|
25
25
|
allowance: string;
|