Skip to content

Commit

Permalink
carbon pol eth conversion - review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanzhelyazkov committed Nov 16, 2023
1 parent c43e5e7 commit 1ca572b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 3 additions & 2 deletions contracts/pol/CarbonPOL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ contract CarbonPOL is ICarbonPOL, Upgradeable, ReentrancyGuardUpgradeable, Utils
/**
* @dev used to initialize the implementation
*/
constructor(Token bntInit) {
_bnt = bntInit;
constructor(Token initBnt) {
_validAddress(Token.unwrap(initBnt));
_bnt = initBnt;
// initialize implementation
initialize();
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/pol/interfaces/ICarbonPOL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ interface ICarbonPOL is IUpgradeable {
function tradingEnabled(Token token) external view returns (bool);

/**
* @notice returns the expected trade output (tokens received) given an eth amount sent for a token
* @notice if token == ETH, return how much bnt will be sent given an eth amount received
* @notice returns the expected trade output (tokens received) given an ETH amount sent for a token
* @notice if token == ETH, return how much BNT will be sent given an ETH amount received
*/
function expectedTradeReturn(Token token, uint128 ethAmount) external view returns (uint128 tokenAmount);

/**
* @notice returns the expected trade input (how much eth to send) given a token amount received
* @notice if token == ETH, return how much eth will be received given a bnt amount sent
* @notice if token == ETH, return how much ETH will be received given a BNT amount sent
*/
function expectedTradeInput(Token token, uint128 tokenAmount) external view returns (uint128 ethAmount);

Expand Down
11 changes: 10 additions & 1 deletion test/forge/CarbonPOL.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { TestFixture } from "./TestFixture.t.sol";
import { POLTestCaseParser } from "./POLTestCaseParser.t.sol";

import { AccessDenied, ZeroValue } from "../../contracts/utility/Utils.sol";
import { AccessDenied, ZeroValue, InvalidAddress } from "../../contracts/utility/Utils.sol";
import { Token, NATIVE_TOKEN } from "../../contracts/token/Token.sol";
import { TestReenterCarbonPOL } from "../../contracts/helpers/TestReenterCarbonPOL.sol";

import { ICarbonPOL } from "../../contracts/pol/interfaces/ICarbonPOL.sol";
import { CarbonPOL } from "../../contracts/pol/CarbonPOL.sol";

contract CarbonPOLTest is TestFixture {
using Address for address payable;
Expand Down Expand Up @@ -89,6 +90,14 @@ contract CarbonPOLTest is TestFixture {
carbonPOL.initialize();
}

/**
* @dev test should revert when deploying CarbonPOL with an invalid bnt address
*/
function testShouldRevertWhenDeployingWithInvalidBNTAddress() public {
vm.expectRevert(InvalidAddress.selector);
new CarbonPOL(Token.wrap(address(0)));
}

/**
* @dev market price multiply tests
*/
Expand Down

0 comments on commit 1ca572b

Please sign in to comment.