diff --git a/packages/protocol/deployments/BondCurrency.Token.json b/packages/protocol/deployments/BondCurrency.Token.json new file mode 100644 index 00000000..033d6307 --- /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": "1722617313", + "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..c413008f --- /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": "1722617313", + "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..c5a19fd2 --- /dev/null +++ b/packages/protocol/deployments/EpochConfigurationModule.json @@ -0,0 +1,413 @@ +{ + "address": "0xceE20f985915a3e218Cc2ABf99F41EAe8C5b4911", + "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": "marketParams", + "type": "tuple", + "internalType": "struct Market.MarketParams", + "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": "marketParams", + "type": "tuple", + "internalType": "struct Market.MarketParams", + "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": "marketParams", + "type": "tuple", + "internalType": "struct Market.MarketParams", + "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": "ReentrancyGuardReentrantCall", + "inputs": [] + }, + { + "type": "error", + "name": "TokensAlreadyCreated", + "inputs": [] + } + ], + "constructorArgs": [], + "linkedLibraries": {}, + "deployTxnHash": "0x3160f02190eb9f29f74ed54e7da02cae4054d74b954cde1dc1de10b1b520ffdc", + "deployTxnBlockNumber": "3", + "deployTimestamp": "1722617310", + "sourceName": "src/contracts/modules/EpochConfigurationModule.sol", + "contractName": "EpochConfigurationModule", + "deployedOn": "deploy.EpochConfigurationModule", + "gasUsed": 2031440, + "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..50c7b32e --- /dev/null +++ b/packages/protocol/deployments/EpochLiquidityModule.json @@ -0,0 +1,418 @@ +{ + "address": "0x408f9283b88015D6B3CfC2cB42168028058adEdb", + "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": "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": "0x5a22ace2d9158dab44ada65eb0da03a939b27a3db8495a1a03bef590e963cc98", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722617309", + "sourceName": "src/contracts/modules/EpochLiquidityModule.sol", + "contractName": "EpochLiquidityModule", + "deployedOn": "deploy.EpochLiquidityModule", + "gasUsed": 2118814, + "gasCost": "1004750543" +} \ 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..fcbb8d20 --- /dev/null +++ b/packages/protocol/deployments/EpochTradeModule.json @@ -0,0 +1,173 @@ +{ + "address": "0x5f62BeB4EFaBdC3B1442ECB3Fad61ED9E1645a4f", + "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": "0xdf736b5d22ac235c47ab4c9e170ee5fff3eb11bfa4d541b92dcf883b3a269f9f", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722617309", + "sourceName": "src/contracts/modules/EpochTradeModule.sol", + "contractName": "EpochTradeModule", + "deployedOn": "deploy.EpochTradeModule", + "gasUsed": 1832691, + "gasCost": "1004240605" +} \ 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..c89bd2cc --- /dev/null +++ b/packages/protocol/deployments/EpochUMASettlementModule.json @@ -0,0 +1,153 @@ +{ + "address": "0xBcC26CeDc5Fa94bc40Bde5247712651FEEDEf693", + "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": "0x3fe24d0bfb5bc2b1699ffba5fd0921f5edcaf32baebb10e3208e03b7f3188501", + "deployTxnBlockNumber": "1", + "deployTimestamp": "1722617309", + "sourceName": "src/contracts/modules/EpochUMASettlementModule.sol", + "contractName": "EpochUMASettlementModule", + "deployedOn": "deploy.EpochUMASettlementModule", + "gasUsed": 766508, + "gasCost": "1003775294" +} \ 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..4affd057 --- /dev/null +++ b/packages/protocol/deployments/Foil.json @@ -0,0 +1,1446 @@ +{ + "address": "0x9661c9974af455b816d6d2a21788c55ebd23105d", + "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": "marketParams", + "type": "tuple", + "internalType": "struct Market.MarketParams", + "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": "marketParams", + "type": "tuple", + "internalType": "struct Market.MarketParams", + "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": "marketParams", + "type": "tuple", + "internalType": "struct Market.MarketParams", + "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": "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": "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": "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": "0xbab1cc68c0d6f5723935ac40b9facdc3cdb6ee33052e1b7e14c39c9325b7cdb1", + "deployTxnBlockNumber": "3", + "deployTimestamp": "1722617314", + "contractName": "Foil", + "sourceName": "Foil.sol", + "gasUsed": 439977, + "gasCost": "1001706705" +} \ 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..f4754dcd --- /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": "1722617309", + "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..d94efd77 --- /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": "1722617311", + "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..53540ce5 --- /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": "1722617309", + "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..c41afeed --- /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": "1722617311", + "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..8f68dae5 --- /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": "1722617310", + "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..65174314 --- /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": "1722617310", + "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..e81f4f3a --- /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": "1722617310", + "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..03fcd866 --- /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": "1722617313", + "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..d48b8db0 --- /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": "1722617311", + "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..d7a2ecb7 --- /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": "1722617312", + "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..59122f88 --- /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": "1722617314", + "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..6001b697 --- /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": "1722617310", + "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..dee6bedb 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": "1722617324", "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..207636b6 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": "1722617324", "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..c5a19fd2 100644 --- a/packages/protocol/deployments/test/EpochConfigurationModule.json +++ b/packages/protocol/deployments/test/EpochConfigurationModule.json @@ -1,5 +1,5 @@ { - "address": "0x2445D612DC7b535332FCAD0B1b1300De90b2aB36", + "address": "0xceE20f985915a3e218Cc2ABf99F41EAe8C5b4911", "abi": [ { "type": "function", @@ -402,12 +402,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x4f1d2d85a972dbb30b722461f5c20d97998c4fd6b0431aa697a43267a0e675ec", + "deployTxnHash": "0x3160f02190eb9f29f74ed54e7da02cae4054d74b954cde1dc1de10b1b520ffdc", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722385871", + "deployTimestamp": "1722617310", "sourceName": "src/contracts/modules/EpochConfigurationModule.sol", "contractName": "EpochConfigurationModule", "deployedOn": "deploy.EpochConfigurationModule", - "gasUsed": 2031872, + "gasUsed": 2031440, "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..50c7b32e 100644 --- a/packages/protocol/deployments/test/EpochLiquidityModule.json +++ b/packages/protocol/deployments/test/EpochLiquidityModule.json @@ -1,5 +1,5 @@ { - "address": "0x2f816f52cD9c1ed34e3Ae10eEeC0c961E112aEF0", + "address": "0x408f9283b88015D6B3CfC2cB42168028058adEdb", "abi": [ { "type": "function", @@ -94,142 +94,171 @@ "internalType": "uint256" } ], - "stateMutability": "payable" + "stateMutability": "nonpayable" }, { "type": "function", - "name": "getPosition", + "name": "decreaseLiquidityPosition", "inputs": [ { - "name": "positionId", + "name": "accountId", "type": "uint256", "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "nonce", - "type": "uint96", - "internalType": "uint96" }, { - "name": "operator", - "type": "address", - "internalType": "address" + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "token0", - "type": "address", - "internalType": "address" + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" }, { - "name": "token1", - "type": "address", - "internalType": "address" + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "fee", - "type": "uint24", - "internalType": "uint24" - }, + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ { - "name": "tickLower", - "type": "int24", - "internalType": "int24" + "name": "amount0", + "type": "uint256", + "internalType": "uint256" }, { - "name": "tickUpper", - "type": "int24", - "internalType": "int24" - }, + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getPosition", + "inputs": [ { - "name": "liquidity", - "type": "uint128", - "internalType": "uint128" - }, + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ { - "name": "feeGrowthInside0LastX128", + "name": "tokenId", "type": "uint256", "internalType": "uint256" }, { - "name": "feeGrowthInside1LastX128", + "name": "collateralAmount", "type": "uint256", "internalType": "uint256" }, { - "name": "tokensOwed0", - "type": "uint128", - "internalType": "uint128" + "name": "borrowedGwei", + "type": "uint256", + "internalType": "uint256" }, { - "name": "tokensOwed1", - "type": "uint128", - "internalType": "uint128" + "name": "borrowedGas", + "type": "uint256", + "internalType": "uint256" } ], "stateMutability": "view" }, { "type": "function", - "name": "onERC721Received", + "name": "getTokenAmounts", "inputs": [ { - "name": "operator", - "type": "address", - "internalType": "address" + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "", - "type": "address", - "internalType": "address" + "name": "sqrtPriceX96", + "type": "uint160", + "internalType": "uint160" }, { - "name": "tokenId", - "type": "uint256", - "internalType": "uint256" + "name": "sqrtPriceAX96", + "type": "uint160", + "internalType": "uint160" }, { - "name": "", - "type": "bytes", - "internalType": "bytes" + "name": "sqrtPriceBX96", + "type": "uint160", + "internalType": "uint160" } ], "outputs": [ { - "name": "", - "type": "bytes4", - "internalType": "bytes4" + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" } ], - "stateMutability": "nonpayable" + "stateMutability": "view" }, { "type": "function", - "name": "updateLiquidityPosition", + "name": "increaseLiquidityPosition", "inputs": [ { - "name": "tokenId", + "name": "accountId", "type": "uint256", "internalType": "uint256" }, { - "name": "collateral", + "name": "collateralAmount", "type": "uint256", "internalType": "uint256" }, { - "name": "liquidity", - "type": "uint128", - "internalType": "uint128" + "name": "gasTokenAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "ethTokenAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "minLiquidity", + "name": "minEthAmount", "type": "uint256", "internalType": "uint256" } ], "outputs": [ + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" + }, { "name": "amount0", "type": "uint256", @@ -241,7 +270,41 @@ "internalType": "uint256" } ], - "stateMutability": "payable" + "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", @@ -276,7 +339,18 @@ { "type": "error", "name": "InsufficientCollateral", - "inputs": [] + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateral", + "type": "uint256", + "internalType": "uint256" + } + ] }, { "type": "error", @@ -333,12 +407,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x4ec8bf490bc87cea051894e6eeda7f778f6f13c6ddae42eb7c59318c980b9835", + "deployTxnHash": "0x5a22ace2d9158dab44ada65eb0da03a939b27a3db8495a1a03bef590e963cc98", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722272465", + "deployTimestamp": "1722617309", "sourceName": "src/contracts/modules/EpochLiquidityModule.sol", "contractName": "EpochLiquidityModule", "deployedOn": "deploy.EpochLiquidityModule", - "gasUsed": 1903984, - "gasCost": "1004158597" + "gasUsed": 2118814, + "gasCost": "1004750543" } \ 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..fcbb8d20 100644 --- a/packages/protocol/deployments/test/EpochTradeModule.json +++ b/packages/protocol/deployments/test/EpochTradeModule.json @@ -1,5 +1,5 @@ { - "address": "0xc617352aCE1AaEA7CD936870b47D330e19246DA4", + "address": "0x5f62BeB4EFaBdC3B1442ECB3Fad61ED9E1645a4f", "abi": [ { "type": "function", @@ -162,12 +162,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x2fa390e9e1f67bd65791fa9bbac6e62ec47a1dbe1eef4cdd30f8bbe559075dfa", + "deployTxnHash": "0xdf736b5d22ac235c47ab4c9e170ee5fff3eb11bfa4d541b92dcf883b3a269f9f", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722385870", + "deployTimestamp": "1722617309", "sourceName": "src/contracts/modules/EpochTradeModule.sol", "contractName": "EpochTradeModule", "deployedOn": "deploy.EpochTradeModule", - "gasUsed": 1829463, - "gasCost": "1004750562" + "gasUsed": 1832691, + "gasCost": "1004240605" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/EpochUMASettlementModule.json b/packages/protocol/deployments/test/EpochUMASettlementModule.json index 90ebf26d..c89bd2cc 100644 --- a/packages/protocol/deployments/test/EpochUMASettlementModule.json +++ b/packages/protocol/deployments/test/EpochUMASettlementModule.json @@ -1,5 +1,5 @@ { - "address": "0x908F7a0B23f28c593255ECf1d3e9dD845f881b5c", + "address": "0xBcC26CeDc5Fa94bc40Bde5247712651FEEDEf693", "abi": [ { "type": "function", @@ -142,12 +142,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0xc5fd90940a289505a5dd22a3ae93711d2c80479531d3e23fc132188ec0ecfd08", + "deployTxnHash": "0x3fe24d0bfb5bc2b1699ffba5fd0921f5edcaf32baebb10e3208e03b7f3188501", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722272465", + "deployTimestamp": "1722617309", "sourceName": "src/contracts/modules/EpochUMASettlementModule.sol", "contractName": "EpochUMASettlementModule", "deployedOn": "deploy.EpochUMASettlementModule", - "gasUsed": 762618, - "gasCost": "1002925078" + "gasUsed": 766508, + "gasCost": "1003775294" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/Foil.json b/packages/protocol/deployments/test/Foil.json index 06b67639..4affd057 100644 --- a/packages/protocol/deployments/test/Foil.json +++ b/packages/protocol/deployments/test/Foil.json @@ -1,5 +1,5 @@ { - "address": "0xcab1bcff7f537afd4065dbf4b1f175ab046a8eda", + "address": "0x9661c9974af455b816d6d2a21788c55ebd23105d", "abi": [ { "type": "function", @@ -492,142 +492,171 @@ "internalType": "uint256" } ], - "stateMutability": "payable" + "stateMutability": "nonpayable" }, { "type": "function", - "name": "getPosition", + "name": "decreaseLiquidityPosition", "inputs": [ { - "name": "positionId", + "name": "accountId", "type": "uint256", "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "nonce", - "type": "uint96", - "internalType": "uint96" }, { - "name": "operator", - "type": "address", - "internalType": "address" + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "token0", - "type": "address", - "internalType": "address" + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" }, { - "name": "token1", - "type": "address", - "internalType": "address" + "name": "minGasAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "fee", - "type": "uint24", - "internalType": "uint24" - }, + "name": "minEthAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ { - "name": "tickLower", - "type": "int24", - "internalType": "int24" + "name": "amount0", + "type": "uint256", + "internalType": "uint256" }, { - "name": "tickUpper", - "type": "int24", - "internalType": "int24" - }, + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getPosition", + "inputs": [ { - "name": "liquidity", - "type": "uint128", - "internalType": "uint128" - }, + "name": "accountId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ { - "name": "feeGrowthInside0LastX128", + "name": "tokenId", "type": "uint256", "internalType": "uint256" }, { - "name": "feeGrowthInside1LastX128", + "name": "collateralAmount", "type": "uint256", "internalType": "uint256" }, { - "name": "tokensOwed0", - "type": "uint128", - "internalType": "uint128" + "name": "borrowedGwei", + "type": "uint256", + "internalType": "uint256" }, { - "name": "tokensOwed1", - "type": "uint128", - "internalType": "uint128" + "name": "borrowedGas", + "type": "uint256", + "internalType": "uint256" } ], "stateMutability": "view" }, { "type": "function", - "name": "onERC721Received", + "name": "getTokenAmounts", "inputs": [ { - "name": "operator", - "type": "address", - "internalType": "address" + "name": "collateralAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "", - "type": "address", - "internalType": "address" + "name": "sqrtPriceX96", + "type": "uint160", + "internalType": "uint160" }, { - "name": "tokenId", - "type": "uint256", - "internalType": "uint256" + "name": "sqrtPriceAX96", + "type": "uint160", + "internalType": "uint160" }, { - "name": "", - "type": "bytes", - "internalType": "bytes" + "name": "sqrtPriceBX96", + "type": "uint160", + "internalType": "uint160" } ], "outputs": [ { - "name": "", - "type": "bytes4", - "internalType": "bytes4" + "name": "amount0", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "internalType": "uint128" } ], - "stateMutability": "nonpayable" + "stateMutability": "view" }, { "type": "function", - "name": "updateLiquidityPosition", + "name": "increaseLiquidityPosition", "inputs": [ { - "name": "tokenId", + "name": "accountId", "type": "uint256", "internalType": "uint256" }, { - "name": "collateral", + "name": "collateralAmount", "type": "uint256", "internalType": "uint256" }, { - "name": "liquidity", - "type": "uint128", - "internalType": "uint128" + "name": "gasTokenAmount", + "type": "uint256", + "internalType": "uint256" }, { - "name": "minLiquidity", + "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", @@ -639,7 +668,41 @@ "internalType": "uint256" } ], - "stateMutability": "payable" + "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", @@ -674,7 +737,18 @@ { "type": "error", "name": "InsufficientCollateral", - "inputs": [] + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateral", + "type": "uint256", + "internalType": "uint256" + } + ] }, { "type": "error", @@ -1362,11 +1436,11 @@ } ], "deployedOn": "router.Foil", - "deployTxnHash": "0xee19df8e37e8c5f84551ff8d60cfc90271bdbd8b665400ca55b15eeeb1caa2b2", + "deployTxnHash": "0xbab1cc68c0d6f5723935ac40b9facdc3cdb6ee33052e1b7e14c39c9325b7cdb1", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722385875", + "deployTimestamp": "1722617314", "contractName": "Foil", "sourceName": "Foil.sol", - "gasUsed": 423046, - "gasCost": "1002169180" + "gasUsed": 439977, + "gasCost": "1001706705" } \ 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..2b80cad8 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": "1722617320", "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..276b1f18 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": "1722617322", "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..8d1ff50a 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": "1722617320", "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..b414eea1 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": "1722617322", "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..c0e1ce41 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": "1722617321", "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..9464b5ac 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": "1722617321", "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..c403c191 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": "1722617321", "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..917b1804 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": "1722617324", "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..2e34fda7 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": "1722617322", "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..4da765ab 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": "1722617323", "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..f0418926 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": "1722617325", "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..3a63a690 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": "1722617321", "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/interfaces/IEpochLiquidityModule.sol b/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol new file mode 100644 index 00000000..2bca9a28 --- /dev/null +++ b/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.2 <0.9.0; + +import {IFoilStructs} from "./IFoilStructs.sol"; + +interface IEpochLiquidityModule { + 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 7200afef..2064170e 100644 --- a/packages/protocol/src/contracts/interfaces/IFoil.sol +++ b/packages/protocol/src/contracts/interfaces/IFoil.sol @@ -4,8 +4,9 @@ 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() external view @@ -28,65 +29,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 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..0aa31bee --- /dev/null +++ b/packages/protocol/src/contracts/libraries/Quote.sol @@ -0,0 +1,38 @@ +// 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, + int24 tick + ) internal pure returns (uint256) { + uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick); + return + FullMath.mulDiv(ethAmount, 1e18, sqrtRatioX96ToPrice(sqrtRatioX96)); + } + + function quoteGasToEth( + uint256 gasAmount, + int24 tick + ) internal pure returns (uint256) { + uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick); + 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/EpochLiquidityModule.sol b/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol index 376e562f..b50dfffd 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, @@ -69,18 +71,12 @@ 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 } function onERC721Received( @@ -98,7 +94,7 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { function collectFees( 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(); @@ -120,44 +116,25 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { // TODO: emit event } - 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 - ) - { - Market.Data storage market = Market.load(); - return market.uniswapPositionManager.positions(positionId); - } - - function updateLiquidityPosition( - uint256 tokenId, - uint256 collateral, + function decreaseLiquidityPosition( + uint256 accountId, + uint256 collateralAmount, 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) { + console2.log("--DECREASE LIQ POSITION--"); Market.Data storage market = Market.load(); - Epoch.Data storage epoch = Epoch.load(); + FAccount.Data storage account = FAccount.load(accountId); + + (, , , , , int24 lowerTick, int24 upperTick, , , , , ) = market + .uniswapPositionManager + .positions(account.tokenId); INonfungiblePositionManager.DecreaseLiquidityParams memory decreaseParams = INonfungiblePositionManager .DecreaseLiquidityParams({ - tokenId: tokenId, + tokenId: account.tokenId, liquidity: liquidity, amount0Min: 0, amount1Min: 0, @@ -167,89 +144,107 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { (amount0, amount1) = market.uniswapPositionManager.decreaseLiquidity( decreaseParams ); - console2.log("REMOVED", amount0, amount1); + + console2.log("DECREASED AMTS", amount0, amount1, liquidity); + + account.updateLoan(account.tokenId, collateralAmount, amount0, amount1); + Epoch.load().validateProvidedLiquidity( + collateralAmount, + liquidity, + lowerTick, + upperTick + ); + + // 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) { + console2.log("--INCREASE LIQ POSITION--"); + Market.Data storage market = Market.load(); + FAccount.Data storage account = FAccount.load(accountId); + + (, , , , , int24 lowerTick, int24 upperTick, , , , , ) = market + .uniswapPositionManager + .positions(account.tokenId); + + 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 + ); + } + + 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 + ); + + uint256 collateralRatio = collateralAmount / requiredCollateral; + + // scale up liquidity by collateral amount + return ( + unitAmount0 * collateralRatio, + uintAmount1 * collateralRatio, + uint128(unitLiquidity * collateralRatio) + ); } - // 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, @@ -265,5 +260,4 @@ contract EpochLiquidityModule is ReentrancyGuard, IERC721Receiver { account.borrowedGas ); } -*/ } diff --git a/packages/protocol/src/contracts/storage/Epoch.sol b/packages/protocol/src/contracts/storage/Epoch.sol index d15d1e0b..68522478 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"; @@ -198,6 +200,138 @@ library Epoch { } } + function validateProvidedLiquidity( + Data storage self, + uint256 collateralAmount, + uint128 liquidity, + int24 lowerTick, + int24 upperTick + ) internal { + uint160 sqrtPriceAX96 = TickMath.getSqrtRatioAtTick(lowerTick); + uint160 sqrtPriceBX96 = TickMath.getSqrtRatioAtTick(upperTick + 1); + + (uint160 sqrtPriceX96, , , , , , ) = self.pool.slot0(); + + uint128 scaleFactor = 8; + ( + uint256 requiredCollateral, + uint256 tokenAmountA, + uint256 tokenAmountB + ) = requiredCollateralForLiquidity( + self, + liquidity / scaleFactor, + sqrtPriceX96, + sqrtPriceAX96, + sqrtPriceBX96 + ); + + 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.marketParams.baseAssetMinPriceTick + ); + 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.marketParams.baseAssetMaxPriceTick + ); + + uint256 amount0LoanLeftover = loanAmount0 - availableAmount0; + return + Quote.quoteGasToEth( + amount0LoanLeftover, + self.marketParams.baseAssetMaxPriceTick + ); + } + // 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 d722cebe..235e4080 100644 --- a/packages/protocol/src/contracts/storage/Errors.sol +++ b/packages/protocol/src/contracts/storage/Errors.sol @@ -23,6 +23,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..38b43966 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,97 @@ library FAccount { return address(uint160(self.tokenId)); } - /* - function updateLoan( - Data storage self, - uint256 collateralAmount, - uint256 amount0, - uint256 amount1 - ) 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) - ); - } - - 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 - - // 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); - } + // function validateProvidedLiquidity( + // Data storage self, + // Ep, + // uint128 liquidity, + // int24 lowerTick, + // int24 upperTick + // ) internal { + // RuntimeValidateParams memory params; + // add +1 + + // uint128 scaleFactor = 1e3; + + // uint256 amountGasAtLowerTick = LiquidityAmounts.getAmount0ForLiquidity( + // params.sqrtPriceAX96, + // params.sqrtPriceBX96, + // liquidity / scaleFactor + // ) * uint256(scaleFactor); + // console2.log("AMOUNT GAS AT LOWER TICK", amountGasAtLowerTick); + + // // 5 - 30 + // // at price 5: X amt of GAS, 0 GWEI + + // uint256 amountGweiAtUpperTick = LiquidityAmounts.getAmount1ForLiquidity( + // params.sqrtPriceAX96, + // params.sqrtPriceBX96, + // liquidity / scaleFactor + // ) * uint256(scaleFactor); + + // // 5 - 30 + // // at price 30: 0 of GAS, X amt GWEI + + // console2.log( + // "AMOUNT GWEI AT UPPER TICK", + // amountGweiAtUpperTick, + // self.borrowedGwei + // ); + // console2.log("BORROWED GWEI", self.borrowedGwei); + // console2.log("amountGasAtLowerTic", amountGasAtLowerTick); + + // uint256 leftoverGweiAmountAtLowerTick; + // if (amountGasAtLowerTick > self.borrowedGas) { + // console2.log("INIF", amountGasAtLowerTick, self.borrowedGas); + // leftoverGweiAmountAtLowerTick = Quote.quoteGasToEth( + // amountGasAtLowerTick - self.borrowedGas, + // marketParams.baseAssetMinPriceTick + // ); + // } + + // // 5 - 30 + // // loan is 25 GAS, 100 GWEI + // // at price 5: 50 amt of GAS, 0 GWEI + // // borrowed 25, 50 - 25 = 25 + // // 25 -> 25 * 1.7 = 42.5 + 50 = 92 + + // console2.log("LEFTOVER GAS AMOUNT", leftoverGweiAmountAtLowerTick); + // 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 = Quote.quoteEthToGas( + // availableGweiFromPosition + self.collateralAmount, + // marketParams.baseAssetMaxPriceTick + // ); + + // console2.log( + // "MAX AVAILABLE GAS TO PAY LOAN", + // maxAvailableGasToPayLoan, + // self.borrowedGas + // ); + + // if (maxAvailableGasToPayLoan < self.borrowedGas) { + // revert Errors.InsufficientCollateral(); + // } + // } } diff --git a/packages/protocol/test/Foil.t.sol b/packages/protocol/test/Foil.t.sol index b4b1dafe..c20f66c9 100644 --- a/packages/protocol/test/Foil.t.sol +++ b/packages/protocol/test/Foil.t.sol @@ -5,7 +5,7 @@ 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"; @@ -18,7 +18,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,7 +28,7 @@ contract FoilTest is Test { 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6; function setUp() public { - foil = IFoil(vm.getAddress("Foil")); + foil = IEpochLiquidityModule(vm.getAddress("Foil")); } function test_addLiquidity() public { @@ -39,26 +39,48 @@ contract FoilTest is Test { // int24 upperTick = TickMath.getTickAtSqrtRatio( // 306849353968360525628702781967 // ); // 15 + uint160 sqrtPriceX96 = 146497135921788803112962621440; + uint160 sqrtPriceAX96 = 111309523877349767887238162754; // 6800 + uint160 sqrtPriceBX96 = 250203434948259642083317319084; // 23000 + (uint256 loanAmount0, uint256 loanAmount1, ) = foil.getTokenAmounts( + 50 ether, + sqrtPriceX96, + sqrtPriceAX96, + sqrtPriceBX96 + ); IFoilStructs.LiquidityPositionParams memory params = IFoilStructs .LiquidityPositionParams({ - amountTokenB: 1000 ether, - amountTokenA: 1000 ether, - collateralAmount: 100000 ether, - lowerTick: 12200, - upperTick: 12400, + amountTokenA: loanAmount0, + amountTokenB: loanAmount1, + collateralAmount: 50 ether, + lowerTick: 6800, + upperTick: 23000, minAmountTokenA: 0, minAmountTokenB: 0 }); - (uint256 tokenId, uint128 liquidity, , ) = foil.createLiquidityPosition( - params - ); + ( + uint256 tokenId, + uint128 liquidity, + uint256 amount0, + uint256 amount1 + ) = foil.createLiquidityPosition(params); + + uint128 halfLiquidity = liquidity / 2; + uint256 coll = 25 ether; + + foil.decreaseLiquidityPosition(tokenId, coll, halfLiquidity, 0, 0); - // uint128 halfLiquidity = liquidity / 2; - // uint256 coll = 10 ether; + coll = 500 ether; - // console2.log(tokenId, halfLiquidity); - // foil.updateLiquidityPosition(tokenId, coll, halfLiquidity); + foil.increaseLiquidityPosition( + tokenId, + coll, + amount0 * 2, + amount1 * 2, + 0, + 0 + ); // (uint256 tokenAmount0, uint256 tokenAmount1) = foil.getPosition(1); // console2.log(tokenAmount0, tokenAmount1); @@ -129,37 +151,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(