diff --git a/packages/protocol/deployments/BondCurrency.Token.json b/packages/protocol/deployments/BondCurrency.Token.json new file mode 100644 index 00000000..fd14bc45 --- /dev/null +++ b/packages/protocol/deployments/BondCurrency.Token.json @@ -0,0 +1,329 @@ +{ + "address": "0xBDF33AE1C1e5f8E3B3ce166F64f2337E2e07a398", + "abi": [ + { + "type": "constructor", + "inputs": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "symbol", + "type": "string", + "internalType": "string" + }, + { + "name": "tokenDecimals", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "subtractedValue", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "addedValue", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "mint", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transfer", + "inputs": [ + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + } + ], + "constructorArgs": [ + "Token", + "USDC", + "6" + ], + "linkedLibraries": {}, + "deployTxnHash": "0x12ee0b194db4db0157edc1ecd4711e1b128110b845c2232c6b427b5749ddc7a5", + "deployTxnBlockNumber": "2", + "deployTimestamp": "1722754532", + "sourceName": "src/MintableTokenPermissionlessMint.sol", + "contractName": "MintableTokenPermissionlessMint", + "deployedOn": "contract.Token", + "highlight": true, + "gasUsed": 639836, + "gasCost": "1586181641" +} \ No newline at end of file diff --git a/packages/protocol/deployments/CollateralAsset.Token.json b/packages/protocol/deployments/CollateralAsset.Token.json new file mode 100644 index 00000000..ca0248bb --- /dev/null +++ b/packages/protocol/deployments/CollateralAsset.Token.json @@ -0,0 +1,329 @@ +{ + "address": "0x7e2c9Dc86Ba53FDf8C14766F53815DB765C8fe40", + "abi": [ + { + "type": "constructor", + "inputs": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "symbol", + "type": "string", + "internalType": "string" + }, + { + "name": "tokenDecimals", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "subtractedValue", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "addedValue", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "mint", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transfer", + "inputs": [ + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + } + ], + "constructorArgs": [ + "Token", + "wstETH", + "18" + ], + "linkedLibraries": {}, + "deployTxnHash": "0x6add4be37a653aaf5ba967fc8163d59e33e29d487ad632af66209495e5d42051", + "deployTxnBlockNumber": "2", + "deployTimestamp": "1722754532", + "sourceName": "src/MintableTokenPermissionlessMint.sol", + "contractName": "MintableTokenPermissionlessMint", + "deployedOn": "contract.Token", + "highlight": true, + "gasUsed": 639860, + "gasCost": "1264678676" +} \ No newline at end of file diff --git a/packages/protocol/deployments/EpochConfigurationModule.json b/packages/protocol/deployments/EpochConfigurationModule.json new file mode 100644 index 00000000..da26501e --- /dev/null +++ b/packages/protocol/deployments/EpochConfigurationModule.json @@ -0,0 +1,418 @@ +{ + "address": "0xDD59E99E336FF485ec3C8420dd7CE128F1b806e3", + "abi": [ + { + "type": "function", + "name": "createEpoch", + "inputs": [ + { + "name": "startTime", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "endTime", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "startingSqrtPriceX96", + "type": "uint160", + "internalType": "uint160" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getAccountData", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct FAccount.Data", + "components": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "borrowedGwei", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "borrowedGas", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "getEpoch", + "inputs": [], + "outputs": [ + { + "name": "startTime", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "endTime", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "pool", + "type": "address", + "internalType": "address" + }, + { + "name": "ethToken", + "type": "address", + "internalType": "address" + }, + { + "name": "gasToken", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getMarket", + "inputs": [], + "outputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "collateralAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapPositionManager", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapQuoter", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapSwapRouter", + "type": "address", + "internalType": "address" + }, + { + "name": "optimisticOracleV3", + "type": "address", + "internalType": "address" + }, + { + "name": "epochParams", + "type": "tuple", + "internalType": "struct Market.EpochParams", + "components": [ + { + "name": "baseAssetMinPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "baseAssetMaxPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "feeRate", + "type": "uint24", + "internalType": "uint24" + }, + { + "name": "assertionLiveness", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "bondCurrency", + "type": "address", + "internalType": "address" + }, + { + "name": "bondAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "priceUnit", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getPositionData", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct Position.Data", + "components": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "vEthAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "vGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currentTokenAmount", + "type": "int256", + "internalType": "int256" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "initializeMarket", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "collateralAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapPositionManager", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapQuoter", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapSwapRouter", + "type": "address", + "internalType": "address" + }, + { + "name": "optimisticOracleV3", + "type": "address", + "internalType": "address" + }, + { + "name": "epochParams", + "type": "tuple", + "internalType": "struct Market.EpochParams", + "components": [ + { + "name": "baseAssetMinPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "baseAssetMaxPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "feeRate", + "type": "uint24", + "internalType": "uint24" + }, + { + "name": "assertionLiveness", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "bondCurrency", + "type": "address", + "internalType": "address" + }, + { + "name": "bondAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "priceUnit", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "updateMarket", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapPositionManager", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapQuoter", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapSwapRouter", + "type": "address", + "internalType": "address" + }, + { + "name": "optimisticOracleV3", + "type": "address", + "internalType": "address" + }, + { + "name": "epochParms", + "type": "tuple", + "internalType": "struct Market.EpochParams", + "components": [ + { + "name": "baseAssetMinPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "baseAssetMaxPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "feeRate", + "type": "uint24", + "internalType": "uint24" + }, + { + "name": "assertionLiveness", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "bondCurrency", + "type": "address", + "internalType": "address" + }, + { + "name": "bondAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "priceUnit", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "error", + "name": "EpochAlreadyStarted", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidMarket", + "inputs": [] + }, + { + "type": "error", + "name": "MarketAlreadyCreated", + "inputs": [] + }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, + { + "type": "error", + "name": "ReentrancyGuardReentrantCall", + "inputs": [] + }, + { + "type": "error", + "name": "TokensAlreadyCreated", + "inputs": [] + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0xb3d7b11ccdbb240b670d6d65fa796bfc2f4cfc9818293378496c36e2add84036", + "deployTxnBlockNumber": "3", + "deployTimestamp": "1722754340", + "sourceName": "src/contracts/modules/EpochConfigurationModule.sol", + "contractName": "EpochConfigurationModule", + "deployedOn": "deploy.EpochConfigurationModule", + "gasUsed": 2256590, + "gasCost": "1005326146" +} \ No newline at end of file diff --git a/packages/protocol/deployments/EpochLiquidityModule.json b/packages/protocol/deployments/EpochLiquidityModule.json new file mode 100644 index 00000000..88056d1e --- /dev/null +++ b/packages/protocol/deployments/EpochLiquidityModule.json @@ -0,0 +1,505 @@ +{ + "address": "0x7C244D9661bF634ca8909C4058924513f30CE6C0", + "abi": [ + { + "type": "function", + "name": "collectFees", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "createLiquidityPosition", + "inputs": [ + { + "name": "params", + "type": "tuple", + "internalType": "struct IFoilStructs.LiquidityPositionParams", + "components": [ + { + "name": "amountTokenA", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amountTokenB", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "lowerTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "upperTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "minAmountTokenA", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minAmountTokenB", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "outputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "addedAmount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "addedAmount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "decreaseLiquidityPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "borrowedGwei", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "borrowedGas", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getTokenAmounts", + "inputs": [ + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "sqrtPriceX96", + "type": "uint160", + "internalType": "uint160" + }, + { + "name": "sqrtPriceAX96", + "type": "uint160", + "internalType": "uint160" + }, + { + "name": "sqrtPriceBX96", + "type": "uint160", + "internalType": "uint160" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "increaseLiquidityPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "gasTokenAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ethTokenAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "onERC721Received", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes4", + "internalType": "bytes4" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "LiquidityPositionCreated", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "addedAmount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "addedAmount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionDecreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionIncreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AccountAlreadyCreated", + "inputs": [] + }, + { + "type": "error", + "name": "InsufficientCollateral", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateral", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidParameter", + "inputs": [ + { + "name": "parameter", + "type": "string", + "internalType": "string" + }, + { + "name": "reason", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, + { + "type": "error", + "name": "OverflowInt256ToUint256", + "inputs": [] + }, + { + "type": "error", + "name": "OverflowUint256ToInt256", + "inputs": [] + }, + { + "type": "error", + "name": "ReentrancyGuardReentrantCall", + "inputs": [] + }, + { + "type": "error", + "name": "TokenAlreadyMinted", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ZeroAddress", + "inputs": [] + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0xc422f47a846c7efdfc6439b4363a85d3054f52a81d1c8e50fd57fbadc24221e9", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722754422", + "sourceName": "src/contracts/modules/EpochLiquidityModule.sol", + "contractName": "EpochLiquidityModule", + "deployedOn": "deploy.EpochLiquidityModule", + "gasUsed": 2132620, + "gasCost": "1006087024" +} \ No newline at end of file diff --git a/packages/protocol/deployments/EpochNftModule.json b/packages/protocol/deployments/EpochNftModule.json new file mode 100644 index 00000000..037b69e2 --- /dev/null +++ b/packages/protocol/deployments/EpochNftModule.json @@ -0,0 +1,474 @@ +{ + "address": "0x2D2d2691C3EDa27230629e63BeA05118f819A532", + "abi": [ + { + "type": "constructor", + "inputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "holder", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "balance", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getApproved", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isApprovedForAll", + "inputs": [ + { + "name": "holder", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "ownerOf", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "safeTransferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "safeTransferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setApprovalForAll", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "approved", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "tokenByIndex", + "inputs": [ + { + "name": "index", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "tokenOfOwnerByIndex", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "index", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "tokenURI", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "approved", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ApprovalForAll", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "approved", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "CannotSelfApprove", + "inputs": [ + { + "name": "addr", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "IndexOverrun", + "inputs": [ + { + "name": "requestedIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "length", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidOwner", + "inputs": [ + { + "name": "addr", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "InvalidTransferRecipient", + "inputs": [ + { + "name": "addr", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "TokenAlreadyMinted", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "TokenDoesNotExist", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Unauthorized", + "inputs": [ + { + "name": "addr", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "ZeroAddress", + "inputs": [] + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0x66e8987f6e5aff04214cd54435403d5a20de7595ee6de8bedaecbcea92c22bc2", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722614880", + "sourceName": "src/contracts/modules/EpochNftModule.sol", + "contractName": "EpochNftModule", + "deployedOn": "deploy.EpochNftModule", + "gasUsed": 1192258, + "gasCost": "1004240135" +} \ No newline at end of file diff --git a/packages/protocol/deployments/EpochTradeModule.json b/packages/protocol/deployments/EpochTradeModule.json new file mode 100644 index 00000000..9f6cb9a0 --- /dev/null +++ b/packages/protocol/deployments/EpochTradeModule.json @@ -0,0 +1,173 @@ +{ + "address": "0x33ad0458323a7b02dC054943EBf4fC0a27aab7D2", + "abi": [ + { + "type": "function", + "name": "createTraderPosition", + "inputs": [ + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokenAmount", + "type": "int256", + "internalType": "int256" + }, + { + "name": "tokenAmountLimit", + "type": "int256", + "internalType": "int256" + } + ], + "outputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getReferencePrice", + "inputs": [], + "outputs": [ + { + "name": "price18Digits", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "modifyTraderPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokenAmount", + "type": "int256", + "internalType": "int256" + }, + { + "name": "tokenAmountLimit", + "type": "int256", + "internalType": "int256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AccountAlreadyCreated", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidAccountId", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidParameter", + "inputs": [ + { + "name": "parameter", + "type": "string", + "internalType": "string" + }, + { + "name": "reason", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "OverflowInt256ToUint256", + "inputs": [] + }, + { + "type": "error", + "name": "OverflowUint256ToInt256", + "inputs": [] + }, + { + "type": "error", + "name": "OverflowUint256ToUint160", + "inputs": [] + }, + { + "type": "error", + "name": "TokenAlreadyMinted", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ZeroAddress", + "inputs": [] + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0xb8082e21b44eb7833bb45a2939ea36f9bbbdd9fa05aada3dd1f95c61a35586d1", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722754339", + "sourceName": "src/contracts/modules/EpochTradeModule.sol", + "contractName": "EpochTradeModule", + "deployedOn": "deploy.EpochTradeModule", + "gasUsed": 1832703, + "gasCost": "1004250407" +} \ No newline at end of file diff --git a/packages/protocol/deployments/EpochUMASettlementModule.json b/packages/protocol/deployments/EpochUMASettlementModule.json new file mode 100644 index 00000000..f1c50c82 --- /dev/null +++ b/packages/protocol/deployments/EpochUMASettlementModule.json @@ -0,0 +1,153 @@ +{ + "address": "0xBF8e2C989bd27f1FF133f29542d2719341BA8954", + "abi": [ + { + "type": "function", + "name": "assertionDisputedCallback", + "inputs": [ + { + "name": "assertionId", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "assertionResolvedCallback", + "inputs": [ + { + "name": "assertionId", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "assertedTruthfully", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "submitSettlementPrice", + "inputs": [ + { + "name": "settlementPrice", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "MarketSettled", + "inputs": [ + { + "name": "settlementPrice", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SettlementDisputed", + "inputs": [ + { + "name": "disputeTime", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SettlementSubmitted", + "inputs": [ + { + "name": "price", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "submissionTime", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AddressEmptyCode", + "inputs": [ + { + "name": "target", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "AddressInsufficientBalance", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "FailedInnerCall", + "inputs": [] + }, + { + "type": "error", + "name": "ReentrancyGuardReentrantCall", + "inputs": [] + }, + { + "type": "error", + "name": "SafeERC20FailedOperation", + "inputs": [ + { + "name": "token", + "type": "address", + "internalType": "address" + } + ] + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0xf8877aed889f507ed352bcbd81ba5c0a9718610039c48ee31e064828044025fb", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722754339", + "sourceName": "src/contracts/modules/EpochUMASettlementModule.sol", + "contractName": "EpochUMASettlementModule", + "deployedOn": "deploy.EpochUMASettlementModule", + "gasUsed": 766496, + "gasCost": "1003784021" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Foil.json b/packages/protocol/deployments/Foil.json new file mode 100644 index 00000000..3c1a4c91 --- /dev/null +++ b/packages/protocol/deployments/Foil.json @@ -0,0 +1,1533 @@ +{ + "address": "0x76f9e59a9e68dee497ec7aeb4261d089bf6360d0", + "abi": [ + { + "type": "function", + "name": "createEpoch", + "inputs": [ + { + "name": "startTime", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "endTime", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "startingSqrtPriceX96", + "type": "uint160", + "internalType": "uint160" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getAccountData", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct FAccount.Data", + "components": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "borrowedGwei", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "borrowedGas", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "getEpoch", + "inputs": [], + "outputs": [ + { + "name": "startTime", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "endTime", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "pool", + "type": "address", + "internalType": "address" + }, + { + "name": "ethToken", + "type": "address", + "internalType": "address" + }, + { + "name": "gasToken", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getMarket", + "inputs": [], + "outputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "collateralAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapPositionManager", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapQuoter", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapSwapRouter", + "type": "address", + "internalType": "address" + }, + { + "name": "optimisticOracleV3", + "type": "address", + "internalType": "address" + }, + { + "name": "epochParams", + "type": "tuple", + "internalType": "struct Market.EpochParams", + "components": [ + { + "name": "baseAssetMinPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "baseAssetMaxPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "feeRate", + "type": "uint24", + "internalType": "uint24" + }, + { + "name": "assertionLiveness", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "bondCurrency", + "type": "address", + "internalType": "address" + }, + { + "name": "bondAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "priceUnit", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getPositionData", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct Position.Data", + "components": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "vEthAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "vGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currentTokenAmount", + "type": "int256", + "internalType": "int256" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "initializeMarket", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "collateralAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapPositionManager", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapQuoter", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapSwapRouter", + "type": "address", + "internalType": "address" + }, + { + "name": "optimisticOracleV3", + "type": "address", + "internalType": "address" + }, + { + "name": "epochParams", + "type": "tuple", + "internalType": "struct Market.EpochParams", + "components": [ + { + "name": "baseAssetMinPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "baseAssetMaxPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "feeRate", + "type": "uint24", + "internalType": "uint24" + }, + { + "name": "assertionLiveness", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "bondCurrency", + "type": "address", + "internalType": "address" + }, + { + "name": "bondAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "priceUnit", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "updateMarket", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapPositionManager", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapQuoter", + "type": "address", + "internalType": "address" + }, + { + "name": "uniswapSwapRouter", + "type": "address", + "internalType": "address" + }, + { + "name": "optimisticOracleV3", + "type": "address", + "internalType": "address" + }, + { + "name": "epochParms", + "type": "tuple", + "internalType": "struct Market.EpochParams", + "components": [ + { + "name": "baseAssetMinPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "baseAssetMaxPriceTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "feeRate", + "type": "uint24", + "internalType": "uint24" + }, + { + "name": "assertionLiveness", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "bondCurrency", + "type": "address", + "internalType": "address" + }, + { + "name": "bondAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "priceUnit", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "error", + "name": "EpochAlreadyStarted", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidMarket", + "inputs": [] + }, + { + "type": "error", + "name": "MarketAlreadyCreated", + "inputs": [] + }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, + { + "type": "error", + "name": "ReentrancyGuardReentrantCall", + "inputs": [] + }, + { + "type": "error", + "name": "TokensAlreadyCreated", + "inputs": [] + }, + { + "type": "function", + "name": "collectFees", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "createLiquidityPosition", + "inputs": [ + { + "name": "params", + "type": "tuple", + "internalType": "struct IFoilStructs.LiquidityPositionParams", + "components": [ + { + "name": "amountTokenA", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amountTokenB", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "lowerTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "upperTick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "minAmountTokenA", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minAmountTokenB", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "outputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "addedAmount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "addedAmount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "decreaseLiquidityPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "borrowedGwei", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "borrowedGas", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getTokenAmounts", + "inputs": [ + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "sqrtPriceX96", + "type": "uint160", + "internalType": "uint160" + }, + { + "name": "sqrtPriceAX96", + "type": "uint160", + "internalType": "uint160" + }, + { + "name": "sqrtPriceBX96", + "type": "uint160", + "internalType": "uint160" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "increaseLiquidityPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "gasTokenAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ethTokenAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "onERC721Received", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes4", + "internalType": "bytes4" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "LiquidityPositionCreated", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "addedAmount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "addedAmount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionDecreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionIncreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AccountAlreadyCreated", + "inputs": [] + }, + { + "type": "error", + "name": "InsufficientCollateral", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateral", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidParameter", + "inputs": [ + { + "name": "parameter", + "type": "string", + "internalType": "string" + }, + { + "name": "reason", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "OverflowInt256ToUint256", + "inputs": [] + }, + { + "type": "error", + "name": "OverflowUint256ToInt256", + "inputs": [] + }, + { + "type": "error", + "name": "TokenAlreadyMinted", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ZeroAddress", + "inputs": [] + }, + { + "type": "function", + "name": "assertionDisputedCallback", + "inputs": [ + { + "name": "assertionId", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "assertionResolvedCallback", + "inputs": [ + { + "name": "assertionId", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "assertedTruthfully", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "submitSettlementPrice", + "inputs": [ + { + "name": "settlementPrice", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "MarketSettled", + "inputs": [ + { + "name": "settlementPrice", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SettlementDisputed", + "inputs": [ + { + "name": "disputeTime", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SettlementSubmitted", + "inputs": [ + { + "name": "price", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "submissionTime", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AddressEmptyCode", + "inputs": [ + { + "name": "target", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "AddressInsufficientBalance", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "FailedInnerCall", + "inputs": [] + }, + { + "type": "error", + "name": "SafeERC20FailedOperation", + "inputs": [ + { + "name": "token", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "function", + "name": "createTraderPosition", + "inputs": [ + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokenAmount", + "type": "int256", + "internalType": "int256" + }, + { + "name": "tokenAmountLimit", + "type": "int256", + "internalType": "int256" + } + ], + "outputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getReferencePrice", + "inputs": [], + "outputs": [ + { + "name": "price18Digits", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "modifyTraderPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokenAmount", + "type": "int256", + "internalType": "int256" + }, + { + "name": "tokenAmountLimit", + "type": "int256", + "internalType": "int256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "error", + "name": "InvalidAccountId", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "OverflowUint256ToUint160", + "inputs": [] + }, + { + "type": "constructor", + "inputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "holder", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "balance", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getApproved", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isApprovedForAll", + "inputs": [ + { + "name": "holder", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "ownerOf", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "safeTransferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "safeTransferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setApprovalForAll", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "approved", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "tokenByIndex", + "inputs": [ + { + "name": "index", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "tokenOfOwnerByIndex", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "index", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "tokenURI", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "approved", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ApprovalForAll", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "approved", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "CannotSelfApprove", + "inputs": [ + { + "name": "addr", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "IndexOverrun", + "inputs": [ + { + "name": "requestedIndex", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "length", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidOwner", + "inputs": [ + { + "name": "addr", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "InvalidTransferRecipient", + "inputs": [ + { + "name": "addr", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "TokenDoesNotExist", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Unauthorized", + "inputs": [ + { + "name": "addr", + "type": "address", + "internalType": "address" + } + ] + } + ], + "deployedOn": "router.Foil", + "deployTxnHash": "0xbf62116248415e97431c6592b08fd2ca6b14152c44ebaa7fd432d2e38b9801b8", + "deployTxnBlockNumber": "3", + "deployTimestamp": "1722754427", + "contractName": "Foil", + "sourceName": "Foil.sol", + "gasUsed": 439989, + "gasCost": "1002787316" +} \ No newline at end of file diff --git a/packages/protocol/deployments/ReentrancyGuard.json b/packages/protocol/deployments/ReentrancyGuard.json new file mode 100644 index 00000000..b003f92e --- /dev/null +++ b/packages/protocol/deployments/ReentrancyGuard.json @@ -0,0 +1,20 @@ +{ + "address": "0xD9D164001a12921CeC9996AA11259d531967646f", + "abi": [ + { + "type": "error", + "name": "ReentrancyGuardReentrantCall", + "inputs": [] + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0x0f84422301028f15368200101d2f1f120bb1199b08f862a7635b4bbef4db326f", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722380030", + "sourceName": "node_modules/@openzeppelin/contracts/utils/ReentrancyGuard.sol", + "contractName": "ReentrancyGuard", + "deployedOn": "deploy.ReentrancyGuard", + "gasUsed": 53000, + "gasCost": "1006087024" +} \ No newline at end of file diff --git a/packages/protocol/deployments/UMA.Finder.json b/packages/protocol/deployments/UMA.Finder.json new file mode 100644 index 00000000..d1b8ad3f --- /dev/null +++ b/packages/protocol/deployments/UMA.Finder.json @@ -0,0 +1,142 @@ +{ + "address": "0x20b32B0b1f7946Dc5335bf9Fe409D33FaB4f7387", + "abi": [ + { + "type": "function", + "name": "changeImplementationAddress", + "inputs": [ + { + "name": "interfaceName", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "implementationAddress", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getImplementationAddress", + "inputs": [ + { + "name": "interfaceName", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "interfacesImplemented", + "inputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "InterfaceImplementationChanged", + "inputs": [ + { + "name": "interfaceName", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "newImplementationAddress", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0x3a4a94e89b04105532165c355ee28b7b969e45233aa52edca551b3b1c82bdc5d", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722754528", + "sourceName": "src/UMA/Finder.sol", + "contractName": "Finder", + "deployedOn": "deploy.Finder", + "gasUsed": 285093, + "gasCost": "1203879509" +} \ No newline at end of file diff --git a/packages/protocol/deployments/UMA.MockOracleAncillary.json b/packages/protocol/deployments/UMA.MockOracleAncillary.json new file mode 100644 index 00000000..34cbc6be --- /dev/null +++ b/packages/protocol/deployments/UMA.MockOracleAncillary.json @@ -0,0 +1,346 @@ +{ + "address": "0xEd2437B477f67e71381fAb8dB271b26ABD4986cE", + "abi": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_finderAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "_timerAddress", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getCurrentTime", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getPendingQueries", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "internalType": "struct MockOracleAncillary.QueryPoint[]", + "components": [ + { + "name": "identifier", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "time", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ancillaryData", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getPrice", + "inputs": [ + { + "name": "identifier", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "time", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ancillaryData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "int256", + "internalType": "int256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRequestParameters", + "inputs": [ + { + "name": "requestId", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct MockOracleAncillary.QueryPoint", + "components": [ + { + "name": "identifier", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "time", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ancillaryData", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "hasPrice", + "inputs": [ + { + "name": "identifier", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "time", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ancillaryData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pushPrice", + "inputs": [ + { + "name": "identifier", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "time", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ancillaryData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "price", + "type": "int256", + "internalType": "int256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "pushPriceByRequestId", + "inputs": [ + { + "name": "requestId", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "price", + "type": "int256", + "internalType": "int256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "requestPrice", + "inputs": [ + { + "name": "identifier", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "time", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ancillaryData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setCurrentTime", + "inputs": [ + { + "name": "time", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "timerAddress", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "PriceRequestAdded", + "inputs": [ + { + "name": "requester", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "identifier", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "time", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "ancillaryData", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + }, + { + "name": "requestId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "PushedPrice", + "inputs": [ + { + "name": "pusher", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "identifier", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "time", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "ancillaryData", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + }, + { + "name": "price", + "type": "int256", + "indexed": false, + "internalType": "int256" + }, + { + "name": "requestId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + } + ], + "anonymous": false + } + ], + "constructorArgs": [ + "0x20b32B0b1f7946Dc5335bf9Fe409D33FaB4f7387", + "0x4b6Ad469Fc85Bf3917E288e1CE973C0F3382dC71" + ], + "linkedLibraries": {}, + "deployTxnHash": "0x43618c7361ca78b0aab21b92675caacbc9e19526846c8e179199b6ccf1566b3f", + "deployTxnBlockNumber": "3", + "deployTimestamp": "1722754530", + "sourceName": "node_modules/@uma/core/contracts/data-verification-mechanism/test/MockOracleAncillary.sol", + "contractName": "MockOracleAncillary", + "deployedOn": "deploy.MockOracleAncillary", + "gasUsed": 1060225, + "gasCost": "1119963562" +} \ No newline at end of file diff --git a/packages/protocol/deployments/UMA.Timer.json b/packages/protocol/deployments/UMA.Timer.json new file mode 100644 index 00000000..6cfc5481 --- /dev/null +++ b/packages/protocol/deployments/UMA.Timer.json @@ -0,0 +1,41 @@ +{ + "address": "0x4b6Ad469Fc85Bf3917E288e1CE973C0F3382dC71", + "abi": [ + { + "type": "function", + "name": "getCurrentTime", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setCurrentTime", + "inputs": [ + { + "name": "time", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0x29b7ae3d95bb5bbf8d49183656651fd97d2f53d56735b7e2fd7d063f6346bf55", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722754528", + "sourceName": "src/UMA/Timer.sol", + "contractName": "Timer", + "deployedOn": "deploy.Timer", + "gasUsed": 112718, + "gasCost": "1178878943" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.Core.UniswapV3Factory.json b/packages/protocol/deployments/Uniswap.Core.UniswapV3Factory.json new file mode 100644 index 00000000..4071e04a --- /dev/null +++ b/packages/protocol/deployments/Uniswap.Core.UniswapV3Factory.json @@ -0,0 +1,249 @@ +{ + "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + } + ], + "name": "FeeAmountEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + }, + { + "indexed": false, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenA", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenB", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + } + ], + "name": "createPool", + "outputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + } + ], + "name": "enableFeeAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "name": "feeAmountTickSpacing", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "name": "getPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "parameters", + "outputs": [ + { + "internalType": "address", + "name": "factory", + "type": "address" + }, + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "setOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0x092ab39ca583e8ec4129b58d4fd95e709512b32cbc98002efadca0218e4a84a3", + "deployTxnBlockNumber": "3", + "deployTimestamp": "1722754530", + "sourceName": "contracts/UniswapV3Factory.sol", + "contractName": "UniswapV3Factory", + "deployedOn": "deploy.UniswapV3Factory", + "gasUsed": 5440656, + "gasCost": "1071030491" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.NFTDescriptor.json b/packages/protocol/deployments/Uniswap.NFTDescriptor.json new file mode 100644 index 00000000..92a1eb17 --- /dev/null +++ b/packages/protocol/deployments/Uniswap.NFTDescriptor.json @@ -0,0 +1,106 @@ +{ + "address": "0x42B24A95702b9986e82d421cC3568932790A48Ec", + "abi": [ + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "quoteTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "baseTokenAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "quoteTokenSymbol", + "type": "string" + }, + { + "internalType": "string", + "name": "baseTokenSymbol", + "type": "string" + }, + { + "internalType": "uint8", + "name": "quoteTokenDecimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "baseTokenDecimals", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "flipRatio", + "type": "bool" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickCurrent", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "internalType": "struct NFTDescriptor.ConstructTokenURIParams", + "name": "params", + "type": "tuple" + } + ], + "name": "constructTokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0x4f80fa4eb9453334f7e1039e6650362b31dbefd37cb97288a4c4ce7343e78f84", + "deployTxnBlockNumber": "6", + "deployTimestamp": "1722754529", + "sourceName": "contracts/libraries/NFTDescriptor.sol", + "contractName": "NFTDescriptor", + "deployedOn": "deploy.NFTDescriptor", + "gasUsed": 5340067, + "gasCost": "1020557502" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.NonfungiblePositionManager.json b/packages/protocol/deployments/Uniswap.NonfungiblePositionManager.json new file mode 100644 index 00000000..d50d1271 --- /dev/null +++ b/packages/protocol/deployments/Uniswap.NonfungiblePositionManager.json @@ -0,0 +1,1238 @@ +{ + "address": "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_factory", + "type": "address" + }, + { + "internalType": "address", + "name": "_WETH9", + "type": "address" + }, + { + "internalType": "address", + "name": "_tokenDescriptor_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "approved", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Collect", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "DecreaseLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "IncreaseLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH9", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "baseURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint128", + "name": "amount0Max", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1Max", + "type": "uint128" + } + ], + "internalType": "struct INonfungiblePositionManager.CollectParams", + "name": "params", + "type": "tuple" + } + ], + "name": "collect", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + } + ], + "name": "createAndInitializePoolIfNecessary", + "outputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "internalType": "struct INonfungiblePositionManager.DecreaseLiquidityParams", + "name": "params", + "type": "tuple" + } + ], + "name": "decreaseLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getApproved", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "internalType": "struct INonfungiblePositionManager.IncreaseLiquidityParams", + "name": "params", + "type": "tuple" + } + ], + "name": "increaseLiquidity", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint256", + "name": "amount0Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "internalType": "struct INonfungiblePositionManager.MintParams", + "name": "params", + "type": "tuple" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "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": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "positions", + "outputs": [ + { + "internalType": "uint96", + "name": "nonce", + "type": "uint96" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "feeGrowthInside0LastX128", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeGrowthInside1LastX128", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "tokensOwed0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "tokensOwed1", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "refundETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "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": "selfPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowed", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowedIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "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": "selfPermitIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "tokenByIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "tokenOfOwnerByIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "tokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount0Owed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Owed", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "uniswapV3MintCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "unwrapWETH9", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "constructorArgs": [ + "0x1F98431c8aD98523631AE4a59f267346ea31F984", + "0x071C46222236E75E6B822A1886611b43c8FBcab2", + "0x91ae842A5Ffd8d12023116943e72A606179294f3" + ], + "linkedLibraries": {}, + "deployTxnHash": "0xde94cbbd26e2b9788d598dc8ec563c9f9703883879a9548c6d5f0d1cfc5af56b", + "deployTxnBlockNumber": "12", + "deployTimestamp": "1722754529", + "sourceName": "contracts/NonfungiblePositionManager.sol", + "contractName": "NonfungiblePositionManager", + "deployedOn": "deploy.NonfungiblePositionManager", + "gasUsed": 5473120, + "gasCost": "1009867053" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.NonfungibleTokenPositionDescriptor.json b/packages/protocol/deployments/Uniswap.NonfungibleTokenPositionDescriptor.json new file mode 100644 index 00000000..62bd6a05 --- /dev/null +++ b/packages/protocol/deployments/Uniswap.NonfungibleTokenPositionDescriptor.json @@ -0,0 +1,154 @@ +{ + "address": "0x91ae842A5Ffd8d12023116943e72A606179294f3", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_WETH9", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "_nativeCurrencyLabelBytes", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH9", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token0", + "type": "address" + }, + { + "internalType": "address", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + } + ], + "name": "flipRatio", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nativeCurrencyLabel", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nativeCurrencyLabelBytes", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + } + ], + "name": "tokenRatioPriority", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract INonfungiblePositionManager", + "name": "positionManager", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "tokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "constructorArgs": [ + "0x0000000000000000000000000000000000000000", + "0x4554480000000000000000000000000000000000000000000000000000000000" + ], + "linkedLibraries": { + "contracts/libraries/NFTDescriptor.sol": { + "NFTDescriptor": "0x42B24A95702b9986e82d421cC3568932790A48Ec" + } + }, + "deployTxnHash": "0x10883daf11b005c175d09ba813de6ea3c63efd9833a92a12ede7276ba7a7c849", + "deployTxnBlockNumber": "8", + "deployTimestamp": "1722754529", + "sourceName": "contracts/NonfungibleTokenPositionDescriptor.sol", + "contractName": "NonfungibleTokenPositionDescriptor", + "deployedOn": "deploy.NonfungibleTokenPositionDescriptor", + "gasUsed": 1198675, + "gasCost": "1016539806" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.ProxyAdmin.json b/packages/protocol/deployments/Uniswap.ProxyAdmin.json new file mode 100644 index 00000000..300dae43 --- /dev/null +++ b/packages/protocol/deployments/Uniswap.ProxyAdmin.json @@ -0,0 +1,164 @@ +{ + "address": "0xB753548F6E010e7e680BA186F9Ca1BdAB2E90cf2", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeProxyAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0xec0692423399c3d742c864060cd640bc3e7a966cb4ede764a323ab91fe6c52d1", + "deployTxnBlockNumber": "5", + "deployTimestamp": "1722754532", + "sourceName": "@openzeppelin/contracts/proxy/ProxyAdmin.sol", + "contractName": "ProxyAdmin", + "deployedOn": "deploy.ProxyAdmin", + "gasUsed": 687009, + "gasCost": "1057200603" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.Quoter.json b/packages/protocol/deployments/Uniswap.Quoter.json new file mode 100644 index 00000000..a46a2cbc --- /dev/null +++ b/packages/protocol/deployments/Uniswap.Quoter.json @@ -0,0 +1,209 @@ +{ + "address": "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_factory", + "type": "address" + }, + { + "internalType": "address", + "name": "_WETH9", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH9", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "name": "quoteExactInput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "name": "quoteExactInputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "name": "quoteExactOutput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "name": "quoteExactOutputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "amount0Delta", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1Delta", + "type": "int256" + }, + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + } + ], + "name": "uniswapV3SwapCallback", + "outputs": [], + "stateMutability": "view", + "type": "function" + } + ], + "constructorArgs": [ + "0x1F98431c8aD98523631AE4a59f267346ea31F984", + "0x071C46222236E75E6B822A1886611b43c8FBcab2" + ], + "linkedLibraries": {}, + "deployTxnHash": "0x77e143643e4884a308dec6693d86e0e658de1f16802df6db35f444c2ebc02ddd", + "deployTxnBlockNumber": "3", + "deployTimestamp": "1722754530", + "sourceName": "contracts/lens/Quoter.sol", + "contractName": "Quoter", + "deployedOn": "deploy.Quoter", + "gasUsed": 1050171, + "gasCost": "1029629692" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.SwapRouter.json b/packages/protocol/deployments/Uniswap.SwapRouter.json new file mode 100644 index 00000000..8e2fd673 --- /dev/null +++ b/packages/protocol/deployments/Uniswap.SwapRouter.json @@ -0,0 +1,581 @@ +{ + "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_factory", + "type": "address" + }, + { + "internalType": "address", + "name": "_WETH9", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH9", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMinimum", + "type": "uint256" + } + ], + "internalType": "struct ISwapRouter.ExactInputParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactInput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMinimum", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct ISwapRouter.ExactInputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactInputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMaximum", + "type": "uint256" + } + ], + "internalType": "struct ISwapRouter.ExactOutputParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactOutput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMaximum", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct ISwapRouter.ExactOutputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactOutputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "refundETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "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": "selfPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowed", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "selfPermitAllowedIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "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": "selfPermitIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "sweepTokenWithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "amount0Delta", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1Delta", + "type": "int256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "uniswapV3SwapCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "unwrapWETH9", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountMinimum", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeBips", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeRecipient", + "type": "address" + } + ], + "name": "unwrapWETH9WithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "constructorArgs": [ + "0x1F98431c8aD98523631AE4a59f267346ea31F984", + "0x071C46222236E75E6B822A1886611b43c8FBcab2" + ], + "linkedLibraries": {}, + "deployTxnHash": "0x34c75edbab5990d7b1e9441df2d4378da661672d4de365f41a3657d1d3c54e11", + "deployTxnBlockNumber": "4", + "deployTimestamp": "1722754531", + "sourceName": "contracts/SwapRouter.sol", + "contractName": "SwapRouter", + "deployedOn": "deploy.SwapRouter", + "gasUsed": 2667896, + "gasCost": "1026185283" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.TickLens.json b/packages/protocol/deployments/Uniswap.TickLens.json new file mode 100644 index 00000000..18515d56 --- /dev/null +++ b/packages/protocol/deployments/Uniswap.TickLens.json @@ -0,0 +1,56 @@ +{ + "address": "0xbfd8137f7d1516D3ea5cA83523914859ec47F573", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "int16", + "name": "tickBitmapIndex", + "type": "int16" + } + ], + "name": "getPopulatedTicksInWord", + "outputs": [ + { + "components": [ + { + "internalType": "int24", + "name": "tick", + "type": "int24" + }, + { + "internalType": "int128", + "name": "liquidityNet", + "type": "int128" + }, + { + "internalType": "uint128", + "name": "liquidityGross", + "type": "uint128" + } + ], + "internalType": "struct ITickLens.PopulatedTick[]", + "name": "populatedTicks", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0xe86d0528829e851224aff055a91d81d0a8ffe44446c2664342f16ed023929f4d", + "deployTxnBlockNumber": "6", + "deployTimestamp": "1722754533", + "sourceName": "contracts/lens/TickLens.sol", + "contractName": "TickLens", + "deployedOn": "deploy.TickLens", + "gasUsed": 352108, + "gasCost": "1050378006" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.TransparentUpgradeableProxy.json b/packages/protocol/deployments/Uniswap.TransparentUpgradeableProxy.json new file mode 100644 index 00000000..486b827b --- /dev/null +++ b/packages/protocol/deployments/Uniswap.TransparentUpgradeableProxy.json @@ -0,0 +1,150 @@ +{ + "address": "0xEe6A57eC80ea46401049E92587E52f5Ec1c24785", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "constructorArgs": [ + "0x91ae842A5Ffd8d12023116943e72A606179294f3", + "0xB753548F6E010e7e680BA186F9Ca1BdAB2E90cf2", + "0x" + ], + "linkedLibraries": {}, + "deployTxnHash": "0x488f88a8c7d794288db591295391a226738ac6ed932f71f0f4fd3a3a5519a868", + "deployTxnBlockNumber": "10", + "deployTimestamp": "1722754529", + "sourceName": "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol", + "contractName": "TransparentUpgradeableProxy", + "deployedOn": "deploy.TransparentUpgradeableProxy", + "gasUsed": 653588, + "gasCost": "1012807853" +} \ No newline at end of file diff --git a/packages/protocol/deployments/Uniswap.WETH.WETH9.json b/packages/protocol/deployments/Uniswap.WETH.WETH9.json new file mode 100644 index 00000000..c8576f3e --- /dev/null +++ b/packages/protocol/deployments/Uniswap.WETH.WETH9.json @@ -0,0 +1,288 @@ +{ + "address": "0x071C46222236E75E6B822A1886611b43c8FBcab2", + "abi": [ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "guy", + "type": "address" + }, + { + "name": "wad", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "src", + "type": "address" + }, + { + "name": "dst", + "type": "address" + }, + { + "name": "wad", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "wad", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "dst", + "type": "address" + }, + { + "name": "wad", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "deposit", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + }, + { + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "src", + "type": "address" + }, + { + "indexed": true, + "name": "guy", + "type": "address" + }, + { + "indexed": false, + "name": "wad", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "src", + "type": "address" + }, + { + "indexed": true, + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "name": "wad", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "name": "wad", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "src", + "type": "address" + }, + { + "indexed": false, + "name": "wad", + "type": "uint256" + } + ], + "name": "Withdrawal", + "type": "event" + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0x7b42a3473054c6d79c1fd51b455e3e25f20ab5226f0ff3907c67bb924c535962", + "sourceName": "contracts/WETH9.sol", + "contractName": "WETH9", + "deployedOn": "contract.WETH9" +} \ No newline at end of file diff --git a/packages/protocol/deployments/test/BondCurrency.Token.json b/packages/protocol/deployments/test/BondCurrency.Token.json index 7adebce0..3fa4f17c 100644 --- a/packages/protocol/deployments/test/BondCurrency.Token.json +++ b/packages/protocol/deployments/test/BondCurrency.Token.json @@ -319,7 +319,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x12ee0b194db4db0157edc1ecd4711e1b128110b845c2232c6b427b5749ddc7a5", "deployTxnBlockNumber": "2", - "deployTimestamp": "1722388948", + "deployTimestamp": "1722754539", "sourceName": "src/MintableTokenPermissionlessMint.sol", "contractName": "MintableTokenPermissionlessMint", "deployedOn": "contract.Token", diff --git a/packages/protocol/deployments/test/CollateralAsset.Token.json b/packages/protocol/deployments/test/CollateralAsset.Token.json index 14dbd9b5..696c94c2 100644 --- a/packages/protocol/deployments/test/CollateralAsset.Token.json +++ b/packages/protocol/deployments/test/CollateralAsset.Token.json @@ -319,7 +319,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x6add4be37a653aaf5ba967fc8163d59e33e29d487ad632af66209495e5d42051", "deployTxnBlockNumber": "2", - "deployTimestamp": "1722388948", + "deployTimestamp": "1722754539", "sourceName": "src/MintableTokenPermissionlessMint.sol", "contractName": "MintableTokenPermissionlessMint", "deployedOn": "contract.Token", diff --git a/packages/protocol/deployments/test/EpochConfigurationModule.json b/packages/protocol/deployments/test/EpochConfigurationModule.json index 3a6d191b..da26501e 100644 --- a/packages/protocol/deployments/test/EpochConfigurationModule.json +++ b/packages/protocol/deployments/test/EpochConfigurationModule.json @@ -1,5 +1,5 @@ { - "address": "0x2445D612DC7b535332FCAD0B1b1300De90b2aB36", + "address": "0xDD59E99E336FF485ec3C8420dd7CE128F1b806e3", "abi": [ { "type": "function", @@ -134,9 +134,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -254,9 +254,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -329,9 +329,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParms", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -389,6 +389,11 @@ "name": "MarketAlreadyCreated", "inputs": [] }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, { "type": "error", "name": "ReentrancyGuardReentrantCall", @@ -402,12 +407,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x4f1d2d85a972dbb30b722461f5c20d97998c4fd6b0431aa697a43267a0e675ec", + "deployTxnHash": "0xb3d7b11ccdbb240b670d6d65fa796bfc2f4cfc9818293378496c36e2add84036", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722385871", + "deployTimestamp": "1722754340", "sourceName": "src/contracts/modules/EpochConfigurationModule.sol", "contractName": "EpochConfigurationModule", "deployedOn": "deploy.EpochConfigurationModule", - "gasUsed": 2031872, + "gasUsed": 2256590, "gasCost": "1005326146" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/EpochLiquidityModule.json b/packages/protocol/deployments/test/EpochLiquidityModule.json index 1ed1032b..88056d1e 100644 --- a/packages/protocol/deployments/test/EpochLiquidityModule.json +++ b/packages/protocol/deployments/test/EpochLiquidityModule.json @@ -1,5 +1,5 @@ { - "address": "0x2f816f52cD9c1ed34e3Ae10eEeC0c961E112aEF0", + "address": "0x7C244D9661bF634ca8909C4058924513f30CE6C0", "abi": [ { "type": "function", @@ -94,81 +94,183 @@ "internalType": "uint256" } ], - "stateMutability": "payable" + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "decreaseLiquidityPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" }, { "type": "function", "name": "getPosition", "inputs": [ { - "name": "positionId", + "name": "accountId", "type": "uint256", "internalType": "uint256" } ], "outputs": [ { - "name": "nonce", - "type": "uint96", - "internalType": "uint96" + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" }, { - "name": "operator", - "type": "address", - "internalType": "address" + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "token0", - "type": "address", - "internalType": "address" + "name": "borrowedGwei", + "type": "uint256", + "internalType": "uint256" }, { - "name": "token1", - "type": "address", - "internalType": "address" + "name": "borrowedGas", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getTokenAmounts", + "inputs": [ + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "fee", - "type": "uint24", - "internalType": "uint24" + "name": "sqrtPriceX96", + "type": "uint160", + "internalType": "uint160" }, { - "name": "tickLower", - "type": "int24", - "internalType": "int24" + "name": "sqrtPriceAX96", + "type": "uint160", + "internalType": "uint160" }, { - "name": "tickUpper", - "type": "int24", - "internalType": "int24" + "name": "sqrtPriceBX96", + "type": "uint160", + "internalType": "uint160" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" }, { "name": "liquidity", "type": "uint128", "internalType": "uint128" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "increaseLiquidityPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" }, { - "name": "feeGrowthInside0LastX128", + "name": "collateralAmount", "type": "uint256", "internalType": "uint256" }, { - "name": "feeGrowthInside1LastX128", + "name": "gasTokenAmount", "type": "uint256", "internalType": "uint256" }, { - "name": "tokensOwed0", - "type": "uint128", - "internalType": "uint128" + "name": "ethTokenAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "tokensOwed1", + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "liquidity", "type": "uint128", "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" } ], - "stateMutability": "view" + "stateMutability": "nonpayable" }, { "type": "function", @@ -205,43 +307,91 @@ "stateMutability": "nonpayable" }, { - "type": "function", - "name": "updateLiquidityPosition", + "type": "event", + "name": "LiquidityPositionCreated", "inputs": [ { "name": "tokenId", "type": "uint256", + "indexed": false, "internalType": "uint256" }, { - "name": "collateral", + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "addedAmount0", "type": "uint256", + "indexed": false, "internalType": "uint256" }, { - "name": "liquidity", - "type": "uint128", - "internalType": "uint128" + "name": "addedAmount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionDecreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" }, { - "name": "minLiquidity", + "name": "amount1", "type": "uint256", + "indexed": false, "internalType": "uint256" } ], - "outputs": [ + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionIncreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, { "name": "amount0", "type": "uint256", + "indexed": false, "internalType": "uint256" }, { "name": "amount1", "type": "uint256", + "indexed": false, "internalType": "uint256" } ], - "stateMutability": "payable" + "anonymous": false }, { "type": "event", @@ -276,7 +426,18 @@ { "type": "error", "name": "InsufficientCollateral", - "inputs": [] + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateral", + "type": "uint256", + "internalType": "uint256" + } + ] }, { "type": "error", @@ -333,12 +494,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x4ec8bf490bc87cea051894e6eeda7f778f6f13c6ddae42eb7c59318c980b9835", + "deployTxnHash": "0xc422f47a846c7efdfc6439b4363a85d3054f52a81d1c8e50fd57fbadc24221e9", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722272465", + "deployTimestamp": "1722754422", "sourceName": "src/contracts/modules/EpochLiquidityModule.sol", "contractName": "EpochLiquidityModule", "deployedOn": "deploy.EpochLiquidityModule", - "gasUsed": 1903984, - "gasCost": "1004158597" + "gasUsed": 2132620, + "gasCost": "1006087024" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/EpochNftModule.json b/packages/protocol/deployments/test/EpochNftModule.json index 996ee7aa..037b69e2 100644 --- a/packages/protocol/deployments/test/EpochNftModule.json +++ b/packages/protocol/deployments/test/EpochNftModule.json @@ -1,5 +1,5 @@ { - "address": "0xF966A4B851DCE09c218Ed74aF89F115087d1bde3", + "address": "0x2D2d2691C3EDa27230629e63BeA05118f819A532", "abi": [ { "type": "constructor", @@ -463,12 +463,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0xf97595b027d50ddcdcda8a7ee275f9cbbe0483d697413e04591dc3baad929b5a", + "deployTxnHash": "0x66e8987f6e5aff04214cd54435403d5a20de7595ee6de8bedaecbcea92c22bc2", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722272465", + "deployTimestamp": "1722614880", "sourceName": "src/contracts/modules/EpochNftModule.sol", "contractName": "EpochNftModule", "deployedOn": "deploy.EpochNftModule", - "gasUsed": 1190314, - "gasCost": "1003704755" + "gasUsed": 1192258, + "gasCost": "1004240135" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/EpochTradeModule.json b/packages/protocol/deployments/test/EpochTradeModule.json index a0d39c51..9f6cb9a0 100644 --- a/packages/protocol/deployments/test/EpochTradeModule.json +++ b/packages/protocol/deployments/test/EpochTradeModule.json @@ -1,5 +1,5 @@ { - "address": "0xc617352aCE1AaEA7CD936870b47D330e19246DA4", + "address": "0x33ad0458323a7b02dC054943EBf4fC0a27aab7D2", "abi": [ { "type": "function", @@ -162,12 +162,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x2fa390e9e1f67bd65791fa9bbac6e62ec47a1dbe1eef4cdd30f8bbe559075dfa", + "deployTxnHash": "0xb8082e21b44eb7833bb45a2939ea36f9bbbdd9fa05aada3dd1f95c61a35586d1", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722385870", + "deployTimestamp": "1722754339", "sourceName": "src/contracts/modules/EpochTradeModule.sol", "contractName": "EpochTradeModule", "deployedOn": "deploy.EpochTradeModule", - "gasUsed": 1829463, - "gasCost": "1004750562" + "gasUsed": 1832703, + "gasCost": "1004250407" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/EpochUMASettlementModule.json b/packages/protocol/deployments/test/EpochUMASettlementModule.json index 90ebf26d..f1c50c82 100644 --- a/packages/protocol/deployments/test/EpochUMASettlementModule.json +++ b/packages/protocol/deployments/test/EpochUMASettlementModule.json @@ -1,5 +1,5 @@ { - "address": "0x908F7a0B23f28c593255ECf1d3e9dD845f881b5c", + "address": "0xBF8e2C989bd27f1FF133f29542d2719341BA8954", "abi": [ { "type": "function", @@ -142,12 +142,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0xc5fd90940a289505a5dd22a3ae93711d2c80479531d3e23fc132188ec0ecfd08", + "deployTxnHash": "0xf8877aed889f507ed352bcbd81ba5c0a9718610039c48ee31e064828044025fb", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722272465", + "deployTimestamp": "1722754339", "sourceName": "src/contracts/modules/EpochUMASettlementModule.sol", "contractName": "EpochUMASettlementModule", "deployedOn": "deploy.EpochUMASettlementModule", - "gasUsed": 762618, - "gasCost": "1002925078" + "gasUsed": 766496, + "gasCost": "1003784021" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/Foil.json b/packages/protocol/deployments/test/Foil.json index 06b67639..3c1a4c91 100644 --- a/packages/protocol/deployments/test/Foil.json +++ b/packages/protocol/deployments/test/Foil.json @@ -1,5 +1,5 @@ { - "address": "0xcab1bcff7f537afd4065dbf4b1f175ab046a8eda", + "address": "0x76f9e59a9e68dee497ec7aeb4261d089bf6360d0", "abi": [ { "type": "function", @@ -134,9 +134,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -254,9 +254,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -329,9 +329,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParms", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -389,6 +389,11 @@ "name": "MarketAlreadyCreated", "inputs": [] }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, { "type": "error", "name": "ReentrancyGuardReentrantCall", @@ -492,81 +497,183 @@ "internalType": "uint256" } ], - "stateMutability": "payable" + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "decreaseLiquidityPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" }, { "type": "function", "name": "getPosition", "inputs": [ { - "name": "positionId", + "name": "accountId", "type": "uint256", "internalType": "uint256" } ], "outputs": [ { - "name": "nonce", - "type": "uint96", - "internalType": "uint96" + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" }, { - "name": "operator", - "type": "address", - "internalType": "address" + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "token0", - "type": "address", - "internalType": "address" + "name": "borrowedGwei", + "type": "uint256", + "internalType": "uint256" }, { - "name": "token1", - "type": "address", - "internalType": "address" + "name": "borrowedGas", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getTokenAmounts", + "inputs": [ + { + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "sqrtPriceX96", + "type": "uint160", + "internalType": "uint160" }, { - "name": "fee", - "type": "uint24", - "internalType": "uint24" + "name": "sqrtPriceAX96", + "type": "uint160", + "internalType": "uint160" }, { - "name": "tickLower", - "type": "int24", - "internalType": "int24" + "name": "sqrtPriceBX96", + "type": "uint160", + "internalType": "uint160" + } + ], + "outputs": [ + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" }, { - "name": "tickUpper", - "type": "int24", - "internalType": "int24" + "name": "amount1", + "type": "uint256", + "internalType": "uint256" }, { "name": "liquidity", "type": "uint128", "internalType": "uint128" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "increaseLiquidityPosition", + "inputs": [ + { + "name": "accountId", + "type": "uint256", + "internalType": "uint256" }, { - "name": "feeGrowthInside0LastX128", + "name": "collateralAmount", "type": "uint256", "internalType": "uint256" }, { - "name": "feeGrowthInside1LastX128", + "name": "gasTokenAmount", "type": "uint256", "internalType": "uint256" }, { - "name": "tokensOwed0", - "type": "uint128", - "internalType": "uint128" + "name": "ethTokenAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "tokensOwed1", + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "liquidity", "type": "uint128", "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" } ], - "stateMutability": "view" + "stateMutability": "nonpayable" }, { "type": "function", @@ -603,43 +710,91 @@ "stateMutability": "nonpayable" }, { - "type": "function", - "name": "updateLiquidityPosition", + "type": "event", + "name": "LiquidityPositionCreated", "inputs": [ { "name": "tokenId", "type": "uint256", + "indexed": false, "internalType": "uint256" }, { - "name": "collateral", + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "addedAmount0", "type": "uint256", + "indexed": false, "internalType": "uint256" }, { - "name": "liquidity", - "type": "uint128", - "internalType": "uint128" + "name": "addedAmount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionDecreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" }, { - "name": "minLiquidity", + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", "type": "uint256", + "indexed": false, "internalType": "uint256" } ], - "outputs": [ + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionIncreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, { "name": "amount0", "type": "uint256", + "indexed": false, "internalType": "uint256" }, { "name": "amount1", "type": "uint256", + "indexed": false, "internalType": "uint256" } ], - "stateMutability": "payable" + "anonymous": false }, { "type": "event", @@ -674,7 +829,18 @@ { "type": "error", "name": "InsufficientCollateral", - "inputs": [] + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateral", + "type": "uint256", + "internalType": "uint256" + } + ] }, { "type": "error", @@ -692,11 +858,6 @@ } ] }, - { - "type": "error", - "name": "OverflowInt24ToUint256", - "inputs": [] - }, { "type": "error", "name": "OverflowInt256ToUint256", @@ -1362,11 +1523,11 @@ } ], "deployedOn": "router.Foil", - "deployTxnHash": "0xee19df8e37e8c5f84551ff8d60cfc90271bdbd8b665400ca55b15eeeb1caa2b2", + "deployTxnHash": "0xbf62116248415e97431c6592b08fd2ca6b14152c44ebaa7fd432d2e38b9801b8", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722385875", + "deployTimestamp": "1722754427", "contractName": "Foil", "sourceName": "Foil.sol", - "gasUsed": 423046, - "gasCost": "1002169180" + "gasUsed": 439989, + "gasCost": "1002787316" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/ReentrancyGuard.json b/packages/protocol/deployments/test/ReentrancyGuard.json index 3b9b7e21..b003f92e 100644 --- a/packages/protocol/deployments/test/ReentrancyGuard.json +++ b/packages/protocol/deployments/test/ReentrancyGuard.json @@ -11,7 +11,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x0f84422301028f15368200101d2f1f120bb1199b08f862a7635b4bbef4db326f", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722272465", + "deployTimestamp": "1722380030", "sourceName": "node_modules/@openzeppelin/contracts/utils/ReentrancyGuard.sol", "contractName": "ReentrancyGuard", "deployedOn": "deploy.ReentrancyGuard", diff --git a/packages/protocol/deployments/test/UMA.Finder.json b/packages/protocol/deployments/test/UMA.Finder.json index f3af950e..932baf61 100644 --- a/packages/protocol/deployments/test/UMA.Finder.json +++ b/packages/protocol/deployments/test/UMA.Finder.json @@ -133,7 +133,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x3a4a94e89b04105532165c355ee28b7b969e45233aa52edca551b3b1c82bdc5d", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722388944", + "deployTimestamp": "1722754535", "sourceName": "src/UMA/Finder.sol", "contractName": "Finder", "deployedOn": "deploy.Finder", diff --git a/packages/protocol/deployments/test/UMA.MockOracleAncillary.json b/packages/protocol/deployments/test/UMA.MockOracleAncillary.json index 1c39b4d9..572327d1 100644 --- a/packages/protocol/deployments/test/UMA.MockOracleAncillary.json +++ b/packages/protocol/deployments/test/UMA.MockOracleAncillary.json @@ -337,7 +337,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x43618c7361ca78b0aab21b92675caacbc9e19526846c8e179199b6ccf1566b3f", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722388946", + "deployTimestamp": "1722754537", "sourceName": "node_modules/@uma/core/contracts/data-verification-mechanism/test/MockOracleAncillary.sol", "contractName": "MockOracleAncillary", "deployedOn": "deploy.MockOracleAncillary", diff --git a/packages/protocol/deployments/test/UMA.Timer.json b/packages/protocol/deployments/test/UMA.Timer.json index e806c289..05e944a5 100644 --- a/packages/protocol/deployments/test/UMA.Timer.json +++ b/packages/protocol/deployments/test/UMA.Timer.json @@ -32,7 +32,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x29b7ae3d95bb5bbf8d49183656651fd97d2f53d56735b7e2fd7d063f6346bf55", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722388944", + "deployTimestamp": "1722754535", "sourceName": "src/UMA/Timer.sol", "contractName": "Timer", "deployedOn": "deploy.Timer", diff --git a/packages/protocol/deployments/test/Uniswap.Core.UniswapV3Factory.json b/packages/protocol/deployments/test/Uniswap.Core.UniswapV3Factory.json index b9a0ee48..2f2742b9 100644 --- a/packages/protocol/deployments/test/Uniswap.Core.UniswapV3Factory.json +++ b/packages/protocol/deployments/test/Uniswap.Core.UniswapV3Factory.json @@ -240,7 +240,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x092ab39ca583e8ec4129b58d4fd95e709512b32cbc98002efadca0218e4a84a3", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722388946", + "deployTimestamp": "1722754537", "sourceName": "contracts/UniswapV3Factory.sol", "contractName": "UniswapV3Factory", "deployedOn": "deploy.UniswapV3Factory", diff --git a/packages/protocol/deployments/test/Uniswap.NFTDescriptor.json b/packages/protocol/deployments/test/Uniswap.NFTDescriptor.json index b6dbbd3e..7f6333f4 100644 --- a/packages/protocol/deployments/test/Uniswap.NFTDescriptor.json +++ b/packages/protocol/deployments/test/Uniswap.NFTDescriptor.json @@ -97,7 +97,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x4f80fa4eb9453334f7e1039e6650362b31dbefd37cb97288a4c4ce7343e78f84", "deployTxnBlockNumber": "6", - "deployTimestamp": "1722388945", + "deployTimestamp": "1722754536", "sourceName": "contracts/libraries/NFTDescriptor.sol", "contractName": "NFTDescriptor", "deployedOn": "deploy.NFTDescriptor", diff --git a/packages/protocol/deployments/test/Uniswap.NonfungiblePositionManager.json b/packages/protocol/deployments/test/Uniswap.NonfungiblePositionManager.json index 77cd8e20..62ad2fea 100644 --- a/packages/protocol/deployments/test/Uniswap.NonfungiblePositionManager.json +++ b/packages/protocol/deployments/test/Uniswap.NonfungiblePositionManager.json @@ -1229,7 +1229,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xde94cbbd26e2b9788d598dc8ec563c9f9703883879a9548c6d5f0d1cfc5af56b", "deployTxnBlockNumber": "12", - "deployTimestamp": "1722388945", + "deployTimestamp": "1722754536", "sourceName": "contracts/NonfungiblePositionManager.sol", "contractName": "NonfungiblePositionManager", "deployedOn": "deploy.NonfungiblePositionManager", diff --git a/packages/protocol/deployments/test/Uniswap.NonfungibleTokenPositionDescriptor.json b/packages/protocol/deployments/test/Uniswap.NonfungibleTokenPositionDescriptor.json index d763e41e..b97a8313 100644 --- a/packages/protocol/deployments/test/Uniswap.NonfungibleTokenPositionDescriptor.json +++ b/packages/protocol/deployments/test/Uniswap.NonfungibleTokenPositionDescriptor.json @@ -145,7 +145,7 @@ }, "deployTxnHash": "0x10883daf11b005c175d09ba813de6ea3c63efd9833a92a12ede7276ba7a7c849", "deployTxnBlockNumber": "8", - "deployTimestamp": "1722388945", + "deployTimestamp": "1722754536", "sourceName": "contracts/NonfungibleTokenPositionDescriptor.sol", "contractName": "NonfungibleTokenPositionDescriptor", "deployedOn": "deploy.NonfungibleTokenPositionDescriptor", diff --git a/packages/protocol/deployments/test/Uniswap.ProxyAdmin.json b/packages/protocol/deployments/test/Uniswap.ProxyAdmin.json index 9aa7747c..3ac0288c 100644 --- a/packages/protocol/deployments/test/Uniswap.ProxyAdmin.json +++ b/packages/protocol/deployments/test/Uniswap.ProxyAdmin.json @@ -155,7 +155,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xec0692423399c3d742c864060cd640bc3e7a966cb4ede764a323ab91fe6c52d1", "deployTxnBlockNumber": "5", - "deployTimestamp": "1722388948", + "deployTimestamp": "1722754539", "sourceName": "@openzeppelin/contracts/proxy/ProxyAdmin.sol", "contractName": "ProxyAdmin", "deployedOn": "deploy.ProxyAdmin", diff --git a/packages/protocol/deployments/test/Uniswap.Quoter.json b/packages/protocol/deployments/test/Uniswap.Quoter.json index d17d1462..d5aeefbe 100644 --- a/packages/protocol/deployments/test/Uniswap.Quoter.json +++ b/packages/protocol/deployments/test/Uniswap.Quoter.json @@ -200,7 +200,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x77e143643e4884a308dec6693d86e0e658de1f16802df6db35f444c2ebc02ddd", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722388946", + "deployTimestamp": "1722754537", "sourceName": "contracts/lens/Quoter.sol", "contractName": "Quoter", "deployedOn": "deploy.Quoter", diff --git a/packages/protocol/deployments/test/Uniswap.SwapRouter.json b/packages/protocol/deployments/test/Uniswap.SwapRouter.json index c06ea5d2..0cbe65d4 100644 --- a/packages/protocol/deployments/test/Uniswap.SwapRouter.json +++ b/packages/protocol/deployments/test/Uniswap.SwapRouter.json @@ -572,7 +572,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x34c75edbab5990d7b1e9441df2d4378da661672d4de365f41a3657d1d3c54e11", "deployTxnBlockNumber": "4", - "deployTimestamp": "1722388947", + "deployTimestamp": "1722754538", "sourceName": "contracts/SwapRouter.sol", "contractName": "SwapRouter", "deployedOn": "deploy.SwapRouter", diff --git a/packages/protocol/deployments/test/Uniswap.TickLens.json b/packages/protocol/deployments/test/Uniswap.TickLens.json index 4f5b8242..4037bd82 100644 --- a/packages/protocol/deployments/test/Uniswap.TickLens.json +++ b/packages/protocol/deployments/test/Uniswap.TickLens.json @@ -47,7 +47,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xe86d0528829e851224aff055a91d81d0a8ffe44446c2664342f16ed023929f4d", "deployTxnBlockNumber": "6", - "deployTimestamp": "1722388949", + "deployTimestamp": "1722754540", "sourceName": "contracts/lens/TickLens.sol", "contractName": "TickLens", "deployedOn": "deploy.TickLens", diff --git a/packages/protocol/deployments/test/Uniswap.TransparentUpgradeableProxy.json b/packages/protocol/deployments/test/Uniswap.TransparentUpgradeableProxy.json index 5f8db36d..d17b6fa9 100644 --- a/packages/protocol/deployments/test/Uniswap.TransparentUpgradeableProxy.json +++ b/packages/protocol/deployments/test/Uniswap.TransparentUpgradeableProxy.json @@ -141,7 +141,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x488f88a8c7d794288db591295391a226738ac6ed932f71f0f4fd3a3a5519a868", "deployTxnBlockNumber": "10", - "deployTimestamp": "1722388945", + "deployTimestamp": "1722754536", "sourceName": "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol", "contractName": "TransparentUpgradeableProxy", "deployedOn": "deploy.TransparentUpgradeableProxy", diff --git a/packages/protocol/package.json b/packages/protocol/package.json index bfe8199c..6d873416 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -5,7 +5,7 @@ "version": "0.1.0", "scripts": { "dev": "cannon build --keep-alive --port 8545 --no-cors --write-deployments ./deployments/13370", - "test": "forge build && cannon build --write-deployments ./deployments/test/ && cannon test", + "test": "forge build && cannon build --write-deployments ./deployments && cannon test", "deploy:sepolia": "cannon build cannonfile.sepolia.toml --chain-id 11155111 --write-deployments ./deployments/11155111", "simulate-deploy:sepolia": "cannon build cannonfile.sepolia.toml --chain-id 11155111 --dry-run" }, diff --git a/packages/protocol/src/contracts/external/IMintableToken.sol b/packages/protocol/src/contracts/external/IMintableToken.sol new file mode 100644 index 00000000..2772c7d4 --- /dev/null +++ b/packages/protocol/src/contracts/external/IMintableToken.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.2 <0.9.0; + +import {IERC20} from "../../synthetix/interfaces/IERC20.sol"; + +interface IMintableToken is IERC20 { + function mint(uint256 amount, address to) external; +} diff --git a/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol b/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol new file mode 100644 index 00000000..da46105a --- /dev/null +++ b/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.2 <0.9.0; + +import {IFoilStructs} from "./IFoilStructs.sol"; + +interface IEpochLiquidityModule { + event LiquidityPositionCreated( + uint256 tokenId, + uint128 liquidity, + uint256 addedAmount0, + uint256 addedAmount1 + ); + + event LiquidityPositionDecreased( + uint256 tokenId, + uint256 amount0, + uint256 amount1 + ); + + event LiquidityPositionIncreased( + uint256 tokenId, + uint128 liquidity, + uint256 amount0, + uint256 amount1 + ); + + function createLiquidityPosition( + IFoilStructs.LiquidityPositionParams memory params + ) + external + returns ( + uint256 tokenId, + uint128 liquidity, + uint256 addedAmount0, + uint256 addedAmount1 + ); + + function decreaseLiquidityPosition( + uint256 accountId, + uint256 collateralAmount, + uint128 liquidity, + uint256 minGasAmount, + uint256 minEthAmount + ) external returns (uint256 amount0, uint256 amount1); + + function increaseLiquidityPosition( + uint256 accountId, + uint256 collateralAmount, + uint256 gasTokenAmount, + uint256 ethTokenAmount, + uint256 minGasAmount, + uint256 minEthAmount + ) external returns (uint128 liquidity, uint256 amount0, uint256 amount1); + + function getTokenAmounts( + uint256 collateralAmount, + uint160 sqrtPriceX96, + uint160 sqrtPriceAX96, + uint160 sqrtPriceBX96 + ) + external + view + returns (uint256 amount0, uint256 amount1, uint128 liquidity); + + function collectFees( + uint256 tokenId + ) external returns (uint256 amount0, uint256 amount1); + + function getPosition( + uint256 accountId + ) + external + view + returns ( + uint256 tokenId, + uint256 collateralAmount, + uint256 borrowedGwei, + uint256 borrowedGas + ); +} diff --git a/packages/protocol/src/contracts/interfaces/IFoil.sol b/packages/protocol/src/contracts/interfaces/IFoil.sol index 7e2d0f8b..1f88a8be 100644 --- a/packages/protocol/src/contracts/interfaces/IFoil.sol +++ b/packages/protocol/src/contracts/interfaces/IFoil.sol @@ -4,10 +4,11 @@ pragma solidity >=0.8.2 <0.9.0; import "./IFoilStructs.sol"; import "../storage/Position.sol"; import "../storage/FAccount.sol"; +import "./IEpochLiquidityModule.sol"; -interface IFoil { +interface IFoil is IEpochLiquidityModule { function getEpoch( - uint256 startTime + uint256 epochId ) external view returns (address pool, address ethToken, address gasToken); // function getPosition( @@ -29,66 +30,11 @@ interface IFoil { int256 tokenAmountLimit ) external; - function createLiquidityPosition( - IFoilStructs.LiquidityPositionParams memory params - ) - external - payable - returns ( - uint256 tokenId, - uint128 liquidity, - uint256 amount0, - uint256 amount1 - ); - - function createLiquidityPositionTwo( - IFoilStructs.LiquidityPositionParams memory params - ) - external - payable - returns ( - uint256 tokenId, - uint128 liquidity, - uint256 amount0, - uint256 amount1 - ); - function swapTokens( uint256 amountInVEth, uint256 amountInVGas ) external returns (uint256 amountOutVEth, uint256 amountOutVGas); - function updateLiquidityPosition( - uint256 epochId, - uint256 tokenId, - uint256 collateral, - uint128 liquidityRatio - ) external payable returns (uint256 amount0, uint256 amount1); - - function collectFees( - uint256 tokenId - ) external returns (uint256 amount0, uint256 amount1); - - function getPosition( - uint256 positionId - ) - external - view - returns ( - uint96 nonce, - address operator, - address token0, - address token1, - uint24 fee, - int24 tickLower, - int24 tickUpper, - uint128 liquidity, - uint256 feeGrowthInside0LastX128, - uint256 feeGrowthInside1LastX128, - uint128 tokensOwed0, - uint128 tokensOwed1 - ); - function fakeSettle(uint256 settlementPrice) external; function getPositionData( diff --git a/packages/protocol/src/contracts/libraries/Quote.sol b/packages/protocol/src/contracts/libraries/Quote.sol new file mode 100644 index 00000000..ca0b112e --- /dev/null +++ b/packages/protocol/src/contracts/libraries/Quote.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.8.2 <0.9.0; + +import {TickMath} from "../external/univ3/TickMath.sol"; +import {FullMath} from "../external/univ3/FullMath.sol"; +import "forge-std/console2.sol"; + +library Quote { + function quoteEthToGas( + uint256 ethAmount, + uint160 sqrtRatioX96 + ) internal pure returns (uint256) { + return + FullMath.mulDiv(ethAmount, 1e18, sqrtRatioX96ToPrice(sqrtRatioX96)); + } + + function quoteGasToEth( + uint256 gasAmount, + uint160 sqrtRatioX96 + ) internal pure returns (uint256) { + return + FullMath.mulDiv(gasAmount, sqrtRatioX96ToPrice(sqrtRatioX96), 1e18); + } + + function sqrtRatioX96ToPrice( + uint160 sqrtRatioX96 + ) internal pure returns (uint256 price) { + // Calculate the price as (sqrtRatioX96^2) / (2^192) + uint256 sqrtRatioX96Squared = uint256(sqrtRatioX96) * + uint256(sqrtRatioX96); + price = sqrtRatioX96Squared >> 96; + // Scale price to have 18 decimal places + price = (price * 10 ** 18) / (2 ** 96); + } +} diff --git a/packages/protocol/src/contracts/modules/EpochConfigurationModule.sol b/packages/protocol/src/contracts/modules/EpochConfigurationModule.sol index c1c13e23..60617729 100644 --- a/packages/protocol/src/contracts/modules/EpochConfigurationModule.sol +++ b/packages/protocol/src/contracts/modules/EpochConfigurationModule.sol @@ -10,7 +10,7 @@ import "../storage/FAccount.sol"; import "../storage/Position.sol"; import "../storage/ERC721Storage.sol"; import "../storage/ERC721EnumerableStorage.sol"; -import "../storage/Market.sol"; // Import the Market library +import "../storage/Market.sol"; import "forge-std/console2.sol"; contract EpochConfigurationModule is ReentrancyGuard { @@ -33,7 +33,7 @@ contract EpochConfigurationModule is ReentrancyGuard { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - Market.MarketParams memory marketParams + Market.EpochParams memory epochParams ) external { Market.createValid( owner, @@ -42,7 +42,7 @@ contract EpochConfigurationModule is ReentrancyGuard { uniswapQuoter, uniswapSwapRouter, optimisticOracleV3, - marketParams + epochParams ); } @@ -52,7 +52,7 @@ contract EpochConfigurationModule is ReentrancyGuard { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - Market.MarketParams memory marketParams + Market.EpochParams memory epochParms ) external onlyOwner { Market.updateValid( owner, // should be nominate/accept @@ -60,7 +60,7 @@ contract EpochConfigurationModule is ReentrancyGuard { uniswapQuoter, uniswapSwapRouter, optimisticOracleV3, - marketParams + epochParms ); } @@ -71,17 +71,7 @@ contract EpochConfigurationModule is ReentrancyGuard { ) external onlyOwner { Market.Data storage market = Market.loadValid(); - Epoch.createValid( - startTime, - endTime, - address(market.uniswapPositionManager), - address(market.uniswapQuoter), - address(market.uniswapSwapRouter), - address(market.collateralAsset), - startingSqrtPriceX96, - address(market.optimisticOracleV3), - market.marketParams - ); + Epoch.createValid(startTime, endTime, startingSqrtPriceX96); } function getMarket() @@ -94,18 +84,18 @@ contract EpochConfigurationModule is ReentrancyGuard { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - Market.MarketParams memory marketParams + Market.EpochParams memory epochParams ) { Market.Data storage market = Market.load(); return ( market.owner, - market.collateralAsset, + address(market.collateralAsset), address(market.uniswapPositionManager), address(market.uniswapQuoter), address(market.uniswapSwapRouter), address(market.optimisticOracleV3), - market.marketParams + market.epochParams ); } diff --git a/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol b/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol index 5a596fef..878cc32f 100644 --- a/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol +++ b/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol @@ -9,24 +9,26 @@ import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "../storage/FAccount.sol"; import "../storage/Market.sol"; import "../storage/Epoch.sol"; +import "../storage/Errors.sol"; import {IFoilStructs} from "../interfaces/IFoilStructs.sol"; +import {IEpochLiquidityModule} from "../interfaces/IEpochLiquidityModule.sol"; import "forge-std/console2.sol"; -// Constants -uint256 constant ONE_ETHER_IN_GWEI = 10 ** 9; -uint256 constant ONE_ETH_IN_WEI = 10 ** 18; -uint256 constant Q192 = 2 ** 192; - -contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { +contract EpochLiquidityModule is + ReentrancyGuard, + IERC721Receiver, + IEpochLiquidityModule +{ using Market for Market.Data; using FAccount for FAccount.Data; + using Epoch for Epoch.Data; function createLiquidityPosition( IFoilStructs.LiquidityPositionParams memory params ) external - payable + override returns ( uint256 tokenId, uint128 liquidity, @@ -41,11 +43,16 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { Market.Data storage market = Market.load(); Epoch.Data storage epoch = Epoch.load(params.epochId); + account.updateCollateral( + market.collateralAsset, + params.collateralAmount + ); + INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager.MintParams({ token0: address(epoch.gasToken), token1: address(epoch.ethToken), - fee: epoch.marketParams.feeRate, + fee: epoch.params.feeRate, tickLower: params.lowerTick, tickUpper: params.upperTick, amount0Desired: params.amountTokenA, @@ -60,8 +67,6 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { .uniswapPositionManager .mint(mintParams); - console2.log("ADDED AMTS", addedAmount0, addedAmount1, liquidity); - account.updateLoan( tokenId, params.collateralAmount, @@ -69,18 +74,20 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { addedAmount1 ); - (, , address token0, address token1, , , , uint128 liq, , , , ) = market - .uniswapPositionManager - .positions(tokenId); - - account.validateProvidedLiquidity( - epoch.marketParams, + epoch.validateProvidedLiquidity( + params.collateralAmount, liquidity, params.lowerTick, params.upperTick ); - // TODO: refund + // emit event + emit LiquidityPositionCreated( + tokenId, + liquidity, + addedAmount0, + addedAmount1 + ); } function onERC721Received( @@ -99,7 +106,7 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { function collectFees( uint256 epochId, uint256 tokenId - ) external returns (uint256 amount0, uint256 amount1) { + ) external override returns (uint256 amount0, uint256 amount1) { Market.Data storage market = Market.load(); Epoch.Data storage epoch = Epoch.load(epochId); @@ -150,16 +157,23 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { uint256 tokenId, uint256 collateral, uint128 liquidity, - uint256 minLiquidity - ) external payable returns (uint256 amount0, uint256 amount1) { - console2.log("UPDATELIQPOSITION"); + uint256 minGasAmount, + uint256 minEthAmount + ) external override returns (uint256 amount0, uint256 amount1) { Market.Data storage market = Market.load(); Epoch.Data storage epoch = Epoch.load(epochId); + FAccount.Data storage account = FAccount.load(accountId); + + (, , , , , int24 lowerTick, int24 upperTick, , , , , ) = market + .uniswapPositionManager + .positions(account.tokenId); + + account.updateCollateral(market.collateralAsset, collateralAmount); INonfungiblePositionManager.DecreaseLiquidityParams memory decreaseParams = INonfungiblePositionManager .DecreaseLiquidityParams({ - tokenId: tokenId, + tokenId: account.tokenId, liquidity: liquidity, amount0Min: 0, amount1Min: 0, @@ -169,89 +183,120 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { (amount0, amount1) = market.uniswapPositionManager.decreaseLiquidity( decreaseParams ); - console2.log("REMOVED", amount0, amount1); + + account.updateLoan(account.tokenId, collateralAmount, amount0, amount1); + Epoch.load().validateProvidedLiquidity( + collateralAmount, + liquidity, + lowerTick, + upperTick + ); + + emit LiquidityPositionDecreased(account.tokenId, amount0, amount1); + + // transfer or remove collateral + } + + function increaseLiquidityPosition( + uint256 accountId, + uint256 collateralAmount, + uint256 gasTokenAmount, + uint256 ethTokenAmount, + uint256 minGasAmount, + uint256 minEthAmount + ) external returns (uint128 liquidity, uint256 amount0, uint256 amount1) { + Market.Data storage market = Market.load(); + FAccount.Data storage account = FAccount.load(accountId); + + (, , , , , int24 lowerTick, int24 upperTick, , , , , ) = market + .uniswapPositionManager + .positions(account.tokenId); + + account.updateCollateral(market.collateralAsset, collateralAmount); + + INonfungiblePositionManager.IncreaseLiquidityParams + memory increaseParams = INonfungiblePositionManager + .IncreaseLiquidityParams({ + tokenId: account.tokenId, + amount0Desired: gasTokenAmount, + amount1Desired: ethTokenAmount, + amount0Min: minGasAmount, + amount1Min: minEthAmount, + deadline: block.timestamp + }); + + (liquidity, amount0, amount1) = market + .uniswapPositionManager + .increaseLiquidity(increaseParams); + + account.updateLoan(account.tokenId, collateralAmount, amount0, amount1); + Epoch.load().validateProvidedLiquidity( + collateralAmount, + liquidity, + lowerTick, + upperTick + ); + + emit LiquidityPositionIncreased( + account.tokenId, + liquidity, + amount0, + amount1 + ); + } + + function getTokenAmounts( + uint256 collateralAmount, + uint160 sqrtPriceX96, + uint160 sqrtPriceAX96, + uint160 sqrtPriceBX96 + ) + external + view + override + returns (uint256 amount0, uint256 amount1, uint128 liquidity) + { + // calculate for unit + uint128 unitLiquidity = LiquidityAmounts.getLiquidityForAmounts( + sqrtPriceX96, + sqrtPriceAX96, + sqrtPriceBX96, + 1e18, + 1e18 + ); + + ( + uint256 requiredCollateral, + uint256 unitAmount0, + uint256 uintAmount1 + ) = Epoch.load().requiredCollateralForLiquidity( + unitLiquidity, + sqrtPriceX96, + sqrtPriceAX96, + sqrtPriceBX96 + ); + + // scale up for fractional collateral ratio + uint256 collateralRatio = FullMath.mulDiv( + collateralAmount, + 1e18, // Create MathUtil and use UNIT + requiredCollateral + ); + + // scale up liquidity by collateral amount + return ( + FullMath.mulDiv(unitAmount0, collateralRatio, 1e18), + FullMath.mulDiv(uintAmount1, collateralRatio, 1e18), + uint128(unitLiquidity * collateralRatio) / 1e18 + ); } - // function getTokenAmounts( - // uint256 collateralAmount, - // int24 tickLower, - // int24 tickUpper - // ) - // public - // view - // returns (uint256 amount0, uint256 amount1, uint128 liquidity) - // { - // Epoch.Data storage epoch = Epoch.load(); - // console2.log("calc liq amts"); - - // uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower); - // uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper); - - // uint160 minTickSqrtRatio = TickMath.getSqrtRatioAtTick( - // epoch.baseAssetMinPriceTick - // ); - // uint256 maxTickSqrtRatio = TickMath.getSqrtRatioAtTick( - // epoch.baseAssetMaxPriceTick - // ); - // // console2.log(minPrice); - - // // liquidity = LiquidityAmounts.getLiquidityForAmount1( - // // sqrtRatioAX96, - // // sqrtRatioBX96, - // // collateralAmount - // // ); - - // liquidity = LiquidityAmounts.getLiquidityForAmount1( - // sqrtRatioAX96, - // sqrtRatioBX96, - // collateralAmount - // ); - - // // console2.log("LIQUIDITY 2", liquidityOne, liquidityTwo); - - // // liquidity = liquidityOne < liquidityTwo ? liquidityOne : liquidityTwo; - - // uint128 scaleFactor = 1e9; - - // console2.log("LIQUIDITY", liquidity); - - // (amount0, amount1) = LiquidityAmounts.getAmountsForLiquidity( - // 396140812571321687967719751680, // 25 - // sqrtRatioAX96, - // sqrtRatioBX96, - // liquidity / scaleFactor - // ); - - // console2.log("Scaled amount0:", amount0); - // console2.log("Scaled amount1:", amount1); - - // // Scale the amounts back up - // amount0 = amount0 * scaleFactor; - // amount1 = amount1 * scaleFactor; - - // console2.log("Final amount0 (GAS):", amount0); - // console2.log("Final amount1 (GWEI):", amount1); - - // (uint256 amount0final, uint256 amount1final) = LiquidityAmounts - // .getAmountsForLiquidity( - // minTickSqrtRatio, - // sqrtRatioAX96, - // sqrtRatioBX96, - // liquidity / scaleFactor - // ); - - // console2.log( - // "amountsmintick", - // amount0final * scaleFactor, - // amount1final * scaleFactor - // ); - // } - /* function getPosition( uint256 accountId ) external view + override returns ( uint256 tokenId, uint256 collateralAmount, @@ -267,5 +312,4 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { account.borrowedGas ); } -*/ } diff --git a/packages/protocol/src/contracts/modules/EpochTradeModule.sol b/packages/protocol/src/contracts/modules/EpochTradeModule.sol index 8bc35897..53a30c99 100644 --- a/packages/protocol/src/contracts/modules/EpochTradeModule.sol +++ b/packages/protocol/src/contracts/modules/EpochTradeModule.sol @@ -561,7 +561,7 @@ contract EpochTradeModule { ); } else { ISwapRouter.ExactInputSingleParams memory swapParams; - swapParams.fee = epoch.marketParams.feeRate; + swapParams.fee = epoch.params.feeRate; swapParams.recipient = address(this); swapParams.deadline = block.timestamp; @@ -675,7 +675,7 @@ contract EpochTradeModule { .ExactOutputSingleParams({ tokenIn: tokenIn, tokenOut: tokenOut, - fee: epoch.marketParams.feeRate, + fee: epoch.params.feeRate, recipient: address(this), deadline: block.timestamp, amountOut: amountOut, diff --git a/packages/protocol/src/contracts/modules/EpochUMASettlementModule.sol b/packages/protocol/src/contracts/modules/EpochUMASettlementModule.sol index 714df021..4d9762f2 100644 --- a/packages/protocol/src/contracts/modules/EpochUMASettlementModule.sol +++ b/packages/protocol/src/contracts/modules/EpochUMASettlementModule.sol @@ -40,18 +40,18 @@ contract EpochUMASettlementModule is ReentrancyGuard { ); require(!epoch.settled, "Market already settled"); - IERC20 bondCurrency = IERC20(epoch.marketParams.bondCurrency); + IERC20 bondCurrency = IERC20(epoch.params.bondCurrency); OptimisticOracleV3Interface optimisticOracleV3 = market .optimisticOracleV3; bondCurrency.safeTransferFrom( msg.sender, address(this), - epoch.marketParams.bondAmount + epoch.params.bondAmount ); bondCurrency.forceApprove( address(optimisticOracleV3), - epoch.marketParams.bondAmount + epoch.params.bondAmount ); epoch.settlement = Epoch.Settlement({ @@ -62,7 +62,7 @@ contract EpochUMASettlementModule is ReentrancyGuard { }); bytes memory claim = abi.encodePacked( - epoch.marketParams.priceUnit, + epoch.params.priceUnit, " TWAP between timestamps ", abi.encodePacked(epoch.startTime), " and ", @@ -76,9 +76,9 @@ contract EpochUMASettlementModule is ReentrancyGuard { msg.sender, address(this), address(0), - epoch.marketParams.assertionLiveness, - IERC20(epoch.marketParams.bondCurrency), - uint64(epoch.marketParams.bondAmount), + epoch.params.assertionLiveness, + IERC20(epoch.params.bondCurrency), + uint64(epoch.params.bondAmount), bytes32(0), bytes32(0) ); diff --git a/packages/protocol/src/contracts/storage/Epoch.sol b/packages/protocol/src/contracts/storage/Epoch.sol index 9eaa866a..42aa4a3c 100644 --- a/packages/protocol/src/contracts/storage/Epoch.sol +++ b/packages/protocol/src/contracts/storage/Epoch.sol @@ -12,6 +12,8 @@ import "../interfaces/external/INonfungiblePositionManager.sol"; import "../interfaces/external/IUniswapV3Quoter.sol"; import "../interfaces/external/ISwapRouter.sol"; import "../external/VirtualToken.sol"; +import "../libraries/Quote.sol"; +import "../external/univ3/LiquidityAmounts.sol"; import "./Debt.sol"; import "./Errors.sol"; import "./Market.sol"; @@ -39,7 +41,9 @@ library Epoch { mapping(uint256 => Debt.Data) lpDebtPositions; bytes32 assertionId; Settlement settlement; - Market.MarketParams marketParams; // Storing MarketParams as a struct within Epoch.Data + Market.EpochParams params; // Storing epochParams as a struct within Epoch.Data + uint160 sqrtPriceMinX96; + uint160 sqrtPriceMaxX96; } function load(uint256 id) internal pure returns (Data storage epoch) { @@ -73,16 +77,14 @@ library Epoch { } function createValid( - uint256 startTime, - uint256 endTime, - address uniswapPositionManager, - address uniswapQuoter, - address uniswapSwapRouter, - address collateralAsset, - uint160 startingSqrtPriceX96, - address optimisticOracleV3, - Market.MarketParams memory marketParams + epoch = load(startTime); + uint startTime, + uint endTime, + uint160 startingSqrtPriceX96 ) internal returns (Data storage epoch) { + Market.Data storage market = Market.loadValid(); + Market.EpochParams storage epochParams = market.epochParams; + epoch = load(startTime); // can only be called once @@ -107,7 +109,9 @@ library Epoch { epoch.startTime = startTime; epoch.endTime = endTime; - epoch.marketParams = marketParams; + + // copy over market parameters into epoch + epoch.params = market.epochParams; VirtualToken tokenA = new VirtualToken( address(this), @@ -128,39 +132,53 @@ library Epoch { epoch.gasToken = tokenB; epoch.ethToken = tokenA; } + + // create & initialize pool epoch.pool = IUniswapV3Pool( IUniswapV3Factory( - INonfungiblePositionManager(uniswapPositionManager).factory() + INonfungiblePositionManager(market.uniswapPositionManager) + .factory() ).createPool( address(epoch.gasToken), address(epoch.ethToken), - marketParams.feeRate + epochParams.feeRate ) ); - IUniswapV3Pool(epoch.pool).initialize(startingSqrtPriceX96); // starting price - (uint160 sqrtPriceX96, int24 tick, , , , , ) = IUniswapV3Pool( - epoch.pool - ).slot0(); + int24 spacing = IUniswapV3Pool(epoch.pool).tickSpacing(); + // store min/max prices + epoch.sqrtPriceMinX96 = TickMath.getSqrtRatioAtTick( + epoch.params.baseAssetMinPriceTick + ); + // use next tick for max price + epoch.sqrtPriceMaxX96 = TickMath.getSqrtRatioAtTick( + epoch.params.baseAssetMaxPriceTick + spacing + ); - // mint + // mint max; track tokens loaned by in FAccount epoch.ethToken.mint(address(this), type(uint256).max); epoch.gasToken.mint(address(this), type(uint256).max); // approve to uniswapPositionManager epoch.ethToken.approve( - address(uniswapPositionManager), + address(market.uniswapPositionManager), type(uint256).max ); epoch.gasToken.approve( - address(uniswapPositionManager), + address(market.uniswapPositionManager), type(uint256).max ); // approve to uniswapSwapRouter - epoch.ethToken.approve(address(uniswapSwapRouter), type(uint256).max); - epoch.gasToken.approve(address(uniswapSwapRouter), type(uint256).max); + epoch.ethToken.approve( + address(market.uniswapSwapRouter), + type(uint256).max + ); + epoch.gasToken.approve( + address(market.uniswapSwapRouter), + type(uint256).max + ); } function loadValid(uint256 id) internal view returns (Data storage epoch) { @@ -205,6 +223,131 @@ library Epoch { } } + function validateProvidedLiquidity( + Data storage self, + uint256 collateralAmount, + uint128 liquidity, + int24 lowerTick, + int24 upperTick + ) internal { + (uint160 sqrtPriceX96, , , , , , ) = self.pool.slot0(); + + uint128 scaleFactor = 8; + ( + uint256 requiredCollateral, + uint256 tokenAmountA, + uint256 tokenAmountB + ) = requiredCollateralForLiquidity( + self, + liquidity / scaleFactor, + sqrtPriceX96, + TickMath.getSqrtRatioAtTick(lowerTick), + TickMath.getSqrtRatioAtTick(upperTick) + ); + + requiredCollateral *= scaleFactor; + + if (collateralAmount < requiredCollateral) { + revert Errors.InsufficientCollateral( + collateralAmount, + requiredCollateral + ); + } + } + + function requiredCollateralForLiquidity( + Data storage self, + uint128 liquidity, + uint160 sqrtPriceX96, + uint160 sqrtPriceAX96, + uint160 sqrtPriceBX96 + ) + internal + view + returns ( + uint256 requiredCollateral, + uint256 loanAmount0, + uint256 loanAmount1 + ) + { + (loanAmount0, loanAmount1) = LiquidityAmounts.getAmountsForLiquidity( + sqrtPriceX96, + sqrtPriceAX96, + sqrtPriceBX96, + liquidity + ); + + uint256 collateralRequirementAtMin = collateralRequirementAtMinTick( + self, + liquidity, + sqrtPriceAX96, + sqrtPriceBX96, + loanAmount0, + loanAmount1 + ); + uint256 collateralRequirementAtMax = collateralRequirementAtMaxTick( + self, + liquidity, + sqrtPriceAX96, + sqrtPriceBX96, + loanAmount0, + loanAmount1 + ); + + requiredCollateral = collateralRequirementAtMin > + collateralRequirementAtMax + ? collateralRequirementAtMin + : collateralRequirementAtMax; + } + + function collateralRequirementAtMinTick( + Data storage self, + uint128 liquidity, + uint160 sqrtPriceAX96, + uint160 sqrtPriceBX96, + uint256 loanAmount0, + uint256 loanAmount1 + ) internal view returns (uint256) { + uint256 maxAmount0 = LiquidityAmounts.getAmount0ForLiquidity( + sqrtPriceAX96, + sqrtPriceBX96, + liquidity + ); + uint256 availableAmount0 = maxAmount0 > loanAmount0 + ? maxAmount0 - loanAmount0 + : 0; + uint256 availableAmount1 = Quote.quoteGasToEth( + availableAmount0, + self.sqrtPriceMinX96 + ); + return loanAmount1 - availableAmount1; + } + + function collateralRequirementAtMaxTick( + Data storage self, + uint128 liquidity, + uint160 sqrtPriceAX96, + uint160 sqrtPriceBX96, + uint256 loanAmount0, + uint256 loanAmount1 + ) internal view returns (uint256) { + uint256 maxAmount1 = LiquidityAmounts.getAmount1ForLiquidity( + sqrtPriceAX96, + sqrtPriceBX96, + liquidity + ); + uint256 availableAmount1 = maxAmount1 > loanAmount1 + ? maxAmount1 - loanAmount1 + : 0; + uint256 availableAmount0 = Quote.quoteEthToGas( + availableAmount1, + self.sqrtPriceMaxX96 + ); + + uint256 amount0LoanLeftover = loanAmount0 - availableAmount0; + return Quote.quoteGasToEth(amount0LoanLeftover, self.sqrtPriceMaxX96); + } + // function transferCollateral(Data storage self, uint256 amount) internal { // IERC20(self.collateralAsset).transferFrom( // msg.sender, diff --git a/packages/protocol/src/contracts/storage/Errors.sol b/packages/protocol/src/contracts/storage/Errors.sol index 3c71604a..527c631e 100644 --- a/packages/protocol/src/contracts/storage/Errors.sol +++ b/packages/protocol/src/contracts/storage/Errors.sol @@ -24,6 +24,7 @@ library Errors { error NoEpochs(); error NotAccountOwnerOrAuthorized(uint256 accountId, address sender); error NotEnoughCredit(uint256 amount, uint256 credit); - error InsufficientCollateral(); + error InsufficientCollateral(uint256 amount, uint256 collateral); error IndexOverrun(uint256 requestedIndex, uint256 length); + error InvalidLiquidityModification(); } diff --git a/packages/protocol/src/contracts/storage/FAccount.sol b/packages/protocol/src/contracts/storage/FAccount.sol index a68a64dc..b4112a52 100644 --- a/packages/protocol/src/contracts/storage/FAccount.sol +++ b/packages/protocol/src/contracts/storage/FAccount.sol @@ -6,6 +6,7 @@ import {TickMath} from "../external/univ3/TickMath.sol"; import "./Position.sol"; import "./Market.sol"; import "../external/univ3/LiquidityAmounts.sol"; +import "../libraries/Quote.sol"; import "forge-std/console2.sol"; library FAccount { @@ -74,135 +75,24 @@ library FAccount { return address(uint160(self.tokenId)); } - /* - function updateLoan( + function updateCollateral( Data storage self, - uint256 collateralAmount, - uint256 amount0, - uint256 amount1 + IERC20 collateralAsset, + uint256 amount ) internal { - self.collateralAmount += collateralAmount; - self.borrowedGwei += amount0; - self.borrowedGas += amount1; - } - -*/ - - struct RuntimeValidateParams { - uint160 sqrtPriceAX96; - uint160 sqrtPriceBX96; - } - - function validateProvidedLiquidity( - Data storage self, - Market.MarketParams memory marketParams, - uint128 liquidity, - int24 lowerTick, - int24 upperTick - ) internal { - RuntimeValidateParams memory params; - params.sqrtPriceAX96 = TickMath.getSqrtRatioAtTick(lowerTick); - params.sqrtPriceBX96 = TickMath.getSqrtRatioAtTick(upperTick); - - uint128 scaleFactor = 1e3; - - uint256 amountGasAtLowerTick = LiquidityAmounts.getAmount0ForLiquidity( - params.sqrtPriceAX96, - params.sqrtPriceBX96, - liquidity / scaleFactor - ) * uint256(scaleFactor); - console2.log("AMOUNT GAS AT LOWER TICK", amountGasAtLowerTick); - - uint256 amountGweiAtUpperTick = LiquidityAmounts.getAmount1ForLiquidity( - params.sqrtPriceAX96, - params.sqrtPriceBX96, - liquidity / scaleFactor - ) * uint256(scaleFactor); - - console2.log( - "AMOUNT GWEI AT UPPER TICK", - amountGweiAtUpperTick, - self.borrowedGwei - ); - console2.log("BORROWED GWEI", self.borrowedGwei); - console2.log("amountGasAtLowerTick", amountGasAtLowerTick); - - uint256 leftoverGweiAmountAtLowerTick = quoteGasToGwei( - amountGasAtLowerTick - self.borrowedGas, - marketParams.baseAssetMinPriceTick - ); - - console2.log( - "LEFTOVER GAS AMOUNT", - amountGasAtLowerTick - self.borrowedGas - ); - console2.log( - "LEFTOVER GWEI AMOUNT LOWER", - leftoverGweiAmountAtLowerTick, - leftoverGweiAmountAtLowerTick + self.collateralAmount - ); - - if ( - leftoverGweiAmountAtLowerTick + self.collateralAmount < - self.borrowedGwei - ) { - revert Errors.InsufficientCollateral(); - } - - uint256 availableGweiFromPosition = amountGweiAtUpperTick > - self.borrowedGwei - ? amountGweiAtUpperTick - self.borrowedGwei - : 0; - console2.log("AVAILABLE GWEI FROM POSITION", availableGweiFromPosition); - uint256 maxAvailableGasToPayLoan = quoteGweiToGas( - availableGweiFromPosition + self.collateralAmount, - marketParams.baseAssetMaxPriceTick - ); - - console2.log( - "MAX AVAILABLE GAS TO PAY LOAN", - maxAvailableGasToPayLoan, - self.borrowedGas - ); - - if (maxAvailableGasToPayLoan < self.borrowedGas) { - revert Errors.InsufficientCollateral(); - } - } - - // MOVE TO LIB - function quoteGweiToGas( - uint256 gweiAmount, - int24 priceTick - ) internal returns (uint256) { - uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(priceTick); - return - FullMath.mulDiv( - gweiAmount, - 1e18, - sqrtRatioX96ToPrice(sqrtRatioX96) + if (amount > self.collateralAmount) { + collateralAsset.transferFrom( + msg.sender, + address(this), + amount - self.collateralAmount ); - } - - function quoteGasToGwei( - uint256 gasAmount, - int24 priceTick - ) internal returns (uint256) { - uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(priceTick); - return - FullMath.mulDiv(gasAmount, sqrtRatioX96ToPrice(sqrtRatioX96), 1e18); - } - // should move to lib + } else { + collateralAsset.transfer( + msg.sender, + self.collateralAmount - amount + ); + } - // Function to convert sqrtRatioX96 to price - function sqrtRatioX96ToPrice( - uint160 sqrtRatioX96 - ) internal pure returns (uint256 price) { - // Calculate the price as (sqrtRatioX96^2) / (2^192) - uint256 sqrtRatioX96Squared = uint256(sqrtRatioX96) * - uint256(sqrtRatioX96); - price = sqrtRatioX96Squared >> 96; - // Scale price to have 18 decimal places - price = (price * 10 ** 18) / (2 ** 96); + self.collateralAmount = amount; } } diff --git a/packages/protocol/src/contracts/storage/Market.sol b/packages/protocol/src/contracts/storage/Market.sol index d8d3e09a..dda39d1a 100644 --- a/packages/protocol/src/contracts/storage/Market.sol +++ b/packages/protocol/src/contracts/storage/Market.sol @@ -11,7 +11,7 @@ import "../interfaces/external/ISwapRouter.sol"; import "./Errors.sol"; library Market { - struct MarketParams { + struct EpochParams { int24 baseAssetMinPriceTick; int24 baseAssetMaxPriceTick; uint24 feeRate; @@ -23,12 +23,12 @@ library Market { struct Data { address owner; - address collateralAsset; + IERC20 collateralAsset; INonfungiblePositionManager uniswapPositionManager; IUniswapV3Quoter uniswapQuoter; ISwapRouter uniswapSwapRouter; OptimisticOracleV3Interface optimisticOracleV3; - MarketParams marketParams; + EpochParams epochParams; } function load() internal pure returns (Data storage market) { @@ -46,7 +46,7 @@ library Market { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - MarketParams memory marketParams + EpochParams memory epochParams ) internal returns (Data storage market) { market = load(); @@ -59,7 +59,7 @@ library Market { } market.owner = owner; - market.collateralAsset = collateralAsset; + market.collateralAsset = IERC20(collateralAsset); market.uniswapPositionManager = INonfungiblePositionManager( uniswapPositionManager ); @@ -68,7 +68,7 @@ library Market { market.optimisticOracleV3 = OptimisticOracleV3Interface( optimisticOracleV3 ); - market.marketParams = marketParams; + market.epochParams = epochParams; } function updateValid( @@ -77,7 +77,7 @@ library Market { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - MarketParams memory marketParams + EpochParams memory epochParams ) internal returns (Data storage market) { market = load(); @@ -90,7 +90,7 @@ library Market { market.optimisticOracleV3 = OptimisticOracleV3Interface( optimisticOracleV3 ); - market.marketParams = marketParams; + market.epochParams = epochParams; } function loadValid() internal view returns (Data storage market) { diff --git a/packages/protocol/src/synthetix/interfaces/IERC20.sol b/packages/protocol/src/synthetix/interfaces/IERC20.sol index 90ee6301..acc497b3 100644 --- a/packages/protocol/src/synthetix/interfaces/IERC20.sol +++ b/packages/protocol/src/synthetix/interfaces/IERC20.sol @@ -19,7 +19,11 @@ interface IERC20 { * @param spender The address that received the allowance. * @param amount The number of tokens that were added to `spender`'s allowance. */ - event Approval(address indexed owner, address indexed spender, uint256 amount); + event Approval( + address indexed owner, + address indexed spender, + uint256 amount + ); /** * @notice Thrown when the address interacting with the contract does not have sufficient allowance to transfer tokens from another contract. @@ -72,7 +76,10 @@ interface IERC20 { * @param spender The user who was given the allowance. * @return The amount of tokens `spender` can transfer on `owner`'s behalf. */ - function allowance(address owner, address spender) external view returns (uint256); + function allowance( + address owner, + address spender + ) external view returns (uint256); /** * @notice Transfer tokens from one address to another. @@ -102,7 +109,10 @@ interface IERC20 { * * - `spender` cannot be the zero address. */ - function increaseAllowance(address spender, uint256 addedValue) external returns (bool); + function increaseAllowance( + address spender, + uint256 addedValue + ) external returns (bool); /** * @notice Atomically decreases the allowance granted to `spender` by the caller. @@ -118,7 +128,10 @@ interface IERC20 { * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ - function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool); + function decreaseAllowance( + address spender, + uint256 subtractedValue + ) external returns (bool); /** * @notice Allows a user who has been given allowance to transfer tokens on another user's behalf. @@ -127,5 +140,9 @@ interface IERC20 { * @param amount The number of tokens to transfer. * @return A boolean which is true if the operation succeeded. */ - function transferFrom(address from, address to, uint256 amount) external returns (bool); + function transferFrom( + address from, + address to, + uint256 amount + ) external returns (bool); } diff --git a/packages/protocol/test/Foil.t.sol b/packages/protocol/test/Foil.t.sol index 38111d75..b4103d31 100644 --- a/packages/protocol/test/Foil.t.sol +++ b/packages/protocol/test/Foil.t.sol @@ -5,10 +5,11 @@ import "forge-std/Test.sol"; import "cannon-std/Cannon.sol"; //import {Foil} from "../src/contracts/Foil.sol"; -import {IFoil} from "../src/contracts/interfaces/IFoil.sol"; +import {IEpochLiquidityModule} from "../src/contracts/interfaces/IEpochLiquidityModule.sol"; import {IFoilStructs} from "../src/contracts/interfaces/IFoilStructs.sol"; import {VirtualToken} from "../src/contracts/external/VirtualToken.sol"; import {TickMath} from "../src/contracts/external/univ3/TickMath.sol"; +import {IMintableToken} from "../src/contracts/external/IMintableToken.sol"; import "../src/contracts/interfaces/external/INonfungiblePositionManager.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol"; @@ -18,7 +19,7 @@ import "forge-std/console2.sol"; contract FoilTest is Test { using Cannon for Vm; - IFoil foil; + IEpochLiquidityModule foil; address constant foilAddress = 0xa886ec907D6529D8f7d0b74a181f709A6a5809fD; address pool; address tokenA; @@ -28,11 +29,20 @@ contract FoilTest is Test { 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6; uint256 constant EPOCH_START_TIME = 1722270000; + IMintableToken collateralAsset; + function setUp() public { - foil = IFoil(vm.getAddress("Foil")); + foil = IEpochLiquidityModule(vm.getAddress("Foil")); + collateralAsset = IMintableToken( + vm.getAddress("CollateralAsset.Token") + ); + collateralAsset.mint(1000 ether, address(this)); + collateralAsset.approve(address(foil), 1000 ether); } function test_addLiquidity() public { + console2.logAddress(address(this)); + console2.log("BALANCE", collateralAsset.balanceOf(address(this))); // int24 tickSpacing = IUniswapV3Pool(pool).tickSpacing(); // int24 lowerTick = TickMath.getTickAtSqrtRatio( // 177159557114295710296101716160 @@ -40,27 +50,55 @@ contract FoilTest is Test { // int24 upperTick = TickMath.getTickAtSqrtRatio( // 306849353968360525628702781967 // ); // 15 + uint160 sqrtPriceX96 = 146497135921788803112962621440; + uint160 sqrtPriceAX96 = 176318465955219228901572735582; + uint160 sqrtPriceBX96 = 273764932352251420676860998407; + (uint256 loanAmount0, uint256 loanAmount1, ) = foil.getTokenAmounts( + 50 ether, + sqrtPriceX96, + sqrtPriceAX96, + sqrtPriceBX96 + ); IFoilStructs.LiquidityPositionParams memory params = IFoilStructs .LiquidityPositionParams({ epochId: EPOCH_START_TIME, - amountTokenB: 1000 ether, - amountTokenA: 1000 ether, - collateralAmount: 100000 ether, - lowerTick: 12200, - upperTick: 12400, + amountTokenA: loanAmount0, + amountTokenB: loanAmount1, + collateralAmount: 50 ether, + lowerTick: 16000, + upperTick: 24800, minAmountTokenA: 0, minAmountTokenB: 0 }); - (uint256 tokenId, uint128 liquidity, , ) = foil.createLiquidityPosition( - params - ); + ( + uint256 tokenId, + uint128 liquidity, + uint256 amount0, + uint256 amount1 + ) = foil.createLiquidityPosition(params); + + assertEq(collateralAsset.balanceOf(address(foil)), 50 ether); + + uint128 halfLiquidity = liquidity / 2; + uint256 coll = 25 ether; + + foil.decreaseLiquidityPosition(tokenId, coll, halfLiquidity, 0, 0); - // uint128 halfLiquidity = liquidity / 2; - // uint256 coll = 10 ether; + assertEq(collateralAsset.balanceOf(address(foil)), 25 ether); - // console2.log(tokenId, halfLiquidity); - // foil.updateLiquidityPosition(tokenId, coll, halfLiquidity); + coll = 500 ether; + + foil.increaseLiquidityPosition( + tokenId, + coll, + amount0 * 2, + amount1 * 2, + 0, + 0 + ); + + assertEq(collateralAsset.balanceOf(address(foil)), 500 ether); // (uint256 tokenAmount0, uint256 tokenAmount1) = foil.getPosition(1); // console2.log(tokenAmount0, tokenAmount1); @@ -131,37 +169,37 @@ contract FoilTest is Test { // // console2.log("TRADED after settle 2", tradedAmoun0, tradedAmount2); // } - function getAndLogPosition(uint256 positionId) public { - ( - uint96 nonce, - address operator, - address token0, - address token1, - uint24 fee, - int24 tickLower, - int24 tickUpper, - uint128 liquidity, - uint256 feeGrowthInside0LastX128, - uint256 feeGrowthInside1LastX128, - uint128 tokensOwed0, - uint128 tokensOwed1 - ) = foil.getPosition(positionId); - - console2.log("START POSITION", positionId); - console2.log(" nonce : ", nonce); - console2.log(" operator : ", operator); - console2.log(" token0 : ", token0); - console2.log(" token1 : ", token1); - console2.log(" fee : ", fee); - console2.log(" tickLower : ", tickLower); - console2.log(" tickUpper : ", tickUpper); - console2.log(" liquidity : ", liquidity); - console2.log(" feeGrowthInside0LastX128 : ", feeGrowthInside0LastX128); - console2.log(" feeGrowthInside1LastX128 : ", feeGrowthInside1LastX128); - console2.log(" tokensOwed0 : ", tokensOwed0); - console2.log(" tokensOwed1 : ", tokensOwed1); - console2.log("END POSITION", positionId); - } + // function getAndLogPosition(uint256 positionId) public { + // ( + // uint96 nonce, + // address operator, + // address token0, + // address token1, + // uint24 fee, + // int24 tickLower, + // int24 tickUpper, + // uint128 liquidity, + // uint256 feeGrowthInside0LastX128, + // uint256 feeGrowthInside1LastX128, + // uint128 tokensOwed0, + // uint128 tokensOwed1 + // ) = foil.getPosition(positionId); + + // console2.log("START POSITION", positionId); + // console2.log(" nonce : ", nonce); + // console2.log(" operator : ", operator); + // console2.log(" token0 : ", token0); + // console2.log(" token1 : ", token1); + // console2.log(" fee : ", fee); + // console2.log(" tickLower : ", tickLower); + // console2.log(" tickUpper : ", tickUpper); + // console2.log(" liquidity : ", liquidity); + // console2.log(" feeGrowthInside0LastX128 : ", feeGrowthInside0LastX128); + // console2.log(" feeGrowthInside1LastX128 : ", feeGrowthInside1LastX128); + // console2.log(" tokensOwed0 : ", tokensOwed0); + // console2.log(" tokensOwed1 : ", tokensOwed1); + // console2.log("END POSITION", positionId); + // } // function test_addLiquidityAndLongs() public { // int24 tickSpacing = IUniswapV3Pool(pool).tickSpacing(); // // int24 lowerTick = TickMath.getTickAtSqrtRatio(