Skip to content

Commit b5d382b

Browse files
lint
1 parent 9183656 commit b5d382b

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

src/abstract/ReceiptVault.sol

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ abstract contract ReceiptVault is
182182
(from, to, ids, amounts);
183183
}
184184

185-
/// @inheritdoc IReceiptVaultV2
186-
function receipt() public view virtual returns (IReceiptV2) {
187-
return sReceipt;
188-
}
189-
190185
/// The spec demands this function ignores per-user concerns. It seems to
191186
/// imply minting but doesn't provide a sibling conversion for burning.
192187
/// > The amount of shares that the Vault would exchange for the amount of
@@ -198,6 +193,26 @@ abstract contract ReceiptVault is
198193
return val;
199194
}
200195

196+
/// The spec demands that this function ignores per-user concerns. It seems
197+
/// to imply burning but doesn't provide a sibling conversion for minting.
198+
/// > The amount of assets that the Vault would exchange for the amount of
199+
/// > shares provided
200+
/// @inheritdoc IReceiptVaultV1
201+
function convertToAssets(uint256 shares, uint256 id) external view virtual returns (uint256) {
202+
return _calculateRedeem(
203+
shares,
204+
// Not clear what a good ID for a hypothetical context free burn
205+
// should be. Next ID is technically nonsense but we don't have
206+
// any other ID to prefer either.
207+
_shareRatioUserAgnostic(id, ShareAction.Burn)
208+
);
209+
}
210+
211+
/// @inheritdoc IReceiptVaultV2
212+
function receipt() public view virtual returns (IReceiptV2) {
213+
return sReceipt;
214+
}
215+
201216
/// @inheritdoc IReceiptVaultV1
202217
function previewDeposit(uint256 assets, uint256 minShareRatio) external payable virtual returns (uint256) {
203218
uint256 val = _calculateDeposit(
@@ -443,21 +458,6 @@ abstract contract ReceiptVault is
443458
return 1;
444459
}
445460

446-
/// The spec demands that this function ignores per-user concerns. It seems
447-
/// to imply burning but doesn't provide a sibling conversion for minting.
448-
/// > The amount of assets that the Vault would exchange for the amount of
449-
/// > shares provided
450-
/// @inheritdoc IReceiptVaultV1
451-
function convertToAssets(uint256 shares, uint256 id) external view virtual returns (uint256) {
452-
return _calculateRedeem(
453-
shares,
454-
// Not clear what a good ID for a hypothetical context free burn
455-
// should be. Next ID is technically nonsense but we don't have
456-
// any other ID to prefer either.
457-
_shareRatioUserAgnostic(id, ShareAction.Burn)
458-
);
459-
}
460-
461461
/// @inheritdoc IReceiptVaultV1
462462
function maxDeposit(address) external pure virtual returns (uint256) {
463463
// The spec states to return this if there is no deposit limit.

test/src/concrete/vault/ERC20PriceOracleReceiptVault.convertToAssets.t.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ contract ERC20PriceOracleReceiptVaultConvertToAssetsTest is ERC20PriceOracleRece
2424
address alice = LibUniqueAddressesGenerator.generateUniqueAddresses(vm, aliceSeed);
2525

2626
id = bound(id, 1, type(uint256).max);
27-
shares = bound(shares, 1, type(uint64).max);
27+
shares = bound(shares, 1, type(uint128).max);
2828

2929
vm.startPrank(alice);
3030

@@ -52,6 +52,7 @@ contract ERC20PriceOracleReceiptVaultConvertToAssetsTest is ERC20PriceOracleRece
5252

5353
vm.startPrank(alice);
5454

55+
uint256 expectedAssets = shares.fixedPointDiv(id, Math.Rounding.Down);
5556
ERC20PriceOracleReceiptVault vault = createVault(iVaultOracle, shareName, shareSymbol);
5657

5758
uint256 resultAssetsAlice = vault.convertToAssets(shares, id);
@@ -62,5 +63,6 @@ contract ERC20PriceOracleReceiptVaultConvertToAssetsTest is ERC20PriceOracleRece
6263
uint256 resultAssetsBob = vault.convertToAssets(shares, id);
6364

6465
assertEqUint(resultAssetsAlice, resultAssetsBob);
66+
assertEqUint(expectedAssets, resultAssetsAlice);
6567
}
6668
}

test/src/concrete/vault/OffchainAssetReceiptVault.convertToAssets.t.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ contract OffchainAssetReceiptVaultConvertToAssetsTest is OffchainAssetReceiptVau
2424
address alice = LibUniqueAddressesGenerator.generateUniqueAddresses(vm, aliceSeed);
2525

2626
id = bound(id, 1, type(uint256).max);
27-
shares = bound(shares, 1, type(uint64).max);
27+
shares = bound(shares, 1, type(uint128).max);
2828

2929
OffchainAssetReceiptVault vault = createVault(alice, shareName, shareSymbol);
3030

3131
uint256 expectedAssets = shares;
3232

33-
vm.startPrank(alice);
3433
uint256 resultAssets = vault.convertToAssets(shares, id);
3534

3635
assertEqUint(expectedAssets, resultAssets);

0 commit comments

Comments
 (0)