Skip to content

Commit

Permalink
Merge pull request #440 from superform-xyz/coverage-payments
Browse files Browse the repository at this point in the history
test: coverage paymentHelper SUP-5257
  • Loading branch information
0xTimepunk authored Jan 18, 2024
2 parents 5f3cd16 + ab5040b commit f761e67
Show file tree
Hide file tree
Showing 4 changed files with 425 additions and 24 deletions.
68 changes: 46 additions & 22 deletions script/Abstract.Deploy.Single.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,27 @@ abstract contract AbstractDeploySingle is Script {

uint256 public constant milionTokensE18 = 1 ether;

/// @dev check https://api-utils.superform.xyz/docs#/Utils/get_gas_prices_gwei_gas_get
uint256[] public gasPrices = [
35 * 10e9, // ETH
5 * 10e9, // BSC
45 * 10e9, // AVAX
200 * 10e9, // POLY
1 * 10e8, // ARBI
1 * 10e8, // OP
1 * 10e8, // BASE
50_000_000_000, // ETH
3_000_000_000, // BSC
25_000_000_000, // AVAX
50_000_000_000, // POLY
100_000_000, // ARBI
4_000_000, // OP
1_000_000, // BASE
4 * 10e9 // GNOSIS
];

/// @dev check https://api-utils.superform.xyz/docs#/Utils/get_native_prices_chainlink_native_get
uint256[] public nativePrices = [
253_400_000_000, // ETH
31_439_000_000, // BSC
3_529_999_999, // AVAX
81_216_600, // POLY
253_400_000_000, // ARBI
253_400_000_000, // OP
253_400_000_000, // BASE
4 * 10e9 // GNOSIS
];

Expand Down Expand Up @@ -658,11 +671,22 @@ abstract contract AbstractDeploySingle is Script {
PaymentHelper(payable(vars.paymentHelper)).updateRemoteChain(
vars.chainId, 1, abi.encode(PRICE_FEEDS[vars.chainId][vars.chainId])
);
/// 500000000000
PaymentHelper(payable(vars.paymentHelper)).updateRemoteChain(
vars.chainId, 7, abi.encode(nativePrices[trueIndex])
);

PaymentHelper(payable(vars.paymentHelper)).updateRemoteChain(vars.chainId, 8, abi.encode(gasPrices[trueIndex]));

/// @dev gas per byte
PaymentHelper(payable(vars.paymentHelper)).updateRemoteChain(vars.chainId, 9, abi.encode(750));
PaymentHelper(payable(vars.paymentHelper)).updateRemoteChain(vars.chainId, 10, abi.encode(40_000));

/// @dev ackGasCost to mint superPositions
PaymentHelper(payable(vars.paymentHelper)).updateRemoteChain(
vars.chainId, 10, abi.encode(vars.chainId == ARBI ? 500_000 : 150_000)
);

PaymentHelper(payable(vars.paymentHelper)).updateRemoteChain(vars.chainId, 11, abi.encode(50_000));

/// @dev FIXME emergencyCost value
PaymentHelper(payable(vars.paymentHelper)).updateRemoteChain(vars.chainId, 12, abi.encode(10_000));

Expand Down Expand Up @@ -908,27 +932,27 @@ abstract contract AbstractDeploySingle is Script {
SuperRegistry(payable(vars.superRegistry)).setRequiredMessagingQuorum(vars.dstChainId, 1);

vars.superRegistryC.setVaultLimitPerDestination(vars.dstChainId, 5);
/*
updateGasUsed Arb = 1M, others = 200k
ackGasCost[CHAIN_ID], Arb = 500k, others = 150k -- i.e. ackGasCost on 42161 of ackGasCost[42161] = 500k
/// @dev these values are mocks and has to be replaced
/// swap gas cost: 50000
/// update gas cost: 40000
/// deposit gas cost: 70000
/// withdraw gas cost: 80000
/// default gas price: 50 Gwei
swapGasUsed Arb = 2M, others = 1M
*/
PaymentHelper(payable(vars.paymentHelper)).addRemoteChain(
vars.dstChainId,
IPaymentHelper.PaymentHelperConfig(
PRICE_FEEDS[vars.chainId][vars.dstChainId],
address(0),
50_000,
40_000,
70_000,
80_000,
12e8,
/// 12 usd
vars.dstChainId == ARBI ? 2_000_000 : 1_000_000,
vars.dstChainId == ARBI ? 1_000_000 : 200_000,
vars.dstChainId == ARBI ? 1_000_000 : 200_000,
vars.dstChainId == ARBI ? 750_000 : 150_000,
nativePrices[vars.dstTrueIndex],
gasPrices[vars.dstTrueIndex],
750,
10_000,
2_000_000,
/// @dev ackGasCost to move a msg from dst to source
10_000,
10_000
)
Expand Down
1 change: 1 addition & 0 deletions src/EmergencyQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ contract EmergencyQueue is IEmergencyQueue {
_executeQueuedWithdrawal(id_);
}

/// @inheritdoc IEmergencyQueue
function batchExecuteQueuedWithdrawal(uint256[] calldata ids_) external override onlyEmergencyAdmin {
for (uint256 i; i < ids_.length; ++i) {
_executeQueuedWithdrawal(ids_[i]);
Expand Down
2 changes: 1 addition & 1 deletion src/payments/PaymentHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ contract PaymentHelper is IPaymentHelper {
}

if (config_.gasPriceOracle != address(0)) {
AggregatorV3Interface gasPriceOracleContract = AggregatorV3Interface(config_.nativeFeedOracle);
AggregatorV3Interface gasPriceOracleContract = AggregatorV3Interface(config_.gasPriceOracle);
if (gasPriceOracleContract.decimals() != SUPPORTED_FEED_PRECISION) {
revert Error.CHAINLINK_UNSUPPORTED_DECIMAL();
}
Expand Down
Loading

0 comments on commit f761e67

Please sign in to comment.