diff --git a/packages/protocol/deployments/BondCurrency.Token.json b/packages/protocol/deployments/BondCurrency.Token.json index 033d6307..fd14bc45 100644 --- a/packages/protocol/deployments/BondCurrency.Token.json +++ b/packages/protocol/deployments/BondCurrency.Token.json @@ -319,7 +319,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x12ee0b194db4db0157edc1ecd4711e1b128110b845c2232c6b427b5749ddc7a5", "deployTxnBlockNumber": "2", - "deployTimestamp": "1722617313", + "deployTimestamp": "1722754532", "sourceName": "src/MintableTokenPermissionlessMint.sol", "contractName": "MintableTokenPermissionlessMint", "deployedOn": "contract.Token", diff --git a/packages/protocol/deployments/CollateralAsset.Token.json b/packages/protocol/deployments/CollateralAsset.Token.json index c413008f..ca0248bb 100644 --- a/packages/protocol/deployments/CollateralAsset.Token.json +++ b/packages/protocol/deployments/CollateralAsset.Token.json @@ -319,7 +319,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x6add4be37a653aaf5ba967fc8163d59e33e29d487ad632af66209495e5d42051", "deployTxnBlockNumber": "2", - "deployTimestamp": "1722617313", + "deployTimestamp": "1722754532", "sourceName": "src/MintableTokenPermissionlessMint.sol", "contractName": "MintableTokenPermissionlessMint", "deployedOn": "contract.Token", diff --git a/packages/protocol/deployments/EpochConfigurationModule.json b/packages/protocol/deployments/EpochConfigurationModule.json index c5a19fd2..da26501e 100644 --- a/packages/protocol/deployments/EpochConfigurationModule.json +++ b/packages/protocol/deployments/EpochConfigurationModule.json @@ -1,5 +1,5 @@ { - "address": "0xceE20f985915a3e218Cc2ABf99F41EAe8C5b4911", + "address": "0xDD59E99E336FF485ec3C8420dd7CE128F1b806e3", "abi": [ { "type": "function", @@ -134,9 +134,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -254,9 +254,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -329,9 +329,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParms", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -389,6 +389,11 @@ "name": "MarketAlreadyCreated", "inputs": [] }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, { "type": "error", "name": "ReentrancyGuardReentrantCall", @@ -402,12 +407,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x3160f02190eb9f29f74ed54e7da02cae4054d74b954cde1dc1de10b1b520ffdc", + "deployTxnHash": "0xb3d7b11ccdbb240b670d6d65fa796bfc2f4cfc9818293378496c36e2add84036", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617310", + "deployTimestamp": "1722754340", "sourceName": "src/contracts/modules/EpochConfigurationModule.sol", "contractName": "EpochConfigurationModule", "deployedOn": "deploy.EpochConfigurationModule", - "gasUsed": 2031440, + "gasUsed": 2256590, "gasCost": "1005326146" } \ No newline at end of file diff --git a/packages/protocol/deployments/EpochLiquidityModule.json b/packages/protocol/deployments/EpochLiquidityModule.json index 50c7b32e..88056d1e 100644 --- a/packages/protocol/deployments/EpochLiquidityModule.json +++ b/packages/protocol/deployments/EpochLiquidityModule.json @@ -1,5 +1,5 @@ { - "address": "0x408f9283b88015D6B3CfC2cB42168028058adEdb", + "address": "0x7C244D9661bF634ca8909C4058924513f30CE6C0", "abi": [ { "type": "function", @@ -306,6 +306,93 @@ ], "stateMutability": "nonpayable" }, + { + "type": "event", + "name": "LiquidityPositionCreated", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "addedAmount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "addedAmount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionDecreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionIncreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, { "type": "event", "name": "Transfer", @@ -407,12 +494,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x5a22ace2d9158dab44ada65eb0da03a939b27a3db8495a1a03bef590e963cc98", + "deployTxnHash": "0xc422f47a846c7efdfc6439b4363a85d3054f52a81d1c8e50fd57fbadc24221e9", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617309", + "deployTimestamp": "1722754422", "sourceName": "src/contracts/modules/EpochLiquidityModule.sol", "contractName": "EpochLiquidityModule", "deployedOn": "deploy.EpochLiquidityModule", - "gasUsed": 2118814, - "gasCost": "1004750543" + "gasUsed": 2132620, + "gasCost": "1006087024" } \ No newline at end of file diff --git a/packages/protocol/deployments/EpochTradeModule.json b/packages/protocol/deployments/EpochTradeModule.json index fcbb8d20..9f6cb9a0 100644 --- a/packages/protocol/deployments/EpochTradeModule.json +++ b/packages/protocol/deployments/EpochTradeModule.json @@ -1,5 +1,5 @@ { - "address": "0x5f62BeB4EFaBdC3B1442ECB3Fad61ED9E1645a4f", + "address": "0x33ad0458323a7b02dC054943EBf4fC0a27aab7D2", "abi": [ { "type": "function", @@ -162,12 +162,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0xdf736b5d22ac235c47ab4c9e170ee5fff3eb11bfa4d541b92dcf883b3a269f9f", + "deployTxnHash": "0xb8082e21b44eb7833bb45a2939ea36f9bbbdd9fa05aada3dd1f95c61a35586d1", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617309", + "deployTimestamp": "1722754339", "sourceName": "src/contracts/modules/EpochTradeModule.sol", "contractName": "EpochTradeModule", "deployedOn": "deploy.EpochTradeModule", - "gasUsed": 1832691, - "gasCost": "1004240605" + "gasUsed": 1832703, + "gasCost": "1004250407" } \ No newline at end of file diff --git a/packages/protocol/deployments/EpochUMASettlementModule.json b/packages/protocol/deployments/EpochUMASettlementModule.json index c89bd2cc..f1c50c82 100644 --- a/packages/protocol/deployments/EpochUMASettlementModule.json +++ b/packages/protocol/deployments/EpochUMASettlementModule.json @@ -1,5 +1,5 @@ { - "address": "0xBcC26CeDc5Fa94bc40Bde5247712651FEEDEf693", + "address": "0xBF8e2C989bd27f1FF133f29542d2719341BA8954", "abi": [ { "type": "function", @@ -142,12 +142,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x3fe24d0bfb5bc2b1699ffba5fd0921f5edcaf32baebb10e3208e03b7f3188501", + "deployTxnHash": "0xf8877aed889f507ed352bcbd81ba5c0a9718610039c48ee31e064828044025fb", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617309", + "deployTimestamp": "1722754339", "sourceName": "src/contracts/modules/EpochUMASettlementModule.sol", "contractName": "EpochUMASettlementModule", "deployedOn": "deploy.EpochUMASettlementModule", - "gasUsed": 766508, - "gasCost": "1003775294" + "gasUsed": 766496, + "gasCost": "1003784021" } \ No newline at end of file diff --git a/packages/protocol/deployments/Foil.json b/packages/protocol/deployments/Foil.json index 4affd057..3c1a4c91 100644 --- a/packages/protocol/deployments/Foil.json +++ b/packages/protocol/deployments/Foil.json @@ -1,5 +1,5 @@ { - "address": "0x9661c9974af455b816d6d2a21788c55ebd23105d", + "address": "0x76f9e59a9e68dee497ec7aeb4261d089bf6360d0", "abi": [ { "type": "function", @@ -134,9 +134,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -254,9 +254,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -329,9 +329,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParms", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -389,6 +389,11 @@ "name": "MarketAlreadyCreated", "inputs": [] }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, { "type": "error", "name": "ReentrancyGuardReentrantCall", @@ -704,6 +709,93 @@ ], "stateMutability": "nonpayable" }, + { + "type": "event", + "name": "LiquidityPositionCreated", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "addedAmount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "addedAmount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionDecreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionIncreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, { "type": "event", "name": "Transfer", @@ -766,11 +858,6 @@ } ] }, - { - "type": "error", - "name": "OverflowInt24ToUint256", - "inputs": [] - }, { "type": "error", "name": "OverflowInt256ToUint256", @@ -1436,11 +1523,11 @@ } ], "deployedOn": "router.Foil", - "deployTxnHash": "0xbab1cc68c0d6f5723935ac40b9facdc3cdb6ee33052e1b7e14c39c9325b7cdb1", + "deployTxnHash": "0xbf62116248415e97431c6592b08fd2ca6b14152c44ebaa7fd432d2e38b9801b8", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617314", + "deployTimestamp": "1722754427", "contractName": "Foil", "sourceName": "Foil.sol", - "gasUsed": 439977, - "gasCost": "1001706705" + "gasUsed": 439989, + "gasCost": "1002787316" } \ No newline at end of file diff --git a/packages/protocol/deployments/UMA.Finder.json b/packages/protocol/deployments/UMA.Finder.json index f4754dcd..d1b8ad3f 100644 --- a/packages/protocol/deployments/UMA.Finder.json +++ b/packages/protocol/deployments/UMA.Finder.json @@ -133,7 +133,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x3a4a94e89b04105532165c355ee28b7b969e45233aa52edca551b3b1c82bdc5d", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617309", + "deployTimestamp": "1722754528", "sourceName": "src/UMA/Finder.sol", "contractName": "Finder", "deployedOn": "deploy.Finder", diff --git a/packages/protocol/deployments/UMA.MockOracleAncillary.json b/packages/protocol/deployments/UMA.MockOracleAncillary.json index d94efd77..34cbc6be 100644 --- a/packages/protocol/deployments/UMA.MockOracleAncillary.json +++ b/packages/protocol/deployments/UMA.MockOracleAncillary.json @@ -337,7 +337,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x43618c7361ca78b0aab21b92675caacbc9e19526846c8e179199b6ccf1566b3f", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617311", + "deployTimestamp": "1722754530", "sourceName": "node_modules/@uma/core/contracts/data-verification-mechanism/test/MockOracleAncillary.sol", "contractName": "MockOracleAncillary", "deployedOn": "deploy.MockOracleAncillary", diff --git a/packages/protocol/deployments/UMA.Timer.json b/packages/protocol/deployments/UMA.Timer.json index 53540ce5..6cfc5481 100644 --- a/packages/protocol/deployments/UMA.Timer.json +++ b/packages/protocol/deployments/UMA.Timer.json @@ -32,7 +32,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x29b7ae3d95bb5bbf8d49183656651fd97d2f53d56735b7e2fd7d063f6346bf55", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617309", + "deployTimestamp": "1722754528", "sourceName": "src/UMA/Timer.sol", "contractName": "Timer", "deployedOn": "deploy.Timer", diff --git a/packages/protocol/deployments/Uniswap.Core.UniswapV3Factory.json b/packages/protocol/deployments/Uniswap.Core.UniswapV3Factory.json index c41afeed..4071e04a 100644 --- a/packages/protocol/deployments/Uniswap.Core.UniswapV3Factory.json +++ b/packages/protocol/deployments/Uniswap.Core.UniswapV3Factory.json @@ -240,7 +240,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x092ab39ca583e8ec4129b58d4fd95e709512b32cbc98002efadca0218e4a84a3", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617311", + "deployTimestamp": "1722754530", "sourceName": "contracts/UniswapV3Factory.sol", "contractName": "UniswapV3Factory", "deployedOn": "deploy.UniswapV3Factory", diff --git a/packages/protocol/deployments/Uniswap.NFTDescriptor.json b/packages/protocol/deployments/Uniswap.NFTDescriptor.json index 8f68dae5..92a1eb17 100644 --- a/packages/protocol/deployments/Uniswap.NFTDescriptor.json +++ b/packages/protocol/deployments/Uniswap.NFTDescriptor.json @@ -97,7 +97,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x4f80fa4eb9453334f7e1039e6650362b31dbefd37cb97288a4c4ce7343e78f84", "deployTxnBlockNumber": "6", - "deployTimestamp": "1722617310", + "deployTimestamp": "1722754529", "sourceName": "contracts/libraries/NFTDescriptor.sol", "contractName": "NFTDescriptor", "deployedOn": "deploy.NFTDescriptor", diff --git a/packages/protocol/deployments/Uniswap.NonfungiblePositionManager.json b/packages/protocol/deployments/Uniswap.NonfungiblePositionManager.json index 65174314..d50d1271 100644 --- a/packages/protocol/deployments/Uniswap.NonfungiblePositionManager.json +++ b/packages/protocol/deployments/Uniswap.NonfungiblePositionManager.json @@ -1229,7 +1229,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xde94cbbd26e2b9788d598dc8ec563c9f9703883879a9548c6d5f0d1cfc5af56b", "deployTxnBlockNumber": "12", - "deployTimestamp": "1722617310", + "deployTimestamp": "1722754529", "sourceName": "contracts/NonfungiblePositionManager.sol", "contractName": "NonfungiblePositionManager", "deployedOn": "deploy.NonfungiblePositionManager", diff --git a/packages/protocol/deployments/Uniswap.NonfungibleTokenPositionDescriptor.json b/packages/protocol/deployments/Uniswap.NonfungibleTokenPositionDescriptor.json index e81f4f3a..62bd6a05 100644 --- a/packages/protocol/deployments/Uniswap.NonfungibleTokenPositionDescriptor.json +++ b/packages/protocol/deployments/Uniswap.NonfungibleTokenPositionDescriptor.json @@ -145,7 +145,7 @@ }, "deployTxnHash": "0x10883daf11b005c175d09ba813de6ea3c63efd9833a92a12ede7276ba7a7c849", "deployTxnBlockNumber": "8", - "deployTimestamp": "1722617310", + "deployTimestamp": "1722754529", "sourceName": "contracts/NonfungibleTokenPositionDescriptor.sol", "contractName": "NonfungibleTokenPositionDescriptor", "deployedOn": "deploy.NonfungibleTokenPositionDescriptor", diff --git a/packages/protocol/deployments/Uniswap.ProxyAdmin.json b/packages/protocol/deployments/Uniswap.ProxyAdmin.json index 03fcd866..300dae43 100644 --- a/packages/protocol/deployments/Uniswap.ProxyAdmin.json +++ b/packages/protocol/deployments/Uniswap.ProxyAdmin.json @@ -155,7 +155,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xec0692423399c3d742c864060cd640bc3e7a966cb4ede764a323ab91fe6c52d1", "deployTxnBlockNumber": "5", - "deployTimestamp": "1722617313", + "deployTimestamp": "1722754532", "sourceName": "@openzeppelin/contracts/proxy/ProxyAdmin.sol", "contractName": "ProxyAdmin", "deployedOn": "deploy.ProxyAdmin", diff --git a/packages/protocol/deployments/Uniswap.Quoter.json b/packages/protocol/deployments/Uniswap.Quoter.json index d48b8db0..a46a2cbc 100644 --- a/packages/protocol/deployments/Uniswap.Quoter.json +++ b/packages/protocol/deployments/Uniswap.Quoter.json @@ -200,7 +200,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x77e143643e4884a308dec6693d86e0e658de1f16802df6db35f444c2ebc02ddd", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617311", + "deployTimestamp": "1722754530", "sourceName": "contracts/lens/Quoter.sol", "contractName": "Quoter", "deployedOn": "deploy.Quoter", diff --git a/packages/protocol/deployments/Uniswap.SwapRouter.json b/packages/protocol/deployments/Uniswap.SwapRouter.json index d7a2ecb7..8e2fd673 100644 --- a/packages/protocol/deployments/Uniswap.SwapRouter.json +++ b/packages/protocol/deployments/Uniswap.SwapRouter.json @@ -572,7 +572,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x34c75edbab5990d7b1e9441df2d4378da661672d4de365f41a3657d1d3c54e11", "deployTxnBlockNumber": "4", - "deployTimestamp": "1722617312", + "deployTimestamp": "1722754531", "sourceName": "contracts/SwapRouter.sol", "contractName": "SwapRouter", "deployedOn": "deploy.SwapRouter", diff --git a/packages/protocol/deployments/Uniswap.TickLens.json b/packages/protocol/deployments/Uniswap.TickLens.json index 59122f88..18515d56 100644 --- a/packages/protocol/deployments/Uniswap.TickLens.json +++ b/packages/protocol/deployments/Uniswap.TickLens.json @@ -47,7 +47,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xe86d0528829e851224aff055a91d81d0a8ffe44446c2664342f16ed023929f4d", "deployTxnBlockNumber": "6", - "deployTimestamp": "1722617314", + "deployTimestamp": "1722754533", "sourceName": "contracts/lens/TickLens.sol", "contractName": "TickLens", "deployedOn": "deploy.TickLens", diff --git a/packages/protocol/deployments/Uniswap.TransparentUpgradeableProxy.json b/packages/protocol/deployments/Uniswap.TransparentUpgradeableProxy.json index 6001b697..486b827b 100644 --- a/packages/protocol/deployments/Uniswap.TransparentUpgradeableProxy.json +++ b/packages/protocol/deployments/Uniswap.TransparentUpgradeableProxy.json @@ -141,7 +141,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x488f88a8c7d794288db591295391a226738ac6ed932f71f0f4fd3a3a5519a868", "deployTxnBlockNumber": "10", - "deployTimestamp": "1722617310", + "deployTimestamp": "1722754529", "sourceName": "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol", "contractName": "TransparentUpgradeableProxy", "deployedOn": "deploy.TransparentUpgradeableProxy", diff --git a/packages/protocol/deployments/test/BondCurrency.Token.json b/packages/protocol/deployments/test/BondCurrency.Token.json index dee6bedb..3fa4f17c 100644 --- a/packages/protocol/deployments/test/BondCurrency.Token.json +++ b/packages/protocol/deployments/test/BondCurrency.Token.json @@ -319,7 +319,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x12ee0b194db4db0157edc1ecd4711e1b128110b845c2232c6b427b5749ddc7a5", "deployTxnBlockNumber": "2", - "deployTimestamp": "1722617324", + "deployTimestamp": "1722754539", "sourceName": "src/MintableTokenPermissionlessMint.sol", "contractName": "MintableTokenPermissionlessMint", "deployedOn": "contract.Token", diff --git a/packages/protocol/deployments/test/CollateralAsset.Token.json b/packages/protocol/deployments/test/CollateralAsset.Token.json index 207636b6..696c94c2 100644 --- a/packages/protocol/deployments/test/CollateralAsset.Token.json +++ b/packages/protocol/deployments/test/CollateralAsset.Token.json @@ -319,7 +319,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x6add4be37a653aaf5ba967fc8163d59e33e29d487ad632af66209495e5d42051", "deployTxnBlockNumber": "2", - "deployTimestamp": "1722617324", + "deployTimestamp": "1722754539", "sourceName": "src/MintableTokenPermissionlessMint.sol", "contractName": "MintableTokenPermissionlessMint", "deployedOn": "contract.Token", diff --git a/packages/protocol/deployments/test/EpochConfigurationModule.json b/packages/protocol/deployments/test/EpochConfigurationModule.json index c5a19fd2..da26501e 100644 --- a/packages/protocol/deployments/test/EpochConfigurationModule.json +++ b/packages/protocol/deployments/test/EpochConfigurationModule.json @@ -1,5 +1,5 @@ { - "address": "0xceE20f985915a3e218Cc2ABf99F41EAe8C5b4911", + "address": "0xDD59E99E336FF485ec3C8420dd7CE128F1b806e3", "abi": [ { "type": "function", @@ -134,9 +134,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -254,9 +254,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -329,9 +329,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParms", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -389,6 +389,11 @@ "name": "MarketAlreadyCreated", "inputs": [] }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, { "type": "error", "name": "ReentrancyGuardReentrantCall", @@ -402,12 +407,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x3160f02190eb9f29f74ed54e7da02cae4054d74b954cde1dc1de10b1b520ffdc", + "deployTxnHash": "0xb3d7b11ccdbb240b670d6d65fa796bfc2f4cfc9818293378496c36e2add84036", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617310", + "deployTimestamp": "1722754340", "sourceName": "src/contracts/modules/EpochConfigurationModule.sol", "contractName": "EpochConfigurationModule", "deployedOn": "deploy.EpochConfigurationModule", - "gasUsed": 2031440, + "gasUsed": 2256590, "gasCost": "1005326146" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/EpochLiquidityModule.json b/packages/protocol/deployments/test/EpochLiquidityModule.json index 50c7b32e..88056d1e 100644 --- a/packages/protocol/deployments/test/EpochLiquidityModule.json +++ b/packages/protocol/deployments/test/EpochLiquidityModule.json @@ -1,5 +1,5 @@ { - "address": "0x408f9283b88015D6B3CfC2cB42168028058adEdb", + "address": "0x7C244D9661bF634ca8909C4058924513f30CE6C0", "abi": [ { "type": "function", @@ -306,6 +306,93 @@ ], "stateMutability": "nonpayable" }, + { + "type": "event", + "name": "LiquidityPositionCreated", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "addedAmount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "addedAmount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionDecreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionIncreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, { "type": "event", "name": "Transfer", @@ -407,12 +494,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x5a22ace2d9158dab44ada65eb0da03a939b27a3db8495a1a03bef590e963cc98", + "deployTxnHash": "0xc422f47a846c7efdfc6439b4363a85d3054f52a81d1c8e50fd57fbadc24221e9", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617309", + "deployTimestamp": "1722754422", "sourceName": "src/contracts/modules/EpochLiquidityModule.sol", "contractName": "EpochLiquidityModule", "deployedOn": "deploy.EpochLiquidityModule", - "gasUsed": 2118814, - "gasCost": "1004750543" + "gasUsed": 2132620, + "gasCost": "1006087024" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/EpochTradeModule.json b/packages/protocol/deployments/test/EpochTradeModule.json index fcbb8d20..9f6cb9a0 100644 --- a/packages/protocol/deployments/test/EpochTradeModule.json +++ b/packages/protocol/deployments/test/EpochTradeModule.json @@ -1,5 +1,5 @@ { - "address": "0x5f62BeB4EFaBdC3B1442ECB3Fad61ED9E1645a4f", + "address": "0x33ad0458323a7b02dC054943EBf4fC0a27aab7D2", "abi": [ { "type": "function", @@ -162,12 +162,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0xdf736b5d22ac235c47ab4c9e170ee5fff3eb11bfa4d541b92dcf883b3a269f9f", + "deployTxnHash": "0xb8082e21b44eb7833bb45a2939ea36f9bbbdd9fa05aada3dd1f95c61a35586d1", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617309", + "deployTimestamp": "1722754339", "sourceName": "src/contracts/modules/EpochTradeModule.sol", "contractName": "EpochTradeModule", "deployedOn": "deploy.EpochTradeModule", - "gasUsed": 1832691, - "gasCost": "1004240605" + "gasUsed": 1832703, + "gasCost": "1004250407" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/EpochUMASettlementModule.json b/packages/protocol/deployments/test/EpochUMASettlementModule.json index c89bd2cc..f1c50c82 100644 --- a/packages/protocol/deployments/test/EpochUMASettlementModule.json +++ b/packages/protocol/deployments/test/EpochUMASettlementModule.json @@ -1,5 +1,5 @@ { - "address": "0xBcC26CeDc5Fa94bc40Bde5247712651FEEDEf693", + "address": "0xBF8e2C989bd27f1FF133f29542d2719341BA8954", "abi": [ { "type": "function", @@ -142,12 +142,12 @@ ], "constructorArgs": [], "linkedLibraries": {}, - "deployTxnHash": "0x3fe24d0bfb5bc2b1699ffba5fd0921f5edcaf32baebb10e3208e03b7f3188501", + "deployTxnHash": "0xf8877aed889f507ed352bcbd81ba5c0a9718610039c48ee31e064828044025fb", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617309", + "deployTimestamp": "1722754339", "sourceName": "src/contracts/modules/EpochUMASettlementModule.sol", "contractName": "EpochUMASettlementModule", "deployedOn": "deploy.EpochUMASettlementModule", - "gasUsed": 766508, - "gasCost": "1003775294" + "gasUsed": 766496, + "gasCost": "1003784021" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/Foil.json b/packages/protocol/deployments/test/Foil.json index 4affd057..3c1a4c91 100644 --- a/packages/protocol/deployments/test/Foil.json +++ b/packages/protocol/deployments/test/Foil.json @@ -1,5 +1,5 @@ { - "address": "0x9661c9974af455b816d6d2a21788c55ebd23105d", + "address": "0x76f9e59a9e68dee497ec7aeb4261d089bf6360d0", "abi": [ { "type": "function", @@ -134,9 +134,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -254,9 +254,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParams", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -329,9 +329,9 @@ "internalType": "address" }, { - "name": "marketParams", + "name": "epochParms", "type": "tuple", - "internalType": "struct Market.MarketParams", + "internalType": "struct Market.EpochParams", "components": [ { "name": "baseAssetMinPriceTick", @@ -389,6 +389,11 @@ "name": "MarketAlreadyCreated", "inputs": [] }, + { + "type": "error", + "name": "OverflowInt24ToUint256", + "inputs": [] + }, { "type": "error", "name": "ReentrancyGuardReentrantCall", @@ -704,6 +709,93 @@ ], "stateMutability": "nonpayable" }, + { + "type": "event", + "name": "LiquidityPositionCreated", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "addedAmount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "addedAmount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionDecreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LiquidityPositionIncreased", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "liquidity", + "type": "uint128", + "indexed": false, + "internalType": "uint128" + }, + { + "name": "amount0", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount1", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, { "type": "event", "name": "Transfer", @@ -766,11 +858,6 @@ } ] }, - { - "type": "error", - "name": "OverflowInt24ToUint256", - "inputs": [] - }, { "type": "error", "name": "OverflowInt256ToUint256", @@ -1436,11 +1523,11 @@ } ], "deployedOn": "router.Foil", - "deployTxnHash": "0xbab1cc68c0d6f5723935ac40b9facdc3cdb6ee33052e1b7e14c39c9325b7cdb1", + "deployTxnHash": "0xbf62116248415e97431c6592b08fd2ca6b14152c44ebaa7fd432d2e38b9801b8", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617314", + "deployTimestamp": "1722754427", "contractName": "Foil", "sourceName": "Foil.sol", - "gasUsed": 439977, - "gasCost": "1001706705" + "gasUsed": 439989, + "gasCost": "1002787316" } \ No newline at end of file diff --git a/packages/protocol/deployments/test/UMA.Finder.json b/packages/protocol/deployments/test/UMA.Finder.json index 2b80cad8..932baf61 100644 --- a/packages/protocol/deployments/test/UMA.Finder.json +++ b/packages/protocol/deployments/test/UMA.Finder.json @@ -133,7 +133,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x3a4a94e89b04105532165c355ee28b7b969e45233aa52edca551b3b1c82bdc5d", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617320", + "deployTimestamp": "1722754535", "sourceName": "src/UMA/Finder.sol", "contractName": "Finder", "deployedOn": "deploy.Finder", diff --git a/packages/protocol/deployments/test/UMA.MockOracleAncillary.json b/packages/protocol/deployments/test/UMA.MockOracleAncillary.json index 276b1f18..572327d1 100644 --- a/packages/protocol/deployments/test/UMA.MockOracleAncillary.json +++ b/packages/protocol/deployments/test/UMA.MockOracleAncillary.json @@ -337,7 +337,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x43618c7361ca78b0aab21b92675caacbc9e19526846c8e179199b6ccf1566b3f", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617322", + "deployTimestamp": "1722754537", "sourceName": "node_modules/@uma/core/contracts/data-verification-mechanism/test/MockOracleAncillary.sol", "contractName": "MockOracleAncillary", "deployedOn": "deploy.MockOracleAncillary", diff --git a/packages/protocol/deployments/test/UMA.Timer.json b/packages/protocol/deployments/test/UMA.Timer.json index 8d1ff50a..05e944a5 100644 --- a/packages/protocol/deployments/test/UMA.Timer.json +++ b/packages/protocol/deployments/test/UMA.Timer.json @@ -32,7 +32,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x29b7ae3d95bb5bbf8d49183656651fd97d2f53d56735b7e2fd7d063f6346bf55", "deployTxnBlockNumber": "1", - "deployTimestamp": "1722617320", + "deployTimestamp": "1722754535", "sourceName": "src/UMA/Timer.sol", "contractName": "Timer", "deployedOn": "deploy.Timer", diff --git a/packages/protocol/deployments/test/Uniswap.Core.UniswapV3Factory.json b/packages/protocol/deployments/test/Uniswap.Core.UniswapV3Factory.json index b414eea1..2f2742b9 100644 --- a/packages/protocol/deployments/test/Uniswap.Core.UniswapV3Factory.json +++ b/packages/protocol/deployments/test/Uniswap.Core.UniswapV3Factory.json @@ -240,7 +240,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x092ab39ca583e8ec4129b58d4fd95e709512b32cbc98002efadca0218e4a84a3", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617322", + "deployTimestamp": "1722754537", "sourceName": "contracts/UniswapV3Factory.sol", "contractName": "UniswapV3Factory", "deployedOn": "deploy.UniswapV3Factory", diff --git a/packages/protocol/deployments/test/Uniswap.NFTDescriptor.json b/packages/protocol/deployments/test/Uniswap.NFTDescriptor.json index c0e1ce41..7f6333f4 100644 --- a/packages/protocol/deployments/test/Uniswap.NFTDescriptor.json +++ b/packages/protocol/deployments/test/Uniswap.NFTDescriptor.json @@ -97,7 +97,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x4f80fa4eb9453334f7e1039e6650362b31dbefd37cb97288a4c4ce7343e78f84", "deployTxnBlockNumber": "6", - "deployTimestamp": "1722617321", + "deployTimestamp": "1722754536", "sourceName": "contracts/libraries/NFTDescriptor.sol", "contractName": "NFTDescriptor", "deployedOn": "deploy.NFTDescriptor", diff --git a/packages/protocol/deployments/test/Uniswap.NonfungiblePositionManager.json b/packages/protocol/deployments/test/Uniswap.NonfungiblePositionManager.json index 9464b5ac..62ad2fea 100644 --- a/packages/protocol/deployments/test/Uniswap.NonfungiblePositionManager.json +++ b/packages/protocol/deployments/test/Uniswap.NonfungiblePositionManager.json @@ -1229,7 +1229,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xde94cbbd26e2b9788d598dc8ec563c9f9703883879a9548c6d5f0d1cfc5af56b", "deployTxnBlockNumber": "12", - "deployTimestamp": "1722617321", + "deployTimestamp": "1722754536", "sourceName": "contracts/NonfungiblePositionManager.sol", "contractName": "NonfungiblePositionManager", "deployedOn": "deploy.NonfungiblePositionManager", diff --git a/packages/protocol/deployments/test/Uniswap.NonfungibleTokenPositionDescriptor.json b/packages/protocol/deployments/test/Uniswap.NonfungibleTokenPositionDescriptor.json index c403c191..b97a8313 100644 --- a/packages/protocol/deployments/test/Uniswap.NonfungibleTokenPositionDescriptor.json +++ b/packages/protocol/deployments/test/Uniswap.NonfungibleTokenPositionDescriptor.json @@ -145,7 +145,7 @@ }, "deployTxnHash": "0x10883daf11b005c175d09ba813de6ea3c63efd9833a92a12ede7276ba7a7c849", "deployTxnBlockNumber": "8", - "deployTimestamp": "1722617321", + "deployTimestamp": "1722754536", "sourceName": "contracts/NonfungibleTokenPositionDescriptor.sol", "contractName": "NonfungibleTokenPositionDescriptor", "deployedOn": "deploy.NonfungibleTokenPositionDescriptor", diff --git a/packages/protocol/deployments/test/Uniswap.ProxyAdmin.json b/packages/protocol/deployments/test/Uniswap.ProxyAdmin.json index 917b1804..3ac0288c 100644 --- a/packages/protocol/deployments/test/Uniswap.ProxyAdmin.json +++ b/packages/protocol/deployments/test/Uniswap.ProxyAdmin.json @@ -155,7 +155,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xec0692423399c3d742c864060cd640bc3e7a966cb4ede764a323ab91fe6c52d1", "deployTxnBlockNumber": "5", - "deployTimestamp": "1722617324", + "deployTimestamp": "1722754539", "sourceName": "@openzeppelin/contracts/proxy/ProxyAdmin.sol", "contractName": "ProxyAdmin", "deployedOn": "deploy.ProxyAdmin", diff --git a/packages/protocol/deployments/test/Uniswap.Quoter.json b/packages/protocol/deployments/test/Uniswap.Quoter.json index 2e34fda7..d5aeefbe 100644 --- a/packages/protocol/deployments/test/Uniswap.Quoter.json +++ b/packages/protocol/deployments/test/Uniswap.Quoter.json @@ -200,7 +200,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x77e143643e4884a308dec6693d86e0e658de1f16802df6db35f444c2ebc02ddd", "deployTxnBlockNumber": "3", - "deployTimestamp": "1722617322", + "deployTimestamp": "1722754537", "sourceName": "contracts/lens/Quoter.sol", "contractName": "Quoter", "deployedOn": "deploy.Quoter", diff --git a/packages/protocol/deployments/test/Uniswap.SwapRouter.json b/packages/protocol/deployments/test/Uniswap.SwapRouter.json index 4da765ab..0cbe65d4 100644 --- a/packages/protocol/deployments/test/Uniswap.SwapRouter.json +++ b/packages/protocol/deployments/test/Uniswap.SwapRouter.json @@ -572,7 +572,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x34c75edbab5990d7b1e9441df2d4378da661672d4de365f41a3657d1d3c54e11", "deployTxnBlockNumber": "4", - "deployTimestamp": "1722617323", + "deployTimestamp": "1722754538", "sourceName": "contracts/SwapRouter.sol", "contractName": "SwapRouter", "deployedOn": "deploy.SwapRouter", diff --git a/packages/protocol/deployments/test/Uniswap.TickLens.json b/packages/protocol/deployments/test/Uniswap.TickLens.json index f0418926..4037bd82 100644 --- a/packages/protocol/deployments/test/Uniswap.TickLens.json +++ b/packages/protocol/deployments/test/Uniswap.TickLens.json @@ -47,7 +47,7 @@ "linkedLibraries": {}, "deployTxnHash": "0xe86d0528829e851224aff055a91d81d0a8ffe44446c2664342f16ed023929f4d", "deployTxnBlockNumber": "6", - "deployTimestamp": "1722617325", + "deployTimestamp": "1722754540", "sourceName": "contracts/lens/TickLens.sol", "contractName": "TickLens", "deployedOn": "deploy.TickLens", diff --git a/packages/protocol/deployments/test/Uniswap.TransparentUpgradeableProxy.json b/packages/protocol/deployments/test/Uniswap.TransparentUpgradeableProxy.json index 3a63a690..d17b6fa9 100644 --- a/packages/protocol/deployments/test/Uniswap.TransparentUpgradeableProxy.json +++ b/packages/protocol/deployments/test/Uniswap.TransparentUpgradeableProxy.json @@ -141,7 +141,7 @@ "linkedLibraries": {}, "deployTxnHash": "0x488f88a8c7d794288db591295391a226738ac6ed932f71f0f4fd3a3a5519a868", "deployTxnBlockNumber": "10", - "deployTimestamp": "1722617321", + "deployTimestamp": "1722754536", "sourceName": "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol", "contractName": "TransparentUpgradeableProxy", "deployedOn": "deploy.TransparentUpgradeableProxy", diff --git a/packages/protocol/src/contracts/external/IMintableToken.sol b/packages/protocol/src/contracts/external/IMintableToken.sol new file mode 100644 index 00000000..2772c7d4 --- /dev/null +++ b/packages/protocol/src/contracts/external/IMintableToken.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.2 <0.9.0; + +import {IERC20} from "../../synthetix/interfaces/IERC20.sol"; + +interface IMintableToken is IERC20 { + function mint(uint256 amount, address to) external; +} diff --git a/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol b/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol index 2bca9a28..da46105a 100644 --- a/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol +++ b/packages/protocol/src/contracts/interfaces/IEpochLiquidityModule.sol @@ -4,6 +4,26 @@ pragma solidity >=0.8.2 <0.9.0; import {IFoilStructs} from "./IFoilStructs.sol"; interface IEpochLiquidityModule { + event LiquidityPositionCreated( + uint256 tokenId, + uint128 liquidity, + uint256 addedAmount0, + uint256 addedAmount1 + ); + + event LiquidityPositionDecreased( + uint256 tokenId, + uint256 amount0, + uint256 amount1 + ); + + event LiquidityPositionIncreased( + uint256 tokenId, + uint128 liquidity, + uint256 amount0, + uint256 amount1 + ); + function createLiquidityPosition( IFoilStructs.LiquidityPositionParams memory params ) diff --git a/packages/protocol/src/contracts/libraries/Quote.sol b/packages/protocol/src/contracts/libraries/Quote.sol index 0aa31bee..ca0b112e 100644 --- a/packages/protocol/src/contracts/libraries/Quote.sol +++ b/packages/protocol/src/contracts/libraries/Quote.sol @@ -9,18 +9,16 @@ import "forge-std/console2.sol"; library Quote { function quoteEthToGas( uint256 ethAmount, - int24 tick + uint160 sqrtRatioX96 ) internal pure returns (uint256) { - uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick); return FullMath.mulDiv(ethAmount, 1e18, sqrtRatioX96ToPrice(sqrtRatioX96)); } function quoteGasToEth( uint256 gasAmount, - int24 tick + uint160 sqrtRatioX96 ) internal pure returns (uint256) { - uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick); return FullMath.mulDiv(gasAmount, sqrtRatioX96ToPrice(sqrtRatioX96), 1e18); } diff --git a/packages/protocol/src/contracts/modules/EpochConfigurationModule.sol b/packages/protocol/src/contracts/modules/EpochConfigurationModule.sol index a65a89c6..a84d8d54 100644 --- a/packages/protocol/src/contracts/modules/EpochConfigurationModule.sol +++ b/packages/protocol/src/contracts/modules/EpochConfigurationModule.sol @@ -10,7 +10,7 @@ import "../storage/FAccount.sol"; import "../storage/Position.sol"; import "../storage/ERC721Storage.sol"; import "../storage/ERC721EnumerableStorage.sol"; -import "../storage/Market.sol"; // Import the Market library +import "../storage/Market.sol"; import "forge-std/console2.sol"; contract EpochConfigurationModule is ReentrancyGuard { @@ -33,7 +33,7 @@ contract EpochConfigurationModule is ReentrancyGuard { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - Market.MarketParams memory marketParams + Market.EpochParams memory epochParams ) external { Market.createValid( owner, @@ -42,7 +42,7 @@ contract EpochConfigurationModule is ReentrancyGuard { uniswapQuoter, uniswapSwapRouter, optimisticOracleV3, - marketParams + epochParams ); } @@ -52,7 +52,7 @@ contract EpochConfigurationModule is ReentrancyGuard { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - Market.MarketParams memory marketParams + Market.EpochParams memory epochParms ) external onlyOwner { Market.updateValid( owner, // should be nominate/accept @@ -60,7 +60,7 @@ contract EpochConfigurationModule is ReentrancyGuard { uniswapQuoter, uniswapSwapRouter, optimisticOracleV3, - marketParams + epochParms ); } function createEpoch( @@ -70,17 +70,7 @@ contract EpochConfigurationModule is ReentrancyGuard { ) external onlyOwner { Market.Data storage market = Market.loadValid(); - Epoch.createValid( - startTime, - endTime, - address(market.uniswapPositionManager), - address(market.uniswapQuoter), - address(market.uniswapSwapRouter), - address(market.collateralAsset), - startingSqrtPriceX96, - address(market.optimisticOracleV3), - market.marketParams - ); + Epoch.createValid(startTime, endTime, startingSqrtPriceX96); } function getMarket() @@ -93,18 +83,18 @@ contract EpochConfigurationModule is ReentrancyGuard { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - Market.MarketParams memory marketParams + Market.EpochParams memory epochParams ) { Market.Data storage market = Market.load(); return ( market.owner, - market.collateralAsset, + address(market.collateralAsset), address(market.uniswapPositionManager), address(market.uniswapQuoter), address(market.uniswapSwapRouter), address(market.optimisticOracleV3), - market.marketParams + market.epochParams ); } diff --git a/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol b/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol index b50dfffd..9389a08d 100644 --- a/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol +++ b/packages/protocol/src/contracts/modules/EpochLiquidityModule.sol @@ -43,11 +43,16 @@ contract EpochLiquidityModule is Market.Data storage market = Market.load(); Epoch.Data storage epoch = Epoch.load(); + account.updateCollateral( + market.collateralAsset, + params.collateralAmount + ); + INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager.MintParams({ token0: address(epoch.gasToken), token1: address(epoch.ethToken), - fee: epoch.marketParams.feeRate, + fee: epoch.params.feeRate, tickLower: params.lowerTick, tickUpper: params.upperTick, amount0Desired: params.amountTokenA, @@ -62,8 +67,6 @@ contract EpochLiquidityModule is .uniswapPositionManager .mint(mintParams); - console2.log("ADDED AMTS", addedAmount0, addedAmount1, liquidity); - account.updateLoan( tokenId, params.collateralAmount, @@ -77,6 +80,14 @@ contract EpochLiquidityModule is params.lowerTick, params.upperTick ); + + // emit event + emit LiquidityPositionCreated( + tokenId, + liquidity, + addedAmount0, + addedAmount1 + ); } function onERC721Received( @@ -123,7 +134,6 @@ contract EpochLiquidityModule is uint256 minGasAmount, uint256 minEthAmount ) external override returns (uint256 amount0, uint256 amount1) { - console2.log("--DECREASE LIQ POSITION--"); Market.Data storage market = Market.load(); FAccount.Data storage account = FAccount.load(accountId); @@ -131,6 +141,8 @@ contract EpochLiquidityModule is .uniswapPositionManager .positions(account.tokenId); + account.updateCollateral(market.collateralAsset, collateralAmount); + INonfungiblePositionManager.DecreaseLiquidityParams memory decreaseParams = INonfungiblePositionManager .DecreaseLiquidityParams({ @@ -145,8 +157,6 @@ contract EpochLiquidityModule is decreaseParams ); - console2.log("DECREASED AMTS", amount0, amount1, liquidity); - account.updateLoan(account.tokenId, collateralAmount, amount0, amount1); Epoch.load().validateProvidedLiquidity( collateralAmount, @@ -155,6 +165,8 @@ contract EpochLiquidityModule is upperTick ); + emit LiquidityPositionDecreased(account.tokenId, amount0, amount1); + // transfer or remove collateral } @@ -166,7 +178,6 @@ contract EpochLiquidityModule is 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); @@ -174,6 +185,8 @@ contract EpochLiquidityModule is .uniswapPositionManager .positions(account.tokenId); + account.updateCollateral(market.collateralAsset, collateralAmount); + INonfungiblePositionManager.IncreaseLiquidityParams memory increaseParams = INonfungiblePositionManager .IncreaseLiquidityParams({ @@ -196,6 +209,13 @@ contract EpochLiquidityModule is lowerTick, upperTick ); + + emit LiquidityPositionIncreased( + account.tokenId, + liquidity, + amount0, + amount1 + ); } function getTokenAmounts( @@ -229,13 +249,18 @@ contract EpochLiquidityModule is sqrtPriceBX96 ); - uint256 collateralRatio = collateralAmount / requiredCollateral; + // scale up for fractional collateral ratio + uint256 collateralRatio = FullMath.mulDiv( + collateralAmount, + 1e18, // Create MathUtil and use UNIT + requiredCollateral + ); // scale up liquidity by collateral amount return ( - unitAmount0 * collateralRatio, - uintAmount1 * collateralRatio, - uint128(unitLiquidity * collateralRatio) + FullMath.mulDiv(unitAmount0, collateralRatio, 1e18), + FullMath.mulDiv(uintAmount1, collateralRatio, 1e18), + uint128(unitLiquidity * collateralRatio) / 1e18 ); } diff --git a/packages/protocol/src/contracts/modules/EpochTradeModule.sol b/packages/protocol/src/contracts/modules/EpochTradeModule.sol index 9417cdcc..b29ed853 100644 --- a/packages/protocol/src/contracts/modules/EpochTradeModule.sol +++ b/packages/protocol/src/contracts/modules/EpochTradeModule.sol @@ -538,7 +538,7 @@ contract EpochTradeModule { ); } else { ISwapRouter.ExactInputSingleParams memory swapParams; - swapParams.fee = epoch.marketParams.feeRate; + swapParams.fee = epoch.params.feeRate; swapParams.recipient = address(this); swapParams.deadline = block.timestamp; @@ -651,7 +651,7 @@ contract EpochTradeModule { .ExactOutputSingleParams({ tokenIn: tokenIn, tokenOut: tokenOut, - fee: epoch.marketParams.feeRate, + fee: epoch.params.feeRate, recipient: address(this), deadline: block.timestamp, amountOut: amountOut, diff --git a/packages/protocol/src/contracts/modules/EpochUMASettlementModule.sol b/packages/protocol/src/contracts/modules/EpochUMASettlementModule.sol index 4da4bcb1..cb9d4e2b 100644 --- a/packages/protocol/src/contracts/modules/EpochUMASettlementModule.sol +++ b/packages/protocol/src/contracts/modules/EpochUMASettlementModule.sol @@ -19,23 +19,39 @@ contract EpochUMASettlementModule is ReentrancyGuard { event SettlementDisputed(uint256 disputeTime); event MarketSettled(uint256 settlementPrice); - modifier afterEndTime() { + modifier afterEndTime() { Epoch.Data storage epoch = Epoch.load(); - require(block.timestamp > epoch.endTime, "Market activity is still allowed"); + require( + block.timestamp > epoch.endTime, + "Market activity is still allowed" + ); _; } - function submitSettlementPrice(uint256 settlementPrice) external afterEndTime nonReentrant returns (bytes32) { + function submitSettlementPrice( + uint256 settlementPrice + ) external afterEndTime nonReentrant returns (bytes32) { Market.Data storage market = Market.load(); Epoch.Data storage epoch = Epoch.load(); - require(msg.sender == market.owner, "Only owner can call this function"); + require( + msg.sender == market.owner, + "Only owner can call this function" + ); require(!epoch.settled, "Market already settled"); - IERC20 bondCurrency = IERC20(epoch.marketParams.bondCurrency); - OptimisticOracleV3Interface optimisticOracleV3 = market.optimisticOracleV3; + IERC20 bondCurrency = IERC20(epoch.params.bondCurrency); + OptimisticOracleV3Interface optimisticOracleV3 = market + .optimisticOracleV3; - bondCurrency.safeTransferFrom(msg.sender, address(this), epoch.marketParams.bondAmount); - bondCurrency.forceApprove(address(optimisticOracleV3), epoch.marketParams.bondAmount); + bondCurrency.safeTransferFrom( + msg.sender, + address(this), + epoch.params.bondAmount + ); + bondCurrency.forceApprove( + address(optimisticOracleV3), + epoch.params.bondAmount + ); epoch.settlement = Epoch.Settlement({ settlementPrice: settlementPrice, @@ -45,7 +61,7 @@ contract EpochUMASettlementModule is ReentrancyGuard { }); bytes memory claim = abi.encodePacked( - epoch.marketParams.priceUnit, + epoch.params.priceUnit, " TWAP between timestamps ", abi.encodePacked(epoch.startTime), " and ", @@ -59,9 +75,9 @@ contract EpochUMASettlementModule is ReentrancyGuard { msg.sender, address(this), address(0), - epoch.marketParams.assertionLiveness, - IERC20(epoch.marketParams.bondCurrency), - uint64(epoch.marketParams.bondAmount), + epoch.params.assertionLiveness, + IERC20(epoch.params.bondCurrency), + uint64(epoch.params.bondAmount), bytes32(0), bytes32(0) ); @@ -71,10 +87,16 @@ contract EpochUMASettlementModule is ReentrancyGuard { return epoch.assertionId; } - function assertionResolvedCallback(bytes32 assertionId, bool assertedTruthfully) external afterEndTime nonReentrant { + function assertionResolvedCallback( + bytes32 assertionId, + bool assertedTruthfully + ) external afterEndTime nonReentrant { Market.Data storage market = Market.load(); Epoch.Data storage epoch = Epoch.load(); - require(msg.sender == address(market.optimisticOracleV3), "Invalid caller"); + require( + msg.sender == address(market.optimisticOracleV3), + "Invalid caller" + ); require(!epoch.settled, "Market already settled"); Epoch.Settlement storage settlement = epoch.settlement; @@ -84,10 +106,15 @@ contract EpochUMASettlementModule is ReentrancyGuard { emit MarketSettled(settlement.settlementPrice); } - function assertionDisputedCallback(bytes32 assertionId) external afterEndTime nonReentrant { + function assertionDisputedCallback( + bytes32 assertionId + ) external afterEndTime nonReentrant { Market.Data storage market = Market.load(); Epoch.Data storage epoch = Epoch.load(); - require(msg.sender == address(market.optimisticOracleV3), "Invalid caller"); + require( + msg.sender == address(market.optimisticOracleV3), + "Invalid caller" + ); Epoch.Settlement storage settlement = epoch.settlement; settlement.disputed = true; diff --git a/packages/protocol/src/contracts/storage/Epoch.sol b/packages/protocol/src/contracts/storage/Epoch.sol index 68522478..ad3fc49d 100644 --- a/packages/protocol/src/contracts/storage/Epoch.sol +++ b/packages/protocol/src/contracts/storage/Epoch.sol @@ -41,7 +41,9 @@ library Epoch { mapping(uint256 => Debt.Data) lpDebtPositions; bytes32 assertionId; Settlement settlement; - Market.MarketParams marketParams; // Storing MarketParams as a struct within Epoch.Data + Market.EpochParams params; // Storing epochParams as a struct within Epoch.Data + uint160 sqrtPriceMinX96; + uint160 sqrtPriceMaxX96; } function load() internal pure returns (Data storage epoch) { @@ -78,14 +80,11 @@ library Epoch { function createValid( uint startTime, uint endTime, - address uniswapPositionManager, - address uniswapQuoter, - address uniswapSwapRouter, - address collateralAsset, - uint160 startingSqrtPriceX96, - address optimisticOracleV3, - Market.MarketParams memory marketParams + uint160 startingSqrtPriceX96 ) internal returns (Data storage epoch) { + Market.Data storage market = Market.loadValid(); + Market.EpochParams storage epochParams = market.epochParams; + epoch = load(); // can only be called once @@ -102,7 +101,9 @@ library Epoch { epoch.startTime = startTime; epoch.endTime = endTime; - epoch.marketParams = marketParams; + + // copy over market parameters into epoch + epoch.params = market.epochParams; VirtualToken tokenA = new VirtualToken( address(this), @@ -123,39 +124,53 @@ library Epoch { epoch.gasToken = tokenB; epoch.ethToken = tokenA; } + + // create & initialize pool epoch.pool = IUniswapV3Pool( IUniswapV3Factory( - INonfungiblePositionManager(uniswapPositionManager).factory() + INonfungiblePositionManager(market.uniswapPositionManager) + .factory() ).createPool( address(epoch.gasToken), address(epoch.ethToken), - marketParams.feeRate + epochParams.feeRate ) ); - IUniswapV3Pool(epoch.pool).initialize(startingSqrtPriceX96); // starting price - (uint160 sqrtPriceX96, int24 tick, , , , , ) = IUniswapV3Pool( - epoch.pool - ).slot0(); + int24 spacing = IUniswapV3Pool(epoch.pool).tickSpacing(); + // store min/max prices + epoch.sqrtPriceMinX96 = TickMath.getSqrtRatioAtTick( + epoch.params.baseAssetMinPriceTick + ); + // use next tick for max price + epoch.sqrtPriceMaxX96 = TickMath.getSqrtRatioAtTick( + epoch.params.baseAssetMaxPriceTick + spacing + ); - // mint + // mint max; track tokens loaned by in FAccount epoch.ethToken.mint(address(this), type(uint256).max); epoch.gasToken.mint(address(this), type(uint256).max); // approve to uniswapPositionManager epoch.ethToken.approve( - address(uniswapPositionManager), + address(market.uniswapPositionManager), type(uint256).max ); epoch.gasToken.approve( - address(uniswapPositionManager), + address(market.uniswapPositionManager), type(uint256).max ); // approve to uniswapSwapRouter - epoch.ethToken.approve(address(uniswapSwapRouter), type(uint256).max); - epoch.gasToken.approve(address(uniswapSwapRouter), type(uint256).max); + epoch.ethToken.approve( + address(market.uniswapSwapRouter), + type(uint256).max + ); + epoch.gasToken.approve( + address(market.uniswapSwapRouter), + type(uint256).max + ); } function loadValid() internal view returns (Data storage epoch) { @@ -207,9 +222,6 @@ library Epoch { int24 lowerTick, int24 upperTick ) internal { - uint160 sqrtPriceAX96 = TickMath.getSqrtRatioAtTick(lowerTick); - uint160 sqrtPriceBX96 = TickMath.getSqrtRatioAtTick(upperTick + 1); - (uint160 sqrtPriceX96, , , , , , ) = self.pool.slot0(); uint128 scaleFactor = 8; @@ -221,8 +233,8 @@ library Epoch { self, liquidity / scaleFactor, sqrtPriceX96, - sqrtPriceAX96, - sqrtPriceBX96 + TickMath.getSqrtRatioAtTick(lowerTick), + TickMath.getSqrtRatioAtTick(upperTick) ); requiredCollateral *= scaleFactor; @@ -298,7 +310,7 @@ library Epoch { : 0; uint256 availableAmount1 = Quote.quoteGasToEth( availableAmount0, - self.marketParams.baseAssetMinPriceTick + self.sqrtPriceMinX96 ); return loanAmount1 - availableAmount1; } @@ -321,15 +333,11 @@ library Epoch { : 0; uint256 availableAmount0 = Quote.quoteEthToGas( availableAmount1, - self.marketParams.baseAssetMaxPriceTick + self.sqrtPriceMaxX96 ); uint256 amount0LoanLeftover = loanAmount0 - availableAmount0; - return - Quote.quoteGasToEth( - amount0LoanLeftover, - self.marketParams.baseAssetMaxPriceTick - ); + return Quote.quoteGasToEth(amount0LoanLeftover, self.sqrtPriceMaxX96); } // function transferCollateral(Data storage self, uint256 amount) internal { diff --git a/packages/protocol/src/contracts/storage/FAccount.sol b/packages/protocol/src/contracts/storage/FAccount.sol index 38b43966..b4112a52 100644 --- a/packages/protocol/src/contracts/storage/FAccount.sol +++ b/packages/protocol/src/contracts/storage/FAccount.sol @@ -75,97 +75,24 @@ library FAccount { return address(uint160(self.tokenId)); } - struct RuntimeValidateParams { - uint160 sqrtPriceAX96; - uint160 sqrtPriceBX96; - } - - // 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 - // ); + function updateCollateral( + Data storage self, + IERC20 collateralAsset, + uint256 amount + ) internal { + if (amount > self.collateralAmount) { + collateralAsset.transferFrom( + msg.sender, + address(this), + amount - self.collateralAmount + ); + } else { + collateralAsset.transfer( + msg.sender, + self.collateralAmount - amount + ); + } - // if (maxAvailableGasToPayLoan < self.borrowedGas) { - // revert Errors.InsufficientCollateral(); - // } - // } + self.collateralAmount = amount; + } } diff --git a/packages/protocol/src/contracts/storage/Market.sol b/packages/protocol/src/contracts/storage/Market.sol index d8d3e09a..dda39d1a 100644 --- a/packages/protocol/src/contracts/storage/Market.sol +++ b/packages/protocol/src/contracts/storage/Market.sol @@ -11,7 +11,7 @@ import "../interfaces/external/ISwapRouter.sol"; import "./Errors.sol"; library Market { - struct MarketParams { + struct EpochParams { int24 baseAssetMinPriceTick; int24 baseAssetMaxPriceTick; uint24 feeRate; @@ -23,12 +23,12 @@ library Market { struct Data { address owner; - address collateralAsset; + IERC20 collateralAsset; INonfungiblePositionManager uniswapPositionManager; IUniswapV3Quoter uniswapQuoter; ISwapRouter uniswapSwapRouter; OptimisticOracleV3Interface optimisticOracleV3; - MarketParams marketParams; + EpochParams epochParams; } function load() internal pure returns (Data storage market) { @@ -46,7 +46,7 @@ library Market { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - MarketParams memory marketParams + EpochParams memory epochParams ) internal returns (Data storage market) { market = load(); @@ -59,7 +59,7 @@ library Market { } market.owner = owner; - market.collateralAsset = collateralAsset; + market.collateralAsset = IERC20(collateralAsset); market.uniswapPositionManager = INonfungiblePositionManager( uniswapPositionManager ); @@ -68,7 +68,7 @@ library Market { market.optimisticOracleV3 = OptimisticOracleV3Interface( optimisticOracleV3 ); - market.marketParams = marketParams; + market.epochParams = epochParams; } function updateValid( @@ -77,7 +77,7 @@ library Market { address uniswapQuoter, address uniswapSwapRouter, address optimisticOracleV3, - MarketParams memory marketParams + EpochParams memory epochParams ) internal returns (Data storage market) { market = load(); @@ -90,7 +90,7 @@ library Market { market.optimisticOracleV3 = OptimisticOracleV3Interface( optimisticOracleV3 ); - market.marketParams = marketParams; + market.epochParams = epochParams; } function loadValid() internal view returns (Data storage market) { diff --git a/packages/protocol/src/synthetix/interfaces/IERC20.sol b/packages/protocol/src/synthetix/interfaces/IERC20.sol index 90ee6301..acc497b3 100644 --- a/packages/protocol/src/synthetix/interfaces/IERC20.sol +++ b/packages/protocol/src/synthetix/interfaces/IERC20.sol @@ -19,7 +19,11 @@ interface IERC20 { * @param spender The address that received the allowance. * @param amount The number of tokens that were added to `spender`'s allowance. */ - event Approval(address indexed owner, address indexed spender, uint256 amount); + event Approval( + address indexed owner, + address indexed spender, + uint256 amount + ); /** * @notice Thrown when the address interacting with the contract does not have sufficient allowance to transfer tokens from another contract. @@ -72,7 +76,10 @@ interface IERC20 { * @param spender The user who was given the allowance. * @return The amount of tokens `spender` can transfer on `owner`'s behalf. */ - function allowance(address owner, address spender) external view returns (uint256); + function allowance( + address owner, + address spender + ) external view returns (uint256); /** * @notice Transfer tokens from one address to another. @@ -102,7 +109,10 @@ interface IERC20 { * * - `spender` cannot be the zero address. */ - function increaseAllowance(address spender, uint256 addedValue) external returns (bool); + function increaseAllowance( + address spender, + uint256 addedValue + ) external returns (bool); /** * @notice Atomically decreases the allowance granted to `spender` by the caller. @@ -118,7 +128,10 @@ interface IERC20 { * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ - function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool); + function decreaseAllowance( + address spender, + uint256 subtractedValue + ) external returns (bool); /** * @notice Allows a user who has been given allowance to transfer tokens on another user's behalf. @@ -127,5 +140,9 @@ interface IERC20 { * @param amount The number of tokens to transfer. * @return A boolean which is true if the operation succeeded. */ - function transferFrom(address from, address to, uint256 amount) external returns (bool); + function transferFrom( + address from, + address to, + uint256 amount + ) external returns (bool); } diff --git a/packages/protocol/test/Foil.t.sol b/packages/protocol/test/Foil.t.sol index c20f66c9..7d6e18ec 100644 --- a/packages/protocol/test/Foil.t.sol +++ b/packages/protocol/test/Foil.t.sol @@ -9,6 +9,7 @@ import {IEpochLiquidityModule} from "../src/contracts/interfaces/IEpochLiquidity import {IFoilStructs} from "../src/contracts/interfaces/IFoilStructs.sol"; import {VirtualToken} from "../src/contracts/external/VirtualToken.sol"; import {TickMath} from "../src/contracts/external/univ3/TickMath.sol"; +import {IMintableToken} from "../src/contracts/external/IMintableToken.sol"; import "../src/contracts/interfaces/external/INonfungiblePositionManager.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol"; @@ -27,11 +28,20 @@ contract FoilTest is Test { address constant UNISWAP_QUOTER = 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6; + IMintableToken collateralAsset; + function setUp() public { foil = IEpochLiquidityModule(vm.getAddress("Foil")); + collateralAsset = IMintableToken( + vm.getAddress("CollateralAsset.Token") + ); + collateralAsset.mint(1000 ether, address(this)); + collateralAsset.approve(address(foil), 1000 ether); } function test_addLiquidity() public { + console2.logAddress(address(this)); + console2.log("BALANCE", collateralAsset.balanceOf(address(this))); // int24 tickSpacing = IUniswapV3Pool(pool).tickSpacing(); // int24 lowerTick = TickMath.getTickAtSqrtRatio( // 177159557114295710296101716160 @@ -40,8 +50,8 @@ contract FoilTest is Test { // 306849353968360525628702781967 // ); // 15 uint160 sqrtPriceX96 = 146497135921788803112962621440; - uint160 sqrtPriceAX96 = 111309523877349767887238162754; // 6800 - uint160 sqrtPriceBX96 = 250203434948259642083317319084; // 23000 + uint160 sqrtPriceAX96 = 176318465955219228901572735582; + uint160 sqrtPriceBX96 = 273764932352251420676860998407; (uint256 loanAmount0, uint256 loanAmount1, ) = foil.getTokenAmounts( 50 ether, sqrtPriceX96, @@ -54,8 +64,8 @@ contract FoilTest is Test { amountTokenA: loanAmount0, amountTokenB: loanAmount1, collateralAmount: 50 ether, - lowerTick: 6800, - upperTick: 23000, + lowerTick: 16000, + upperTick: 24800, minAmountTokenA: 0, minAmountTokenB: 0 }); @@ -66,11 +76,15 @@ contract FoilTest is Test { uint256 amount1 ) = foil.createLiquidityPosition(params); + assertEq(collateralAsset.balanceOf(address(foil)), 50 ether); + uint128 halfLiquidity = liquidity / 2; uint256 coll = 25 ether; foil.decreaseLiquidityPosition(tokenId, coll, halfLiquidity, 0, 0); + assertEq(collateralAsset.balanceOf(address(foil)), 25 ether); + coll = 500 ether; foil.increaseLiquidityPosition( @@ -82,6 +96,8 @@ contract FoilTest is Test { 0 ); + assertEq(collateralAsset.balanceOf(address(foil)), 500 ether); + // (uint256 tokenAmount0, uint256 tokenAmount1) = foil.getPosition(1); // console2.log(tokenAmount0, tokenAmount1); // // new account!