Use mumbai testnet (#60)

* Switch to Mumbai testnet

* Using mumbai testnet

* fix makefile
This commit is contained in:
derpy-duck 2023-01-27 17:46:57 -05:00 committed by GitHub
parent dc872cb7b4
commit adb9110554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 35 deletions

View File

@ -25,12 +25,12 @@ unit-test: forge-test
.PHONY: forge-test
forge-test: dependencies
forge test --fork-url ${TESTING_FORK_RPC_AVAX} -vv --via-ir
forge test --fork-url ${TESTING_FORK_RPC_MUMBAI} -vv --via-ir
rm -rf lib/forge-std/.git
.PHONY: forge-test-verbose
forge-test-verbose: dependencies
forge test --fork-url ${TESTING_FORK_RPC_AVAX} -vvvvv --via-ir
forge test --fork-url ${TESTING_FORK_RPC_MUMBAI} -vvvvv --via-ir
rm -rf lib/forge-std/.git
.PHONY: test

View File

@ -86,7 +86,7 @@ contract Hub is HubSpokeStructs, HubSpokeMessages, HubGetters, HubSetters, HubWo
* One way to think about crb is that for every '$1 worth' of effective deposits we allow $c worth of this asset borrowed
* @param ratePrecision: A precision number that allows us to represent noninteger rate intercept value ri and rate coefficient value rca as integers.
* @param kinks: x values of points on the piecewise linear curve, using ratePrecision for decimal expression
* @param rates: y values of points on the piecewise linear curve, using ratePrecision for decimal expression; TODO: maybe these two should have different precisions
* @param rates: y values of points on the piecewise linear curve, using ratePrecision for decimal expression;
* @param reserveFactor: reserveFactor = rf * reservePrecision, The portion of the paid interest by borrowers that is diverted to the protocol for rainy day,
* the remainder is distributed among lenders of the asset
* @param reservePrecision: A precision number that allows us to represent our noninteger reserve factor rf as an integer (specifically reserveFactor = rf * reservePrecision)

View File

@ -4,6 +4,7 @@ pragma solidity ^0.8.0;
import "../HubSpokeStructs.sol";
import "./HubGetters.sol";
import "./HubSetters.sol";
import "forge-std/console.sol";
contract HubInterestUtilities is HubSpokeStructs, HubGetters, HubSetters {
/*
@ -72,10 +73,9 @@ contract HubInterestUtilities is HubSpokeStructs, HubGetters, HubSetters {
interestRate = rates[0];
}
else {
interestRate += (rates[i] - rates[i-1]) * ((borrowed * interestRateModel.ratePrecision - kinks[i-1] * deposited) / deposited) / (kinks[i] - kinks[i-1]);
interestRate += (rates[i] - rates[i-1]) * ((borrowed - kinks[i-1] * deposited) / deposited) / (kinks[i] - kinks[i-1]);
}
return (getInterestAccrualIndexPrecision() * secondsElapsed * interestRate / interestRateModel.ratePrecision) / 365 / 24 / 60 / 60;
}

View File

@ -26,7 +26,6 @@ contract SpokeUtilities is HubSpokeStructs, SpokeState, SpokeGetters, SpokeSette
SafeERC20.safeApprove(IERC20(assetAddress), tokenBridgeAddress(), assetAmount);
// TODO: Do we need to check some sort of maximum limit of assetAmount
sequence = tokenBridge().transferTokensWithPayload(
assetAddress, assetAmount, hubChainId(), bytes32(uint256(uint160(hubContractAddress()))), 0, payload
);

View File

@ -40,14 +40,14 @@ contract HubTest is Test, HubSpokeStructs, HubSpokeMessages, TestStructs, TestSt
rates0[1] = 0;
addAsset(AddAsset({
assetAddress: 0x442F7f22b1EE2c842bEAFf52880d4573E9201158, // WBNB
assetAddress: 0xF8542587BCaFCA72D78f29734cE8Ccf08fCd5E5D, // WBNB
collateralizationRatioDeposit: 100 * 10 ** 4,
collateralizationRatioBorrow: 110 * 10 ** 4,
ratePrecision: 1 * 10**6,
kinks: kinks0,
rates: rates0,
reserveFactor: 0,
pythId: vm.envBytes32("PYTH_PRICE_FEED_AVAX_bnb")
pythId: vm.envBytes32("PYTH_PRICE_FEED_bnb")
}));
uint256[] memory kinks1 = new uint256[](2);
@ -57,14 +57,14 @@ contract HubTest is Test, HubSpokeStructs, HubSpokeMessages, TestStructs, TestSt
rates1[0] = 0;
rates1[1] = 0;
addAsset(AddAsset({assetAddress: 0x8b82A291F83ca07Af22120ABa21632088fC92931, // WETH
addAsset(AddAsset({assetAddress: 0xc6735cc74553Cc2caeB9F5e1Ea0A4dAe12ef4632, // WETH
collateralizationRatioDeposit: 100 * 10 ** 4,
collateralizationRatioBorrow: 110 * 10 ** 4,
ratePrecision: 1 * 10**6,
kinks: kinks1,
rates: rates1,
reserveFactor: 0,
pythId: vm.envBytes32("PYTH_PRICE_FEED_AVAX_eth")
pythId: vm.envBytes32("PYTH_PRICE_FEED_eth")
}));
uint256[] memory kinks2 = new uint256[](2);
@ -74,14 +74,14 @@ contract HubTest is Test, HubSpokeStructs, HubSpokeMessages, TestStructs, TestSt
rates2[0] = 0;
rates2[1] = 0;
addAsset(AddAsset({assetAddress: address(getHubData().tokenBridgeContract.WETH()), // WAVAX
addAsset(AddAsset({assetAddress: address(getHubData().tokenBridgeContract.WETH()),
collateralizationRatioDeposit: 100 * 10 ** 4,
collateralizationRatioBorrow: 110 * 10 ** 4,
ratePrecision: 1 * 10**6,
kinks: kinks2,
rates: rates2,
reserveFactor: 0,
pythId: vm.envBytes32("PYTH_PRICE_FEED_AVAX_avax")
pythId: vm.envBytes32("PYTH_PRICE_FEED_matic")
}));
uint256[] memory kinks3 = new uint256[](2);
@ -91,20 +91,20 @@ contract HubTest is Test, HubSpokeStructs, HubSpokeMessages, TestStructs, TestSt
rates3[0] = 1 * 10**4;
rates3[1] = 1 * 10**4;
addAsset(AddAsset({assetAddress: 0xA56B1b9f4e5A1A1e0868F5Fd4352ce7CdF0C2A4F, // WMATIC
addAsset(AddAsset({assetAddress: 0xF8542587BCaFCA72D78f29734cE8Ccf08fCd5E5D,
collateralizationRatioDeposit: 100 * 10 ** 4,
collateralizationRatioBorrow: 100 * 10 ** 4,
ratePrecision: 1 * 10**6,
kinks: kinks3,
rates: rates3,
reserveFactor: 0,
pythId: vm.envBytes32("PYTH_PRICE_FEED_AVAX_matic")
pythId: vm.envBytes32("PYTH_PRICE_FEED_bnb")
}));
addSpoke(
uint16(vm.envUint("TESTING_WORMHOLE_CHAINID_AVAX")),
vm.envAddress("TESTING_WORMHOLE_ADDRESS_AVAX"),
vm.envAddress("TESTING_TOKEN_BRIDGE_ADDRESS_AVAX")
uint16(vm.envUint("TESTING_WORMHOLE_CHAINID_MUMBAI")),
vm.envAddress("TESTING_WORMHOLE_ADDRESS_MUMBAI"),
vm.envAddress("TESTING_TOKEN_BRIDGE_ADDRESS_MUMBAI")
);
}

View File

@ -35,24 +35,24 @@ contract TestHelpers is TestStructs, TestState, TestGetters, TestSetters, TestUt
uint256 guardianSigner = uint256(vm.envBytes32("TESTING_DEVNET_GUARDIAN"));
WormholeSimulator wormholeSimulator =
new WormholeSimulator(vm.envAddress("TESTING_WORMHOLE_ADDRESS_AVAX"), guardianSigner);
new WormholeSimulator(vm.envAddress("TESTING_WORMHOLE_ADDRESS_MUMBAI"), guardianSigner);
// we may need to interact with Wormhole throughout the test
IWormhole wormholeContract = wormholeSimulator.wormhole();
// verify Wormhole state from fork
require(wormholeContract.chainId() == uint16(vm.envUint("TESTING_WORMHOLE_CHAINID_AVAX")), "wrong chainId");
require(wormholeContract.messageFee() == vm.envUint("TESTING_WORMHOLE_MESSAGE_FEE_AVAX"), "wrong messageFee");
require(wormholeContract.chainId() == uint16(vm.envUint("TESTING_WORMHOLE_CHAINID_MUMBAI")), "wrong chainId");
require(wormholeContract.messageFee() == vm.envUint("TESTING_WORMHOLE_MESSAGE_FEE_MUMBAI"), "wrong messageFee");
require(
wormholeContract.getCurrentGuardianSetIndex() == uint32(vm.envUint("TESTING_WORMHOLE_GUARDIAN_SET_INDEX_AVAX")),
wormholeContract.getCurrentGuardianSetIndex() == uint32(vm.envUint("TESTING_WORMHOLE_GUARDIAN_SET_INDEX_MUMBAI")),
"wrong guardian set index"
);
// set up Token Bridge
ITokenBridge tokenBridgeContract = ITokenBridge(vm.envAddress("TESTING_TOKEN_BRIDGE_ADDRESS_AVAX"));
ITokenBridge tokenBridgeContract = ITokenBridge(vm.envAddress("TESTING_TOKEN_BRIDGE_ADDRESS_MUMBAI"));
// verify Token Bridge state from fork
require(tokenBridgeContract.chainId() == uint16(vm.envUint("TESTING_WORMHOLE_CHAINID_AVAX")), "wrong chainId");
require(tokenBridgeContract.chainId() == uint16(vm.envUint("TESTING_WORMHOLE_CHAINID_MUMBAI")), "wrong chainId");
// initialize Hub contract
@ -65,7 +65,7 @@ contract TestHelpers is TestStructs, TestState, TestGetters, TestSetters, TestUt
uint8 oracleMode = 1;
uint64 priceStandardDeviations = 424;
uint64 priceStandardDeviationsPrecision = 10 ** 2;
address pythAddress = vm.envAddress("TESTING_PYTH_ADDRESS_AVAX");
address pythAddress = vm.envAddress("TESTING_PYTH_ADDRESS_MUMBAI");
Hub hub = new Hub(
address(wormholeContract),
@ -97,7 +97,7 @@ contract TestHelpers is TestStructs, TestState, TestGetters, TestSetters, TestUt
setPublishTime(1);
registerChainOnHub(6, bytes32(uint256(uint160(vm.envAddress("TESTING_TOKEN_BRIDGE_ADDRESS_AVAX")))));
registerChainOnHub(uint16(vm.envUint("TESTING_WORMHOLE_CHAINID_MUMBAI")), bytes32(uint256(uint160(vm.envAddress("TESTING_TOKEN_BRIDGE_ADDRESS_MUMBAI")))));
}
@ -573,8 +573,7 @@ contract TestHelpers is TestStructs, TestState, TestGetters, TestSetters, TestUt
}
function setPrice(Asset memory asset, int64 price, uint64 conf, int32 expo, int64 emaPrice, uint64 emaConf) internal {
// TODO: Double check publish time is correct
uint64 publishTime = getPublishTime();
publishTime += 1;
setPublishTime(publishTime);

View File

@ -22,6 +22,7 @@ export TESTING_WORMHOLE_ADDRESS_BNB=0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B
export TESTING_WORMHOLE_ADDRESS_POLYGON=0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7
export TESTING_WORMHOLE_ADDRESS_AVAX=0x54a8e5f9c4CbA08F9943965859F6c34eAF03E26c
export TESTING_WORMHOLE_ADDRESS_FANTOM=0x126783A6Cb203a3E35344528B26ca3a0489a1485
export TESTING_WORMHOLE_ADDRESS_MUMBAI=0x0CBE91CF822c73C2315FB05100C2F714765d5c20
###############################################################################
@ -31,13 +32,14 @@ export TESTING_WORMHOLE_ADDRESS_FANTOM=0x126783A6Cb203a3E35344528B26ca3a0489a148
###############################################################################
export TESTING_FORK_RPC_ETH=
export TESTING_FORK_RPC_BNB=
export TESTING_FORK_RPC_POLYGON=
export TESTING_FORK_RPC_MUMBAI=https://matic-mumbai.chainstacklabs.com/
export TESTING_FORK_RPC_AVAX=https://api.avax.network/ext/bc/C/rpc
export TESTING_FORK_RPC_FANTOM=
export TESTING_FORK_CHAINID_ETH=1
export TESTING_FORK_CHAINID_BNB=56
export TESTING_FORK_CHAINID_POLYGON=137
export TESTING_FORK_CHAINID_MUMBAI=80001
export TESTING_FORK_CHAINID_AVAX=43114
export TESTING_FORK_CHAINID_FANTOM=250
@ -50,13 +52,14 @@ export TESTING_FORK_CHAINID_FANTOM=250
export TESTING_WORMHOLE_CHAINID_ETH=2
export TESTING_WORMHOLE_CHAINID_BNB=4
export TESTING_WORMHOLE_CHAINID_POLYGON=5
export TESTING_WORMHOLE_CHAINID_MUMBAI=5
export TESTING_WORMHOLE_CHAINID_AVAX=6
export TESTING_WORMHOLE_CHAINID_FANTOM=10
export TESTING_WORMHOLE_MESSAGE_FEE_AVAX=0
export TESTING_WORMHOLE_MESSAGE_FEE_MUMBAI=0
export TESTING_WORMHOLE_GUARDIAN_SET_INDEX_AVAX=3
export TESTING_WORMHOLE_GUARDIAN_SET_INDEX_MUMBAI=0
###############################################################################
export TESTING_TOKEN_BRIDGE_ADDRESS_ETH=0x3ee18B2214AFF97000D974cf647E7C347E8fa585
@ -64,6 +67,7 @@ export TESTING_TOKEN_BRIDGE_ADDRESS_BNB=0xB6F6D86a8f9879A9c87f643768d9efc38c1Da6
export TESTING_TOKEN_BRIDGE_ADDRESS_POLYGON=0x5a58505a96D1dbf8dF91cB21B54419FC36e93fdE
export TESTING_TOKEN_BRIDGE_ADDRESS_AVAX=0x0e082F06FF657D94310cB8cE8B0D9a04541d8052
export TESTING_TOKEN_BRIDGE_ADDRESS_FANTOM=0x7C9Fc5741288cDFdD83CeB07f3ea7e22618D79D2
export TESTING_TOKEN_BRIDGE_ADDRESS_MUMBAI=0x377D55a7928c046E18eEbb61977e714d2a76472a
###############################################################################
#
@ -80,8 +84,9 @@ export TESTING_FOREIGN_TOKEN_BRIDGE_ADDRESS=0000000000000000000000003ee18b2214af
#
###############################################################################
export TESTING_PYTH_ADDRESS_AVAX=0x4305FB66699C3B2702D4d05CF36551390A4c69C6
export PYTH_PRICE_FEED_AVAX_sol=0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d
export PYTH_PRICE_FEED_AVAX_bnb=0x2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f
export PYTH_PRICE_FEED_AVAX_avax=0x93da3352f9f1d105fdfe4971cfa80e9dd777bfc5d0f683ebb6e1294b92137bb7
export PYTH_PRICE_FEED_AVAX_eth=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
export PYTH_PRICE_FEED_AVAX_matic=0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52
export TESTING_PYTH_ADDRESS_MUMBAI=0xff1a0f4744e8582DF1aE09D5611b887B6a12925C
export PYTH_PRICE_FEED_sol=0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d
export PYTH_PRICE_FEED_bnb=0x2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f
export PYTH_PRICE_FEED_avax=0x93da3352f9f1d105fdfe4971cfa80e9dd777bfc5d0f683ebb6e1294b92137bb7
export PYTH_PRICE_FEED_eth=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
export PYTH_PRICE_FEED_matic=0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52