@paxoslabs/amplify-sdk 0.0.1-alpha.3 → 0.0.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.
Files changed (38) hide show
  1. package/README.md +4 -479
  2. package/dist/{chunk-GBWBO6ZF.mjs → chunk-774KTF7A.mjs} +7 -7
  3. package/dist/chunk-774KTF7A.mjs.map +1 -0
  4. package/dist/{chunk-BXUG3WDV.js → chunk-ANL3PE7L.js} +8 -8
  5. package/dist/chunk-ANL3PE7L.js.map +1 -0
  6. package/dist/{chunk-ZCVMGIMV.js → chunk-BMN6KTOC.js} +11 -11
  7. package/dist/chunk-BMN6KTOC.js.map +1 -0
  8. package/dist/{chunk-YP2TR5RP.mjs → chunk-LVJ44U7Z.mjs} +8 -8
  9. package/dist/chunk-LVJ44U7Z.mjs.map +1 -0
  10. package/dist/{chunk-AIBI7ZQM.js → chunk-NLLEYTJ6.js} +8 -8
  11. package/dist/{chunk-AIBI7ZQM.js.map → chunk-NLLEYTJ6.js.map} +1 -1
  12. package/dist/{chunk-ZLS2AAMI.mjs → chunk-SYVANMRO.mjs} +3 -3
  13. package/dist/{chunk-ZLS2AAMI.mjs.map → chunk-SYVANMRO.mjs.map} +1 -1
  14. package/dist/core.d.mts +6 -6
  15. package/dist/core.d.ts +6 -6
  16. package/dist/core.js +13 -13
  17. package/dist/core.js.map +1 -1
  18. package/dist/core.mjs +5 -5
  19. package/dist/core.mjs.map +1 -1
  20. package/dist/display.d.mts +3 -3
  21. package/dist/display.d.ts +3 -3
  22. package/dist/display.js +13 -13
  23. package/dist/display.js.map +1 -1
  24. package/dist/display.mjs +7 -7
  25. package/dist/display.mjs.map +1 -1
  26. package/dist/{exchange-rate-CRA_CMaX.d.mts → exchange-rate-BfPH_fQt.d.mts} +4 -4
  27. package/dist/{exchange-rate-D3_FVgqa.d.ts → exchange-rate-Cp1ddpw4.d.ts} +4 -4
  28. package/dist/index.d.mts +11 -11
  29. package/dist/index.d.ts +11 -11
  30. package/dist/index.js +54 -34
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +41 -21
  33. package/dist/index.mjs.map +1 -1
  34. package/package.json +7 -7
  35. package/dist/chunk-BXUG3WDV.js.map +0 -1
  36. package/dist/chunk-GBWBO6ZF.mjs.map +0 -1
  37. package/dist/chunk-YP2TR5RP.mjs.map +0 -1
  38. package/dist/chunk-ZCVMGIMV.js.map +0 -1
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/boring-vault.ts","../src/abi/chainlink-abi.ts","../src/api/chainlink.ts","../src/api/withdraw-assets.ts","../src/api/solver-slippage.ts"],"names":["getClient","erc20Abi","CHAINLINK_ADDRESS","NUCLEUS_BASE_URL","DEFAULT_SLIPPAGE_BPS"],"mappings":";;;;;;;;;AAWA,eAAsB,iBAAA,CAAkB;AAAA,EACtC,YAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA,EAAoC;AAClC,EAAA,MAAM,MAAA,GAAS,MAAMA,0BAAA,CAAU,OAAO,CAAA;AACtC,EAAA,MAAM,SAAA,GAAY,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IAC1C,GAAA,EAAKC,aAAA;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,CAAC,WAAA,EAAa,cAAc;AAAA,GACnC,CAAA;AAED,EAAA,OAAO,SAAA;AACT;AAOA,eAAsB,cAAA,CAAe;AAAA,EACnC,YAAA;AAAA,EACA;AACF,CAAA,EAAsC;AACpC,EAAA,MAAM,MAAA,GAAS,MAAMD,0BAAA,CAAU,OAAO,CAAA;AACtC,EAAA,MAAM,WAAA,GAAc,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IAC5C,GAAA,EAAKC,aAAA;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,YAAA,EAAc;AAAA,GACf,CAAA;AAED,EAAA,OAAO,W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A,EACF;AACF;;;AC3DA,eAAsB,gBAAA,CACpB,OAAA,EACA,YAAA,EACA,YAAA,EACA,kBAA0BC,qCAAA,EAC1B;AACA,EAAA,IAAI;AAEF,IAAA,MAAM,cAAA,GAAiB,MAAM,mBAAA,EAAoB;AACjD,IAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IAAI,CAAC,cAAA,CAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,EAAG;AACvC,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IAAI,CAAC,eAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,EAAG;AACnE,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IACE,CAAC,cAAA,CAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,CAC5D,YAAA,CAAa,WAAA,EACf,CAAA,EACA;AACA,MAAA,OAAO,eAAA;AAAA,IACT;AAEA,IAAA,OAAO,cAAA,CAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,CAClE,YAAA,CAAa,WAAA,EACf,CAAA;AAAA,EACF,SAAS,KAAA,EAAO;AAEd,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,wCAAA,EAA2C,OAAO,CAAA,EAAA,EAChD,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CACvD,CAAA;AAAA,KACF;AAAA,EACF;AACF","file":"core.js","sourcesContent":["import { type Address, erc20Abi } from \"viem\";\nimport { getClient } from \"../lib/viem/client\";\nimport type { ChainId } from \"./vault-config\";\n\ntype AllowanceProps = {\n tokenAddress: Address;\n spenderAddress: Address;\n userAddress: Address;\n chainId: ChainId;\n};\n\nexport async function getVaultAllowance({\n tokenAddress,\n spenderAddress,\n userAddress,\n chainId,\n}: AllowanceProps): Promise<bigint> {\n const client = await getClient(chainId);\n const allowance = await client.readContract({\n abi: erc20Abi,\n address: tokenAddress,\n functionName: \"allowance\",\n args: [userAddress, spenderAddress],\n });\n\n return allowance;\n}\n\ntype TotalSupplyProps = {\n tokenAddress: Address;\n chainId: ChainId;\n};\n\nexport async function getTotalSupply({\n tokenAddress,\n chainId,\n}: TotalSupplyProps): Promise<bigint> {\n const client = await getClient(chainId);\n const totalSupply = await client.readContract({\n abi: erc20Abi,\n address: tokenAddress,\n functionName: \"totalSupply\",\n });\n\n return totalSupply;\n}\n","export const ChainlinkAbi = [\n {\n type: \"function\",\n name: \"latestRoundData\",\n inputs: [],\n outputs: [\n {\n name: \"roundId\",\n type: \"uint80\",\n internalType: \"uint80\",\n },\n {\n name: \"answer\",\n type: \"int256\",\n internalType: \"int256\",\n },\n {\n name: \"startedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"updatedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"answeredInRound\",\n type: \"uint80\",\n internalType: \"uint80\",\n },\n ],\n stateMutability: \"view\",\n },\n];\n","import { ChainlinkAbi } from \"../abi/chainlink-abi\";\nimport { CHAINLINK_ADDRESS } from \"../constants\";\nimport { getClient } from \"../lib/viem/client\";\nimport type { ChainId } from \"./vault-config\";\n\ninterface GetEthPriceProps {\n chainId: ChainId;\n}\n\nexport async function getEthPrice({\n chainId,\n}: GetEthPriceProps): Promise<bigint> {\n const client = await getClient(chainId);\n const priceData = (await client.readContract({\n abi: ChainlinkAbi,\n address: CHAINLINK_ADDRESS,\n functionName: \"latestRoundData\",\n args: [],\n })) as Array<bigint>;\n\n if (!priceData || !priceData[1]) {\n throw new Error(\"Failed to fetch ETH price from Chainlink\");\n }\n\n return priceData[1];\n}\n","import type { Address } from \"viem\";\nimport { NUCLEUS_BASE_URL } from \"../constants\";\nimport type { ChainId } from \"./vault-config\";\n\nexport interface WithdrawAssetsResponse {\n [chainId: string]: {\n [vaultAddress: string]: {\n [tokenAddress: string]: number;\n };\n };\n}\n\nlet assetsCache: WithdrawAssetsResponse | null = null;\n\n/**\n * Interface for optional parameters when fetching withdraw assets\n */\ninterface FetchWithdrawAssetsParams {\n chainId?: ChainId;\n vaultAddress?: Address;\n}\n\n/**\n * Constructs the URL with optional query parameters\n */\nfunction constructUrl(params?: FetchWithdrawAssetsParams): string {\n const withdrawAssetsUrl = `${NUCLEUS_BASE_URL}/withdraw-assets`;\n if (!params) return withdrawAssetsUrl;\n\n const queryParams = new URLSearchParams();\n if (params.chainId) queryParams.append(\"chainId\", params.chainId.toString());\n if (params.vaultAddress)\n queryParams.append(\"vaultAddress\", params.vaultAddress.toLowerCase());\n\n return `${withdrawAssetsUrl}?${queryParams.toString()}`;\n}\n\n/**\n * Fetches withdraw assets configuration from the API\n * @param params Optional parameters for chainId and vaultAddress\n * @returns Promise<WithdrawAssetsResponse>\n */\nasync function fetchWithdrawAssets(\n params?: FetchWithdrawAssetsParams\n): Promise<WithdrawAssetsResponse> {\n // If no specific params are provided and we have cached data, return it\n if (!params && assetsCache) {\n return assetsCache;\n }\n\n try {\n const url = constructUrl(params);\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: WithdrawAssetsResponse = await response.json();\n\n // Only cache the full response (when no params are provided)\n if (!params) {\n assetsCache = data;\n }\n\n return data;\n } catch (error: unknown) {\n throw new Error(\n `An unknown error occurred while fetching withdraw assets: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n\n/**\n * Fetches withdraw assets for a specific chain\n * @param chainId The chain ID to fetch assets for\n * @returns Promise<WithdrawAssetsResponse[string]>\n */\nasync function fetchChainWithdrawAssets(\n chainId: ChainId\n): Promise<WithdrawAssetsResponse[string]> {\n const assets = await fetchWithdrawAssets({ chainId });\n return assets[chainId.toString()];\n}\n\n/**\n * Fetches withdraw assets for a specific vault on a chain\n * @param chainId The chain ID\n * @param vaultAddress The vault address\n * @returns Promise<WithdrawAssetsResponse[string][string]>\n */\nasync function fetchVaultWithdrawAssets(\n chainId: ChainId,\n vaultAddress: Address\n): Promise<WithdrawAssetsResponse[string][string]> {\n const assets = await fetchWithdrawAssets({ chainId, vaultAddress });\n return assets[chainId.toString()]?.[vaultAddress.toLowerCase()];\n}\n\n/**\n * Clears the assets cache\n */\nfunction clearAssetsCache(): void {\n assetsCache = null;\n}\n\nexport {\n clearAssetsCache,\n fetchChainWithdrawAssets,\n fetchVaultWithdrawAssets,\n fetchWithdrawAssets,\n type FetchWithdrawAssetsParams,\n};\n","import type { Address } from \"viem\";\nimport { DEFAULT_SLIPPAGE_BPS } from \"../constants/config\";\nimport type { ChainId } from \"./vault-config\";\nimport { fetchWithdrawAssets } from \"./withdraw-assets\";\n\n/**\n * Gets the slippage value for a specific asset in a vault\n * @param chainId The chain ID\n * @param vaultAddress The boring vault address\n * @param tokenAddress The token address\n * @param defaultSlippage Optional default slippage value if none is found (defaults to 0)\n * @returns Promise<number> The slippage value\n * @throws {AssetSlippageError} If there's an error fetching or processing the slippage data\n */\nexport async function getAssetSlippage(\n chainId: ChainId,\n vaultAddress: Address,\n tokenAddress: Address,\n defaultSlippage: number = DEFAULT_SLIPPAGE_BPS\n) {\n try {\n // Fetch withdraw assets data, using cache if available\n const withdrawAssets = await fetchWithdrawAssets();\n if (!withdrawAssets) {\n return defaultSlippage;\n }\n if (!withdrawAssets[chainId.toString()]) {\n return defaultSlippage;\n }\n if (!withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()]) {\n return defaultSlippage;\n }\n if (\n !withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()][\n tokenAddress.toLowerCase()\n ]\n ) {\n return defaultSlippage;\n }\n\n return withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()][\n tokenAddress.toLowerCase()\n ];\n } catch (error) {\n // Re-throw with contextual information\n throw new Error(\n `Error fetching asset slippage for chain ${chainId}: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/api/boring-vault.ts","../src/abi/chainlink-abi.ts","../src/api/chainlink.ts","../src/api/withdraw-assets.ts","../src/api/solver-slippage.ts"],"names":["getClient","erc20Abi","CHAINLINK_ADDRESS","NUCLEUS_BASE_URL","DEFAULT_SLIPPAGE_BPS"],"mappings":";;;;;;;;;AAWA,eAAsB,iBAAA,CAAkB;AAAA,EACtC,YAAA;AAAA,EACA,cAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF,CAAA,EAAoC;AAClC,EAAA,MAAM,MAAA,GAAS,MAAMA,0BAAA,CAAU,OAAO,CAAA;AACtC,EAAA,MAAM,SAAA,GAAY,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IAC1C,GAAA,EAAKC,aAAA;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,CAAC,gBAAA,EAAkB,cAAc;AAAA,GACxC,CAAA;AAED,EAAA,OAAO,SAAA;AACT;AAOA,eAAsB,cAAA,CAAe;AAAA,EACnC,YAAA;AAAA,EACA;AACF,CAAA,EAAsC;AACpC,EAAA,MAAM,MAAA,GAAS,MAAMD,0BAAA,CAAU,OAAO,CAAA;AACtC,EAAA,MAAM,WAAA,GAAc,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IAC5C,GAAA,EAAKC,aAAA;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,YAAA,EAAc;AAAA,GACf,CAAA;AAED,EAAA,OAAO,WAAA;AACT;;;AC7CO,IAAM,YAAA,GAAe;AAAA,EAC1B;AAAA,IACE,IAAA,EAAM,UAAA;AAAA,IACN,IAAA,EAAM,iBAAA;AAAA,IACN,QAAQ,EAAC;AAAA,IACT,OAAA,EAAS;AAAA,MACP;AAAA,QACE,IAAA,EAAM,SAAA;AAAA,QACN,IAAA,EAAM,QAAA;AAAA,QACN,YAAA,EAAc;AAAA,OAChB;AAAA,MACA;AAAA,QAC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,CAAQ,QAAA,EAAU,CAAA,EAAG;AACvC,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IAAI,CAAC,eAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,EAAG;AACnE,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IACE,CAAC,cAAA,CAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,CAC5D,YAAA,CAAa,WAAA,EACf,CAAA,EACA;AACA,MAAA,OAAO,eAAA;AAAA,IACT;AAEA,IAAA,OAAO,cAAA,CAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,CAClE,YAAA,CAAa,WAAA,EACf,CAAA;AAAA,EACF,SAAS,KAAA,EAAO;AAEd,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,wCAAA,EAA2C,OAAO,CAAA,EAAA,EAChD,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CACvD,CAAA;AAAA,KACF;AAAA,EACF;AACF","file":"core.js","sourcesContent":["import { type Address, erc20Abi } from \"viem\";\nimport { getClient } from \"../lib/viem/client\";\nimport type { ChainId } from \"./vault-config\";\n\ntype AllowanceProps = {\n tokenAddress: Address;\n spenderAddress: Address;\n recipientAddress: Address;\n chainId: ChainId;\n};\n\nexport async function getVaultAllowance({\n tokenAddress,\n spenderAddress,\n recipientAddress,\n chainId,\n}: AllowanceProps): Promise<bigint> {\n const client = await getClient(chainId);\n const allowance = await client.readContract({\n abi: erc20Abi,\n address: tokenAddress,\n functionName: \"allowance\",\n args: [recipientAddress, spenderAddress],\n });\n\n return allowance;\n}\n\ntype TotalSupplyProps = {\n tokenAddress: Address;\n chainId: ChainId;\n};\n\nexport async function getTotalSupply({\n tokenAddress,\n chainId,\n}: TotalSupplyProps): Promise<bigint> {\n const client = await getClient(chainId);\n const totalSupply = await client.readContract({\n abi: erc20Abi,\n address: tokenAddress,\n functionName: \"totalSupply\",\n });\n\n return totalSupply;\n}\n","export const ChainlinkAbi = [\n {\n type: \"function\",\n name: \"latestRoundData\",\n inputs: [],\n outputs: [\n {\n name: \"roundId\",\n type: \"uint80\",\n internalType: \"uint80\",\n },\n {\n name: \"answer\",\n type: \"int256\",\n internalType: \"int256\",\n },\n {\n name: \"startedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"updatedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"answeredInRound\",\n type: \"uint80\",\n internalType: \"uint80\",\n },\n ],\n stateMutability: \"view\",\n },\n];\n","import { ChainlinkAbi } from \"../abi/chainlink-abi\";\nimport { CHAINLINK_ADDRESS } from \"../constants\";\nimport { getClient } from \"../lib/viem/client\";\nimport type { ChainId } from \"./vault-config\";\n\ninterface GetEthPriceProps {\n chainId: ChainId;\n}\n\nexport async function getEthPrice({\n chainId,\n}: GetEthPriceProps): Promise<bigint> {\n const client = await getClient(chainId);\n const priceData = (await client.readContract({\n abi: ChainlinkAbi,\n address: CHAINLINK_ADDRESS,\n functionName: \"latestRoundData\",\n args: [],\n })) as Array<bigint>;\n\n if (!priceData || !priceData[1]) {\n throw new Error(\"Failed to fetch ETH price from Chainlink\");\n }\n\n return priceData[1];\n}\n","import type { Address } from \"viem\";\nimport { NUCLEUS_BASE_URL } from \"../constants\";\nimport type { ChainId } from \"./vault-config\";\n\nexport interface WithdrawAssetsResponse {\n [chainId: string]: {\n [vaultAddress: string]: {\n [tokenAddress: string]: number;\n };\n };\n}\n\nlet assetsCache: WithdrawAssetsResponse | null = null;\n\n/**\n * Interface for optional parameters when fetching withdraw assets\n */\ninterface FetchWithdrawAssetsParams {\n chainId?: ChainId;\n vaultAddress?: Address;\n}\n\n/**\n * Constructs the URL with optional query parameters\n */\nfunction constructUrl(params?: FetchWithdrawAssetsParams): string {\n const withdrawAssetsUrl = `${NUCLEUS_BASE_URL}/withdraw-assets`;\n if (!params) return withdrawAssetsUrl;\n\n const queryParams = new URLSearchParams();\n if (params.chainId) queryParams.append(\"chainId\", params.chainId.toString());\n if (params.vaultAddress)\n queryParams.append(\"vaultAddress\", params.vaultAddress.toLowerCase());\n\n return `${withdrawAssetsUrl}?${queryParams.toString()}`;\n}\n\n/**\n * Fetches withdraw assets configuration from the API\n * @param params Optional parameters for chainId and vaultAddress\n * @returns Promise<WithdrawAssetsResponse>\n */\nasync function fetchWithdrawAssets(\n params?: FetchWithdrawAssetsParams\n): Promise<WithdrawAssetsResponse> {\n // If no specific params are provided and we have cached data, return it\n if (!params && assetsCache) {\n return assetsCache;\n }\n\n try {\n const url = constructUrl(params);\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: WithdrawAssetsResponse = await response.json();\n\n // Only cache the full response (when no params are provided)\n if (!params) {\n assetsCache = data;\n }\n\n return data;\n } catch (error: unknown) {\n throw new Error(\n `An unknown error occurred while fetching withdraw assets: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n\n/**\n * Fetches withdraw assets for a specific chain\n * @param chainId The chain ID to fetch assets for\n * @returns Promise<WithdrawAssetsResponse[string]>\n */\nasync function fetchChainWithdrawAssets(\n chainId: ChainId\n): Promise<WithdrawAssetsResponse[string]> {\n const assets = await fetchWithdrawAssets({ chainId });\n return assets[chainId.toString()];\n}\n\n/**\n * Fetches withdraw assets for a specific vault on a chain\n * @param chainId The chain ID\n * @param vaultAddress The vault address\n * @returns Promise<WithdrawAssetsResponse[string][string]>\n */\nasync function fetchVaultWithdrawAssets(\n chainId: ChainId,\n vaultAddress: Address\n): Promise<WithdrawAssetsResponse[string][string]> {\n const assets = await fetchWithdrawAssets({ chainId, vaultAddress });\n return assets[chainId.toString()]?.[vaultAddress.toLowerCase()];\n}\n\n/**\n * Clears the assets cache\n */\nfunction clearAssetsCache(): void {\n assetsCache = null;\n}\n\nexport {\n clearAssetsCache,\n fetchChainWithdrawAssets,\n fetchVaultWithdrawAssets,\n fetchWithdrawAssets,\n type FetchWithdrawAssetsParams,\n};\n","import type { Address } from \"viem\";\nimport { DEFAULT_SLIPPAGE_BPS } from \"../constants/config\";\nimport type { ChainId } from \"./vault-config\";\nimport { fetchWithdrawAssets } from \"./withdraw-assets\";\n\n/**\n * Gets the slippage value for a specific asset in a vault\n * @param chainId The chain ID\n * @param vaultAddress The boring vault address\n * @param tokenAddress The token address\n * @param defaultSlippage Optional default slippage value if none is found (defaults to 0)\n * @returns Promise<number> The slippage value\n * @throws {AssetSlippageError} If there's an error fetching or processing the slippage data\n */\nexport async function getAssetSlippage(\n chainId: ChainId,\n vaultAddress: Address,\n tokenAddress: Address,\n defaultSlippage: number = DEFAULT_SLIPPAGE_BPS\n) {\n try {\n // Fetch withdraw assets data, using cache if available\n const withdrawAssets = await fetchWithdrawAssets();\n if (!withdrawAssets) {\n return defaultSlippage;\n }\n if (!withdrawAssets[chainId.toString()]) {\n return defaultSlippage;\n }\n if (!withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()]) {\n return defaultSlippage;\n }\n if (\n !withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()][\n tokenAddress.toLowerCase()\n ]\n ) {\n return defaultSlippage;\n }\n\n return withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()][\n tokenAddress.toLowerCase()\n ];\n } catch (error) {\n // Re-throw with contextual information\n throw new Error(\n `Error fetching asset slippage for chain ${chainId}: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n"]}
package/dist/core.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DEFAULT_SLIPPAGE_BPS } from './chunk-XXHRCCZS.mjs';
2
- export { getPausedStates, getPreviewFee } from './chunk-ZLS2AAMI.mjs';
3
- import { getClient } from './chunk-YP2TR5RP.mjs';
4
- export { getErc20Allowance, getErc20Balance, getErc20Decimals, getRateInQuoteWithAssetDecimals } from './chunk-YP2TR5RP.mjs';
2
+ export { getPausedStates, getPreviewFee } from './chunk-SYVANMRO.mjs';
3
+ import { getClient } from './chunk-LVJ44U7Z.mjs';
4
+ export { getErc20Allowance, getErc20Balance, getErc20Decimals, getRateInQuoteWithAssetDecimals } from './chunk-LVJ44U7Z.mjs';
5
5
  export { fetchVaultConfig, toChainId } from './chunk-J3662HYT.mjs';
6
6
  import { CHAINLINK_ADDRESS, NUCLEUS_BASE_URL } from './chunk-WFCHKDDG.mjs';
7
7
  import { erc20Abi } from 'viem';
@@ -9,7 +9,7 @@ import { erc20Abi } from 'viem';
9
9
  async function getVaultAllowance({
10
10
  tokenAddress,
11
11
  spenderAddress,
12
- userAddress,
12
+ recipientAddress,
13
13
  chainId
14
14
  }) {
15
15
  const client = await getClient(chainId);
@@ -17,7 +17,7 @@ async function getVaultAllowance({
17
17
  abi: erc20Abi,
18
18
  address: tokenAddress,
19
19
  functionName: "allowance",
20
- args: [userAddress, spenderAddress]
20
+ args: [recipientAddress, spenderAddress]
21
21
  });
22
22
  return allowance;
23
23
  }
package/dist/core.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/boring-vault.ts","../src/abi/chainlink-abi.ts","../src/api/chainlink.ts","../src/api/withdraw-assets.ts","../src/api/solver-slippage.ts"],"names":[],"mappings":";;;;;;;;AAWA,eAAsB,iBAAA,CAAkB;AAAA,EACtC,YAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA,EAAoC;AAClC,EAAA,MAAM,MAAA,GAAS,MAAM,SAAA,CAAU,OAAO,CAAA;AACtC,EAAA,MAAM,SAAA,GAAY,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IAC1C,GAAA,EAAK,QAAA;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,CAAC,WAAA,EAAa,cAAc;AAAA,GACnC,CAAA;AAED,EAAA,OAAO,SAAA;AACT;AAOA,eAA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M,OAAA,GAAU,MAAA,CAAO,KAAK,CACvD,CAAA;AAAA,KACF;AAAA,EACF;AACF","file":"core.mjs","sourcesContent":["import { type Address, erc20Abi } from \"viem\";\nimport { getClient } from \"../lib/viem/client\";\nimport type { ChainId } from \"./vault-config\";\n\ntype AllowanceProps = {\n tokenAddress: Address;\n spenderAddress: Address;\n userAddress: Address;\n chainId: ChainId;\n};\n\nexport async function getVaultAllowance({\n tokenAddress,\n spenderAddress,\n userAddress,\n chainId,\n}: AllowanceProps): Promise<bigint> {\n const client = await getClient(chainId);\n const allowance = await client.readContract({\n abi: erc20Abi,\n address: tokenAddress,\n functionName: \"allowance\",\n args: [userAddress, spenderAddress],\n });\n\n return allowance;\n}\n\ntype TotalSupplyProps = {\n tokenAddress: Address;\n chainId: ChainId;\n};\n\nexport async function getTotalSupply({\n tokenAddress,\n chainId,\n}: TotalSupplyProps): Promise<bigint> {\n const client = await getClient(chainId);\n const totalSupply = await client.readContract({\n abi: erc20Abi,\n address: tokenAddress,\n functionName: \"totalSupply\",\n });\n\n return totalSupply;\n}\n","export const ChainlinkAbi = [\n {\n type: \"function\",\n name: \"latestRoundData\",\n inputs: [],\n outputs: [\n {\n name: \"roundId\",\n type: \"uint80\",\n internalType: \"uint80\",\n },\n {\n name: \"answer\",\n type: \"int256\",\n internalType: \"int256\",\n },\n {\n name: \"startedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"updatedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"answeredInRound\",\n type: \"uint80\",\n internalType: \"uint80\",\n },\n ],\n stateMutability: \"view\",\n },\n];\n","import { ChainlinkAbi } from \"../abi/chainlink-abi\";\nimport { CHAINLINK_ADDRESS } from \"../constants\";\nimport { getClient } from \"../lib/viem/client\";\nimport type { ChainId } from \"./vault-config\";\n\ninterface GetEthPriceProps {\n chainId: ChainId;\n}\n\nexport async function getEthPrice({\n chainId,\n}: GetEthPriceProps): Promise<bigint> {\n const client = await getClient(chainId);\n const priceData = (await client.readContract({\n abi: ChainlinkAbi,\n address: CHAINLINK_ADDRESS,\n functionName: \"latestRoundData\",\n args: [],\n })) as Array<bigint>;\n\n if (!priceData || !priceData[1]) {\n throw new Error(\"Failed to fetch ETH price from Chainlink\");\n }\n\n return priceData[1];\n}\n","import type { Address } from \"viem\";\nimport { NUCLEUS_BASE_URL } from \"../constants\";\nimport type { ChainId } from \"./vault-config\";\n\nexport interface WithdrawAssetsResponse {\n [chainId: string]: {\n [vaultAddress: string]: {\n [tokenAddress: string]: number;\n };\n };\n}\n\nlet assetsCache: WithdrawAssetsResponse | null = null;\n\n/**\n * Interface for optional parameters when fetching withdraw assets\n */\ninterface FetchWithdrawAssetsParams {\n chainId?: ChainId;\n vaultAddress?: Address;\n}\n\n/**\n * Constructs the URL with optional query parameters\n */\nfunction constructUrl(params?: FetchWithdrawAssetsParams): string {\n const withdrawAssetsUrl = `${NUCLEUS_BASE_URL}/withdraw-assets`;\n if (!params) return withdrawAssetsUrl;\n\n const queryParams = new URLSearchParams();\n if (params.chainId) queryParams.append(\"chainId\", params.chainId.toString());\n if (params.vaultAddress)\n queryParams.append(\"vaultAddress\", params.vaultAddress.toLowerCase());\n\n return `${withdrawAssetsUrl}?${queryParams.toString()}`;\n}\n\n/**\n * Fetches withdraw assets configuration from the API\n * @param params Optional parameters for chainId and vaultAddress\n * @returns Promise<WithdrawAssetsResponse>\n */\nasync function fetchWithdrawAssets(\n params?: FetchWithdrawAssetsParams\n): Promise<WithdrawAssetsResponse> {\n // If no specific params are provided and we have cached data, return it\n if (!params && assetsCache) {\n return assetsCache;\n }\n\n try {\n const url = constructUrl(params);\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: WithdrawAssetsResponse = await response.json();\n\n // Only cache the full response (when no params are provided)\n if (!params) {\n assetsCache = data;\n }\n\n return data;\n } catch (error: unknown) {\n throw new Error(\n `An unknown error occurred while fetching withdraw assets: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n\n/**\n * Fetches withdraw assets for a specific chain\n * @param chainId The chain ID to fetch assets for\n * @returns Promise<WithdrawAssetsResponse[string]>\n */\nasync function fetchChainWithdrawAssets(\n chainId: ChainId\n): Promise<WithdrawAssetsResponse[string]> {\n const assets = await fetchWithdrawAssets({ chainId });\n return assets[chainId.toString()];\n}\n\n/**\n * Fetches withdraw assets for a specific vault on a chain\n * @param chainId The chain ID\n * @param vaultAddress The vault address\n * @returns Promise<WithdrawAssetsResponse[string][string]>\n */\nasync function fetchVaultWithdrawAssets(\n chainId: ChainId,\n vaultAddress: Address\n): Promise<WithdrawAssetsResponse[string][string]> {\n const assets = await fetchWithdrawAssets({ chainId, vaultAddress });\n return assets[chainId.toString()]?.[vaultAddress.toLowerCase()];\n}\n\n/**\n * Clears the assets cache\n */\nfunction clearAssetsCache(): void {\n assetsCache = null;\n}\n\nexport {\n clearAssetsCache,\n fetchChainWithdrawAssets,\n fetchVaultWithdrawAssets,\n fetchWithdrawAssets,\n type FetchWithdrawAssetsParams,\n};\n","import type { Address } from \"viem\";\nimport { DEFAULT_SLIPPAGE_BPS } from \"../constants/config\";\nimport type { ChainId } from \"./vault-config\";\nimport { fetchWithdrawAssets } from \"./withdraw-assets\";\n\n/**\n * Gets the slippage value for a specific asset in a vault\n * @param chainId The chain ID\n * @param vaultAddress The boring vault address\n * @param tokenAddress The token address\n * @param defaultSlippage Optional default slippage value if none is found (defaults to 0)\n * @returns Promise<number> The slippage value\n * @throws {AssetSlippageError} If there's an error fetching or processing the slippage data\n */\nexport async function getAssetSlippage(\n chainId: ChainId,\n vaultAddress: Address,\n tokenAddress: Address,\n defaultSlippage: number = DEFAULT_SLIPPAGE_BPS\n) {\n try {\n // Fetch withdraw assets data, using cache if available\n const withdrawAssets = await fetchWithdrawAssets();\n if (!withdrawAssets) {\n return defaultSlippage;\n }\n if (!withdrawAssets[chainId.toString()]) {\n return defaultSlippage;\n }\n if (!withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()]) {\n return defaultSlippage;\n }\n if (\n !withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()][\n tokenAddress.toLowerCase()\n ]\n ) {\n return defaultSlippage;\n }\n\n return withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()][\n tokenAddress.toLowerCase()\n ];\n } catch (error) {\n // Re-throw with contextual information\n throw new Error(\n `Error fetching asset slippage for chain ${chainId}: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/api/boring-vault.ts","../src/abi/chainlink-abi.ts","../src/api/chainlink.ts","../src/api/withdraw-assets.ts","../src/api/solver-slippage.ts"],"names":[],"mappings":";;;;;;;;AAWA,eAAsB,iBAAA,CAAkB;AAAA,EACtC,YAAA;AAAA,EACA,cAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF,CAAA,EAAoC;AAClC,EAAA,MAAM,MAAA,GAAS,MAAM,SAAA,CAAU,OAAO,CAAA;AACtC,EAAA,MAAM,SAAA,GAAY,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IAC1C,GAAA,EAAK,QAAA;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,CAAC,gBAAA,EAAkB,cAAc;AAAA,GACxC,CAAA;AAED,EAAA,OAAO,SAAA;AACT;AAOA,eAAsB,cAAA,CAAe;AAAA,EACnC,YAAA;AAAA,EACA;AACF,CAAA,EAAsC;AACpC,EAAA,MAAM,MAAA,GAAS,MAAM,SAAA,CAAU,OAAO,CAAA;AACtC,EAAA,MAAM,WAAA,GAAc,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IAC5C,GAAA,EAAK,QAAA;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,YAAA,EAAc;AAAA,GACf,CAAA;AAED,EAAA,OAAO,WAAA;AACT;;;AC7CO,IAAM,YAAA,GAAe;AAAA,EAC1B;AAAA,IACE,I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AA,EACA,kBAA0B,oBAAA,EAC1B;AACA,EAAA,IAAI;AAEF,IAAA,MAAM,cAAA,GAAiB,MAAM,mBAAA,EAAoB;AACjD,IAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IAAI,CAAC,cAAA,CAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,EAAG;AACvC,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IAAI,CAAC,eAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,EAAG;AACnE,MAAA,OAAO,eAAA;AAAA,IACT;AACA,IAAA,IACE,CAAC,cAAA,CAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,CAC5D,YAAA,CAAa,WAAA,EACf,CAAA,EACA;AACA,MAAA,OAAO,eAAA;AAAA,IACT;AAEA,IAAA,OAAO,cAAA,CAAe,OAAA,CAAQ,QAAA,EAAU,CAAA,CAAE,YAAA,CAAa,WAAA,EAAa,CAAA,CAClE,YAAA,CAAa,WAAA,EACf,CAAA;AAAA,EACF,SAAS,KAAA,EAAO;AAEd,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,wCAAA,EAA2C,OAAO,CAAA,EAAA,EAChD,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CACvD,CAAA;AAAA,KACF;AAAA,EACF;AACF","file":"core.mjs","sourcesContent":["import { type Address, erc20Abi } from \"viem\";\nimport { getClient } from \"../lib/viem/client\";\nimport type { ChainId } from \"./vault-config\";\n\ntype AllowanceProps = {\n tokenAddress: Address;\n spenderAddress: Address;\n recipientAddress: Address;\n chainId: ChainId;\n};\n\nexport async function getVaultAllowance({\n tokenAddress,\n spenderAddress,\n recipientAddress,\n chainId,\n}: AllowanceProps): Promise<bigint> {\n const client = await getClient(chainId);\n const allowance = await client.readContract({\n abi: erc20Abi,\n address: tokenAddress,\n functionName: \"allowance\",\n args: [recipientAddress, spenderAddress],\n });\n\n return allowance;\n}\n\ntype TotalSupplyProps = {\n tokenAddress: Address;\n chainId: ChainId;\n};\n\nexport async function getTotalSupply({\n tokenAddress,\n chainId,\n}: TotalSupplyProps): Promise<bigint> {\n const client = await getClient(chainId);\n const totalSupply = await client.readContract({\n abi: erc20Abi,\n address: tokenAddress,\n functionName: \"totalSupply\",\n });\n\n return totalSupply;\n}\n","export const ChainlinkAbi = [\n {\n type: \"function\",\n name: \"latestRoundData\",\n inputs: [],\n outputs: [\n {\n name: \"roundId\",\n type: \"uint80\",\n internalType: \"uint80\",\n },\n {\n name: \"answer\",\n type: \"int256\",\n internalType: \"int256\",\n },\n {\n name: \"startedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"updatedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"answeredInRound\",\n type: \"uint80\",\n internalType: \"uint80\",\n },\n ],\n stateMutability: \"view\",\n },\n];\n","import { ChainlinkAbi } from \"../abi/chainlink-abi\";\nimport { CHAINLINK_ADDRESS } from \"../constants\";\nimport { getClient } from \"../lib/viem/client\";\nimport type { ChainId } from \"./vault-config\";\n\ninterface GetEthPriceProps {\n chainId: ChainId;\n}\n\nexport async function getEthPrice({\n chainId,\n}: GetEthPriceProps): Promise<bigint> {\n const client = await getClient(chainId);\n const priceData = (await client.readContract({\n abi: ChainlinkAbi,\n address: CHAINLINK_ADDRESS,\n functionName: \"latestRoundData\",\n args: [],\n })) as Array<bigint>;\n\n if (!priceData || !priceData[1]) {\n throw new Error(\"Failed to fetch ETH price from Chainlink\");\n }\n\n return priceData[1];\n}\n","import type { Address } from \"viem\";\nimport { NUCLEUS_BASE_URL } from \"../constants\";\nimport type { ChainId } from \"./vault-config\";\n\nexport interface WithdrawAssetsResponse {\n [chainId: string]: {\n [vaultAddress: string]: {\n [tokenAddress: string]: number;\n };\n };\n}\n\nlet assetsCache: WithdrawAssetsResponse | null = null;\n\n/**\n * Interface for optional parameters when fetching withdraw assets\n */\ninterface FetchWithdrawAssetsParams {\n chainId?: ChainId;\n vaultAddress?: Address;\n}\n\n/**\n * Constructs the URL with optional query parameters\n */\nfunction constructUrl(params?: FetchWithdrawAssetsParams): string {\n const withdrawAssetsUrl = `${NUCLEUS_BASE_URL}/withdraw-assets`;\n if (!params) return withdrawAssetsUrl;\n\n const queryParams = new URLSearchParams();\n if (params.chainId) queryParams.append(\"chainId\", params.chainId.toString());\n if (params.vaultAddress)\n queryParams.append(\"vaultAddress\", params.vaultAddress.toLowerCase());\n\n return `${withdrawAssetsUrl}?${queryParams.toString()}`;\n}\n\n/**\n * Fetches withdraw assets configuration from the API\n * @param params Optional parameters for chainId and vaultAddress\n * @returns Promise<WithdrawAssetsResponse>\n */\nasync function fetchWithdrawAssets(\n params?: FetchWithdrawAssetsParams\n): Promise<WithdrawAssetsResponse> {\n // If no specific params are provided and we have cached data, return it\n if (!params && assetsCache) {\n return assetsCache;\n }\n\n try {\n const url = constructUrl(params);\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: WithdrawAssetsResponse = await response.json();\n\n // Only cache the full response (when no params are provided)\n if (!params) {\n assetsCache = data;\n }\n\n return data;\n } catch (error: unknown) {\n throw new Error(\n `An unknown error occurred while fetching withdraw assets: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n\n/**\n * Fetches withdraw assets for a specific chain\n * @param chainId The chain ID to fetch assets for\n * @returns Promise<WithdrawAssetsResponse[string]>\n */\nasync function fetchChainWithdrawAssets(\n chainId: ChainId\n): Promise<WithdrawAssetsResponse[string]> {\n const assets = await fetchWithdrawAssets({ chainId });\n return assets[chainId.toString()];\n}\n\n/**\n * Fetches withdraw assets for a specific vault on a chain\n * @param chainId The chain ID\n * @param vaultAddress The vault address\n * @returns Promise<WithdrawAssetsResponse[string][string]>\n */\nasync function fetchVaultWithdrawAssets(\n chainId: ChainId,\n vaultAddress: Address\n): Promise<WithdrawAssetsResponse[string][string]> {\n const assets = await fetchWithdrawAssets({ chainId, vaultAddress });\n return assets[chainId.toString()]?.[vaultAddress.toLowerCase()];\n}\n\n/**\n * Clears the assets cache\n */\nfunction clearAssetsCache(): void {\n assetsCache = null;\n}\n\nexport {\n clearAssetsCache,\n fetchChainWithdrawAssets,\n fetchVaultWithdrawAssets,\n fetchWithdrawAssets,\n type FetchWithdrawAssetsParams,\n};\n","import type { Address } from \"viem\";\nimport { DEFAULT_SLIPPAGE_BPS } from \"../constants/config\";\nimport type { ChainId } from \"./vault-config\";\nimport { fetchWithdrawAssets } from \"./withdraw-assets\";\n\n/**\n * Gets the slippage value for a specific asset in a vault\n * @param chainId The chain ID\n * @param vaultAddress The boring vault address\n * @param tokenAddress The token address\n * @param defaultSlippage Optional default slippage value if none is found (defaults to 0)\n * @returns Promise<number> The slippage value\n * @throws {AssetSlippageError} If there's an error fetching or processing the slippage data\n */\nexport async function getAssetSlippage(\n chainId: ChainId,\n vaultAddress: Address,\n tokenAddress: Address,\n defaultSlippage: number = DEFAULT_SLIPPAGE_BPS\n) {\n try {\n // Fetch withdraw assets data, using cache if available\n const withdrawAssets = await fetchWithdrawAssets();\n if (!withdrawAssets) {\n return defaultSlippage;\n }\n if (!withdrawAssets[chainId.toString()]) {\n return defaultSlippage;\n }\n if (!withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()]) {\n return defaultSlippage;\n }\n if (\n !withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()][\n tokenAddress.toLowerCase()\n ]\n ) {\n return defaultSlippage;\n }\n\n return withdrawAssets[chainId.toString()][vaultAddress.toLowerCase()][\n tokenAddress.toLowerCase()\n ];\n } catch (error) {\n // Re-throw with contextual information\n throw new Error(\n `Error fetching asset slippage for chain ${chainId}: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-CRA_CMaX.mjs';
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
- userAddress: Address;
12
+ recipientAddress: Address;
13
13
  nativeTokenForBridgeFee?: Address;
14
14
  }
15
- declare const getBridgeFee: ({ vaultKey, bridgeAmount, sourceChainId, destinationChainId, userAddress, nativeTokenForBridgeFee, }: GetPreviewFeeParams) => Promise<bigint>;
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-D3_FVgqa.js';
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
- userAddress: Address;
12
+ recipientAddress: Address;
13
13
  nativeTokenForBridgeFee?: Address;
14
14
  }
15
- declare const getBridgeFee: ({ vaultKey, bridgeAmount, sourceChainId, destinationChainId, userAddress, nativeTokenForBridgeFee, }: GetPreviewFeeParams) => Promise<bigint>;
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,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkZCVMGIMV_js = require('./chunk-ZCVMGIMV.js');
4
- var chunkAIBI7ZQM_js = require('./chunk-AIBI7ZQM.js');
5
- require('./chunk-BXUG3WDV.js');
3
+ var chunkBMN6KTOC_js = require('./chunk-BMN6KTOC.js');
4
+ var chunkNLLEYTJ6_js = require('./chunk-NLLEYTJ6.js');
5
+ require('./chunk-ANL3PE7L.js');
6
6
  var chunkICKDAKVS_js = require('./chunk-ICKDAKVS.js');
7
7
  require('./chunk-RUIAH5HY.js');
8
8
  require('./chunk-3I3PYX2F.js');
@@ -11,12 +11,12 @@ var chunkIBNTWZ4S_js = require('./chunk-IBNTWZ4S.js');
11
11
  // src/vaults/bridge.ts
12
12
  var prepareBridgeContractArg = ({
13
13
  bridgeChainIdentifier,
14
- userAddress,
14
+ recipientAddress,
15
15
  nativeTokenForBridgeFee = chunkIBNTWZ4S_js.NATIVE_TOKEN_FOR_BRIDGE_FEE
16
16
  }) => {
17
17
  return {
18
18
  chainSelector: bridgeChainIdentifier,
19
- destinationChainReceiver: userAddress,
19
+ destinationChainReceiver: recipientAddress,
20
20
  bridgeFeeToken: nativeTokenForBridgeFee,
21
21
  messageGas: BigInt(1e5),
22
22
  data: "0x"
@@ -29,7 +29,7 @@ var getBridgeFee = async ({
29
29
  bridgeAmount,
30
30
  sourceChainId,
31
31
  destinationChainId,
32
- userAddress,
32
+ recipientAddress,
33
33
  nativeTokenForBridgeFee = chunkIBNTWZ4S_js.NATIVE_TOKEN_FOR_BRIDGE_FEE
34
34
  }) => {
35
35
  const vault = await chunkICKDAKVS_js.getVaultByKey(vaultKey);
@@ -61,10 +61,10 @@ var getBridgeFee = async ({
61
61
  const bridgeChainIdentifier = destinationChain.bridge.chainIdentifier;
62
62
  const bridgeContractArg = prepareBridgeContractArg({
63
63
  bridgeChainIdentifier,
64
- userAddress,
64
+ recipientAddress,
65
65
  nativeTokenForBridgeFee
66
66
  });
67
- const previewFee = await chunkAIBI7ZQM_js.getPreviewFee({
67
+ const previewFee = await chunkNLLEYTJ6_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 chunkAIBI7ZQM_js.getPausedStates({
84
+ const [tellerStatus, accountantStatus] = await chunkNLLEYTJ6_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 chunkZCVMGIMV_js.getDepositExchangeRate; }
107
+ get: function () { return chunkBMN6KTOC_js.getDepositExchangeRate; }
108
108
  });
109
109
  Object.defineProperty(exports, "getWithdrawExchangeRate", {
110
110
  enumerable: true,
111
- get: function () { return chunkZCVMGIMV_js.getWithdrawExchangeRate; }
111
+ get: function () { return chunkBMN6KTOC_js.getWithdrawExchangeRate; }
112
112
  });
113
113
  Object.defineProperty(exports, "isDepositSpendApproved", {
114
114
  enumerable: true,
115
- get: function () { return chunkZCVMGIMV_js.isDepositSpendApproved; }
115
+ get: function () { return chunkBMN6KTOC_js.isDepositSpendApproved; }
116
116
  });
117
117
  Object.defineProperty(exports, "isWithdrawalSpendApproved", {
118
118
  enumerable: true,
119
- get: function () { return chunkZCVMGIMV_js.isWithdrawalSpendApproved; }
119
+ get: function () { return chunkBMN6KTOC_js.isWithdrawalSpendApproved; }
120
120
  });
121
121
  exports.getBridgeFee = getBridgeFee;
122
122
  exports.getVaultStatus = getVaultStatus;
@@ -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,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,EA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A,GAAiB,OAAO,EAAE,QAAA,EAAU,SAAQ,KAAyB;AACzE,EAAA,MAAM,KAAA,GAAQ,MAAMD,8BAAA,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,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} 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,qBAAA;AAAA,EACA,gBAAA;AAAA,EACA,uBAAA,GAA0BA;AAC5B,CAAA,KAAkD;AAChD,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,qBAAA;AAAA,IACf,wBAAA,EAA0B,gBAAA;AAAA,IAC1B,cAAA,EAAgB,uBAAA;AAAA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A,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 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 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 of the user initiating the bridge\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,6 +1,6 @@
1
- export { getDepositExchangeRate, getWithdrawExchangeRate, isDepositSpendApproved, isWithdrawalSpendApproved } from './chunk-GBWBO6ZF.mjs';
2
- import { getPreviewFee, getPausedStates } from './chunk-ZLS2AAMI.mjs';
3
- import './chunk-YP2TR5RP.mjs';
1
+ export { getDepositExchangeRate, getWithdrawExchangeRate, isDepositSpendApproved, isWithdrawalSpendApproved } from './chunk-774KTF7A.mjs';
2
+ import { getPreviewFee, getPausedStates } from './chunk-SYVANMRO.mjs';
3
+ import './chunk-LVJ44U7Z.mjs';
4
4
  import { getVaultByKey } from './chunk-R663BFAZ.mjs';
5
5
  import './chunk-J3662HYT.mjs';
6
6
  import './chunk-7RWWVUHP.mjs';
@@ -9,12 +9,12 @@ import { NATIVE_TOKEN_FOR_BRIDGE_FEE } from './chunk-WFCHKDDG.mjs';
9
9
  // src/vaults/bridge.ts
10
10
  var prepareBridgeContractArg = ({
11
11
  bridgeChainIdentifier,
12
- userAddress,
12
+ recipientAddress,
13
13
  nativeTokenForBridgeFee = NATIVE_TOKEN_FOR_BRIDGE_FEE
14
14
  }) => {
15
15
  return {
16
16
  chainSelector: bridgeChainIdentifier,
17
- destinationChainReceiver: userAddress,
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
- userAddress,
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
- userAddress,
62
+ recipientAddress,
63
63
  nativeTokenForBridgeFee
64
64
  });
65
65
  const previewFee = await getPreviewFee({
@@ -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,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,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,CA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AAS;AAAA,GACV,CAAA;AAGD,EAAA,OAAO,UAAA;AACT;;;ACjEA,IAAM,cAAA,GAAiB,OAAO,EAAE,QAAA,EAAU,SAAQ,KAAyB;AACzE,EAAA,MAAM,KAAA,GAAQ,MAAM,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} 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;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AM,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 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 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 of the user initiating the bridge\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, userAddress, }: {
6
+ declare const isDepositSpendApproved: ({ yieldType, chainId, depositAssetAddress, recipientAddress, }: {
7
7
  yieldType: YieldType;
8
8
  chainId: ChainId;
9
9
  depositAssetAddress: Address;
10
- userAddress: Address;
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, userAddress, }: {
18
+ declare const isWithdrawalSpendApproved: ({ yieldType, chainId, wantAssetAddress, recipientAddress, }: {
19
19
  yieldType: YieldType;
20
20
  chainId: ChainId;
21
21
  wantAssetAddress: Address;
22
- userAddress: Address;
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, userAddress, }: {
6
+ declare const isDepositSpendApproved: ({ yieldType, chainId, depositAssetAddress, recipientAddress, }: {
7
7
  yieldType: YieldType;
8
8
  chainId: ChainId;
9
9
  depositAssetAddress: Address;
10
- userAddress: Address;
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, userAddress, }: {
18
+ declare const isWithdrawalSpendApproved: ({ yieldType, chainId, wantAssetAddress, recipientAddress, }: {
19
19
  yieldType: YieldType;
20
20
  chainId: ChainId;
21
21
  wantAssetAddress: Address;
22
- userAddress: Address;
22
+ recipientAddress: Address;
23
23
  }) => Promise<{
24
24
  isApproved: boolean;
25
25
  allowance: string;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Address, erc20Abi, Hex } from 'viem';
2
2
  import { A as AmplifyVault, S as SupportedAsset, a as AssetFilterOptions, V as VaultFilterOptions, W as WithdrawSupportedAsset } from './amplify-sdk-api-DPrRhynk.mjs';
3
3
  export { b as APIError } from './amplify-sdk-api-DPrRhynk.mjs';
4
- export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-CRA_CMaX.mjs';
4
+ export { g as getDepositExchangeRate, a as getWithdrawExchangeRate, i as isDepositSpendApproved, b as isWithdrawalSpendApproved } from './exchange-rate-BfPH_fQt.mjs';
5
5
  import { Y as YieldType } from './config-B-u3VqEX.mjs';
6
6
  import { C as ChainId } from './vault-config-BjSE7oL8.mjs';
7
7
  import './config-BQynVNDC.mjs';
@@ -1969,7 +1969,7 @@ interface UnencodedDepositWithPermitData {
1969
1969
  * yieldType: 'PRIME',
1970
1970
  * depositToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
1971
1971
  * depositAmount: '1000.0',
1972
- * recipientAddress: userAddress,
1972
+ * recipientAddress: recipientAddress,
1973
1973
  * chainId: 1,
1974
1974
  * deadline: BigInt(Math.floor(Date.now() / 1000) + 3600),
1975
1975
  * });
@@ -2056,7 +2056,7 @@ interface PrepareDepositWithPermitTxDataParams {
2056
2056
  * });
2057
2057
  * ```
2058
2058
  */
2059
- declare function prepareDepositWithPermitTransactionData(params: PrepareDepositWithPermitTxDataParams): Promise<UnencodedDepositWithPermitData>;
2059
+ declare function prepareDepositWithPermitTxData(params: PrepareDepositWithPermitTxDataParams): Promise<UnencodedDepositWithPermitData>;
2060
2060
 
2061
2061
  declare const BoringVaultAbi: readonly [{
2062
2062
  readonly type: "constructor";
@@ -2753,7 +2753,7 @@ interface PrepareBulkWithdrawTxDataParams {
2753
2753
  wantAssetAddress: Address;
2754
2754
  chainId: ChainId;
2755
2755
  slippage?: number;
2756
- userAddress: Address;
2756
+ recipientAddress: Address;
2757
2757
  }
2758
2758
  /**
2759
2759
  * Prepares the transaction data needed to withdraw assets from a vault
@@ -2770,7 +2770,7 @@ interface PrepareBulkWithdrawTxDataParams {
2770
2770
  * vault: vaults[0],
2771
2771
  * wantAsset: wantAssets[0],
2772
2772
  * chainId: 1,
2773
- * userAddress: '0x1234...',
2773
+ * recipientAddress: '0x1234...',
2774
2774
  * offerAmount: "1.0", // 1 vault share
2775
2775
  * deadline: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
2776
2776
  * slippage: 100, // 1% slippage (100 bps)
@@ -2781,7 +2781,7 @@ interface PrepareBulkWithdrawTxDataParams {
2781
2781
  * @param {AmplifyVault} params.vault - Vault configuration from fetchVaults()
2782
2782
  * @param {SupportedAsset} params.wantAsset - Asset metadata from fetchSupportedAssets()
2783
2783
  * @param {ChainId} params.chainId - ID of the chain where the withdrawal will occur
2784
- * @param {Address} params.userAddress - Ethereum address of the user making the withdrawal
2784
+ * @param {Address} params.recipientAddress - Ethereum address of the user making the withdrawal
2785
2785
  * @param {string} params.offerAmount - Amount of vault shares to withdraw as a decimal string
2786
2786
  * @param {number} [params.deadline] - Unix timestamp when the request expires
2787
2787
  * @param {number} [params.slippage] - Maximum acceptable slippage in basis points
@@ -3146,7 +3146,7 @@ type UserRequest = {
3146
3146
  * @property {Address} wantAssetAddress - Address of the want token
3147
3147
  * @property {ChainId} chainId - ID of the chain where the withdrawal will occur
3148
3148
  * @property {string} offerAmount - Amount of vault shares to withdraw as a decimal string
3149
- * @property {Address} userAddress - Ethereum address of the user making the withdrawal
3149
+ * @property {Address} recipientAddress - Ethereum address of the user making the withdrawal
3150
3150
  * @property {number} [deadline] - Unix timestamp when the request expires (optional)
3151
3151
  * @property {number} [slippage] - Maximum acceptable slippage in basis points (optional, default: 100 for 1%)
3152
3152
  *
@@ -3178,7 +3178,7 @@ interface PrepareWithdrawTxDataParams {
3178
3178
  wantAssetAddress: Address;
3179
3179
  chainId: ChainId;
3180
3180
  offerAmount: string;
3181
- userAddress: Address;
3181
+ recipientAddress: Address;
3182
3182
  deadline?: number;
3183
3183
  slippage?: number;
3184
3184
  }
@@ -3212,7 +3212,7 @@ interface WithdrawTxData {
3212
3212
  * yieldType: 'PRIME',
3213
3213
  * wantAssetAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
3214
3214
  * chainId: 1,
3215
- * userAddress: '0x1234...',
3215
+ * recipientAddress: '0x1234...',
3216
3216
  * offerAmount: "1.0", // 1 vault share
3217
3217
  * deadline: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
3218
3218
  * slippage: 100, // 1% slippage (100 bps)
@@ -3223,7 +3223,7 @@ interface WithdrawTxData {
3223
3223
  * @param {YieldType} params.yieldType - Yield strategy type (PRIME, TBILL, or LENDING)
3224
3224
  * @param {Address} params.wantAssetAddress - Address of the want token
3225
3225
  * @param {ChainId} params.chainId - ID of the chain where the withdrawal will occur
3226
- * @param {Address} params.userAddress - Ethereum address of the user making the withdrawal
3226
+ * @param {Address} params.recipientAddress - Ethereum address of the user making the withdrawal
3227
3227
  * @param {string} params.offerAmount - Amount of vault shares to withdraw as a decimal string
3228
3228
  * @param {number} [params.deadline] - Unix timestamp when the request expires
3229
3229
  * @param {number} [params.slippage] - Maximum acceptable slippage in basis points
@@ -3233,4 +3233,4 @@ interface WithdrawTxData {
3233
3233
  */
3234
3234
  declare const prepareWithdrawTxData: ({ yieldType, wantAssetAddress, chainId, offerAmount, deadline, slippage, }: PrepareWithdrawTxDataParams) => Promise<WithdrawTxData>;
3235
3235
 
3236
- export { AmplifyVault, type ApproveDepositTokenTxData, type ApproveWithdrawTokenTxData, AssetFilterOptions, type BulkWithdrawTxData, type DepositTxData, type EIP712Domain, type InitErrorCode, PERMIT_TYPES, type ParsedPermitSignature, type PermitSignatureData, type PrepareDepositPermitSignatureParams, type PrepareDepositWithPermitTxDataParams, type RequestHeaders, type SDKConfig, SupportedAsset, type UnencodedDepositWithPermitData, VaultFilterOptions, WithdrawSupportedAsset, type WithdrawTxData, YieldType, fetchSupportedAssets, fetchVaults, findVaultByConfig, getAssetsFromCache, getCache, getWithdrawSupportedAssets, initAmplifySDK, initializeCache, parsePermitSignature, prepareApproveDepositTokenTxData, prepareApproveWithdrawTxData, prepareBulkWithdrawTxData, prepareDepositPermitSignature, prepareDepositTxData, prepareDepositWithPermitTransactionData, prepareWithdrawTxData, refreshVaultCache };
3236
+ export { AmplifyVault, type ApproveDepositTokenTxData, type ApproveWithdrawTokenTxData, AssetFilterOptions, type BulkWithdrawTxData, type DepositTxData, type EIP712Domain, type InitErrorCode, PERMIT_TYPES, type ParsedPermitSignature, type PermitSignatureData, type PrepareDepositPermitSignatureParams, type PrepareDepositWithPermitTxDataParams, type RequestHeaders, type SDKConfig, SupportedAsset, type UnencodedDepositWithPermitData, VaultFilterOptions, WithdrawSupportedAsset, type WithdrawTxData, YieldType, fetchSupportedAssets, fetchVaults, findVaultByConfig, getAssetsFromCache, getCache, getWithdrawSupportedAssets, initAmplifySDK, initializeCache, parsePermitSignature, prepareApproveDepositTokenTxData, prepareApproveWithdrawTxData, prepareBulkWithdrawTxData, prepareDepositPermitSignature, prepareDepositTxData, prepareDepositWithPermitTxData, prepareWithdrawTxData, refreshVaultCache };