Skip to content

Commit

Permalink
Update natspec and variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincheng96 committed Apr 30, 2024
1 parent bd9be8c commit 778b6f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/quark-core-scripts/src/Paycall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ contract Paycall {
/// @notice This contract's address
address internal immutable scriptAddress;

/// @notice ETH based price feed address (i.e. ETH/USD, ETH/BTC)
address public immutable ethBasedPriceFeedAddress;
/// @notice Native token (e.g. ETH) based price feed address (e.g. ETH/USD, ETH/BTC)
address public immutable nativeTokenBasedPriceFeedAddress;

/// @notice Payment token address
address public immutable paymentTokenAddress;
Expand All @@ -34,22 +34,22 @@ contract Paycall {
/// This is a constant to account for the gas used by the Paycall contract itself that's not tracked by gasleft()
uint256 internal constant GAS_OVERHEAD = 75000;

/// @notice Difference in scale between the payment token and ETH, used to scale the payment token.
/// Will be used to scale decimals to the correct amount for payment token
/// @notice Difference in scale between the native token + price feed and the payment token, used to scale the payment token
uint256 internal immutable divisorScale;

/**
* @notice Constructor
* @param ethBasedPriceFeedAddress_ Eth based price feed address that follows Chainlink's AggregatorV3Interface correlated to the payment token
* @param nativeTokenBasedPriceFeedAddress_ Native token price feed address that follows Chainlink's AggregatorV3Interface correlated to the payment token
* @param paymentTokenAddress_ Payment token address
* @param propagateReverts_ Flag for indicating if reverts from the call should be propagated or swallowed
*/
constructor(address ethBasedPriceFeedAddress_, address paymentTokenAddress_, bool propagateReverts_) {
ethBasedPriceFeedAddress = ethBasedPriceFeedAddress_;
constructor(address nativeTokenBasedPriceFeedAddress_, address paymentTokenAddress_, bool propagateReverts_) {
nativeTokenBasedPriceFeedAddress = nativeTokenBasedPriceFeedAddress_;
paymentTokenAddress = paymentTokenAddress_;
propagateReverts = propagateReverts_;
scriptAddress = address(this);

// Note: Assumes the native token has 18 decimals
divisorScale = 10
** uint256(
18 + AggregatorV3Interface(ethBasedPriceFeedAddress).decimals()
Expand Down Expand Up @@ -81,7 +81,7 @@ contract Paycall {
}
}

(, int256 price,,,) = AggregatorV3Interface(ethBasedPriceFeedAddress).latestRoundData();
(, int256 price,,,) = AggregatorV3Interface(nativeTokenBasedPriceFeedAddress).latestRoundData();
uint256 gasUsed = gasInitial - gasleft() + GAS_OVERHEAD;
uint256 paymentAmount = gasUsed * tx.gasprice * uint256(price) / divisorScale;
if (paymentAmount > maxPaymentCost) {
Expand Down
24 changes: 12 additions & 12 deletions src/quark-core-scripts/src/Quotecall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@ contract Quotecall {
/// @notice This contract's address
address internal immutable scriptAddress;

/// @notice ETH based price feed address (i.e. ETH/USD, ETH/BTC)
address public immutable ethBasedPriceFeedAddress;
/// @notice Native token (e.g. ETH) based price feed address (e.g. ETH/USD, ETH/BTC)
address public immutable nativeTokenBasedPriceFeedAddress;

/// @notice Payment token address
address public immutable paymentTokenAddress;

/// @notice The max delta in basis points
uint256 public immutable maxDelta;
uint256 public immutable maxDeltaBps;

/// @notice Constant buffer for gas overhead
/// This is a constant to accounted for the gas used by the Quotecall contract itself that's not tracked by gasleft()
uint256 internal constant GAS_OVERHEAD = 75000;

/// @notice Difference in scale between the payment token and ETH, used to scale the payment token.
/// Will be used to scale decimals to the correct amount for payment token
/// @notice Difference in scale between the native token + price feed and the payment token, used to scale the payment token
uint256 internal immutable divisorScale;

/**
* @notice Constructor
* @param ethPriceFeed Eth based price feed address that follows Chainlink's AggregatorV3Interface correlated to the payment token
* @param paymentToken Payment token address
* @param maxDeltaBps Maximal allowed delta in basis points (100 bps = 1%)
* @param nativeTokenBasedPriceFeedAddress_ Native token based price feed address that follows Chainlink's AggregatorV3Interface correlated to the payment token
* @param paymentTokenAddress_ Payment token address
* @param maxDeltaBps_ Maximal allowed delta in basis points (100 bps = 1%)
*/
constructor(address ethPriceFeed, address paymentToken, uint256 maxDeltaBps) {
ethBasedPriceFeedAddress = ethPriceFeed;
paymentTokenAddress = paymentToken;
constructor(address nativeTokenBasedPriceFeedAddress_, address paymentTokenAddress_, uint256 maxDeltaBps_) {
nativeTokenBasedPriceFeedAddress = nativeTokenBasedPriceFeedAddress_;
paymentTokenAddress = paymentTokenAddress_;
maxDeltaBps = maxDeltaBps_;
scriptAddress = address(this);
maxDelta = maxDeltaBps;

// Note: Assumes the native token has 18 decimals
divisorScale = 10
** uint256(
18 + AggregatorV3Interface(ethBasedPriceFeedAddress).decimals()
Expand Down

0 comments on commit 778b6f5

Please sign in to comment.