Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions snapshots/Hub.Operations.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"add": "86703",
"add: with transfer": "108000",
"draw": "104159",
"eliminateDeficit: full": "72578",
"eliminateDeficit: partial": "82183",
"mintFeeShares": "82752",
"payFee": "70816",
"refreshPremium": "70373",
"remove: full": "75607",
"remove: partial": "80745",
"reportDeficit": "111893",
"restore: full": "76563",
"restore: full - with transfer": "169172",
"restore: partial": "85273",
"restore: partial - with transfer": "143253",
"transferShares": "69630"
"add": "86699",
"add: with transfer": "107996",
"draw": "104155",
"eliminateDeficit: full": "72574",
"eliminateDeficit: partial": "82179",
"mintFeeShares": "82809",
"payFee": "70875",
"refreshPremium": "70393",
"remove: full": "75603",
"remove: partial": "80741",
"reportDeficit": "111972",
"restore: full": "76642",
"restore: full - with transfer": "169241",
"restore: partial": "85352",
"restore: partial - with transfer": "143332",
"transferShares": "69689"
}
12 changes: 6 additions & 6 deletions snapshots/NativeTokenGateway.Operations.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"borrowNative": "228656",
"repayNative": "166471",
"supplyAsCollateralNative": "160133",
"supplyNative": "135762",
"withdrawNative: full": "125557",
"withdrawNative: partial": "136746"
"borrowNative": "228670",
"repayNative": "166489",
"supplyAsCollateralNative": "160129",
"supplyNative": "135759",
"withdrawNative: full": "125552",
"withdrawNative: partial": "136740"
}
8 changes: 4 additions & 4 deletions snapshots/SignatureGateway.Operations.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"borrowWithSig": "213889",
"repayWithSig": "186743",
"borrowWithSig": "213903",
"repayWithSig": "186761",
"setSelfAsUserPositionManagerWithSig": "75385",
"setUsingAsCollateralWithSig": "85387",
"supplyWithSig": "151994",
"supplyWithSig": "151991",
"updateUserDynamicConfigWithSig": "63120",
"updateUserRiskPremiumWithSig": "62090",
"withdrawWithSig": "130812"
"withdrawWithSig": "130807"
}
8 changes: 4 additions & 4 deletions snapshots/Spoke.Getters.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"getUserAccountData: supplies: 0, borrows: 0": "13014",
"getUserAccountData: supplies: 1, borrows: 0": "49426",
"getUserAccountData: supplies: 2, borrows: 0": "81102",
"getUserAccountData: supplies: 2, borrows: 1": "101531",
"getUserAccountData: supplies: 2, borrows: 2": "120791"
"getUserAccountData: supplies: 1, borrows: 0": "49424",
"getUserAccountData: supplies: 2, borrows: 0": "81098",
"getUserAccountData: supplies: 2, borrows: 1": "101527",
"getUserAccountData: supplies: 2, borrows: 2": "120787"
}
50 changes: 25 additions & 25 deletions snapshots/Spoke.Operations.ZeroRiskPremium.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"borrow: first": "190384",
"borrow: second action, same reserve": "170250",
"liquidationCall (receiveShares): full": "303257",
"liquidationCall (receiveShares): partial": "302675",
"liquidationCall (reportDeficit): full": "367686",
"liquidationCall: full": "320893",
"liquidationCall: partial": "320311",
"permitReserve + repay (multicall)": "164576",
"permitReserve + supply (multicall)": "146756",
"permitReserve + supply + enable collateral (multicall)": "161207",
"repay: full": "123914",
"repay: partial": "128872",
"borrow: first": "190439",
"borrow: second action, same reserve": "170305",
"liquidationCall (receiveShares): full": "303320",
"liquidationCall (receiveShares): partial": "302738",
"liquidationCall (reportDeficit): full": "367763",
"liquidationCall: full": "320950",
"liquidationCall: partial": "320368",
"permitReserve + repay (multicall)": "164594",
"permitReserve + supply (multicall)": "146752",
"permitReserve + supply + enable collateral (multicall)": "161203",
"repay: full": "123932",
"repay: partial": "128890",
"setUserPositionManagersWithSig: disable": "47039",
"setUserPositionManagersWithSig: enable": "68951",
"supply + enable collateral (multicall)": "141409",
"supply: 0 borrows, collateral disabled": "122846",
"supply: 0 borrows, collateral enabled": "105817",
"supply: second action, same reserve": "105746",
"supply + enable collateral (multicall)": "141405",
"supply: 0 borrows, collateral disabled": "122842",
"supply: 0 borrows, collateral enabled": "105813",
"supply: second action, same reserve": "105742",
"updateUserDynamicConfig: 1 collateral": "74545",
"updateUserDynamicConfig: 2 collaterals": "89413",
"updateUserRiskPremium: 1 borrow": "95734",
"updateUserRiskPremium: 2 borrows": "105414",
"updateUserRiskPremium: 1 borrow": "95730",
"updateUserRiskPremium: 2 borrows": "105469",
"usingAsCollateral: 0 borrows, enable": "59616",
"usingAsCollateral: 1 borrow, disable": "105778",
"usingAsCollateral: 1 borrow, disable": "105774",
"usingAsCollateral: 1 borrow, enable": "42504",
"usingAsCollateral: 2 borrows, disable": "127327",
"usingAsCollateral: 2 borrows, disable": "127321",
"usingAsCollateral: 2 borrows, enable": "42516",
"withdraw: 0 borrows, full": "127955",
"withdraw: 0 borrows, partial": "132851",
"withdraw: 1 borrow, partial": "159982",
"withdraw: 2 borrows, partial": "174540",
"withdraw: non collateral": "105902"
"withdraw: 0 borrows, full": "127949",
"withdraw: 0 borrows, partial": "132843",
"withdraw: 1 borrow, partial": "159972",
"withdraw: 2 borrows, partial": "174530",
"withdraw: non collateral": "105896"
}
50 changes: 25 additions & 25 deletions snapshots/Spoke.Operations.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"borrow: first": "259319",
"borrow: second action, same reserve": "202185",
"liquidationCall (receiveShares): full": "335301",
"liquidationCall (receiveShares): partial": "334719",
"liquidationCall (reportDeficit): full": "359886",
"liquidationCall: full": "352937",
"liquidationCall: partial": "352355",
"permitReserve + repay (multicall)": "162044",
"permitReserve + supply (multicall)": "146756",
"permitReserve + supply + enable collateral (multicall)": "161207",
"repay: full": "117993",
"repay: partial": "137351",
"borrow: first": "259394",
"borrow: second action, same reserve": "202260",
"liquidationCall (receiveShares): full": "335384",
"liquidationCall (receiveShares): partial": "334802",
"liquidationCall (reportDeficit): full": "359963",
"liquidationCall: full": "353014",
"liquidationCall: partial": "352432",
"permitReserve + repay (multicall)": "162059",
"permitReserve + supply (multicall)": "146752",
"permitReserve + supply + enable collateral (multicall)": "161203",
"repay: full": "118011",
"repay: partial": "137369",
"setUserPositionManagersWithSig: disable": "47039",
"setUserPositionManagersWithSig: enable": "68951",
"supply + enable collateral (multicall)": "141409",
"supply: 0 borrows, collateral disabled": "122846",
"supply: 0 borrows, collateral enabled": "105817",
"supply: second action, same reserve": "105746",
"supply + enable collateral (multicall)": "141405",
"supply: 0 borrows, collateral disabled": "122842",
"supply: 0 borrows, collateral enabled": "105813",
"supply: second action, same reserve": "105742",
"updateUserDynamicConfig: 1 collateral": "74545",
"updateUserDynamicConfig: 2 collaterals": "89413",
"updateUserRiskPremium: 1 borrow": "149093",
"updateUserRiskPremium: 2 borrows": "199355",
"updateUserRiskPremium: 1 borrow": "149168",
"updateUserRiskPremium: 2 borrows": "199568",
"usingAsCollateral: 0 borrows, enable": "59616",
"usingAsCollateral: 1 borrow, disable": "159134",
"usingAsCollateral: 1 borrow, disable": "159209",
"usingAsCollateral: 1 borrow, enable": "42504",
"usingAsCollateral: 2 borrows, disable": "229264",
"usingAsCollateral: 2 borrows, disable": "229416",
"usingAsCollateral: 2 borrows, enable": "42516",
"withdraw: 0 borrows, full": "127955",
"withdraw: 0 borrows, partial": "132851",
"withdraw: 1 borrow, partial": "210836",
"withdraw: 2 borrows, partial": "257012",
"withdraw: non collateral": "105902"
"withdraw: 0 borrows, full": "127949",
"withdraw: 0 borrows, partial": "132843",
"withdraw: 1 borrow, partial": "210905",
"withdraw: 2 borrows, partial": "257044",
"withdraw: non collateral": "105896"
}
2 changes: 1 addition & 1 deletion src/hub/libraries/AssetLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ library AssetLogic {
});

return
(aggregatedOwedRayAfter.fromRayUp() - aggregatedOwedRayBefore.fromRayUp()).percentMulDown(
(aggregatedOwedRayAfter.fromRayUp() - aggregatedOwedRayBefore.fromRayUp()).percentMulUp(
liquidityFee
);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2549,7 +2549,7 @@ abstract contract Base is Test {
uint256 premiumIncrease,
uint256 liquidityFee
) internal pure returns (uint256) {
return (drawnIncrease + premiumIncrease).percentMulDown(liquidityFee);
return (drawnIncrease + premiumIncrease).percentMulUp(liquidityFee);
}

function _calculateExpectedFeesAmount(
Expand All @@ -2559,7 +2559,7 @@ abstract contract Base is Test {
uint256 indexDelta
) internal pure returns (uint256 feesAmount) {
return
indexDelta.rayMulUp(initialDrawnShares + initialPremiumShares).percentMulDown(liquidityFee);
indexDelta.rayMulUp(initialDrawnShares + initialPremiumShares).percentMulUp(liquidityFee);
}

function _calculateMaxSupplyAmount(
Expand Down Expand Up @@ -3123,7 +3123,7 @@ abstract contract Base is Test {
previousIndex).toInt256() - asset.premiumOffsetRay).toUint256() + asset.deficitRay;

return
(aggregatedOwedRayAfter.fromRayUp() - aggregatedOwedRayBefore.fromRayUp()).percentMulDown(
(aggregatedOwedRayAfter.fromRayUp() - aggregatedOwedRayBefore.fromRayUp()).percentMulUp(
asset.liquidityFee
);
}
Expand Down
28 changes: 6 additions & 22 deletions tests/unit/Hub/Hub.Add.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,15 @@ contract HubAddTest is HubBase {
}

function test_add_revertsWith_AmountDowncastOverflow() public {
_addAndDrawLiquidity({
hub: hub1,
assetId: daiAssetId,
addUser: bob,
addSpoke: address(spoke2),
addAmount: 1,
drawUser: alice,
drawSpoke: address(spoke1),
drawAmount: 1,
skipTime: 365 days
});
// Test that adding an amount > uint120.max reverts with SafeCast overflow
uint256 overflowAmount = uint256(type(uint120).max) + 1;
deal(address(tokenList.dai), address(hub1), overflowAmount);

uint256 shares = type(uint120).max - 2;
uint256 amount = hub1.previewAddByShares(daiAssetId, shares);
assertGt(amount, type(uint120).max);

deal(address(tokenList.dai), alice, amount);

vm.startPrank(address(spoke1));
tokenList.dai.transferFrom(alice, address(hub1), amount);
vm.prank(address(spoke1));
vm.expectRevert(
abi.encodeWithSelector(SafeCast.SafeCastOverflowedUintDowncast.selector, 120, amount)
abi.encodeWithSelector(SafeCast.SafeCastOverflowedUintDowncast.selector, 120, overflowAmount)
);
hub1.add(daiAssetId, amount);
vm.stopPrank();
hub1.add(daiAssetId, overflowAmount);
}

function test_add_fuzz_revertsWith_AddCapExceeded(uint40 newAddCap) public {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Hub/Hub.Rounding.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract HubRoundingTest is HubBase {
});

uint256 initialSharePrice = getAddExRate(daiAssetId);
assertGt(initialSharePrice, 1e30);
assertGe(initialSharePrice, 1e30);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bc fees can take entirety of the growth when its too little yeah? thats a problem of this approach like tomer said

assertLt(initialSharePrice, 1.000001e30);

for (uint256 i = 0; i < 1e4; ++i) {
Expand Down
Loading
Loading