From 7587f98b08ff64f6ab8e3c9f0871b6f9757aebc1 Mon Sep 17 00:00:00 2001 From: Vitor Date: Thu, 12 Dec 2024 21:16:43 -0300 Subject: [PATCH] fix: withdraw and deposit actions --- .../src/processing/limit-order/get-actions.ts | 92 ++ .../src/processing/limit-order/index.ts | 76 +- .../limit-order/protocols/aave-v3.ts | 65 + .../limit-order/protocols/compound-v3.ts | 44 + .../limit-order/protocols/pool-together-v5.ts | 73 ++ .../limit-order/protocols/underlying-asset.ts | 30 + .../src/processing/limit-order/utils.ts | 46 + .../src/abis/compound-v3-abi.ts | 1003 ++++++++++++++++ .../src/abis/delegation-manager-abi.ts | 17 + ...rc20-balance-gte-after-all-enforcer-abi.ts | 25 +- .../src/abis/pool-together-v5-abi.ts | 1056 +++++++++++++++++ packages/universal-data/src/exports/index.ts | 3 + .../src/token-list/stablecoin-token-list.ts | 44 +- .../src/actions/use-sign-erc20-swap.ts | 50 +- 14 files changed, 2520 insertions(+), 104 deletions(-) create mode 100644 apps/api-delegations/src/processing/limit-order/get-actions.ts create mode 100644 apps/api-delegations/src/processing/limit-order/protocols/aave-v3.ts create mode 100644 apps/api-delegations/src/processing/limit-order/protocols/compound-v3.ts create mode 100644 apps/api-delegations/src/processing/limit-order/protocols/pool-together-v5.ts create mode 100644 apps/api-delegations/src/processing/limit-order/protocols/underlying-asset.ts create mode 100644 packages/universal-data/src/abis/compound-v3-abi.ts create mode 100644 packages/universal-data/src/abis/pool-together-v5-abi.ts diff --git a/apps/api-delegations/src/processing/limit-order/get-actions.ts b/apps/api-delegations/src/processing/limit-order/get-actions.ts new file mode 100644 index 00000000..4c00a64b --- /dev/null +++ b/apps/api-delegations/src/processing/limit-order/get-actions.ts @@ -0,0 +1,92 @@ +import { stablecoinTokenList } from 'universal-data'; +import type { Address, Hex } from 'viem'; +import { + getDepositAaveV3HookData, + getWithdrawAaveV3HookData, +} from './protocols/aave-v3.js'; +import { + getDepositPoolTogetherV5HookData, + getWithdrawPoolTogetherV5HookData, +} from './protocols/pool-together-v5.js'; +import { getDepositUnderlyingAssetHookData } from './protocols/underlying-asset.js'; + +type HookActions = { + target: Address; + value: bigint; + callData: Hex; +}[]; + +type GetHookActionsParams = { + tokenIn: Address; + tokenOut: Address; + amountIn: bigint; + amountOut: bigint; + delegator: Address; +}; + +type GetHookActionsReturnType = { + withdrawActions: HookActions; + depositActions: HookActions; +}; + +export function getHookActions({ + tokenIn, + tokenOut, + amountIn, + amountOut, + delegator, +}: GetHookActionsParams): GetHookActionsReturnType { + let withdrawActions: HookActions = []; + let depositActions: HookActions = []; + + const tokenInData = stablecoinTokenList.tokens.find( + (token) => token.address.toLowerCase() === tokenIn.toLowerCase(), + ); + const tokenOutData = stablecoinTokenList.tokens.find( + (token) => token.address.toLowerCase() === tokenOut.toLowerCase(), + ); + + if (!tokenInData || !tokenOutData) { + throw new Error('Token not found'); + } + + // Withdraw actions + if (tokenOutData.extensions?.protocol === 'aave-v3') { + withdrawActions = getWithdrawAaveV3HookData({ + amountIn, + tokenIn, + }); + } else if (tokenOutData.extensions?.protocol === 'pool-together-v5') { + withdrawActions = getWithdrawPoolTogetherV5HookData({ + amountOut, + tokenOut, + }); + } + + // Deposit actions + if (tokenInData.extensions?.protocol === 'aave-v3') { + depositActions = getDepositAaveV3HookData({ + amountIn, + delegator, + tokenOut, + }); + } else if (tokenInData.extensions?.protocol === 'pool-together-v5') { + depositActions = getDepositPoolTogetherV5HookData({ + amountIn, + delegator, + tokenIn, + tokenOut, + }); + } else if (!tokenInData.extensions?.protocol) { + depositActions = getDepositUnderlyingAssetHookData({ + amountIn, + delegator, + tokenIn, + }); + } + + return { + withdrawActions, + depositActions, + }; +} diff --git a/apps/api-delegations/src/processing/limit-order/index.ts b/apps/api-delegations/src/processing/limit-order/index.ts index 265ca419..f70197ac 100644 --- a/apps/api-delegations/src/processing/limit-order/index.ts +++ b/apps/api-delegations/src/processing/limit-order/index.ts @@ -1,9 +1,11 @@ import type { Delegation, DelegationExecution } from 'universal-types'; import { + decodeERC20BalanceGteWrapEnforcerTerms, decodeEnforcerERC20TransferAmount, encodeDelegation, encodeExternalCallEnforcerArgs, encodeSingleExecution, + getERC20BalanceGteWrapEnforcerFromDelegation, getErc20TransferAmountEnforcerFromDelegation, getExternalHookEnforcerFromDelegation, } from './utils.js'; @@ -11,49 +13,12 @@ import { getResolverWalletClient } from '../../resolver/resolver-wallet-client.j import type { ValidChain } from 'universal-data'; import { SINGLE_EXECUTION_MODE, - aaveV3PoolAbi, delegationManagerAbi, + multicallAbi, universalDeployments, } from 'universal-data'; -import { encodeFunctionData, type Address, type Hex, erc20Abi } from 'viem'; -import { multicallAbi } from 'universal-data'; - -const AAVE_V3_POOL_BASE = '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5'; - -function getDepositAaveV3HookData({ - amount, - delegator, - token, -}: { amount: bigint; delegator: Address; token: Address }): Hex { - return encodeFunctionData({ - abi: multicallAbi, - functionName: 'multicall', - args: [ - [ - // Approves the token to the Aave Pool - { - target: token, - value: 0n, - callData: encodeFunctionData({ - abi: erc20Abi, - functionName: 'approve', - args: [AAVE_V3_POOL_BASE, amount], - }), - }, - // Deposits the token to the Aave Pool on behalf of the delegator - { - target: AAVE_V3_POOL_BASE, - value: 0n, - callData: encodeFunctionData({ - abi: aaveV3PoolAbi, - functionName: 'supply', - args: [token, amount, delegator, 0], - }), - }, - ], - ], - }); -} +import { encodeFunctionData, erc20Abi } from 'viem'; +import { getHookActions } from './get-actions.js'; export async function processLimitOrderDelegation({ chainId, @@ -61,22 +26,35 @@ export async function processLimitOrderDelegation({ }: { chainId: ValidChain['id']; delegation: Delegation }) { const { erc20TransferAmountEnforcer } = getErc20TransferAmountEnforcerFromDelegation(delegation); - const { token, amount } = decodeEnforcerERC20TransferAmount( - erc20TransferAmountEnforcer.terms, - ); + const { token: tokenOut, amount: amountOut } = + decodeEnforcerERC20TransferAmount(erc20TransferAmountEnforcer.terms); + + const { erc20BalanceGteWrapEnforcer } = + getERC20BalanceGteWrapEnforcerFromDelegation(delegation); + + const { token: tokenIn, amount: amountIn } = + decodeERC20BalanceGteWrapEnforcerTerms(erc20BalanceGteWrapEnforcer.terms); const { externalHookEnforcer, index: externalHookEnforcerIndex } = getExternalHookEnforcerFromDelegation(delegation); + const { withdrawActions, depositActions } = getHookActions({ + amountIn, + amountOut, + delegator: delegation.delegator, + tokenIn, + tokenOut, + }); + delegation.caveats[externalHookEnforcerIndex] = { ...externalHookEnforcer, // Update the args of the external hook enforcer to include the data for the Aave V3 deposit args: encodeExternalCallEnforcerArgs({ target: universalDeployments.Multicall, - callData: getDepositAaveV3HookData({ - amount, - token, - delegator: delegation.delegator, + callData: encodeFunctionData({ + abi: multicallAbi, + functionName: 'multicall', + args: [[...withdrawActions, ...depositActions]], }), }), }; @@ -87,11 +65,11 @@ export async function processLimitOrderDelegation({ // Set the delegation execution to transfer the delegator tokens to the multicall contract const execution: DelegationExecution = { value: 0n, - target: token, + target: tokenOut, calldata: encodeFunctionData({ abi: erc20Abi, functionName: 'transfer', - args: [universalDeployments.Multicall, amount], + args: [universalDeployments.Multicall, amountOut], }), }; diff --git a/apps/api-delegations/src/processing/limit-order/protocols/aave-v3.ts b/apps/api-delegations/src/processing/limit-order/protocols/aave-v3.ts new file mode 100644 index 00000000..939d180c --- /dev/null +++ b/apps/api-delegations/src/processing/limit-order/protocols/aave-v3.ts @@ -0,0 +1,65 @@ +import { encodeFunctionData, erc20Abi, type Address, type Hex } from 'viem'; +import { aaveV3PoolAbi, universalDeployments } from 'universal-data'; + +const AAVE_V3_POOL_BASE = '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5'; + +type GetDepositAaveV3HookDataReturnType = { + target: Address; + value: bigint; + callData: Hex; +}[]; + +export function getDepositAaveV3HookData({ + amountIn, + delegator, + tokenOut, +}: { + amountIn: bigint; + delegator: Address; + tokenOut: Address; +}): GetDepositAaveV3HookDataReturnType { + return [ + // Approves the token to the Aave Pool + { + target: tokenOut, + value: 0n, + callData: encodeFunctionData({ + abi: erc20Abi, + functionName: 'approve', + args: [AAVE_V3_POOL_BASE, amountIn], + }), + }, + // Deposits the token to the Aave Pool on behalf of the delegator + { + target: AAVE_V3_POOL_BASE, + value: 0n, + callData: encodeFunctionData({ + abi: aaveV3PoolAbi, + functionName: 'supply', + args: [tokenOut, amountIn, delegator, 0], + }), + }, + ]; +} + +type GetWithdrawAaveV3HookDataReturnType = GetDepositAaveV3HookDataReturnType; +export function getWithdrawAaveV3HookData({ + amountIn, + tokenIn, +}: { + amountIn: bigint; + tokenIn: Address; +}): GetWithdrawAaveV3HookDataReturnType { + return [ + // Withdraws the token from the Aave Pool on behalf of the delegator + { + target: AAVE_V3_POOL_BASE, + value: 0n, + callData: encodeFunctionData({ + abi: aaveV3PoolAbi, + functionName: 'withdraw', + args: [tokenIn, amountIn, universalDeployments.Multicall], + }), + }, + ]; +} diff --git a/apps/api-delegations/src/processing/limit-order/protocols/compound-v3.ts b/apps/api-delegations/src/processing/limit-order/protocols/compound-v3.ts new file mode 100644 index 00000000..2fcf6bb0 --- /dev/null +++ b/apps/api-delegations/src/processing/limit-order/protocols/compound-v3.ts @@ -0,0 +1,44 @@ +import { encodeFunctionData, erc20Abi, type Address, type Hex } from 'viem'; +import { multicallAbi } from 'universal-data'; +import { compoundV3Abi } from 'universal-data'; + +export function getDepositCompoundV3HookData({ + amountIn, + delegator, + tokenOut, + tokenIn, +}: { + amountIn: bigint; + delegator: Address; + tokenIn: Address; + tokenOut: Address; +}): Hex { + return encodeFunctionData({ + abi: multicallAbi, + functionName: 'multicall', + args: [ + [ + // Approves the token to the Compound Pool + { + target: tokenOut, + value: 0n, + callData: encodeFunctionData({ + abi: erc20Abi, + functionName: 'approve', + args: [tokenIn, amountIn], + }), + }, + // Deposits the token to the Compound Pool on behalf of the delegator + { + target: tokenIn, + value: 0n, + callData: encodeFunctionData({ + abi: compoundV3Abi, + functionName: 'supplyTo', + args: [delegator, tokenOut, amountIn], + }), + }, + ], + ], + }); +} diff --git a/apps/api-delegations/src/processing/limit-order/protocols/pool-together-v5.ts b/apps/api-delegations/src/processing/limit-order/protocols/pool-together-v5.ts new file mode 100644 index 00000000..60e6c2f6 --- /dev/null +++ b/apps/api-delegations/src/processing/limit-order/protocols/pool-together-v5.ts @@ -0,0 +1,73 @@ +import { encodeFunctionData, erc20Abi, type Address, type Hex } from 'viem'; +import { poolTogetherV5Abi, universalDeployments } from 'universal-data'; + +type GetDepositPoolTogetherV5HookDataReturnType = { + target: Address; + value: bigint; + callData: Hex; +}[]; + +export function getDepositPoolTogetherV5HookData({ + amountIn, + delegator, + tokenOut, + tokenIn, +}: { + amountIn: bigint; + delegator: Address; + tokenIn: Address; + tokenOut: Address; +}): GetDepositPoolTogetherV5HookDataReturnType { + return [ + // Approves the token to the Prize vault + { + target: tokenOut, + value: 0n, + callData: encodeFunctionData({ + abi: erc20Abi, + functionName: 'approve', + args: [tokenIn, amountIn], + }), + }, + // Deposits the token to the Prize vault on behalf of the delegator + { + target: tokenIn, + value: 0n, + callData: encodeFunctionData({ + abi: poolTogetherV5Abi, + functionName: 'deposit', + args: [amountIn, delegator], + }), + }, + ]; +} + +type GetWithdrawPoolTogetherV5HookDataReturnType = + GetDepositPoolTogetherV5HookDataReturnType; + +export function getWithdrawPoolTogetherV5HookData({ + amountOut, + + tokenOut, +}: { + amountOut: bigint; + + tokenOut: Address; +}): GetWithdrawPoolTogetherV5HookDataReturnType { + return [ + // Deposits the token to the Prize vault on behalf of the delegator + { + target: tokenOut, + value: 0n, + callData: encodeFunctionData({ + abi: poolTogetherV5Abi, + functionName: 'redeem', + args: [ + amountOut, + universalDeployments.Multicall, + universalDeployments.Multicall, + ], + }), + }, + ]; +} diff --git a/apps/api-delegations/src/processing/limit-order/protocols/underlying-asset.ts b/apps/api-delegations/src/processing/limit-order/protocols/underlying-asset.ts new file mode 100644 index 00000000..0420d617 --- /dev/null +++ b/apps/api-delegations/src/processing/limit-order/protocols/underlying-asset.ts @@ -0,0 +1,30 @@ +import { encodeFunctionData, erc20Abi, type Address, type Hex } from 'viem'; + +type GetDepositUnderlyingAssetHookDataReturnType = { + target: Address; + value: bigint; + callData: Hex; +}[]; + +export function getDepositUnderlyingAssetHookData({ + amountIn, + delegator, + tokenIn, +}: { + amountIn: bigint; + delegator: Address; + tokenIn: Address; +}): GetDepositUnderlyingAssetHookDataReturnType { + return [ + // Approves the token to the Aave Pool + { + target: tokenIn, + value: 0n, + callData: encodeFunctionData({ + abi: erc20Abi, + functionName: 'transfer', + args: [delegator, amountIn], + }), + }, + ]; +} diff --git a/apps/api-delegations/src/processing/limit-order/utils.ts b/apps/api-delegations/src/processing/limit-order/utils.ts index 5fa0670d..0710010b 100644 --- a/apps/api-delegations/src/processing/limit-order/utils.ts +++ b/apps/api-delegations/src/processing/limit-order/utils.ts @@ -62,6 +62,27 @@ export function getErc20TransferAmountEnforcerFromDelegation( return { erc20TransferAmountEnforcer, index }; } +export function getERC20BalanceGteWrapEnforcerFromDelegation( + delegation: Delegation, +) { + const index = delegation.caveats.findIndex( + ({ enforcer }) => + enforcer.toLowerCase() === + universalDeployments.ERC20BalanceGteWrapEnforcer.toLowerCase(), + ); + if (index === -1) { + throw NoEnforcerFoundError; + } + + const erc20BalanceGteWrapEnforcer = delegation.caveats[index]; + + if (!erc20BalanceGteWrapEnforcer) { + throw NoEnforcerFoundError; + } + + return { erc20BalanceGteWrapEnforcer, index }; +} + export function getExternalHookEnforcerFromDelegation(delegation: Delegation) { const index = delegation.caveats.findIndex( ({ enforcer }) => @@ -150,3 +171,28 @@ export function encodeExternalCallEnforcerArgs({ }: EncodeExternalHookArgsParams) { return encodePacked(['address', 'bytes'], [target, callData]); } + +export function encodeERC20BalanceGteWrapEnforcerTerms({ + amount, + token, +}: { + amount: bigint; + token: Address; +}) { + return encodePacked(['address', 'uint256'], [token, amount]); +} + +export function decodeERC20BalanceGteWrapEnforcerTerms(data: Hex) { + // Addresses are 20 bytes, uint256 is 32 bytes + const addressSize = 20; + const uint256Size = 32; + + // Decode `token` (first 20 bytes) + const token = sliceHex(data, 0, addressSize) as Address; + + // Decode `amount` (next 32 bytes) + const amountHex = sliceHex(data, addressSize, addressSize + uint256Size); + const amount = hexToBigInt(amountHex); + + return { token, amount }; +} diff --git a/packages/universal-data/src/abis/compound-v3-abi.ts b/packages/universal-data/src/abis/compound-v3-abi.ts new file mode 100644 index 00000000..ac292b66 --- /dev/null +++ b/packages/universal-data/src/abis/compound-v3-abi.ts @@ -0,0 +1,1003 @@ +export const compoundV3Abi = [ + { + inputs: [ + { + components: [ + { internalType: 'address', name: 'governor', type: 'address' }, + { internalType: 'address', name: 'pauseGuardian', type: 'address' }, + { internalType: 'address', name: 'baseToken', type: 'address' }, + { + internalType: 'address', + name: 'baseTokenPriceFeed', + type: 'address', + }, + { + internalType: 'address', + name: 'extensionDelegate', + type: 'address', + }, + { internalType: 'uint64', name: 'supplyKink', type: 'uint64' }, + { + internalType: 'uint64', + name: 'supplyPerYearInterestRateSlopeLow', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'supplyPerYearInterestRateSlopeHigh', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'supplyPerYearInterestRateBase', + type: 'uint64', + }, + { internalType: 'uint64', name: 'borrowKink', type: 'uint64' }, + { + internalType: 'uint64', + name: 'borrowPerYearInterestRateSlopeLow', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'borrowPerYearInterestRateSlopeHigh', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'borrowPerYearInterestRateBase', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'storeFrontPriceFactor', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'trackingIndexScale', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'baseTrackingSupplySpeed', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'baseTrackingBorrowSpeed', + type: 'uint64', + }, + { + internalType: 'uint104', + name: 'baseMinForRewards', + type: 'uint104', + }, + { internalType: 'uint104', name: 'baseBorrowMin', type: 'uint104' }, + { internalType: 'uint104', name: 'targetReserves', type: 'uint104' }, + { + components: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'address', name: 'priceFeed', type: 'address' }, + { internalType: 'uint8', name: 'decimals', type: 'uint8' }, + { + internalType: 'uint64', + name: 'borrowCollateralFactor', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'liquidateCollateralFactor', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'liquidationFactor', + type: 'uint64', + }, + { internalType: 'uint128', name: 'supplyCap', type: 'uint128' }, + ], + internalType: 'struct CometConfiguration.AssetConfig[]', + name: 'assetConfigs', + type: 'tuple[]', + }, + ], + internalType: 'struct CometConfiguration.Configuration', + name: 'config', + type: 'tuple', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { inputs: [], name: 'Absurd', type: 'error' }, + { inputs: [], name: 'AlreadyInitialized', type: 'error' }, + { inputs: [], name: 'BadAsset', type: 'error' }, + { inputs: [], name: 'BadDecimals', type: 'error' }, + { inputs: [], name: 'BadDiscount', type: 'error' }, + { inputs: [], name: 'BadMinimum', type: 'error' }, + { inputs: [], name: 'BadPrice', type: 'error' }, + { inputs: [], name: 'BorrowCFTooLarge', type: 'error' }, + { inputs: [], name: 'BorrowTooSmall', type: 'error' }, + { inputs: [], name: 'InsufficientReserves', type: 'error' }, + { inputs: [], name: 'InvalidInt104', type: 'error' }, + { inputs: [], name: 'InvalidInt256', type: 'error' }, + { inputs: [], name: 'InvalidUInt104', type: 'error' }, + { inputs: [], name: 'InvalidUInt128', type: 'error' }, + { inputs: [], name: 'InvalidUInt64', type: 'error' }, + { inputs: [], name: 'LiquidateCFTooLarge', type: 'error' }, + { inputs: [], name: 'NegativeNumber', type: 'error' }, + { inputs: [], name: 'NoSelfTransfer', type: 'error' }, + { inputs: [], name: 'NotCollateralized', type: 'error' }, + { inputs: [], name: 'NotForSale', type: 'error' }, + { inputs: [], name: 'NotLiquidatable', type: 'error' }, + { inputs: [], name: 'Paused', type: 'error' }, + { inputs: [], name: 'SupplyCapExceeded', type: 'error' }, + { inputs: [], name: 'TimestampTooLarge', type: 'error' }, + { inputs: [], name: 'TooManyAssets', type: 'error' }, + { inputs: [], name: 'TooMuchSlippage', type: 'error' }, + { inputs: [], name: 'TransferInFailed', type: 'error' }, + { inputs: [], name: 'TransferOutFailed', type: 'error' }, + { inputs: [], name: 'Unauthorized', type: 'error' }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'absorber', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'borrower', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'collateralAbsorbed', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'usdValue', + type: 'uint256', + }, + ], + name: 'AbsorbCollateral', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'absorber', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'borrower', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'basePaidOut', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'usdValue', + type: 'uint256', + }, + ], + name: 'AbsorbDebt', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'buyer', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'baseAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'collateralAmount', + type: 'uint256', + }, + ], + name: 'BuyCollateral', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bool', + name: 'supplyPaused', + type: 'bool', + }, + { + indexed: false, + internalType: 'bool', + name: 'transferPaused', + type: 'bool', + }, + { + indexed: false, + internalType: 'bool', + name: 'withdrawPaused', + type: 'bool', + }, + { + indexed: false, + internalType: 'bool', + name: 'absorbPaused', + type: 'bool', + }, + { indexed: false, internalType: 'bool', name: 'buyPaused', type: 'bool' }, + ], + name: 'PauseAction', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { indexed: true, internalType: 'address', name: 'dst', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Supply', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { indexed: true, internalType: 'address', name: 'dst', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'SupplyCollateral', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'TransferCollateral', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'src', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Withdraw', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'src', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'WithdrawCollateral', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'WithdrawReserves', + type: 'event', + }, + { stateMutability: 'payable', type: 'fallback' }, + { + inputs: [ + { internalType: 'address', name: 'absorber', type: 'address' }, + { internalType: 'address[]', name: 'accounts', type: 'address[]' }, + ], + name: 'absorb', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'accrueAccount', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'manager', type: 'address' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'approveThis', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'balanceOf', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseBorrowMin', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseMinForRewards', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseScale', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseToken', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseTokenPriceFeed', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseTrackingBorrowSpeed', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseTrackingSupplySpeed', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'borrowBalanceOf', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'borrowKink', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'borrowPerSecondInterestRateBase', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'borrowPerSecondInterestRateSlopeHigh', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'borrowPerSecondInterestRateSlopeLow', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'minAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'baseAmount', type: 'uint256' }, + { internalType: 'address', name: 'recipient', type: 'address' }, + ], + name: 'buyCollateral', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'extensionDelegate', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint8', name: 'i', type: 'uint8' }], + name: 'getAssetInfo', + outputs: [ + { + components: [ + { internalType: 'uint8', name: 'offset', type: 'uint8' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'address', name: 'priceFeed', type: 'address' }, + { internalType: 'uint64', name: 'scale', type: 'uint64' }, + { + internalType: 'uint64', + name: 'borrowCollateralFactor', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'liquidateCollateralFactor', + type: 'uint64', + }, + { internalType: 'uint64', name: 'liquidationFactor', type: 'uint64' }, + { internalType: 'uint128', name: 'supplyCap', type: 'uint128' }, + ], + internalType: 'struct CometCore.AssetInfo', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getAssetInfoByAddress', + outputs: [ + { + components: [ + { internalType: 'uint8', name: 'offset', type: 'uint8' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'address', name: 'priceFeed', type: 'address' }, + { internalType: 'uint64', name: 'scale', type: 'uint64' }, + { + internalType: 'uint64', + name: 'borrowCollateralFactor', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'liquidateCollateralFactor', + type: 'uint64', + }, + { internalType: 'uint64', name: 'liquidationFactor', type: 'uint64' }, + { internalType: 'uint128', name: 'supplyCap', type: 'uint128' }, + ], + internalType: 'struct CometCore.AssetInfo', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'utilization', type: 'uint256' }], + name: 'getBorrowRate', + outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'getCollateralReserves', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'priceFeed', type: 'address' }], + name: 'getPrice', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getReserves', + outputs: [{ internalType: 'int256', name: '', type: 'int256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'utilization', type: 'uint256' }], + name: 'getSupplyRate', + outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getUtilization', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'governor', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'address', name: 'manager', type: 'address' }, + ], + name: 'hasPermission', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'initializeStorage', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'isAbsorbPaused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'address', name: '', type: 'address' }, + ], + name: 'isAllowed', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'isBorrowCollateralized', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'isBuyPaused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'isLiquidatable', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'isSupplyPaused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'isTransferPaused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'isWithdrawPaused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'liquidatorPoints', + outputs: [ + { internalType: 'uint32', name: 'numAbsorbs', type: 'uint32' }, + { internalType: 'uint64', name: 'numAbsorbed', type: 'uint64' }, + { internalType: 'uint128', name: 'approxSpend', type: 'uint128' }, + { internalType: 'uint32', name: '_reserved', type: 'uint32' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'numAssets', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bool', name: 'supplyPaused', type: 'bool' }, + { internalType: 'bool', name: 'transferPaused', type: 'bool' }, + { internalType: 'bool', name: 'withdrawPaused', type: 'bool' }, + { internalType: 'bool', name: 'absorbPaused', type: 'bool' }, + { internalType: 'bool', name: 'buyPaused', type: 'bool' }, + ], + name: 'pause', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'pauseGuardian', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'baseAmount', type: 'uint256' }, + ], + name: 'quoteCollateral', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'storeFrontPriceFactor', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'supply', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'address', name: 'dst', type: 'address' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'supplyFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'supplyKink', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'supplyPerSecondInterestRateBase', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'supplyPerSecondInterestRateSlopeHigh', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'supplyPerSecondInterestRateSlopeLow', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'dst', type: 'address' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'supplyTo', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'targetReserves', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalBorrow', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'totalsCollateral', + outputs: [ + { internalType: 'uint128', name: 'totalSupplyAsset', type: 'uint128' }, + { internalType: 'uint128', name: '_reserved', type: 'uint128' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'trackingIndexScale', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'dst', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transfer', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'dst', type: 'address' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transferAsset', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'src', type: 'address' }, + { internalType: 'address', name: 'dst', type: 'address' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transferAssetFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'src', type: 'address' }, + { internalType: 'address', name: 'dst', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transferFrom', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'userBasic', + outputs: [ + { internalType: 'int104', name: 'principal', type: 'int104' }, + { internalType: 'uint64', name: 'baseTrackingIndex', type: 'uint64' }, + { internalType: 'uint64', name: 'baseTrackingAccrued', type: 'uint64' }, + { internalType: 'uint16', name: 'assetsIn', type: 'uint16' }, + { internalType: 'uint8', name: '_reserved', type: 'uint8' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'address', name: '', type: 'address' }, + ], + name: 'userCollateral', + outputs: [ + { internalType: 'uint128', name: 'balance', type: 'uint128' }, + { internalType: 'uint128', name: '_reserved', type: 'uint128' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'userNonce', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'withdraw', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'src', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'withdrawFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'withdrawReserves', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'address', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'withdrawTo', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; diff --git a/packages/universal-data/src/abis/delegation-manager-abi.ts b/packages/universal-data/src/abis/delegation-manager-abi.ts index 242fa7da..437462c4 100644 --- a/packages/universal-data/src/abis/delegation-manager-abi.ts +++ b/packages/universal-data/src/abis/delegation-manager-abi.ts @@ -603,6 +603,23 @@ export const delegationManagerAbi = [ name: 'ECDSAInvalidSignatureS', inputs: [{ name: 's', type: 'bytes32', internalType: 'bytes32' }], }, + { + type: 'error', + name: 'BalanceNotGreaterOrEqualThan', + inputs: [ + { name: 'balance', type: 'uint256', internalType: 'uint256' }, + { name: 'expected', type: 'uint256', internalType: 'uint256' }, + ], + }, + { type: 'error', name: 'EnforcerIsLocked', inputs: [] }, + { + type: 'error', + name: 'InvalidTermsLength', + inputs: [ + { name: 'length', type: 'uint256', internalType: 'uint256' }, + { name: 'expected', type: 'uint256', internalType: 'uint256' }, + ], + }, { type: 'error', name: 'EmptySignature', inputs: [] }, { type: 'error', name: 'EnforcedPause', inputs: [] }, { type: 'error', name: 'ExpectedPause', inputs: [] }, diff --git a/packages/universal-data/src/abis/erc20-balance-gte-after-all-enforcer-abi.ts b/packages/universal-data/src/abis/erc20-balance-gte-after-all-enforcer-abi.ts index f60dedfe..6ea1282b 100644 --- a/packages/universal-data/src/abis/erc20-balance-gte-after-all-enforcer-abi.ts +++ b/packages/universal-data/src/abis/erc20-balance-gte-after-all-enforcer-abi.ts @@ -1,4 +1,4 @@ -export const erc20TransferAmountEnforcerAbi = [ +export const erc20BalanceGteWrapEnforcerAbi = [ { type: 'function', name: 'afterAllHook', @@ -40,12 +40,12 @@ export const erc20TransferAmountEnforcerAbi = [ type: 'function', name: 'beforeAllHook', inputs: [ - { name: '', type: 'bytes', internalType: 'bytes' }, + { name: '_terms', type: 'bytes', internalType: 'bytes' }, { name: '', type: 'bytes', internalType: 'bytes' }, { name: '', type: 'bytes32', internalType: 'ModeCode' }, { name: '', type: 'bytes', internalType: 'bytes' }, - { name: '', type: 'bytes32', internalType: 'bytes32' }, - { name: '', type: 'address', internalType: 'address' }, + { name: '_delegationHash', type: 'bytes32', internalType: 'bytes32' }, + { name: '_delegator', type: 'address', internalType: 'address' }, { name: '', type: 'address', internalType: 'address' }, ], outputs: [], @@ -94,4 +94,21 @@ export const erc20TransferAmountEnforcerAbi = [ outputs: [{ name: 'lock', type: 'bool', internalType: 'bool' }], stateMutability: 'view', }, + { + type: 'error', + name: 'BalanceNotGreaterOrEqualThan', + inputs: [ + { name: 'balance', type: 'uint256', internalType: 'uint256' }, + { name: 'expected', type: 'uint256', internalType: 'uint256' }, + ], + }, + { type: 'error', name: 'EnforcerIsLocked', inputs: [] }, + { + type: 'error', + name: 'InvalidTermsLength', + inputs: [ + { name: 'length', type: 'uint256', internalType: 'uint256' }, + { name: 'expected', type: 'uint256', internalType: 'uint256' }, + ], + }, ] as const; diff --git a/packages/universal-data/src/abis/pool-together-v5-abi.ts b/packages/universal-data/src/abis/pool-together-v5-abi.ts new file mode 100644 index 00000000..6d7aef4c --- /dev/null +++ b/packages/universal-data/src/abis/pool-together-v5-abi.ts @@ -0,0 +1,1056 @@ +export const poolTogetherV5Abi = [ + { + inputs: [ + { internalType: 'string', name: 'name_', type: 'string' }, + { internalType: 'string', name: 'symbol_', type: 'string' }, + { + internalType: 'contract IERC4626', + name: 'yieldVault_', + type: 'address', + }, + { + internalType: 'contract PrizePool', + name: 'prizePool_', + type: 'address', + }, + { internalType: 'address', name: 'claimer_', type: 'address' }, + { internalType: 'address', name: 'yieldFeeRecipient_', type: 'address' }, + { internalType: 'uint32', name: 'yieldFeePercentage_', type: 'uint32' }, + { internalType: 'uint256', name: 'yieldBuffer_', type: 'uint256' }, + { internalType: 'address', name: 'owner_', type: 'address' }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { inputs: [], name: 'BurnZeroShares', type: 'error' }, + { + inputs: [ + { internalType: 'address', name: 'caller', type: 'address' }, + { internalType: 'address', name: 'claimer', type: 'address' }, + ], + name: 'CallerNotClaimer', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'caller', type: 'address' }, + { internalType: 'address', name: 'liquidationPair', type: 'address' }, + ], + name: 'CallerNotLP', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'caller', type: 'address' }, + { internalType: 'address', name: 'yieldFeeRecipient', type: 'address' }, + ], + name: 'CallerNotYieldFeeRecipient', + type: 'error', + }, + { inputs: [], name: 'ClaimRecipientZeroAddress', type: 'error' }, + { inputs: [], name: 'ClaimerZeroAddress', type: 'error' }, + { inputs: [], name: 'DepositZeroAssets', type: 'error' }, + { + inputs: [{ internalType: 'address', name: 'asset', type: 'address' }], + name: 'FailedToGetAssetDecimals', + type: 'error', + }, + { inputs: [], name: 'InvalidShortString', type: 'error' }, + { inputs: [], name: 'LPZeroAddress', type: 'error' }, + { inputs: [], name: 'LiquidationAmountOutZero', type: 'error' }, + { + inputs: [ + { internalType: 'uint256', name: 'totalToWithdraw', type: 'uint256' }, + { internalType: 'uint256', name: 'availableYield', type: 'uint256' }, + ], + name: 'LiquidationExceedsAvailable', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'tokenIn', type: 'address' }, + { internalType: 'address', name: 'prizeToken', type: 'address' }, + ], + name: 'LiquidationTokenInNotPrizeToken', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'tokenOut', type: 'address' }], + name: 'LiquidationTokenOutNotSupported', + type: 'error', + }, + { + inputs: [ + { internalType: 'uint256', name: 'totalAssets', type: 'uint256' }, + { internalType: 'uint256', name: 'totalSupply', type: 'uint256' }, + ], + name: 'LossyDeposit', + type: 'error', + }, + { + inputs: [ + { internalType: 'uint256', name: 'shares', type: 'uint256' }, + { internalType: 'uint256', name: 'maxShares', type: 'uint256' }, + ], + name: 'MaxSharesExceeded', + type: 'error', + }, + { + inputs: [ + { internalType: 'uint256', name: 'assets', type: 'uint256' }, + { internalType: 'uint256', name: 'minAssets', type: 'uint256' }, + ], + name: 'MinAssetsNotReached', + type: 'error', + }, + { + inputs: [{ internalType: 'uint256', name: 'excess', type: 'uint256' }], + name: 'MintLimitExceeded', + type: 'error', + }, + { inputs: [], name: 'MintZeroShares', type: 'error' }, + { inputs: [], name: 'OwnerZeroAddress', type: 'error' }, + { + inputs: [ + { internalType: 'address', name: 'caller', type: 'address' }, + { internalType: 'address', name: 'owner', type: 'address' }, + ], + name: 'PermitCallerNotOwner', + type: 'error', + }, + { inputs: [], name: 'PrizePoolZeroAddress', type: 'error' }, + { + inputs: [ + { internalType: 'uint256', name: 'returnDataSize', type: 'uint256' }, + { internalType: 'uint256', name: 'hookDataLimit', type: 'uint256' }, + ], + name: 'ReturnDataOverLimit', + type: 'error', + }, + { + inputs: [ + { internalType: 'uint256', name: 'shares', type: 'uint256' }, + { internalType: 'uint256', name: 'yieldFeeBalance', type: 'uint256' }, + ], + name: 'SharesExceedsYieldFeeBalance', + type: 'error', + }, + { + inputs: [{ internalType: 'string', name: 'str', type: 'string' }], + name: 'StringTooLong', + type: 'error', + }, + { inputs: [], name: 'TwabControllerZeroAddress', type: 'error' }, + { inputs: [], name: 'WithdrawZeroAssets', type: 'error' }, + { + inputs: [ + { internalType: 'uint256', name: 'yieldFeePercentage', type: 'uint256' }, + { + internalType: 'uint256', + name: 'maxYieldFeePercentage', + type: 'uint256', + }, + ], + name: 'YieldFeePercentageExceedsMax', + type: 'error', + }, + { inputs: [], name: 'YieldVaultZeroAddress', type: 'error' }, + { inputs: [], name: 'ZeroTotalAssets', type: 'error' }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'ClaimYieldFeeShares', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'claimer', + type: 'address', + }, + ], + name: 'ClaimerSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Deposit', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'EIP712DomainChanged', type: 'event' }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'tokenOut', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'liquidationPair', + type: 'address', + }, + ], + name: 'LiquidationPairSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'pendingOwner', + type: 'address', + }, + ], + name: 'OwnershipOffered', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + components: [ + { internalType: 'bool', name: 'useBeforeClaimPrize', type: 'bool' }, + { internalType: 'bool', name: 'useAfterClaimPrize', type: 'bool' }, + { + internalType: 'contract IPrizeHooks', + name: 'implementation', + type: 'address', + }, + ], + indexed: false, + internalType: 'struct PrizeHooks', + name: 'hooks', + type: 'tuple', + }, + ], + name: 'SetHooks', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'liquidationPair', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'tokenOut', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'yieldFee', + type: 'uint256', + }, + ], + name: 'TransferYieldOut', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Withdraw', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'yieldFeePercentage', + type: 'uint256', + }, + ], + name: 'YieldFeePercentageSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'yieldFeeRecipient', + type: 'address', + }, + ], + name: 'YieldFeeRecipientSet', + type: 'event', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'FEE_PRECISION', + outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'HOOK_GAS', + outputs: [{ internalType: 'uint24', name: '', type: 'uint24' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'HOOK_RETURN_DATA_LIMIT', + outputs: [{ internalType: 'uint16', name: '', type: 'uint16' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_YIELD_FEE', + outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'address', name: 'spender', type: 'address' }, + ], + name: 'allowance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'approve', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'asset', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'availableYieldBalance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_account', type: 'address' }], + name: 'balanceOf', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'claimOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '_winner', type: 'address' }, + { internalType: 'uint8', name: '_tier', type: 'uint8' }, + { internalType: 'uint32', name: '_prizeIndex', type: 'uint32' }, + { internalType: 'uint96', name: '_reward', type: 'uint96' }, + { internalType: 'address', name: '_rewardRecipient', type: 'address' }, + ], + name: 'claimPrize', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_shares', type: 'uint256' }], + name: 'claimYieldFeeShares', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'claimer', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_shares', type: 'uint256' }], + name: 'convertToAssets', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_assets', type: 'uint256' }], + name: 'convertToShares', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'currentYieldBuffer', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'subtractedValue', type: 'uint256' }, + ], + name: 'decreaseAllowance', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: '_assets', type: 'uint256' }, + { internalType: 'address', name: '_receiver', type: 'address' }, + ], + name: 'deposit', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: '_assets', type: 'uint256' }, + { internalType: 'address', name: '_owner', type: 'address' }, + { internalType: 'uint256', name: '_deadline', type: 'uint256' }, + { internalType: 'uint8', name: '_v', type: 'uint8' }, + { internalType: 'bytes32', name: '_r', type: 'bytes32' }, + { internalType: 'bytes32', name: '_s', type: 'bytes32' }, + ], + name: 'depositWithPermit', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'eip712Domain', + outputs: [ + { 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[]' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'getHooks', + outputs: [ + { + components: [ + { internalType: 'bool', name: 'useBeforeClaimPrize', type: 'bool' }, + { internalType: 'bool', name: 'useAfterClaimPrize', type: 'bool' }, + { + internalType: 'contract IPrizeHooks', + name: 'implementation', + type: 'address', + }, + ], + internalType: 'struct PrizeHooks', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'addedValue', type: 'uint256' }, + ], + name: 'increaseAllowance', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '_tokenOut', type: 'address' }, + { internalType: 'address', name: '_liquidationPair', type: 'address' }, + ], + name: 'isLiquidationPair', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_tokenOut', type: 'address' }], + name: 'liquidatableBalanceOf', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'liquidationPair', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'maxDeposit', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_owner', type: 'address' }], + name: 'maxMint', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_owner', type: 'address' }], + name: 'maxRedeem', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_owner', type: 'address' }], + name: 'maxWithdraw', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: '_shares', type: 'uint256' }, + { internalType: 'address', name: '_receiver', type: 'address' }, + ], + name: 'mint', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'owner', type: 'address' }], + name: 'nonces', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'pendingOwner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'value', type: 'uint256' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + { internalType: 'uint8', name: 'v', type: 'uint8' }, + { internalType: 'bytes32', name: 'r', type: 'bytes32' }, + { internalType: 'bytes32', name: 's', type: 'bytes32' }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_assets', type: 'uint256' }], + name: 'previewDeposit', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_shares', type: 'uint256' }], + name: 'previewMint', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_shares', type: 'uint256' }], + name: 'previewRedeem', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_assets', type: 'uint256' }], + name: 'previewWithdraw', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'prizePool', + outputs: [ + { internalType: 'contract PrizePool', name: '', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: '_shares', type: 'uint256' }, + { internalType: 'address', name: '_receiver', type: 'address' }, + { internalType: 'address', name: '_owner', type: 'address' }, + { internalType: 'uint256', name: '_minAssets', type: 'uint256' }, + ], + name: 'redeem', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: '_shares', type: 'uint256' }, + { internalType: 'address', name: '_receiver', type: 'address' }, + { internalType: 'address', name: '_owner', type: 'address' }, + ], + name: 'redeem', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_claimer', type: 'address' }], + name: 'setClaimer', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'bool', name: 'useBeforeClaimPrize', type: 'bool' }, + { internalType: 'bool', name: 'useAfterClaimPrize', type: 'bool' }, + { + internalType: 'contract IPrizeHooks', + name: 'implementation', + type: 'address', + }, + ], + internalType: 'struct PrizeHooks', + name: 'hooks', + type: 'tuple', + }, + ], + name: 'setHooks', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '_liquidationPair', type: 'address' }, + ], + name: 'setLiquidationPair', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint32', name: '_yieldFeePercentage', type: 'uint32' }, + ], + name: 'setYieldFeePercentage', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '_yieldFeeRecipient', type: 'address' }, + ], + name: 'setYieldFeeRecipient', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'targetOf', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalAssets', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalDebt', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalPreciseAssets', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalYieldBalance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transfer', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transferFrom', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_newOwner', type: 'address' }], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'address', name: '_receiver', type: 'address' }, + { internalType: 'address', name: '_tokenOut', type: 'address' }, + { internalType: 'uint256', name: '_amountOut', type: 'uint256' }, + ], + name: 'transferTokensOut', + outputs: [{ internalType: 'bytes', name: '', type: 'bytes' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'twabController', + outputs: [ + { internalType: 'contract TwabController', name: '', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '_tokenIn', type: 'address' }, + { internalType: 'uint256', name: '_amountIn', type: 'uint256' }, + { internalType: 'bytes', name: '', type: 'bytes' }, + ], + name: 'verifyTokensIn', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: '_assets', type: 'uint256' }, + { internalType: 'address', name: '_receiver', type: 'address' }, + { internalType: 'address', name: '_owner', type: 'address' }, + { internalType: 'uint256', name: '_maxShares', type: 'uint256' }, + ], + name: 'withdraw', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: '_assets', type: 'uint256' }, + { internalType: 'address', name: '_receiver', type: 'address' }, + { internalType: 'address', name: '_owner', type: 'address' }, + ], + name: 'withdraw', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'yieldBuffer', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'yieldFeeBalance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'yieldFeePercentage', + outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'yieldFeeRecipient', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'yieldVault', + outputs: [{ internalType: 'contract IERC4626', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, +] as const; diff --git a/packages/universal-data/src/exports/index.ts b/packages/universal-data/src/exports/index.ts index 9c134480..26e1e917 100644 --- a/packages/universal-data/src/exports/index.ts +++ b/packages/universal-data/src/exports/index.ts @@ -1,4 +1,7 @@ export { aaveV3PoolAbi } from '../abis/aave-v3-pool-abi.js'; +export { compoundV3Abi } from '../abis/compound-v3-abi.js'; +export { poolTogetherV5Abi } from '../abis/pool-together-v5-abi.js'; +export { erc20BalanceGteWrapEnforcerAbi } from '../abis/erc20-balance-gte-after-all-enforcer-abi.js'; export { multicallAbi } from '../abis/multicall-abi.js'; export { delegationManagerAbi } from '../abis/delegation-manager-abi.js'; export { erc20TransferAmountEnforcerAbi } from '../abis/erc20-transfer-amount-enforcer-abi.js'; diff --git a/packages/universal-data/src/token-list/stablecoin-token-list.ts b/packages/universal-data/src/token-list/stablecoin-token-list.ts index ff983048..7dd84964 100644 --- a/packages/universal-data/src/token-list/stablecoin-token-list.ts +++ b/packages/universal-data/src/token-list/stablecoin-token-list.ts @@ -34,6 +34,9 @@ export const stablecoinTokenList: TokenList = { logoURI: 'https://app.cabana.fi/icons/przUSDC.svg', address: '0x7f5C2b379b88499aC2B997Db583f8079503f25b9', decimals: 6, + extensions: { + protocol: 'pool-together-v5', + }, }, { chainId: 8453, @@ -43,37 +46,20 @@ export const stablecoinTokenList: TokenList = { 'https://assets.coingecko.com/coins/images/14318/standard/aUSDC.e260d492.png?1696514006', address: '0x4e65fE4DbA92790696d040ac24Aa414708F5c0AB', decimals: 6, - }, - { - name: 'Dai Stablecoin', - address: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb', - symbol: 'DAI', - decimals: 18, - chainId: 8453, - logoURI: 'https://ethereum-optimism.github.io/data/DAI/logo.svg', extensions: { - bridgeInfo: { - '1': { - tokenAddress: '0x6B175474E89094C44Da98b954EedeAC495271d0F', - }, - }, - }, - }, - { - chainId: 8453, - name: 'Liquity USD', - symbol: 'LUSD', - logoURI: - 'https://assets.coingecko.com/coins/images/14666/thumb/Group_3.png?1617631327', - address: '0x368181499736d0c0CC614DBB145E2EC1AC86b8c6', - decimals: 18, - extensions: { - bridgeInfo: { - '1': { - tokenAddress: '0x5f98805A4E8be255a32880FDeC7F6728C6568bA0', - }, - }, + protocol: 'aave-v3', }, }, + // { + // chainId: 8453, + // name: 'Compound USDC', + // symbol: 'cUSDCv3', + // logoURI: 'https://ethereum-optimism.github.io/data/USDC/logo.png', + // address: '0xb125e6687d4313864e53df431d5425969c15eb2f', + // decimals: 6, + // extensions: { + // protocol: 'compound-v3', + // }, + // }, ], }; diff --git a/packages/universal-delegations-sdk/src/actions/use-sign-erc20-swap.ts b/packages/universal-delegations-sdk/src/actions/use-sign-erc20-swap.ts index 3baa643f..22633c58 100644 --- a/packages/universal-delegations-sdk/src/actions/use-sign-erc20-swap.ts +++ b/packages/universal-delegations-sdk/src/actions/use-sign-erc20-swap.ts @@ -2,12 +2,18 @@ import { useState } from 'react'; import { ROOT_AUTHORITY, SALT, universalDeployments } from 'universal-data'; import type { Delegation, DelegationWithMetadata } from 'universal-types'; -import { type Address, zeroAddress } from 'viem'; +import { + type Address, + parseUnits, + // , + // parseUnits +} from 'viem'; import { useSignTypedData } from 'wagmi'; import { useInsertDelegation } from '../api/actions/insert-delegation.js'; import { eip712DelegationTypes } from '../delegation/eip712-delegation-type.js'; import { getDelegationHash } from '../delegation/get-delegation-hash.js'; import { encodeEnforcerERC20TransferAmount } from '../enforcers/enforcer-erc20-transfer-amount.js'; +import { encodeERC20BalanceGteWrapEnforcerTerms } from '../enforcers/erc20-balance-gte-wrap-enforcer.js'; // import { encodeERC20BalanceGteWrapEnforcerTerms } from '../enforcers/erc20-balance-gte-wrap-enforcer.js'; type SignDelegationParams = { @@ -34,12 +40,12 @@ export function useSignErc20SwapDelegation() { delegator, delegate, salt = SALT, - tokenOut = zeroAddress, - decimalsOut = 18, - amountOut = '0', - // tokenIn = zeroAddress, - // decimalsIn = 18, - // amountIn = '0', + tokenOut, + decimalsOut, + amountOut, + tokenIn, + decimalsIn, + amountIn, }: SignDelegationParams) { const signature = await signTypedDataAsync({ types: eip712DelegationTypes, @@ -56,13 +62,13 @@ export function useSignErc20SwapDelegation() { authority: ROOT_AUTHORITY, salt: salt, caveats: [ - // { - // enforcer: universalDeployments.ERC20BalanceGteWrapEnforcer, - // terms: encodeERC20BalanceGteWrapEnforcerTerms({ - // token: tokenIn, - // amount: parseUnits(amountIn, decimalsIn), - // }), - // }, + { + enforcer: universalDeployments.ERC20BalanceGteWrapEnforcer, + terms: encodeERC20BalanceGteWrapEnforcerTerms({ + token: tokenIn, + amount: parseUnits(amountIn, decimalsIn), + }), + }, { enforcer: universalDeployments.ERC20TransferAmountEnforcer, terms: encodeEnforcerERC20TransferAmount({ @@ -86,14 +92,14 @@ export function useSignErc20SwapDelegation() { salt, signature, caveats: [ - // { - // enforcer: universalDeployments.ERC20BalanceGteWrapEnforcer, - // terms: encodeERC20BalanceGteWrapEnforcerTerms({ - // token: tokenIn, - // amount: parseUnits(amountIn, decimalsIn), - // }), - // args: '0x', - // }, + { + enforcer: universalDeployments.ERC20BalanceGteWrapEnforcer, + terms: encodeERC20BalanceGteWrapEnforcerTerms({ + token: tokenIn, + amount: parseUnits(amountIn, decimalsIn), + }), + args: '0x', + }, { enforcer: universalDeployments.ERC20TransferAmountEnforcer, terms: encodeEnforcerERC20TransferAmount({