diff --git a/packages/blue-sdk-ethers/src/fetch/Token.ts b/packages/blue-sdk-ethers/src/fetch/Token.ts index 1ee040f4..df72da99 100644 --- a/packages/blue-sdk-ethers/src/fetch/Token.ts +++ b/packages/blue-sdk-ethers/src/fetch/Token.ts @@ -18,6 +18,7 @@ import { ChainId, ChainUtils, ConstantWrappedToken, + Eip5267Domain, ExchangeRateWrappedToken, NATIVE_ADDRESS, Token, @@ -158,11 +159,33 @@ export async function fetchToken( const erc20 = ERC20Metadata__factory.connect(address, chainId, runner); const erc20Permit = ERC20Permit__factory.connect(address, runner); - const [decimals, symbol, name, eip712Domain] = await Promise.all([ + const [decimals, symbol, name, eip5267Domain] = await Promise.all([ erc20.decimals(overrides).catch(() => undefined), erc20.symbol(overrides).catch(() => undefined), erc20.name(overrides).catch(() => undefined), - erc20Permit.eip712Domain(overrides).catch(() => undefined), + erc20Permit + .eip712Domain(overrides) + .then( + ({ + fields, + name, + version, + chainId, + verifyingContract, + salt, + extensions, + }) => + new Eip5267Domain({ + fields: fields as `0x${string}`, + name, + version, + chainId, + verifyingContract: verifyingContract as Address, + salt: salt as `0x${string}`, + extensions, + }), + ) + .catch(() => undefined), ]); const token = { @@ -170,12 +193,7 @@ export async function fetchToken( name, symbol, decimals, - eip712Domain: eip712Domain && { - chainId: eip712Domain.chainId, - name: eip712Domain.name, - verifyingContract: eip712Domain.verifyingContract as Address, - version: eip712Domain.version, - }, + eip5267Domain, }; const { wstEth, stEth } = getChainAddresses(chainId); diff --git a/packages/blue-sdk-ethers/src/fetch/VaultConfig.ts b/packages/blue-sdk-ethers/src/fetch/VaultConfig.ts index c62c9675..3faba474 100644 --- a/packages/blue-sdk-ethers/src/fetch/VaultConfig.ts +++ b/packages/blue-sdk-ethers/src/fetch/VaultConfig.ts @@ -1,55 +1,39 @@ import type { Provider } from "ethers"; import { MetaMorpho__factory } from "ethers-types"; -import { - type Address, - type ChainId, - ChainUtils, - UnknownVaultConfigError, - VaultConfig, - _try, -} from "@morpho-org/blue-sdk"; +import { type Address, ChainUtils, VaultConfig } from "@morpho-org/blue-sdk"; +import type { FetchOptions } from "../types"; +import { fetchToken } from "./Token"; export async function fetchVaultConfig( address: Address, runner: { provider: Provider }, - { chainId }: { chainId?: ChainId } = {}, + options: FetchOptions = {}, ) { - chainId = ChainUtils.parseSupportedChainId( - chainId ?? (await runner.provider.getNetwork()).chainId, + options.chainId = ChainUtils.parseSupportedChainId( + options.chainId ?? (await runner.provider.getNetwork()).chainId, ); - let config = _try( - () => VaultConfig.get(address, chainId), - UnknownVaultConfigError, + const mm = MetaMorpho__factory.connect( + address, + // @ts-ignore incompatible commonjs type + runner, ); - if (!config) { - const mm = MetaMorpho__factory.connect( - address, - // @ts-ignore incompatible commonjs type - runner, - ); + const { overrides = {} } = options; - // always fetch at latest block because config is immutable - const [asset, symbol, name, decimalsOffset] = await Promise.all([ - mm.asset() as Promise
, - mm.symbol(), - mm.name(), - mm.DECIMALS_OFFSET(), - ]); + const [token, asset, decimalsOffset] = await Promise.all([ + fetchToken(address, runner, options), + mm.asset() as Promise
, + mm.DECIMALS_OFFSET(overrides), + ]); - config = new VaultConfig( - { - address, - asset, - symbol, - name, - decimalsOffset, - }, - chainId, - ); - } - - return config; + return new VaultConfig( + { + ...token, + asset, + decimalsOffset, + }, + options.chainId, + ); } diff --git a/packages/blue-sdk-ethers/src/signatures/permit.ts b/packages/blue-sdk-ethers/src/signatures/permit.ts index 35a4e644..ef329993 100644 --- a/packages/blue-sdk-ethers/src/signatures/permit.ts +++ b/packages/blue-sdk-ethers/src/signatures/permit.ts @@ -27,7 +27,7 @@ export const getPermitMessage = ( ): SignatureMessage => { const { usdc, dai } = getChainAddresses(chainId); - const domain = erc20.eip712Domain ?? { + const domain = erc20.eip5267Domain?.eip712Domain ?? { name: erc20.name, version: erc20.address === usdc ? "2" : "1", chainId, diff --git a/packages/blue-sdk-ethers/test/e2e/Token.test.ts b/packages/blue-sdk-ethers/test/e2e/Token.test.ts index cbe8af28..d2fe3959 100644 --- a/packages/blue-sdk-ethers/test/e2e/Token.test.ts +++ b/packages/blue-sdk-ethers/test/e2e/Token.test.ts @@ -3,10 +3,12 @@ import { test } from "./setup"; import { ChainId, + Eip5267Domain, ExchangeRateWrappedToken, addresses, } from "@morpho-org/blue-sdk"; import { randomAddress } from "@morpho-org/test"; +import { zeroHash } from "viem"; import { Token } from "../../src/augment/Token"; const { mkr, usdc, stEth, wstEth } = addresses[ChainId.EthMainnet]; @@ -63,23 +65,26 @@ describe("augment/Token", () => { expect(value).toStrictEqual(expectedData); }); - test("should fetch token data with eip712Domain", async ({ wallet }) => { + test("should fetch token data with eip5267Domain", async ({ wallet }) => { const steakUSDC = "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB"; const expectedData = new Token({ address: steakUSDC, decimals: 18, symbol: "steakUSDC", name: "Steakhouse USDC", - eip712Domain: { + eip5267Domain: new Eip5267Domain({ + fields: "0x0f", name: "Steakhouse USDC", - verifyingContract: steakUSDC, version: "1", chainId: 1n, - }, + verifyingContract: steakUSDC, + salt: zeroHash, + extensions: [], + }), }); const value = await Token.fetch(expectedData.address, wallet); - expect(value).toStrictEqual(expectedData); + expect(value).toEqual(expectedData); }); }); diff --git a/packages/blue-sdk-ethers/test/e2e/Vault.test.ts b/packages/blue-sdk-ethers/test/e2e/Vault.test.ts index c2a5bfcf..38ac06d3 100644 --- a/packages/blue-sdk-ethers/test/e2e/Vault.test.ts +++ b/packages/blue-sdk-ethers/test/e2e/Vault.test.ts @@ -1,10 +1,15 @@ import { describe, expect } from "vitest"; import { test } from "./setup"; -import { ChainId, type MarketId, addresses } from "@morpho-org/blue-sdk"; +import { + ChainId, + Eip5267Domain, + type MarketId, + addresses, +} from "@morpho-org/blue-sdk"; import { vaults } from "@morpho-org/morpho-test"; -import { zeroAddress } from "viem"; +import { zeroAddress, zeroHash } from "viem"; import { Vault } from "../../src/augment/Vault"; import { metaMorphoAbi, publicAllocatorAbi } from "./abis"; @@ -71,10 +76,19 @@ describe("augment/Vault", () => { lastTotalAssets: 26129569140552n, totalAssets: 26138940196162n, totalSupply: 25752992371062043744406063n, + eip5267Domain: new Eip5267Domain({ + fields: "0x0f", + name: "Steakhouse USDC", + version: "1", + chainId: 1n, + verifyingContract: steakUsdc.address, + salt: zeroHash, + extensions: [], + }), }); const value = await Vault.fetch(steakUsdc.address, wallet); - expect(value).toStrictEqual(expectedData); + expect(value).toEqual(expectedData); }); }); diff --git a/packages/blue-sdk-viem/contracts/GetToken.sol b/packages/blue-sdk-viem/contracts/GetToken.sol index e676dd1e..66323c96 100644 --- a/packages/blue-sdk-viem/contracts/GetToken.sol +++ b/packages/blue-sdk-viem/contracts/GetToken.sol @@ -1,17 +1,10 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; -import {IERC20Permit} from "./interfaces/IERC20Permit.sol"; +import {IERC20Permit, Eip5267Domain} from "./interfaces/IERC20Permit.sol"; import {IERC20} from "./interfaces/IERC20.sol"; import {IWstEth} from "./interfaces/IWstEth.sol"; -struct Eip712Domain { - string name; - string version; - address verifyingContract; - uint256 chainId; -} - struct TokenResponse { uint256 decimals; bool hasSymbol; @@ -19,8 +12,8 @@ struct TokenResponse { bool hasName; string name; uint256 stEthPerWstEth; - Eip712Domain eip712Domain; - bool hasEip712Domain; + Eip5267Domain eip5267Domain; + bool hasEip5267Domain; } contract GetToken { @@ -41,22 +34,9 @@ contract GetToken { if (isWstEth) res.stEthPerWstEth = IWstEth(address(token)).stEthPerToken(); - try IERC20Permit(address(token)).eip712Domain() returns ( - bytes1 /* fields */, - string memory name, - string memory version, - uint256 chainId, - address verifyingContract, - bytes32 /* salt */, - uint256[] memory /* extensions */ - ) { - res.hasEip712Domain = true; - res.eip712Domain = Eip712Domain({ - name: name, - version: version, - verifyingContract: verifyingContract, - chainId: chainId - }); + try IERC20Permit(address(token)).eip712Domain() returns (Eip5267Domain memory eip5267Domain) { + res.hasEip5267Domain = true; + res.eip5267Domain = eip5267Domain; } catch {} } } diff --git a/packages/blue-sdk-viem/contracts/GetVault.sol b/packages/blue-sdk-viem/contracts/GetVault.sol index c227c9ca..3679f3fc 100644 --- a/packages/blue-sdk-viem/contracts/GetVault.sol +++ b/packages/blue-sdk-viem/contracts/GetVault.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.0; import {IMorpho, Id, MarketParams} from "./interfaces/IMorpho.sol"; +import {Eip5267Domain} from "./interfaces/IERC20Permit.sol"; import {IMetaMorpho, PendingUint192, PendingAddress} from "./interfaces/IMetaMorpho.sol"; import {IPublicAllocator} from "./interfaces/IPublicAllocator.sol"; @@ -11,6 +12,7 @@ struct VaultConfig { string name; uint256 decimals; uint256 decimalsOffset; + Eip5267Domain eip5267Domain; } struct PublicAllocatorConfig { @@ -50,7 +52,8 @@ contract GetVault { symbol: vault.symbol(), name: vault.name(), decimals: vault.decimals(), - decimalsOffset: vault.DECIMALS_OFFSET() + decimalsOffset: vault.DECIMALS_OFFSET(), + eip5267Domain: vault.eip712Domain() }); res.owner = vault.owner(); diff --git a/packages/blue-sdk-viem/contracts/interfaces/IERC20Permit.sol b/packages/blue-sdk-viem/contracts/interfaces/IERC20Permit.sol index 0feb8cec..7229ffe2 100644 --- a/packages/blue-sdk-viem/contracts/interfaces/IERC20Permit.sol +++ b/packages/blue-sdk-viem/contracts/interfaces/IERC20Permit.sol @@ -5,6 +5,16 @@ pragma solidity >=0.5.0; import {IERC20} from "./IERC20.sol"; +struct Eip5267Domain { + bytes1 fields; + string name; + string version; + uint256 chainId; + address verifyingContract; + bytes32 salt; + uint256[] extensions; +} + /** * @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612]. @@ -84,18 +94,8 @@ interface IERC20Permit is IERC20 { function DOMAIN_SEPARATOR() external view returns (bytes32); /** - * @dev See {IERC-5267}. + * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 + * signature. */ - function eip712Domain() - external - view - returns ( - bytes1 fields, - string memory name, - string memory version, - uint256 chainId, - address verifyingContract, - bytes32 salt, - uint256[] memory extensions - ); + function eip712Domain() external view returns (Eip5267Domain memory); } diff --git a/packages/blue-sdk-viem/src/abis.ts b/packages/blue-sdk-viem/src/abis.ts index c2627e6f..a7d00636 100644 --- a/packages/blue-sdk-viem/src/abis.ts +++ b/packages/blue-sdk-viem/src/abis.ts @@ -7865,7 +7865,7 @@ export const permissionedErc20WrapperAbi = [ }, ] as const; -export const eip712DomainAbi = [ +export const erc5267Abi = [ { inputs: [], name: "eip712Domain", diff --git a/packages/blue-sdk-viem/src/fetch/Token.ts b/packages/blue-sdk-viem/src/fetch/Token.ts index a19c431e..f9df0ee3 100644 --- a/packages/blue-sdk-viem/src/fetch/Token.ts +++ b/packages/blue-sdk-viem/src/fetch/Token.ts @@ -10,6 +10,7 @@ import { import { ChainUtils, ConstantWrappedToken, + Eip5267Domain, ExchangeRateWrappedToken, NATIVE_ADDRESS, Token, @@ -17,7 +18,7 @@ import { getUnwrappedToken, } from "@morpho-org/blue-sdk"; import { getChainId, readContract } from "viem/actions"; -import { eip712DomainAbi, wstEthAbi } from "../abis"; +import { erc5267Abi, wstEthAbi } from "../abis"; import { abi, code } from "../queries/GetToken"; import type { DeploylessFetchParameters } from "../types"; @@ -52,13 +53,13 @@ export async function fetchToken( args: [address, isWstEth], }); - const eip712Domain = token.hasEip712Domain - ? token.eip712Domain + const eip5267Domain = token.hasEip5267Domain + ? new Eip5267Domain(token.eip5267Domain) : undefined; if (isWstEth && stEth != null) return new ExchangeRateWrappedToken( - { ...token, address, eip712Domain }, + { ...token, address, eip5267Domain }, stEth, token.stEthPerWstEth, ); @@ -66,18 +67,18 @@ export async function fetchToken( const unwrapToken = getUnwrappedToken(address, parameters.chainId); if (unwrapToken) return new ConstantWrappedToken( - { ...token, address, eip712Domain }, + { ...token, address, eip5267Domain }, unwrapToken, token.decimals, ); - return new Token({ ...token, address, eip712Domain }); + return new Token({ ...token, address, eip5267Domain }); } catch { // Fallback to multicall if deployless call fails. } } - const [decimals, symbol, name, eip712Domain] = await Promise.all([ + const [decimals, symbol, name, eip5267Domain] = await Promise.all([ readContract(client, { ...parameters, address, @@ -117,9 +118,30 @@ export async function fetchToken( readContract(client, { ...parameters, address, - abi: eip712DomainAbi, + abi: erc5267Abi, functionName: "eip712Domain", - }).catch(() => undefined), + }) + .then( + ([ + fields, + name, + version, + chainId, + verifyingContract, + salt, + extensions, + ]) => + new Eip5267Domain({ + fields, + name, + version, + chainId, + verifyingContract, + salt, + extensions, + }), + ) + .catch(() => undefined), ]); const token = { @@ -127,12 +149,7 @@ export async function fetchToken( name, symbol, decimals, - eip712Domain: eip712Domain && { - chainId: eip712Domain[3], - name: eip712Domain[1], - verifyingContract: eip712Domain[4], - version: eip712Domain[2], - }, + eip5267Domain, }; switch (address) { diff --git a/packages/blue-sdk-viem/src/fetch/Vault.ts b/packages/blue-sdk-viem/src/fetch/Vault.ts index b4472035..c68bf210 100644 --- a/packages/blue-sdk-viem/src/fetch/Vault.ts +++ b/packages/blue-sdk-viem/src/fetch/Vault.ts @@ -3,6 +3,7 @@ import type { Address, Client } from "viem"; import { AccrualVault, ChainUtils, + Eip5267Domain, type MarketId, Vault, VaultConfig, @@ -58,7 +59,14 @@ export async function fetchVault( }); return new Vault({ - ...new VaultConfig({ ...config, address }, parameters.chainId), + ...new VaultConfig( + { + ...config, + eip5267Domain: new Eip5267Domain(config.eip5267Domain), + address, + }, + parameters.chainId, + ), owner, curator, guardian, diff --git a/packages/blue-sdk-viem/src/fetch/VaultConfig.ts b/packages/blue-sdk-viem/src/fetch/VaultConfig.ts index ca2fe68a..4d99ae17 100644 --- a/packages/blue-sdk-viem/src/fetch/VaultConfig.ts +++ b/packages/blue-sdk-viem/src/fetch/VaultConfig.ts @@ -1,69 +1,42 @@ import type { Address, Client } from "viem"; -import { - ChainUtils, - UnknownVaultConfigError, - VaultConfig, - _try, -} from "@morpho-org/blue-sdk"; +import { ChainUtils, VaultConfig } from "@morpho-org/blue-sdk"; import { getChainId, readContract } from "viem/actions"; import { metaMorphoAbi } from "../abis"; -import type { FetchParameters } from "../types"; +import type { DeploylessFetchParameters } from "../types"; +import { fetchToken } from "./Token"; export async function fetchVaultConfig( address: Address, client: Client, - { chainId }: Pick = {}, + parameters: DeploylessFetchParameters = {}, ) { - chainId = ChainUtils.parseSupportedChainId( - chainId ?? (await getChainId(client)), + parameters.chainId = ChainUtils.parseSupportedChainId( + parameters.chainId ?? (await getChainId(client)), ); - let config = _try( - () => VaultConfig.get(address, chainId!), - UnknownVaultConfigError, - ); - - if (!config) { - // Always fetch at latest block because config is immutable. - const [asset, symbol, name, decimalsOffset] = await Promise.all([ - readContract(client, { - address, - abi: metaMorphoAbi, - functionName: "asset", - blockTag: "latest", - }), - readContract(client, { - address, - abi: metaMorphoAbi, - functionName: "symbol", - blockTag: "latest", - }), - readContract(client, { - address, - abi: metaMorphoAbi, - functionName: "name", - blockTag: "latest", - }), - readContract(client, { - address, - abi: metaMorphoAbi, - functionName: "DECIMALS_OFFSET", - blockTag: "latest", - }), - ]); + const [token, asset, decimalsOffset] = await Promise.all([ + fetchToken(address, client, parameters), + readContract(client, { + ...parameters, + address, + abi: metaMorphoAbi, + functionName: "asset", + }), + readContract(client, { + ...parameters, + address, + abi: metaMorphoAbi, + functionName: "DECIMALS_OFFSET", + }), + ]); - config = new VaultConfig( - { - address, - asset, - symbol, - name, - decimalsOffset: BigInt(decimalsOffset), - }, - chainId, - ); - } - - return config; + return new VaultConfig( + { + ...token, + asset, + decimalsOffset: BigInt(decimalsOffset), + }, + parameters.chainId, + ); } diff --git a/packages/blue-sdk-viem/src/queries/GetHolding.ts b/packages/blue-sdk-viem/src/queries/GetHolding.ts index 805b65a3..a7d95083 100644 --- a/packages/blue-sdk-viem/src/queries/GetHolding.ts +++ b/packages/blue-sdk-viem/src/queries/GetHolding.ts @@ -126,4 +126,4 @@ export const abi = [ ] as const; export const code = - "0x60808060405234601557610847908161001a8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c634755ff3e14610025575f80fd5b346105285760e0366003190112610528576004356001600160a01b03811690819003610528576024356001600160a01b0381169182820361052857604435926001600160a01b0384168403610528576064356001600160a01b038116939084900361052857608435926001600160a01b03841684036105285760a4359081151582036105285760c4359182151583036105285760c0890189811067ffffffffffffffff8211176106fc576040525f895260208901926100e261076a565b845260408a01946040516100f581610710565b6100fd61076a565b815261010761076a565b6020820152865260608b01975f895260808c01995f8b5260a08d019b5f8d526040516370a0823160e01b81528a60048201526020816024818b5afa9081156105ef578f905f926106c8575b5052604051636eb1769f60e11b81526001600160a01b03858116600483015282166024820152906020826044818b5afa9182156105ef575f92610694575b50604051636eb1769f60e11b81526001600160a01b038681166004830152841660248201526020816044818c5afa9081156105ef575f91610662575b50604051636eb1769f60e11b81526001600160a01b03878116600483015286166024820152906020826044818d5afa9182156105ef575f92610626575b50926060929161026a94604051926102208461072c565b83526020830152604080830191909152908b525163927da10560e01b81526001600160a01b038088166004830152808b166024830152909116604482015291829081906064820190565b0381855afa9384156105ef5787915f956105fa575b5060405163927da10560e01b81526001600160a01b0391821660048201529181166024830152909216604483015260609082908180606481015b03915afa9081156105ef575f916105c0575b50604051916102d983610710565b825260208201528552604051623f675f60e91b8152866004820152602081602481875afa5f918161058c575b50610580575b50604051624b894760e91b815260048101879052602081602481875afa5f918161055f575b5061053e5750156105345761034760015b89610805565b61041a575b506103df9250906040602092815198518952518051848a015283810151828a015201516060880152516103a960808801825165ffffffffffff6040809260018060a01b038151168552826020820151166020860152015116910152565b015180516001600160a01b031660e0870152602081015165ffffffffffff90811661010088015260409091015116610120860152565b5115156101408401525161016083015251906003821015610406576101a091610180820152f35b634e487b7160e01b5f52602160045260245ffd5b60206004915f89526040519283809263650369bf60e01b82525afa935f91856104e6575b5091604091602094936103df9661045a575b505091925061034c565b8351633af32abf60e01b81526004810191909152908590829060249082906001600160a01b03165afa5f91816104b7575b50610497575b80610450565b156104ad576104a7600289610805565b5f610491565b6104a76001610341565b6104d8919250863d88116104df575b6104d08183610748565b8101906107ed565b905f61048b565b503d6104c6565b90939291506020813d60201161052c575b8161050460209383610748565b810103126105285751906001600160a01b03821682036105285791926103df61043e565b5f80fd5b3d91506104f7565b6103476002610341565b15905061055557610550600289610805565b610347565b6105506001610341565b61057991925060203d6020116104df576104d08183610748565b905f610330565b6001885288525f61030b565b9091506020813d6020116105b8575b816105a860209383610748565b810103126105285751905f610305565b3d915061059b565b6105e2915060603d6060116105e8575b6105da8183610748565b81019061079b565b5f6102cb565b503d6105d0565b6040513d5f823e3d90fd5b6060939195509161061b6102b99593853d87116105e8576105da8183610748565b95919350919361027f565b929150926020833d60201161065a575b8161064360209383610748565b81010312610528579151919290919061026a610209565b3d9150610636565b90506020813d60201161068c575b8161067d60209383610748565b8101031261052857515f6101cc565b3d9150610670565b9091506020813d6020116106c0575b816106b060209383610748565b810103126105285751905f610190565b3d91506106a3565b9150506020813d6020116106f4575b816106e460209383610748565b8101031261052857518e5f610152565b3d91506106d7565b634e487b7160e01b5f52604160045260245ffd5b6040810190811067ffffffffffffffff8211176106fc57604052565b6060810190811067ffffffffffffffff8211176106fc57604052565b90601f8019910116810190811067ffffffffffffffff8211176106fc57604052565b604051906107778261072c565b5f6040838281528260208201520152565b519065ffffffffffff8216820361052857565b9081606091031261052857604051906107b38261072c565b80516001600160a01b0381168103610528576107e59160409184526107da60208201610788565b602085015201610788565b604082015290565b90816020910312610528575180151581036105285790565b6003821015610406575256fea2646970667358221220dae87bc1ff534c922eed4b52ab132a034af00ad3a78e800d4d394c00a8363d2564736f6c634300081b0033"; + "0x60808060405234601557610847908161001a8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c634755ff3e14610025575f80fd5b346105285760e0366003190112610528576004356001600160a01b03811690819003610528576024356001600160a01b0381169182820361052857604435926001600160a01b0384168403610528576064356001600160a01b038116939084900361052857608435926001600160a01b03841684036105285760a4359081151582036105285760c4359182151583036105285760c0890189811067ffffffffffffffff8211176106fc576040525f895260208901926100e261076a565b845260408a01946040516100f581610710565b6100fd61076a565b815261010761076a565b6020820152865260608b01975f895260808c01995f8b5260a08d019b5f8d526040516370a0823160e01b81528a60048201526020816024818b5afa9081156105ef578f905f926106c8575b5052604051636eb1769f60e11b81526001600160a01b03858116600483015282166024820152906020826044818b5afa9182156105ef575f92610694575b50604051636eb1769f60e11b81526001600160a01b038681166004830152841660248201526020816044818c5afa9081156105ef575f91610662575b50604051636eb1769f60e11b81526001600160a01b03878116600483015286166024820152906020826044818d5afa9182156105ef575f92610626575b50926060929161026a94604051926102208461072c565b83526020830152604080830191909152908b525163927da10560e01b81526001600160a01b038088166004830152808b166024830152909116604482015291829081906064820190565b0381855afa9384156105ef5787915f956105fa575b5060405163927da10560e01b81526001600160a01b0391821660048201529181166024830152909216604483015260609082908180606481015b03915afa9081156105ef575f916105c0575b50604051916102d983610710565b825260208201528552604051623f675f60e91b8152866004820152602081602481875afa5f918161058c575b50610580575b50604051624b894760e91b815260048101879052602081602481875afa5f918161055f575b5061053e5750156105345761034760015b89610805565b61041a575b506103df9250906040602092815198518952518051848a015283810151828a015201516060880152516103a960808801825165ffffffffffff6040809260018060a01b038151168552826020820151166020860152015116910152565b015180516001600160a01b031660e0870152602081015165ffffffffffff90811661010088015260409091015116610120860152565b5115156101408401525161016083015251906003821015610406576101a091610180820152f35b634e487b7160e01b5f52602160045260245ffd5b60206004915f89526040519283809263650369bf60e01b82525afa935f91856104e6575b5091604091602094936103df9661045a575b505091925061034c565b8351633af32abf60e01b81526004810191909152908590829060249082906001600160a01b03165afa5f91816104b7575b50610497575b80610450565b156104ad576104a7600289610805565b5f610491565b6104a76001610341565b6104d8919250863d88116104df575b6104d08183610748565b8101906107ed565b905f61048b565b503d6104c6565b90939291506020813d60201161052c575b8161050460209383610748565b810103126105285751906001600160a01b03821682036105285791926103df61043e565b5f80fd5b3d91506104f7565b6103476002610341565b15905061055557610550600289610805565b610347565b6105506001610341565b61057991925060203d6020116104df576104d08183610748565b905f610330565b6001885288525f61030b565b9091506020813d6020116105b8575b816105a860209383610748565b810103126105285751905f610305565b3d915061059b565b6105e2915060603d6060116105e8575b6105da8183610748565b81019061079b565b5f6102cb565b503d6105d0565b6040513d5f823e3d90fd5b6060939195509161061b6102b99593853d87116105e8576105da8183610748565b95919350919361027f565b929150926020833d60201161065a575b8161064360209383610748565b81010312610528579151919290919061026a610209565b3d9150610636565b90506020813d60201161068c575b8161067d60209383610748565b8101031261052857515f6101cc565b3d9150610670565b9091506020813d6020116106c0575b816106b060209383610748565b810103126105285751905f610190565b3d91506106a3565b9150506020813d6020116106f4575b816106e460209383610748565b8101031261052857518e5f610152565b3d91506106d7565b634e487b7160e01b5f52604160045260245ffd5b6040810190811067ffffffffffffffff8211176106fc57604052565b6060810190811067ffffffffffffffff8211176106fc57604052565b90601f8019910116810190811067ffffffffffffffff8211176106fc57604052565b604051906107778261072c565b5f6040838281528260208201520152565b519065ffffffffffff8216820361052857565b9081606091031261052857604051906107b38261072c565b80516001600160a01b0381168103610528576107e59160409184526107da60208201610788565b602085015201610788565b604082015290565b90816020910312610528575180151581036105285790565b6003821015610406575256fea2646970667358221220c9a20e72aef67c86c81a88085f9ef9c0efb04022f03ae699731b970b15912ca564736f6c634300081b0033"; diff --git a/packages/blue-sdk-viem/src/queries/GetToken.ts b/packages/blue-sdk-viem/src/queries/GetToken.ts index 5c48a444..69a76911 100644 --- a/packages/blue-sdk-viem/src/queries/GetToken.ts +++ b/packages/blue-sdk-viem/src/queries/GetToken.ts @@ -28,30 +28,45 @@ export const abi = [ }, { components: [ + { + internalType: "bytes1", + name: "fields", + type: "bytes1", + }, { internalType: "string", name: "name", type: "string" }, { internalType: "string", name: "version", type: "string", }, + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, { internalType: "address", name: "verifyingContract", type: "address", }, { - internalType: "uint256", - name: "chainId", - type: "uint256", + internalType: "bytes32", + name: "salt", + type: "bytes32", + }, + { + internalType: "uint256[]", + name: "extensions", + type: "uint256[]", }, ], - internalType: "struct Eip712Domain", - name: "eip712Domain", + internalType: "struct Eip5267Domain", + name: "eip5267Domain", type: "tuple", }, { internalType: "bool", - name: "hasEip712Domain", + name: "hasEip5267Domain", type: "bool", }, ], @@ -66,4 +81,4 @@ export const abi = [ ] as const; export const code = - "0x608080604052346015576105b5908161001a8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c63287861f914610025575f80fd5b3461037b57604036600319011261037b576004356001600160a01b038116919082900361037b5760243591821515830361037b57610100820182811067ffffffffffffffff82111761037f576040525f825260208201925f8452604083019160608352606084015f8152608085016060815260a08601945f865260c08701936040516100b0816104c2565b60608152606060208201525f60408201525f6060820152855260e08801955f87526040516306fdde0360e01b81525f81600481865afa5f9181610482575b50610476575b506040516395d89b4160e01b81525f81600481865afa5f9181610452575b50610446575b5060405163313ce56760e01b8152602081600481865afa5f9181610408575b506103fd575b50610393575b5f600491604051928380926342580cb760e11b82525afa905f915f815f935f93610263575b50916101c797969593916101ac959361022d575b50505050604051998a9960208b525160208b015251151560408a01525161010060608a015261012089019061049e565b91511515608088015251868203601f190160a088015261049e565b925160c08501525191601f198482030160e08501526060806102076101f5865160808652608086019061049e565b6020870151858203602087015261049e565b6040808701516001600160a01b0316908501529401519101525115156101008301520390f35b60018b526040519361023e856104c2565b845260208401526001600160a01b03166040830152606082015286525f80808061017c565b9350935050503d805f833e61027881836104de565b81019160e08284031261037b5781516001600160f81b031981160361037b57602082015167ffffffffffffffff811161037b57836102b7918401610500565b92604083015167ffffffffffffffff811161037b57816102d8918501610500565b9360608401519160808501519460018060a01b038616860361037b5760c08101519067ffffffffffffffff821161037b570181601f8201121561037b5780519067ffffffffffffffff821161037f576020808360051b936040519061033f838701836104de565b8152019282010192831161037b57602001905b82821061036b5750919592949391506101c79050610168565b8151815260209182019101610352565b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b6040516301afd7c160e11b8152602081600481855afa9081156103f2575f916103bf575b508752610143565b90506020813d6020116103ea575b816103da602093836104de565b8101031261037b575160046103b7565b3d91506103cd565b6040513d5f823e3d90fd5b60ff1689525f61013d565b9091506020813d60201161043e575b81610424602093836104de565b8101031261037b575160ff8116810361037b57905f610137565b3d9150610417565b60018b5283525f610118565b61046f9192503d805f833e61046781836104de565b810190610556565b905f610112565b6001865284525f6100f4565b6104979192503d805f833e61046781836104de565b905f6100ee565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b6080810190811067ffffffffffffffff82111761037f57604052565b90601f8019910116810190811067ffffffffffffffff82111761037f57604052565b81601f8201121561037b5780519067ffffffffffffffff821161037f5760405192610535601f8401601f1916602001856104de565b8284526020838301011161037b57815f9260208093018386015e8301015290565b9060208282031261037b57815167ffffffffffffffff811161037b5761057c9201610500565b9056fea2646970667358221220eef42094154227b11b9450292e0814cb7dc32e1b25b4a86870932aa5040d3d1564736f6c634300081b0033"; + "0x60808060405234601557610635908161001a8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c63287861f914610025575f80fd5b346103fb5760403660031901126103fb576004356001600160a01b03811691908290036103fb576024359182151583036103fb57610100820182811067ffffffffffffffff8211176103ff576040525f825260208201905f8252604083016060815260608401905f825260808501906060825260a08601945f865260c08701946040516100b181610542565b5f815260606020820152606060408201525f60608201525f60808201525f60a0820152606060c0820152865260e08801985f8a526040516306fdde0360e01b81525f81600481865afa5f9181610502575b506104f6575b506040516395d89b4160e01b81525f81600481865afa5f91816104d2575b506104c6575b5060405163313ce56760e01b8152602081600481865afa5f9181610488575b5061047d575b50610413575b5f600491604051928380926342580cb760e11b82525afa5f918161029b575b50916101ce959493916101b39361028f575b506040519860208a525160208a0152511515604089015251610100606089015261012088019061051e565b91511515608087015251858203601f190160a087015261051e565b915160c08401525192601f198383030160e084015260ff60f81b845116825260c061021d61020b602087015160e0602087015260e086019061051e565b6040870151858203604087015261051e565b946060810151606085015260018060a01b03608082015116608085015260a081015160a085015201519160c08186039101526020808351958681520192015f945b8086106102775750508293505115156101008301520390f35b9092602080600192865181520194019501949061025e565b60018b5287525f610188565b9091503d805f833e6102ad818361055e565b8101906020818303126103fb5780519067ffffffffffffffff82116103fb57019060e0828203126103fb57604051916102e583610542565b80516001600160f81b0319811681036103fb578352602081015167ffffffffffffffff81116103fb578261031a918301610580565b6020840152604081015167ffffffffffffffff81116103fb578261033f918301610580565b60408401526060818101519084015260808101516001600160a01b03811681036103fb57608084015260a081015160a084015260c08101519067ffffffffffffffff82116103fb57019080601f830112156103fb5781519167ffffffffffffffff83116103ff578260051b90604051936103bc602084018661055e565b84526020808501928201019283116103fb57602001905b8282106103eb5750505060c0820152906101b3610176565b81518152602091820191016103d3565b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b6040516301afd7c160e11b8152602081600481855afa908115610472575f9161043f575b508752610157565b90506020813d60201161046a575b8161045a6020938361055e565b810103126103fb57516004610437565b3d915061044d565b6040513d5f823e3d90fd5b60ff1689525f610151565b9091506020813d6020116104be575b816104a46020938361055e565b810103126103fb575160ff811681036103fb57905f61014b565b3d9150610497565b6001845284525f61012c565b6104ef9192503d805f833e6104e7818361055e565b8101906105d6565b905f610126565b6001875285525f610108565b6105179192503d805f833e6104e7818361055e565b905f610102565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b60e0810190811067ffffffffffffffff8211176103ff57604052565b90601f8019910116810190811067ffffffffffffffff8211176103ff57604052565b81601f820112156103fb5780519067ffffffffffffffff82116103ff57604051926105b5601f8401601f19166020018561055e565b828452602083830101116103fb57815f9260208093018386015e8301015290565b906020828203126103fb57815167ffffffffffffffff81116103fb576105fc9201610580565b9056fea2646970667358221220389a149f2e0bd6ff1dee73cba200ac22d6611d304a114c8d87d33392f9d891a264736f6c634300081b0033"; diff --git a/packages/blue-sdk-viem/src/queries/GetVault.ts b/packages/blue-sdk-viem/src/queries/GetVault.ts index 5361dbc0..929e1de4 100644 --- a/packages/blue-sdk-viem/src/queries/GetVault.ts +++ b/packages/blue-sdk-viem/src/queries/GetVault.ts @@ -39,6 +39,48 @@ export const abi = [ name: "decimalsOffset", type: "uint256", }, + { + components: [ + { + internalType: "bytes1", + name: "fields", + type: "bytes1", + }, + { + internalType: "string", + name: "name", + type: "string", + }, + { + internalType: "string", + name: "version", + type: "string", + }, + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + internalType: "address", + name: "verifyingContract", + type: "address", + }, + { + internalType: "bytes32", + name: "salt", + type: "bytes32", + }, + { + internalType: "uint256[]", + name: "extensions", + type: "uint256[]", + }, + ], + internalType: "struct Eip5267Domain", + name: "eip5267Domain", + type: "tuple", + }, ], internalType: "struct VaultConfig", name: "config", @@ -161,4 +203,4 @@ export const abi = [ ] as const; export const code = - "0x6080806040523460155761111b908161001a8239f35b5f80fdfe60806040526004361015610011575f80fd5b5f3560e01c63f6f030ce14610024575f80fd5b346108c15760403660031901126108c1576004356001600160a01b03811681036108c1576024356001600160a01b03811681036108c1576102a060405260405161006d81610f48565b5f815260606020820152606060408201525f60608201525f60808201526080525f6020608001525f6040608001525f6060608001525f60808001526040516100b481610f80565b5f8082526020820152610120526040516100cd81610f80565b5f80825260208201819052610140919091526101608190526101808190526101a08190526101c08190526101e08190526102008190526102205260606102408190526102605260405161011f81610f64565b5f81525f60208201525f6040820152610200608001526040516338d52e0f60e01b815260208160048160018060a01b0387165afa9081156108cd575f91610ea3575b506040516395d89b4160e01b81525f816004816001600160a01b0388165afa9081156108cd575f91610e89575b506040516306fdde0360e01b8152905f826004816001600160a01b0389165afa9182156108cd575f92610e65575b5060405163313ce56760e01b8152916020836004816001600160a01b038a165afa9283156108cd575f93610e44575b50604051632ba9c2b360e21b8152926020846004816001600160a01b038b165afa9182156108cd5760ff945f93610e13575b508492936040519661022e88610f48565b60018060a01b0316875260208701526040860152166060840152166080820152608052604051638da5cb5b60e01b815260208160048160018060a01b0387165afa9081156108cd575f91610dd9575b506001600160a01b0390811660a05260405163e66f53b760e01b8152906020908290600490829087165afa9081156108cd575f91610d9f575b506001600160a01b0390811660c052604051630229549960e51b8152906020908290600490829087165afa9081156108cd575f91610d65575b506001600160a01b0390811660e0526040516334cc866d60e21b8152906020908290600490829087165afa9081156108cd575f91610d33575b506101005260408051637cc4d9a160e01b815290816004816001600160a01b0387165afa9081156108cd575f91610cd0575b506101205260408051633b1618dd60e11b815290816004816001600160a01b0387165afa9081156108cd575f91610c77575b5061014052604051631c61872f60e31b81526020816004816001600160a01b0387165afa9081156108cd575f91610c3d575b506001600160a01b039081166101605260405163ddca3f4360e01b8152906020908290600490829087165afa80156108cd575f90610bf4575b6001600160601b0316610180525060405163011a412160e61b81526020816004816001600160a01b0387165afa9081156108cd575f91610bba575b506001600160a01b039081166101a05260405163388af5b560e01b8152906020908290600490829087165afa9081156108cd575f91610b80575b506001600160a01b039081166101c0526040516318160ddd60e01b8152906020908290600490829087165afa9081156108cd575f91610b4e575b506101e0526040516278744560e21b81526020816004816001600160a01b0387165afa9081156108cd575f91610b1c575b506102005260405163568efc0760e01b81526020816004816001600160a01b0387165afa9081156108cd575f91610aea575b5061022052604051630a17b31360e41b81526020816004816001600160a01b0387165afa9081156108cd575f91610ab8575b506105458161108b565b610240525f5b818110610a375750506040516333f91ebb60e01b81526020816004816001600160a01b0387165afa9081156108cd575f91610a05575b5061058b8161108b565b610260525f5b8181106109845750506040516326f6f90760e11b81526001600160a01b0382811660048301526020908290602490829087165afa9081156108cd575f91610949575b506107b4575b604051602081528061078461076e6080516102a0602085015260018060a01b038151166102c0850152608061063a610622602084015160a06102e0890152610360880190610ef1565b60408401518782036102bf1901610300890152610ef1565b916060810151610320870152015161034085015260018060a01b0360206080015116604085015260018060a01b0360406080015116606085015260018060a01b03606060800151166080850152608080015160a085015267ffffffffffffffff602060a06080015160018060c01b0381511660c088015201511660e085015267ffffffffffffffff602060c06080015160018060a01b0381511661010088015201511661012085015260018060a01b0360e060800151166101408501526101006080015161016085015260018060a01b03610120608001511661018085015260018060a01b0361014060800151166101a0850152610160608001516101c0850152610180608001516101e08501526101a0608001516102008501526101c060800151601f1985830301610220860152610f15565b61026051838203601f1901610240850152610f15565b610280805180516001600160a01b0316610260850152602081015191840191909152604001516102a08301520390f35b604051630c7508df60e31b81526001600160a01b0380841660048301529092906020908490602490829086165afa9283156108cd575f9361090d575b50604051636fcca69b60e01b81526001600160a01b0380831660048301529091906020908390602490829087165afa9182156108cd575f926108d8575b506040516348d88a5960e11b81526001600160a01b0391821660048201529260209184916024918391165afa9182156108cd575f92610895575b506040519261087584610f64565b6001600160a01b0316835260208301526040820152610280525f806105d9565b9091506020813d6020116108c5575b816108b160209383610f9c565b810103126108c15751905f610867565b5f80fd5b3d91506108a4565b6040513d5f823e3d90fd5b9091506020813d602011610905575b816108f460209383610f9c565b810103126108c1575190602061082d565b3d91506108e7565b9092506020813d602011610941575b8161092960209383610f9c565b810103126108c15761093a90610fbe565b915f6107f0565b3d915061091c565b90506020813d60201161097c575b8161096460209383610f9c565b810103126108c1575180151581036108c1575f6105d3565b3d9150610957565b6040516362518ddf60e01b815260048101829052906020826024816001600160a01b0389165afa80156108cd575f906109d3575b600192506109cc826101e0608001516110bd565b5201610591565b506020823d82116109fd575b816109ec60209383610f9c565b810103126108c157600191516109b8565b3d91506109df565b90506020813d602011610a2f575b81610a2060209383610f9c565b810103126108c157515f610581565b3d9150610a13565b60405163f7d1852160e01b815260048101829052906020826024816001600160a01b0389165afa80156108cd575f90610a86575b60019250610a7f826101c0608001516110bd565b520161054b565b506020823d8211610ab0575b81610a9f60209383610f9c565b810103126108c15760019151610a6b565b3d9150610a92565b90506020813d602011610ae2575b81610ad360209383610f9c565b810103126108c157515f61053b565b3d9150610ac6565b90506020813d602011610b14575b81610b0560209383610f9c565b810103126108c157515f610509565b3d9150610af8565b90506020813d602011610b46575b81610b3760209383610f9c565b810103126108c157515f6104d7565b3d9150610b2a565b90506020813d602011610b78575b81610b6960209383610f9c565b810103126108c157515f6104a6565b3d9150610b5c565b90506020813d602011610bb2575b81610b9b60209383610f9c565b810103126108c157610bac90610fbe565b5f61046c565b3d9150610b8e565b90506020813d602011610bec575b81610bd560209383610f9c565b810103126108c157610be690610fbe565b5f610432565b3d9150610bc8565b506020813d602011610c35575b81610c0e60209383610f9c565b810103126108c157516001600160601b03811681036108c1576001600160601b03906103f7565b3d9150610c01565b90506020813d602011610c6f575b81610c5860209383610f9c565b810103126108c157610c6990610fbe565b5f6103be565b3d9150610c4b565b90506040813d604011610cc8575b81610c9260409383610f9c565b810103126108c157610cbd602060405192610cac84610f80565b610cb581610fbe565b84520161105e565b60208201525f61038c565b3d9150610c85565b90506040813d604011610d2b575b81610ceb60409383610f9c565b810103126108c15760405190610d0082610f80565b80516001600160c01b03811681036108c1578252610d209060200161105e565b60208201525f61035a565b3d9150610cde565b90506020813d602011610d5d575b81610d4e60209383610f9c565b810103126108c157515f610328565b3d9150610d41565b90506020813d602011610d97575b81610d8060209383610f9c565b810103126108c157610d9190610fbe565b5f6102ef565b3d9150610d73565b90506020813d602011610dd1575b81610dba60209383610f9c565b810103126108c157610dcb90610fbe565b5f6102b6565b3d9150610dad565b90506020813d602011610e0b575b81610df460209383610f9c565b810103126108c157610e0590610fbe565b5f61027d565b3d9150610de7565b859350610e379060203d602011610e3d575b610e2f8183610f9c565b810190611045565b9261021d565b503d610e25565b610e5e91935060203d602011610e3d57610e2f8183610f9c565b915f6101eb565b610e829192503d805f833e610e7a8183610f9c565b810190610fd2565b905f6101bc565b610e9d91503d805f833e610e7a8183610f9c565b5f61018e565b90506020813d602011610ed5575b81610ebe60209383610f9c565b810103126108c157610ecf90610fbe565b5f610161565b3d9150610eb1565b634e487b7160e01b5f52604160045260245ffd5b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b90602080835192838152019201905f5b818110610f325750505090565b8251845260209384019390920191600101610f25565b60a0810190811067ffffffffffffffff821117610edd57604052565b6060810190811067ffffffffffffffff821117610edd57604052565b6040810190811067ffffffffffffffff821117610edd57604052565b90601f8019910116810190811067ffffffffffffffff821117610edd57604052565b51906001600160a01b03821682036108c157565b6020818303126108c15780519067ffffffffffffffff82116108c1570181601f820112156108c15780519067ffffffffffffffff8211610edd5760405192611024601f8401601f191660200185610f9c565b828452602083830101116108c157815f9260208093018386015e8301015290565b908160209103126108c1575160ff811681036108c15790565b519067ffffffffffffffff821682036108c157565b67ffffffffffffffff8111610edd5760051b60200190565b9061109582611073565b6110a26040519182610f9c565b82815280926110b3601f1991611073565b0190602036910137565b80518210156110d15760209160051b010190565b634e487b7160e01b5f52603260045260245ffdfea26469706673582212209e68487385cad38d312864a6648ff5117ec42eaf9ac714f0957a2d6efe1634c664736f6c634300081b0033"; + "0x60808060405234601557611386908161001a8239f35b5f80fdfe60806040526004361015610011575f80fd5b5f3560e01c63f6f030ce14610024575f80fd5b346109b65760403660031901126109b6576004356001600160a01b03811681036109b6576024356001600160a01b03811681036109b6576102a060405260405161006d81611194565b5f815260606020820152606060408201525f60608201525f6080820152604051610096816111af565b5f815260606020820152606060408201525f60608201525f60808201525f60a0820152606060c082015260a08201526080525f6020608001525f6040608001525f6060608001525f60808001526040516100ef816111e5565b5f808252602082015261012052604051610108816111e5565b5f80825260208201819052610140919091526101608190526101808190526101a08190526101c08190526101e08190526102008190526102205260606102408190526102605260405161015a816111ca565b5f81525f60208201525f6040820152610200608001526040516338d52e0f60e01b815260208160048160018060a01b0387165afa9081156109c2575f916110ef575b506040516395d89b4160e01b81525f816004816001600160a01b0388165afa9081156109c2575f916110d5575b506040516306fdde0360e01b81525f816004816001600160a01b0389165afa9081156109c2575f916110b3575b5060405163313ce56760e01b81526020816004816001600160a01b038a165afa9081156109c2575f91611094575b50604051632ba9c2b360e21b8152916020836004816001600160a01b038b165afa9283156109c2575f93611063575b506040516342580cb760e11b8152935f856004816001600160a01b038c165afa9485156109c2575f95610f08575b509160ff93929184926040519761029789611194565b60018060a01b031688526020880152604087015216606085015216608083015260a0820152608052604051638da5cb5b60e01b815260208160048160018060a01b0387165afa9081156109c2575f91610ece575b506001600160a01b0390811660a05260405163e66f53b760e01b8152906020908290600490829087165afa9081156109c2575f91610e94575b506001600160a01b0390811660c052604051630229549960e51b8152906020908290600490829087165afa9081156109c2575f91610e5a575b506001600160a01b0390811660e0526040516334cc866d60e21b8152906020908290600490829087165afa9081156109c2575f91610e28575b506101005260408051637cc4d9a160e01b815290816004816001600160a01b0387165afa9081156109c2575f91610dc5575b506101205260408051633b1618dd60e11b815290816004816001600160a01b0387165afa9081156109c2575f91610d6c575b5061014052604051631c61872f60e31b81526020816004816001600160a01b0387165afa9081156109c2575f91610d32575b506001600160a01b039081166101605260405163ddca3f4360e01b8152906020908290600490829087165afa80156109c2575f90610ce9575b6001600160601b0316610180525060405163011a412160e61b81526020816004816001600160a01b0387165afa9081156109c2575f91610caf575b506001600160a01b039081166101a05260405163388af5b560e01b8152906020908290600490829087165afa9081156109c2575f91610c75575b506001600160a01b039081166101c0526040516318160ddd60e01b8152906020908290600490829087165afa9081156109c2575f91610c43575b506101e0526040516278744560e21b81526020816004816001600160a01b0387165afa9081156109c2575f91610c11575b506102005260405163568efc0760e01b81526020816004816001600160a01b0387165afa9081156109c2575f91610bdf575b5061022052604051630a17b31360e41b81526020816004816001600160a01b0387165afa9081156109c2575f91610bad575b506105b3816112f6565b610240525f5b818110610b2c5750506040516333f91ebb60e01b81526020816004816001600160a01b0387165afa9081156109c2575f91610afa575b506105f9816112f6565b610260525f5b818110610a795750506040516326f6f90760e11b81526001600160a01b0382811660048301526020908290602490829087165afa9081156109c2575f91610a3e575b506108a9575b505060405160208152806080516102a0602083015260018060a01b038151166102c083015260a06106a461068c602084015160c06102e087015261038086019061113d565b60408401518582036102bf190161030087015261113d565b916060810151610320850152608081015161034085015201516102bf198383030161036084015260ff60f81b815116825260c06107056106f3602084015160e0602087015260e086019061113d565b6040840151858203604087015261113d565b916060810151606085015260018060a01b03608082015116608085015260a081015160a085015201519160c0818303910152602080835192838152019201905f5b81811061089057505060a080516001600160a01b03908116604086015260c080518216606087015260e0805183166080880152610100805194880194909452610120805180516001600160c01b0316938901939093526020928301516001600160401b0390811692890192909252610140805180518616968a01969096529490920151169086015261016080518216928601929092526101808051928601929092526101a080518216928601929092526101c08051909116918501919091526101e080519185019190915261020080519185019190915261022080519185019190915261024051848403601f1901918501919091526108609261084a925090611161565b61026051838203601f1901610240850152611161565b610280805180516001600160a01b0316610260850152602081015191840191909152604001516102a08301520390f35b8251845285945060209384019390920191600101610746565b604051630c7508df60e31b81526001600160a01b0380841660048301529092906020908490602490829086165afa9283156109c2575f93610a02575b50604051636fcca69b60e01b81526001600160a01b0380831660048301529091906020908390602490829087165afa9182156109c2575f926109cd575b506040516348d88a5960e11b81526001600160a01b0391821660048201529260209184916024918391165afa9182156109c2575f9261098a575b506040519261096a846111ca565b6001600160a01b0316835260208301526040820152610280525f80610647565b9091506020813d6020116109ba575b816109a660209383611200565b810103126109b65751905f61095c565b5f80fd5b3d9150610999565b6040513d5f823e3d90fd5b9091506020813d6020116109fa575b816109e960209383611200565b810103126109b65751906020610922565b3d91506109dc565b9092506020813d602011610a36575b81610a1e60209383611200565b810103126109b657610a2f90611221565b915f6108e5565b3d9150610a11565b90506020813d602011610a71575b81610a5960209383611200565b810103126109b6575180151581036109b6575f610641565b3d9150610a4c565b6040516362518ddf60e01b815260048101829052906020826024816001600160a01b0389165afa80156109c2575f90610ac8575b60019250610ac1826101e060800151611328565b52016105ff565b506020823d8211610af2575b81610ae160209383611200565b810103126109b65760019151610aad565b3d9150610ad4565b90506020813d602011610b24575b81610b1560209383611200565b810103126109b657515f6105ef565b3d9150610b08565b60405163f7d1852160e01b815260048101829052906020826024816001600160a01b0389165afa80156109c2575f90610b7b575b60019250610b74826101c060800151611328565b52016105b9565b506020823d8211610ba5575b81610b9460209383611200565b810103126109b65760019151610b60565b3d9150610b87565b90506020813d602011610bd7575b81610bc860209383611200565b810103126109b657515f6105a9565b3d9150610bbb565b90506020813d602011610c09575b81610bfa60209383611200565b810103126109b657515f610577565b3d9150610bed565b90506020813d602011610c3b575b81610c2c60209383611200565b810103126109b657515f610545565b3d9150610c1f565b90506020813d602011610c6d575b81610c5e60209383611200565b810103126109b657515f610514565b3d9150610c51565b90506020813d602011610ca7575b81610c9060209383611200565b810103126109b657610ca190611221565b5f6104da565b3d9150610c83565b90506020813d602011610ce1575b81610cca60209383611200565b810103126109b657610cdb90611221565b5f6104a0565b3d9150610cbd565b506020813d602011610d2a575b81610d0360209383611200565b810103126109b657516001600160601b03811681036109b6576001600160601b0390610465565b3d9150610cf6565b90506020813d602011610d64575b81610d4d60209383611200565b810103126109b657610d5e90611221565b5f61042c565b3d9150610d40565b90506040813d604011610dbd575b81610d8760409383611200565b810103126109b657610db2602060405192610da1846111e5565b610daa81611221565b8452016112e2565b60208201525f6103fa565b3d9150610d7a565b90506040813d604011610e20575b81610de060409383611200565b810103126109b65760405190610df5826111e5565b80516001600160c01b03811681036109b6578252610e15906020016112e2565b60208201525f6103c8565b3d9150610dd3565b90506020813d602011610e52575b81610e4360209383611200565b810103126109b657515f610396565b3d9150610e36565b90506020813d602011610e8c575b81610e7560209383611200565b810103126109b657610e8690611221565b5f61035d565b3d9150610e68565b90506020813d602011610ec6575b81610eaf60209383611200565b810103126109b657610ec090611221565b5f610324565b3d9150610ea2565b90506020813d602011610f00575b81610ee960209383611200565b810103126109b657610efa90611221565b5f6102eb565b3d9150610edc565b9094503d805f833e610f1a8183611200565b8101906020818303126109b6578051906001600160401b0382116109b6570160e0818303126109b65760405191610f50836111af565b81516001600160f81b0319811681036109b657835260208201516001600160401b0381116109b65781610f84918401611235565b602084015260408201516001600160401b0381116109b65781610fa8918401611235565b604084015260608201516060840152610fc360808301611221565b608084015260a082015160a084015260c0820151906001600160401b0382116109b65780601f8385010112156109b6578183015191611001836112cb565b9361100f6040519586611200565b838552602085019260208560051b8484010101116109b65790602081830101925b60208560051b8385010101841061105357505050505060c08201529360ff610281565b8351815260209384019301611030565b61108691935060203d60201161108d575b61107e8183611200565b8101906112b2565b915f610253565b503d611074565b6110ad915060203d60201161108d5761107e8183611200565b5f610224565b6110cf91503d805f833e6110c78183611200565b81019061128a565b5f6101f6565b6110e991503d805f833e6110c78183611200565b5f6101c9565b90506020813d602011611121575b8161110a60209383611200565b810103126109b65761111b90611221565b5f61019c565b3d91506110fd565b634e487b7160e01b5f52604160045260245ffd5b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b90602080835192838152019201905f5b81811061117e5750505090565b8251845260209384019390920191600101611171565b60c081019081106001600160401b0382111761112957604052565b60e081019081106001600160401b0382111761112957604052565b606081019081106001600160401b0382111761112957604052565b604081019081106001600160401b0382111761112957604052565b90601f801991011681019081106001600160401b0382111761112957604052565b51906001600160a01b03821682036109b657565b81601f820112156109b6578051906001600160401b0382116111295760405192611269601f8401601f191660200185611200565b828452602083830101116109b657815f9260208093018386015e8301015290565b906020828203126109b65781516001600160401b0381116109b6576112af9201611235565b90565b908160209103126109b6575160ff811681036109b65790565b6001600160401b0381116111295760051b60200190565b51906001600160401b03821682036109b657565b90611300826112cb565b61130d6040519182611200565b828152809261131e601f19916112cb565b0190602036910137565b805182101561133c5760209160051b010190565b634e487b7160e01b5f52603260045260245ffdfea26469706673582212204dc46f9e26949ca9651058395721d8c490cfbab9c77805c825dfb3c9bc26ba2e64736f6c634300081b0033"; diff --git a/packages/blue-sdk-viem/src/queries/GetVaultUser.ts b/packages/blue-sdk-viem/src/queries/GetVaultUser.ts index 42bc36be..21d1faa7 100644 --- a/packages/blue-sdk-viem/src/queries/GetVaultUser.ts +++ b/packages/blue-sdk-viem/src/queries/GetVaultUser.ts @@ -30,4 +30,4 @@ export const abi = [ ] as const; export const code = - "0x6080806040523460155761025b908161001a8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c63f6f030ce14610025575f80fd5b34610156576040366003190112610156576004356001600160a01b0381169190829003610156576024356001600160a01b0381169290839003610156576040820182811067ffffffffffffffff8211176101ef576040525f825260208201905f82526040516326f6f90760e11b8152846004820152602081602481855afa908115610162575f916101b4575b50151583526040516338d52e0f60e01b815293602085600481855afa948515610162575f9561016d575b509060446020926040519687938492636eb1769f60e11b84526004840152602483015260018060a01b03165afa8015610162575f9061012b575b6040935081528251915115158252516020820152f35b506020833d60201161015a575b8161014560209383610203565b810103126101565760409251610115565b5f80fd5b3d9150610138565b6040513d5f823e3d90fd5b9094506020813d6020116101ac575b8161018960209383610203565b810103126101565751906001600160a01b038216820361015657909360446100db565b3d915061017c565b90506020813d6020116101e7575b816101cf60209383610203565b8101031261015657518015158103610156575f6100b1565b3d91506101c2565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176101ef5760405256fea26469706673582212203853eab10deb4f7057c537f34a373f43cd1201b7cff85ad804437613eb91f11564736f6c634300081b0033"; + "0x6080806040523460155761025b908161001a8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c63f6f030ce14610025575f80fd5b34610156576040366003190112610156576004356001600160a01b0381169190829003610156576024356001600160a01b0381169290839003610156576040820182811067ffffffffffffffff8211176101ef576040525f825260208201905f82526040516326f6f90760e11b8152846004820152602081602481855afa908115610162575f916101b4575b50151583526040516338d52e0f60e01b815293602085600481855afa948515610162575f9561016d575b509060446020926040519687938492636eb1769f60e11b84526004840152602483015260018060a01b03165afa8015610162575f9061012b575b6040935081528251915115158252516020820152f35b506020833d60201161015a575b8161014560209383610203565b810103126101565760409251610115565b5f80fd5b3d9150610138565b6040513d5f823e3d90fd5b9094506020813d6020116101ac575b8161018960209383610203565b810103126101565751906001600160a01b038216820361015657909360446100db565b3d915061017c565b90506020813d6020116101e7575b816101cf60209383610203565b8101031261015657518015158103610156575f6100b1565b3d91506101c2565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176101ef5760405256fea2646970667358221220dab07071235db46cf4ce3e33469d528ea840db8713e312abcc6046560cb9b95d64736f6c634300081b0033"; diff --git a/packages/blue-sdk-viem/src/signatures/permit.ts b/packages/blue-sdk-viem/src/signatures/permit.ts index e476c279..7e6c39b0 100644 --- a/packages/blue-sdk-viem/src/signatures/permit.ts +++ b/packages/blue-sdk-viem/src/signatures/permit.ts @@ -35,7 +35,7 @@ export const getPermitTypedData = ( ): TypedDataDefinition => { const { usdc } = getChainAddresses(chainId); - const domain = erc20.eip712Domain ?? { + const domain = erc20.eip5267Domain?.eip712Domain ?? { name: erc20.name, version: erc20.address === usdc ? "2" : "1", chainId, diff --git a/packages/blue-sdk-viem/test/Token.test.ts b/packages/blue-sdk-viem/test/Token.test.ts index 1f93938c..f5c397d8 100644 --- a/packages/blue-sdk-viem/test/Token.test.ts +++ b/packages/blue-sdk-viem/test/Token.test.ts @@ -3,10 +3,12 @@ import { test } from "./setup"; import { ChainId, + Eip5267Domain, ExchangeRateWrappedToken, addresses, } from "@morpho-org/blue-sdk"; import { randomAddress } from "@morpho-org/test"; +import { zeroHash } from "viem"; import { Token } from "../src/augment/Token"; const { mkr, usdc, stEth, wstEth } = addresses[ChainId.EthMainnet]; @@ -63,19 +65,22 @@ describe("augment/Token", () => { expect(value).toStrictEqual(expectedData); }); - test("should fetch token data with eip712Domain", async ({ client }) => { + test("should fetch token data with eip5267Domain", async ({ client }) => { const steakUSDC = "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB"; const expectedData = new Token({ address: steakUSDC, decimals: 18, symbol: "steakUSDC", name: "Steakhouse USDC", - eip712Domain: { + eip5267Domain: new Eip5267Domain({ + fields: "0x0f", name: "Steakhouse USDC", - verifyingContract: steakUSDC, version: "1", chainId: 1n, - }, + verifyingContract: steakUSDC, + salt: zeroHash, + extensions: [], + }), }); const value = await Token.fetch(expectedData.address, client); diff --git a/packages/blue-sdk-viem/test/Vault.test.ts b/packages/blue-sdk-viem/test/Vault.test.ts index ca5f948d..1b0fd005 100644 --- a/packages/blue-sdk-viem/test/Vault.test.ts +++ b/packages/blue-sdk-viem/test/Vault.test.ts @@ -1,10 +1,15 @@ import { describe, expect } from "vitest"; import { test } from "./setup"; -import { ChainId, type MarketId, addresses } from "@morpho-org/blue-sdk"; +import { + ChainId, + Eip5267Domain, + type MarketId, + addresses, +} from "@morpho-org/blue-sdk"; import { vaults } from "@morpho-org/morpho-test"; -import { zeroAddress } from "viem"; +import { zeroAddress, zeroHash } from "viem"; import { metaMorphoAbi, publicAllocatorAbi } from "../src"; import { Vault } from "../src/augment/Vault"; @@ -71,6 +76,15 @@ describe("augment/Vault", () => { lastTotalAssets: 26129569140552n, totalAssets: 26138940196162n, totalSupply: 25752992371062043744406063n, + eip5267Domain: new Eip5267Domain({ + fields: "0x0f", + name: "Steakhouse USDC", + version: "1", + chainId: 1n, + verifyingContract: steakUsdc.address, + salt: zeroHash, + extensions: [], + }), }); const value = await Vault.fetch(steakUsdc.address, client); diff --git a/packages/blue-sdk/src/token/Eip5267Domain.ts b/packages/blue-sdk/src/token/Eip5267Domain.ts new file mode 100644 index 00000000..2b897c75 --- /dev/null +++ b/packages/blue-sdk/src/token/Eip5267Domain.ts @@ -0,0 +1,105 @@ +import type { Address } from "../types.js"; + +export const EIP_712_FIELDS = [ + "name", + "version", + "chainId", + "verifyingContract", + "salt", +] as const; + +export type Eip712Field = (typeof EIP_712_FIELDS)[number]; + +export interface IEip5267Domain { + fields: `0x${string}`; + name: string; + version: string; + chainId: bigint; + verifyingContract: Address; + salt: `0x${string}`; + extensions: readonly bigint[]; +} + +export class Eip5267Domain implements IEip5267Domain { + /** + * A bit map where bit i is set to 1 if and only if domain field i is present (0 ≤ i ≤ 4). + * Bits are read from least significant to most significant, and fields are indexed in the order that is specified by EIP-712, identical to the order in which they are listed in the function type. + */ + public readonly fields; + + /** + * The user readable name of signing domain, i.e. the name of the DApp or the protocol. + */ + public readonly name; + + /** + * The current major version of the signing domain. + * Signatures from different versions are not compatible. + */ + public readonly version; + + /** + * The EIP-155 chain id. + */ + public readonly chainId; + + /** + * The address of the contract that will verify the EIP-712 signature. + */ + public readonly verifyingContract; + + /** + * A disambiguating salt for the protocol. + * This can be used as a domain separator of last resort. + */ + public readonly salt; + + /** + * A list of EIP numbers, each of which MUST refer to an EIP that extends EIP-712 with new domain fields, along with a method to obtain the value for those fields, and potentially conditions for inclusion. + * The value of fields does not affect their inclusion. + */ + public readonly extensions; + + public readonly eip712Domain; + + constructor({ + fields, + name, + version, + chainId, + verifyingContract, + salt, + extensions, + }: IEip5267Domain) { + this.fields = fields; + this.name = name; + this.version = version; + this.chainId = chainId; + this.verifyingContract = verifyingContract; + this.salt = salt; + this.extensions = extensions; + + this.eip712Domain = this.asEip712Domain(); + } + + private asEip712Domain() { + const fields = BigInt(this.fields); + + return EIP_712_FIELDS.reduce<{ + [field in Eip712Field]?: field extends "chainId" + ? number + : Eip5267Domain[field]; + }>((acc, field, i) => { + if (fields & (2n ** BigInt(i))) { + // @ts-expect-error Typescript doesn't infer value type based on field. + acc[field] = + field === "chainId" + ? // Signature does not correspond if chainId is a bigint. + Number(this.chainId) + : this[field]; + } + + return acc; + }, {}); + } +} diff --git a/packages/blue-sdk/src/token/Token.ts b/packages/blue-sdk/src/token/Token.ts index bb757a25..6b7e4895 100644 --- a/packages/blue-sdk/src/token/Token.ts +++ b/packages/blue-sdk/src/token/Token.ts @@ -2,6 +2,7 @@ import { NATIVE_ADDRESS } from "../addresses.js"; import { type ChainId, ChainUtils } from "../chain.js"; import { MathLib, type RoundingDirection } from "../math/index.js"; import type { Address, BigIntish } from "../types.js"; +import type { Eip5267Domain } from "./Eip5267Domain.js"; export interface IToken { address: Address; @@ -9,14 +10,7 @@ export interface IToken { symbol?: string; decimals?: BigIntish; price?: BigIntish; - eip712Domain?: EIP712Domain; -} - -interface EIP712Domain { - name: string; - version: string; - chainId: bigint; - verifyingContract: Address; + eip5267Domain?: Eip5267Domain; } export class Token implements IToken { @@ -49,7 +43,7 @@ export class Token implements IToken { /** * The eip712 domain of the token if it can be directly queried onchain */ - public readonly eip712Domain?: EIP712Domain; + public readonly eip5267Domain?: Eip5267Domain; /** * Price of the token in USD (scaled by WAD). @@ -62,13 +56,13 @@ export class Token implements IToken { symbol, decimals = 0, price, - eip712Domain, + eip5267Domain, }: IToken) { this.address = address; this.name = name; this.symbol = symbol; this.decimals = Number(decimals); - this.eip712Domain = eip712Domain; + this.eip5267Domain = eip5267Domain; if (price != null) this.price = BigInt(price); } diff --git a/packages/blue-sdk/src/token/index.ts b/packages/blue-sdk/src/token/index.ts index ee3e5f91..26c1bc8d 100644 --- a/packages/blue-sdk/src/token/index.ts +++ b/packages/blue-sdk/src/token/index.ts @@ -3,3 +3,4 @@ export * from "./WrappedToken.js"; export * from "./ConstantWrappedToken.js"; export * from "./ExchangeRateWrappedToken.js"; export * from "./VaultToken.js"; +export * from "./Eip5267Domain.js"; diff --git a/packages/blue-sdk/src/vault/VaultConfig.ts b/packages/blue-sdk/src/vault/VaultConfig.ts index 578c24ff..185ff95f 100644 --- a/packages/blue-sdk/src/vault/VaultConfig.ts +++ b/packages/blue-sdk/src/vault/VaultConfig.ts @@ -1,47 +1,22 @@ -import type { ChainId } from "../chain.js"; -import { UnknownVaultConfigError } from "../errors.js"; +import { type IToken, Token } from "../token/Token.js"; import type { Address, BigIntish } from "../types.js"; -export interface IVaultConfig { - address: Address; +export interface IVaultConfig extends Omit { decimalsOffset: BigIntish; - symbol: string; - name: string; asset: Address; } -export class VaultConfig implements IVaultConfig { - protected static readonly _CACHE: Record< - number, - Record - > = {}; - - static get(address: Address, chainId: ChainId) { - const config = VaultConfig._CACHE[chainId]?.[address]; - - if (!config) throw new UnknownVaultConfigError(address); - - return config; - } - - public readonly address: Address; - public readonly decimals: number; - public readonly decimalsOffset: bigint; - public readonly symbol: string; - public readonly name: string; - public readonly asset: Address; +export class VaultConfig extends Token implements IVaultConfig { + public readonly decimalsOffset; + public readonly asset; constructor( - { address, decimalsOffset, symbol, name, asset }: IVaultConfig, + { decimalsOffset, asset, ...config }: IVaultConfig, public readonly chainId?: number, ) { - this.address = address; - this.decimals = 18; + super({ ...config, decimals: 18 }); + this.decimalsOffset = BigInt(decimalsOffset); - this.symbol = symbol; - this.name = name; this.asset = asset; - - if (chainId != null) (VaultConfig._CACHE[chainId] ??= {})[address] = this; } } diff --git a/packages/test/package.json b/packages/test/package.json index e2f11f10..a3515499 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -28,7 +28,7 @@ "dependencies": { "lodash.kebabcase": "^4.1.1", "viem-deal": "^2.0.3", - "viem-tracer": "^1.4.0" + "viem-tracer": "^1.4.1" }, "peerDependencies": { "@playwright/test": "^1.48.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ae9aee64..59495da7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -648,8 +648,8 @@ importers: specifier: ^2.0.3 version: 2.0.4(viem@2.22.2(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10)) viem-tracer: - specifier: ^1.4.0 - version: 1.4.0(viem@2.22.2(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10)) + specifier: ^1.4.1 + version: 1.4.1(viem@2.22.2(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10)) devDependencies: '@playwright/test': specifier: ^1.48.1 @@ -5368,8 +5368,8 @@ packages: peerDependencies: viem: ^2.21.18 - viem-tracer@1.4.0: - resolution: {integrity: sha512-KrJSb3qYnOzuwrppqOwpLve0efj/1v6OVgrr2uQnnW1KugnR13Aq7PZnBfCPxJN6PwHYVJtW5O0Cbkdt1Q8Z3g==} + viem-tracer@1.4.1: + resolution: {integrity: sha512-KG3yt+goEbm6kgRMvOC8rAVEmkKtEEbbclo0RRPpvcmUAJ36SXECdXVB8cj2w5RUkppv8yUBRmFdGbI9LS4shQ==} peerDependencies: viem: ^2.21.0 @@ -11250,7 +11250,7 @@ snapshots: dependencies: viem: 2.22.2(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10) - viem-tracer@1.4.0(viem@2.22.2(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10)): + viem-tracer@1.4.1(viem@2.22.2(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10)): dependencies: colors: 1.4.0 viem: 2.22.2(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10)