Skip to content

Commit

Permalink
Merge pull request #119 from valorem-labs-inc/bug/remove-dupe-functions
Browse files Browse the repository at this point in the history
Remove dupe functions
  • Loading branch information
neodaoist authored Nov 18, 2022
2 parents b0cf4df + 7169d9e commit ef6bcf8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
15 changes: 0 additions & 15 deletions src/OptionSettlementEngine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,6 @@ contract OptionSettlementEngine is ERC1155, IOptionSettlementEngine {
claimNum = uint96(tokenId & claimNumMask);
}

/**
* @notice Return the option for the supplied token id
* @dev See encodeTokenId() for encoding scheme
* @param tokenId The token id of the Option
* @return The stored Option
*/
function getOptionForTokenId(uint256 tokenId) public view returns (Option memory) {
(uint160 optionKey,) = decodeTokenId(tokenId);
return _option[optionKey];
}

function getClaimForTokenId(uint256 tokenId) public view returns (OptionLotClaim memory) {
return _claim[tokenId];
}

/*//////////////////////////////////////////////////////////////
// Write Options
//////////////////////////////////////////////////////////////*/
Expand Down
9 changes: 3 additions & 6 deletions test/OptionSettlement.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ contract OptionSettlementTest is Test, NFTreceiver {
option.settlementSeed = optionKey; // settlement seed is initially equal to option key
option.nextClaimNum = 1; // next claim num has been incremented

assertEq(engine.getOptionForTokenId(optionId), option);
assertEq(engine.option(optionId), option);
}

function testGetClaimForTokenId() public {
Expand All @@ -632,10 +632,7 @@ contract OptionSettlementTest is Test, NFTreceiver {
vm.prank(ALICE);
uint256 claimId = engine.write(optionId, 7);

IOptionSettlementEngine.OptionLotClaim memory claim = engine.getClaimForTokenId(claimId);

emit log_named_uint("Amount written", claim.amountWritten);
// emit log_named_boolean("Claimed", claim.claimed);
IOptionSettlementEngine.OptionLotClaim memory claim = engine.claim(claimId);

assertEq(claim.amountWritten, 7);
assertEq(claim.claimed, false);
Expand Down Expand Up @@ -1649,7 +1646,7 @@ contract OptionSettlementTest is Test, NFTreceiver {

function _assertClaimAmountExercised(uint256 claimId, uint112 amount) internal {
IOptionSettlementEngine.Underlying memory underlying = engine.underlying(claimId);
IOptionSettlementEngine.Option memory option = engine.getOptionForTokenId(claimId);
IOptionSettlementEngine.Option memory option = engine.option(claimId);
uint112 amountExercised = uint112(uint256(underlying.exercisePosition) / option.exerciseAmount);
assertEq(amount, amountExercised);
}
Expand Down

0 comments on commit ef6bcf8

Please sign in to comment.