diff --git a/packages/frontend/public/assets/images/protocol-icons/tokens/stMATIC.svg b/packages/frontend/public/assets/images/protocol-icons/tokens/stMATIC.svg
new file mode 100644
index 000000000..0fedd8461
--- /dev/null
+++ b/packages/frontend/public/assets/images/protocol-icons/tokens/stMATIC.svg
@@ -0,0 +1,10 @@
+
diff --git a/packages/protocol/deploy-configs/arbitrum.json b/packages/protocol/deploy-configs/arbitrum.json
index 48b776fbf..ca69de11f 100644
--- a/packages/protocol/deploy-configs/arbitrum.json
+++ b/packages/protocol/deploy-configs/arbitrum.json
@@ -105,6 +105,15 @@
"providers": ["Aave_V3_Arbitrum", "Compound_V3_Arbitrum", "DForce_Arbitrum"],
"rating": 80
},
+ {
+ "collateral": "WETH",
+ "debt": "USDT",
+ "liqRatio": 820000000000000000,
+ "maxLtv": 780000000000000000,
+ "name": "BorrowingVault-WETHUSDT-1",
+ "providers": ["Aave_V3_Arbitrum", "DForce_Arbitrum"],
+ "rating": 80
+ },
{
"collateral": "WETH",
"debt": "DAI",
diff --git a/packages/protocol/deploy-configs/ethereum.json b/packages/protocol/deploy-configs/ethereum.json
index cb113b824..8dc8cdcab 100644
--- a/packages/protocol/deploy-configs/ethereum.json
+++ b/packages/protocol/deploy-configs/ethereum.json
@@ -127,7 +127,7 @@
},
{
"asset": "USDT",
- "market": "0x71fc860F7D3A592A4a98740e39dB31d25db65ae8",
+ "market": "0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811",
"name": "Aave_V2"
}
],
@@ -194,7 +194,25 @@
"liqRatio": 820000000000000000,
"maxLtv": 780000000000000000,
"name": "BorrowingVault-WETHUSDC-3",
- "providers": ["Morpho_Compound", "Morpho_Aave_V2"],
+ "providers": ["Morpho_Aave_V2","Morpho_Compound","Compound_V3"],
+ "rating": 85
+ },
+ {
+ "collateral": "WETH",
+ "debt": "USDT",
+ "liqRatio": 820000000000000000,
+ "maxLtv": 780000000000000000,
+ "name": "BorrowingVault-WETHUSDT-1",
+ "providers": ["Morpho_Aave_V2","Morpho_Compound"],
+ "rating": 85
+ },
+ {
+ "collateral": "WETH",
+ "debt": "DAI",
+ "liqRatio": 820000000000000000,
+ "maxLtv": 800000000000000000,
+ "name": "BorrowingVault-WETHDAI-1",
+ "providers": ["Spark","Morpho_Compound", "Morpho_Aave_V2"],
"rating": 85
},
{
diff --git a/packages/protocol/deploy-configs/gnosis.json b/packages/protocol/deploy-configs/gnosis.json
index bc15915a2..b5f9208fe 100644
--- a/packages/protocol/deploy-configs/gnosis.json
+++ b/packages/protocol/deploy-configs/gnosis.json
@@ -73,6 +73,33 @@
"name": "BorrowingVault-WSTETGNO-1",
"providers": ["Agave_Gnosis"],
"rating": 75
+ },
+ {
+ "collateral": "WETH",
+ "debt": "DAI",
+ "liqRatio": 800000000000000000,
+ "maxLtv": 750000000000000000,
+ "name": "BorrowingVault-WETHDAI-1",
+ "providers": ["Agave_Gnosis"],
+ "rating": 80
+ },
+ {
+ "collateral": "WBTC",
+ "debt": "USDC",
+ "liqRatio": 750000000000000000,
+ "maxLtv": 700000000000000000,
+ "name": "BorrowingVault-WBTCUSDC-1",
+ "providers": ["Agave_Gnosis"],
+ "rating": 80
+ },
+ {
+ "collateral": "WBTC",
+ "debt": "DAI",
+ "liqRatio": 750000000000000000,
+ "maxLtv": 700000000000000000,
+ "name": "BorrowingVault-WBTCDAI-1",
+ "providers": ["Agave_Gnosis"],
+ "rating": 80
}
],
"yield-vaults": [
diff --git a/packages/protocol/deploy-configs/optimism.json b/packages/protocol/deploy-configs/optimism.json
index 194898cda..2266dced5 100644
--- a/packages/protocol/deploy-configs/optimism.json
+++ b/packages/protocol/deploy-configs/optimism.json
@@ -101,6 +101,15 @@
"providers": ["DForce_Optimism", "Aave_V3_Optimism"],
"rating": 90
},
+ {
+ "collateral": "WETH",
+ "debt": "USDT",
+ "liqRatio": 820000000000000000,
+ "maxLtv": 800000000000000000,
+ "name": "BorrowingVault-WETHUSDT-1",
+ "providers": ["DForce_Optimism", "Aave_V3_Optimism"],
+ "rating": 80
+ },
{
"collateral": "WETH",
"debt": "DAI",
diff --git a/packages/protocol/deploy-configs/polygon.json b/packages/protocol/deploy-configs/polygon.json
index e99e67299..f4dac229c 100644
--- a/packages/protocol/deploy-configs/polygon.json
+++ b/packages/protocol/deploy-configs/polygon.json
@@ -95,10 +95,10 @@
{
"collateral": "MATICX",
"debt": "USDC",
- "liqRatio": 670000000000000000,
- "maxLtv": 560000000000000000,
+ "liqRatio": 600000000000000000,
+ "maxLtv": 550000000000000000,
"name": "BorrowingVault-MATICXUSDC-1",
- "providers": ["Aave_V3_Polygon"],
+ "providers": ["Aave_V3_Polygon","Compound_V3_Polygon"],
"rating": 90
},
{
@@ -136,6 +136,42 @@
"name": "BorrowingVault-WETHDAI-2",
"providers": ["DForce_Polygon", "Aave_V2_Polygon", "Aave_V3_Polygon"],
"rating": 85
+ },
+ {
+ "collateral": "WETH",
+ "debt": "USDT",
+ "liqRatio": 820000000000000000,
+ "maxLtv": 800000000000000000,
+ "name": "BorrowingVault-WETHUSDT-1",
+ "providers": ["Aave_V2_Polygon", "Aave_V3_Polygon","DForce_Polygon"],
+ "rating": 85
+ },
+ {
+ "collateral": "MATICX",
+ "debt": "WMATIC",
+ "liqRatio": 940000000000000000,
+ "maxLtv": 920000000000000000,
+ "name": "BorrowingVault-MATICXWMATIC-1",
+ "providers": ["Aave_V3_Polygon"],
+ "rating": 95
+ },
+ {
+ "collateral": "STMATIC",
+ "debt": "WMATIC",
+ "liqRatio": 940000000000000000,
+ "maxLtv": 920000000000000000,
+ "name": "BorrowingVault-STMATICWMATIC-1",
+ "providers": ["Aave_V3_Polygon"],
+ "rating": 95
+ },
+ {
+ "collateral": "STMATIC",
+ "debt": "MATICX",
+ "liqRatio": 940000000000000000,
+ "maxLtv": 920000000000000000,
+ "name": "BorrowingVault-STMATICMATICX-1",
+ "providers": ["Aave_V3_Polygon"],
+ "rating": 95
}
],
"yield-vaults": [
diff --git a/packages/protocol/deployments/arbitrum/BorrowingVault-WETHUSDT-1 b/packages/protocol/deployments/arbitrum/BorrowingVault-WETHUSDT-1
new file mode 100644
index 000000000..a9251ce8b
--- /dev/null
+++ b/packages/protocol/deployments/arbitrum/BorrowingVault-WETHUSDT-1
@@ -0,0 +1 @@
+0x404CE931E95Bd8B53433e5f96e0F678f3C8bee9A
diff --git a/packages/protocol/deployments/arbitrum/RebalancerManager b/packages/protocol/deployments/arbitrum/RebalancerManager
index 490d9e481..95ec74595 100644
--- a/packages/protocol/deployments/arbitrum/RebalancerManager
+++ b/packages/protocol/deployments/arbitrum/RebalancerManager
@@ -1 +1 @@
-0x3C4a35203013C26220281B425052A069c54bB0f4
+0xc60BC5a846BE0312A25f7628fF505C774A43FEA2
diff --git a/packages/protocol/deployments/ethereum/BorrowingVault-WETHDAI-1 b/packages/protocol/deployments/ethereum/BorrowingVault-WETHDAI-1
new file mode 100644
index 000000000..d4ca4c614
--- /dev/null
+++ b/packages/protocol/deployments/ethereum/BorrowingVault-WETHDAI-1
@@ -0,0 +1 @@
+0x997102a0eC576a71B91B673eDfb673B3b2Ee922A
diff --git a/packages/protocol/deployments/ethereum/BorrowingVault-WETHUSDT-1 b/packages/protocol/deployments/ethereum/BorrowingVault-WETHUSDT-1
new file mode 100644
index 000000000..ddd5aa8f7
--- /dev/null
+++ b/packages/protocol/deployments/ethereum/BorrowingVault-WETHUSDT-1
@@ -0,0 +1 @@
+0x442Ff33a7759e3a82AaD380876Ea1B9D26997fCD
diff --git a/packages/protocol/deployments/ethereum/RebalancerManager b/packages/protocol/deployments/ethereum/RebalancerManager
index 4e3910e1e..8c29fe398 100644
--- a/packages/protocol/deployments/ethereum/RebalancerManager
+++ b/packages/protocol/deployments/ethereum/RebalancerManager
@@ -1 +1 @@
-0xA2A7c7DC114765B21E7D167d9665D3992152E6d9
+0x229195fE6CdB876eD7D55f939b5695e27B3cB425
diff --git a/packages/protocol/deployments/gnosis/BorrowingVault-WBTCDAI-1 b/packages/protocol/deployments/gnosis/BorrowingVault-WBTCDAI-1
new file mode 100644
index 000000000..f77da10dd
--- /dev/null
+++ b/packages/protocol/deployments/gnosis/BorrowingVault-WBTCDAI-1
@@ -0,0 +1 @@
+0x2f4F37f06179d0e969D2350beE8ABe663De0dab7
diff --git a/packages/protocol/deployments/gnosis/BorrowingVault-WBTCUSDC b/packages/protocol/deployments/gnosis/BorrowingVault-WBTCUSDC
deleted file mode 100644
index ad0b15d24..000000000
--- a/packages/protocol/deployments/gnosis/BorrowingVault-WBTCUSDC
+++ /dev/null
@@ -1 +0,0 @@
-0xAc8b2Ef955A36fc3a74d7eC4E5346304BD4C4a71
diff --git a/packages/protocol/deployments/gnosis/BorrowingVault-WBTCUSDC-1 b/packages/protocol/deployments/gnosis/BorrowingVault-WBTCUSDC-1
new file mode 100644
index 000000000..d544283b3
--- /dev/null
+++ b/packages/protocol/deployments/gnosis/BorrowingVault-WBTCUSDC-1
@@ -0,0 +1 @@
+0xe3298F965553b4aeF40fBe4BBa916DEc12F3d694
diff --git a/packages/protocol/deployments/gnosis/BorrowingVault-WETHDAI-1 b/packages/protocol/deployments/gnosis/BorrowingVault-WETHDAI-1
new file mode 100644
index 000000000..9a383a2f7
--- /dev/null
+++ b/packages/protocol/deployments/gnosis/BorrowingVault-WETHDAI-1
@@ -0,0 +1 @@
+0x848bE4352c984173D1927239f1c3a2b3FC3baf7b
diff --git a/packages/protocol/deployments/gnosis/RebalancerManager b/packages/protocol/deployments/gnosis/RebalancerManager
index 9ad88c177..afba1847e 100644
--- a/packages/protocol/deployments/gnosis/RebalancerManager
+++ b/packages/protocol/deployments/gnosis/RebalancerManager
@@ -1 +1 @@
-0xD4444B5c9f2fD888AdCA17673056F4497E526448
\ No newline at end of file
+0x1C3378782be2a268627194C95A06535e8945F618
diff --git a/packages/protocol/deployments/optimism/BorrowingVault-WETHUSDT-1 b/packages/protocol/deployments/optimism/BorrowingVault-WETHUSDT-1
new file mode 100644
index 000000000..282c4b644
--- /dev/null
+++ b/packages/protocol/deployments/optimism/BorrowingVault-WETHUSDT-1
@@ -0,0 +1 @@
+0x2EDaEecDA025579be8A0B4E0C77401bB5a56f26A
diff --git a/packages/protocol/deployments/optimism/RebalancerManager b/packages/protocol/deployments/optimism/RebalancerManager
index 023d3d49e..cd6bc26d6 100644
--- a/packages/protocol/deployments/optimism/RebalancerManager
+++ b/packages/protocol/deployments/optimism/RebalancerManager
@@ -1 +1 @@
-0x82a2646400032eaa9C32022F7b1d4335E1789F85
+0x079bE6D395F6fF0090F5bdC20b4B618590A81b5D
diff --git a/packages/protocol/deployments/polygon/BorrowingVault-MATICXWMATIC-1 b/packages/protocol/deployments/polygon/BorrowingVault-MATICXWMATIC-1
new file mode 100644
index 000000000..68893da3b
--- /dev/null
+++ b/packages/protocol/deployments/polygon/BorrowingVault-MATICXWMATIC-1
@@ -0,0 +1 @@
+0xFcA5b6897Aa76e475a69F166c0a738541a0F22a0
diff --git a/packages/protocol/deployments/polygon/BorrowingVault-STMATICMATICX-1 b/packages/protocol/deployments/polygon/BorrowingVault-STMATICMATICX-1
new file mode 100644
index 000000000..37d33fa0e
--- /dev/null
+++ b/packages/protocol/deployments/polygon/BorrowingVault-STMATICMATICX-1
@@ -0,0 +1 @@
+0x18534C6ed4c46bC1A3755aC8A2B218447f625528
diff --git a/packages/protocol/deployments/polygon/BorrowingVault-STMATICWMATIC-1 b/packages/protocol/deployments/polygon/BorrowingVault-STMATICWMATIC-1
new file mode 100644
index 000000000..d44f50b7b
--- /dev/null
+++ b/packages/protocol/deployments/polygon/BorrowingVault-STMATICWMATIC-1
@@ -0,0 +1 @@
+0x0358734be360822845Db69d41781Bf3f4d71F5E9
diff --git a/packages/protocol/deployments/polygon/BorrowingVault-WETHUSDT-1 b/packages/protocol/deployments/polygon/BorrowingVault-WETHUSDT-1
new file mode 100644
index 000000000..caf61ee78
--- /dev/null
+++ b/packages/protocol/deployments/polygon/BorrowingVault-WETHUSDT-1
@@ -0,0 +1 @@
+0x0660a711812BE76C61ec704A1D39Fc9612dEAff9
diff --git a/packages/protocol/deployments/polygon/RebalancerManager b/packages/protocol/deployments/polygon/RebalancerManager
index 41df17dfc..cc743ccca 100644
--- a/packages/protocol/deployments/polygon/RebalancerManager
+++ b/packages/protocol/deployments/polygon/RebalancerManager
@@ -1 +1 @@
-0x656337719FD1FD94914962f3752f6d04d437d62f
+0x8aCc490C1c110fF070539e9fb283168412849292
diff --git a/packages/protocol/src/RebalancerManager.sol b/packages/protocol/src/RebalancerManager.sol
index 0d1c42208..f3faa5404 100644
--- a/packages/protocol/src/RebalancerManager.sol
+++ b/packages/protocol/src/RebalancerManager.sol
@@ -76,21 +76,28 @@ contract RebalancerManager is IRebalancerManager, SystemAccessControl {
}
vault.rebalance(assets, 0, from, to, 0, setToAsActiveProvider);
} else {
+ // BorrowingVault
if (debt == type(uint256).max) {
debt = from.getBorrowBalance(address(vault), vault);
}
- // BorrowingVault
if (assets == 0 && debt == 0) {
// Should at least move some assets or debt across providers.
revert RebalancerManager__rebalanceVault_invalidAmount();
}
- _checkDebtAmount(vault, debt, from);
- if (!chief.allowedFlasher(address(flasher))) {
- revert RebalancerManager__rebalanceVault_notValidFlasher();
+
+ if (debt == 0) {
+ // Rebalance only assets do not require flashloan
+ vault.rebalance(assets, 0, from, to, 0, setToAsActiveProvider);
+ } else {
+ // Check flasher is valid
+ if (!chief.allowedFlasher(address(flasher))) {
+ revert RebalancerManager__rebalanceVault_notValidFlasher();
+ }
+ _checkDebtAmount(vault, debt, from);
+ _checkLtvChange(vault, from, to, assets, debt);
+ _getFlashloan(vault, assets, debt, from, to, flasher, setToAsActiveProvider);
}
- _checkLtvChange(vault, from, to, assets, debt);
- _getFlashloan(vault, assets, debt, from, to, flasher, setToAsActiveProvider);
}
success = true;
@@ -271,6 +278,14 @@ contract RebalancerManager is IRebalancerManager, SystemAccessControl {
flasher.initiateFlashloan(debtAsset, debt, address(this), requestorCall);
}
+ /**
+ * @dev Reset the `_entryPoint` state variable.
+ */
+ function _resetEntryPoint() private {
+ // Reset the `_entryPoint`.
+ _entryPoint = "";
+ }
+
/**
* @notice Callback function that completes execution logic of a rebalance
* operation with a flashloan.
@@ -299,6 +314,11 @@ contract RebalancerManager is IRebalancerManager, SystemAccessControl {
external
returns (bool success)
{
+ // Check caller is a valid flasher
+ if (!chief.allowedFlasher(msg.sender)) {
+ revert RebalancerManager__rebalanceVault_notValidFlasher();
+ }
+ // Check flashloan originator is reentering properly
_checkReentry(vault, assets, debt, from, to, flasher, setToAsActiveProvider);
IERC20 debtAsset = IERC20(vault.debtAsset());
@@ -315,8 +335,20 @@ contract RebalancerManager is IRebalancerManager, SystemAccessControl {
debtAsset.safeTransfer(address(flasher), debt + flashloanFee);
- // Re-initialize the `_entryPoint`.
- _entryPoint = "";
+ _resetEntryPoint();
success = true;
}
+
+ /**
+ * @dev Forces to reset the `_entryPoint` state variable.
+ * This is needed in emergency case that `_resetEntryPoint()` is not reached due to
+ * external failure in execution of `completeRebalance()`.
+ * Otherwise, RebalancerManager will remain inoperable.
+ *
+ * Requirements:
+ * - Must be called from the timelock.
+ */
+ function hardResetEntryPoint() external onlyTimelock {
+ _resetEntryPoint();
+ }
}
diff --git a/packages/protocol/test/mocking/vaults/VaultRebalancing.t.sol b/packages/protocol/test/mocking/vaults/VaultRebalancing.t.sol
index 7899d3629..8b150ed8b 100644
--- a/packages/protocol/test/mocking/vaults/VaultRebalancing.t.sol
+++ b/packages/protocol/test/mocking/vaults/VaultRebalancing.t.sol
@@ -346,6 +346,38 @@ contract VaultRebalancingUnitTests is MockingSetup, MockRoutines {
assertEq(mockProviderB.getBorrowBalance(address(bvault), IVault(address(bvault))), debt);
}
+ function test_rebalanceBorrowingVaultWithRebalancerOnlyPartialAssets() public {
+ uint256 assets = DEPOSIT_AMOUNT / 2; // ALICE, BOB, CHARLIE, DAVID
+
+ //rebalance only partial assets should be ok
+ rebalancer.rebalanceVault(bvault, assets, 0, mockProviderA, mockProviderB, flasher, false);
+ assertEq(mockProviderB.getDepositBalance(address(bvault), IVault(address(bvault))), assets);
+
+ MockFlasher invalidFlasher = new MockFlasher();
+ //rebalance only partial assets even with invalid flasher should be ok since only assets do not use flashloan
+ rebalancer.rebalanceVault(
+ bvault, assets, 0, mockProviderB, mockProviderA, invalidFlasher, false
+ );
+ assertEq(mockProviderB.getDepositBalance(address(bvault), IVault(address(bvault))), 0);
+ }
+
+ function test_rebalanceBorrowingVaultWithRebalancerOnlyFullAssets() public {
+ // Payback all debt properly.
+ do_payback(BORROW_AMOUNT, bvault, ALICE);
+ do_payback(BORROW_AMOUNT, bvault, BOB);
+ do_payback(BORROW_AMOUNT, bvault, CHARLIE);
+ do_payback(BORROW_AMOUNT, bvault, DAVID);
+
+ uint256 assets = 4 * DEPOSIT_AMOUNT + initVaultShares; // ALICE, BOB, CHARLIE, DAVID
+ //rebalance only partial assets should be ok
+ rebalancer.rebalanceVault(bvault, assets, 0, mockProviderA, mockProviderB, flasher, true);
+ assertEq(mockProviderA.getDepositBalance(address(bvault), IVault(address(bvault))), 0);
+ assertEq(mockProviderB.getDepositBalance(address(bvault), IVault(address(bvault))), assets);
+
+ ILendingProvider currentProvider = bvault.activeProvider();
+ assertEq(address(currentProvider), address(mockProviderB));
+ }
+
function test_rebalanceYieldVaultWithRebalancer() public {
uint256 assets = 4 * DEPOSIT_AMOUNT + initVaultShares; // ALICE, BOB, CHARLIE, DAVID
@@ -383,10 +415,13 @@ contract VaultRebalancingUnitTests is MockingSetup, MockRoutines {
function test_notValidFlasher() public {
uint256 assets = 4 * DEPOSIT_AMOUNT; // ALICE, BOB, CHARLIE, DAVID
MockFlasher invalidFlasher = new MockFlasher();
+ uint256 debt = 4 * BORROW_AMOUNT; // ALICE, BOB, CHARLIE, DAVID
//rebalance with invalid flasher should fail
vm.expectRevert(RebalancerManager.RebalancerManager__rebalanceVault_notValidFlasher.selector);
- rebalancer.rebalanceVault(bvault, assets, 0, mockProviderA, mockProviderB, invalidFlasher, true);
+ rebalancer.rebalanceVault(
+ bvault, assets, debt, mockProviderA, mockProviderB, invalidFlasher, true
+ );
}
// error RebalancerManager__checkAssetsAmount_invalidAmount();
diff --git a/packages/sdk/src/constants/addresses.ts b/packages/sdk/src/constants/addresses.ts
index fb416f839..60dfc9489 100644
--- a/packages/sdk/src/constants/addresses.ts
+++ b/packages/sdk/src/constants/addresses.ts
@@ -94,6 +94,24 @@ export const RETH_ADDRESS: AddressMap = {
[ChainId.GNOSIS]: Address.from(AddressZero),
};
+export const WBTC_ADDRESS: AddressMap = {
+ [ChainId.ETHEREUM]: Address.from(
+ '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'
+ ),
+ [ChainId.MATIC]: Address.from('0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6'),
+ [ChainId.FANTOM]: Address.from(AddressZero),
+ [ChainId.ARBITRUM]: Address.from(
+ '0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f'
+ ),
+ [ChainId.OPTIMISM]: Address.from(
+ '0x68f180fcCe6836688e9084f035309E29Bf0A2095'
+ ),
+ [ChainId.GOERLI]: Address.from(AddressZero),
+ [ChainId.OPTIMISM_GOERLI]: Address.from(AddressZero),
+ [ChainId.MATIC_MUMBAI]: Address.from(AddressZero),
+ [ChainId.GNOSIS]: Address.from('0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252'),
+};
+
export const GNO_ADDRESS: AddressMap = {
[ChainId.ETHEREUM]: Address.from(
'0x6810e776880C02933D47DB1b9fc05908e5386b96'
diff --git a/packages/sdk/src/constants/tokens.ts b/packages/sdk/src/constants/tokens.ts
index a41ef3640..db3972fa7 100644
--- a/packages/sdk/src/constants/tokens.ts
+++ b/packages/sdk/src/constants/tokens.ts
@@ -12,6 +12,7 @@ import {
RETH_ADDRESS,
USDC_ADDRESS,
USDT_ADDRESS,
+ WBTC_ADDRESS,
WETH9_ADDRESS,
WNATIVE_ADDRESS,
WSTETH_ADDRESS,
@@ -347,6 +348,72 @@ export const WETH9: TokenMap = {
),
};
+export const WBTC: TokenMap = {
+ [ChainId.ETHEREUM]: new Token(
+ ChainId.ETHEREUM,
+ WBTC_ADDRESS[ChainId.ETHEREUM],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+ [ChainId.GOERLI]: new Token(
+ ChainId.GOERLI,
+ WBTC_ADDRESS[ChainId.GOERLI],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+ [ChainId.ARBITRUM]: new Token(
+ ChainId.ARBITRUM,
+ WBTC_ADDRESS[ChainId.ARBITRUM],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+ [ChainId.FANTOM]: new Token(
+ ChainId.FANTOM,
+ WBTC_ADDRESS[ChainId.FANTOM],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+ [ChainId.MATIC]: new Token(
+ ChainId.MATIC,
+ WBTC_ADDRESS[ChainId.MATIC],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+ [ChainId.MATIC_MUMBAI]: new Token(
+ ChainId.MATIC_MUMBAI,
+ WBTC_ADDRESS[ChainId.MATIC_MUMBAI],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+ [ChainId.OPTIMISM]: new Token(
+ ChainId.OPTIMISM,
+ WBTC_ADDRESS[ChainId.OPTIMISM],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+ [ChainId.OPTIMISM_GOERLI]: new Token(
+ ChainId.OPTIMISM_GOERLI,
+ WBTC_ADDRESS[ChainId.OPTIMISM_GOERLI],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+ [ChainId.GNOSIS]: new Token(
+ ChainId.GNOSIS,
+ WBTC_ADDRESS[ChainId.GNOSIS],
+ 8,
+ 'WBTC',
+ 'Wrapped BTC'
+ ),
+};
+
export const MATICX = new Token(
ChainId.MATIC,
Address.from('0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6'),
@@ -355,6 +422,14 @@ export const MATICX = new Token(
'Liquid Staking Matic'
);
+export const STMATIC = new Token(
+ ChainId.MATIC,
+ Address.from('0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4'),
+ 18,
+ 'stMatic',
+ 'Staked Matic (POS)'
+);
+
export const WSTETH: TokenMap = {
[ChainId.ETHEREUM]: new Token(
ChainId.ETHEREUM,
diff --git a/packages/sdk/src/constants/vaults.ts b/packages/sdk/src/constants/vaults.ts
index 2b7f12c9e..940b52879 100644
--- a/packages/sdk/src/constants/vaults.ts
+++ b/packages/sdk/src/constants/vaults.ts
@@ -49,11 +49,11 @@ export const VAULT_LIST: ChainVaultList = {
WETH9[ChainId.ETHEREUM],
USDC[ChainId.ETHEREUM]
),
- //new BorrowingVault(
- //Address.from('0xC5A93F0EEaB26ef8f6bE7D35451E2f4B55Dfd25d'),
- //WETH9[ChainId.ETHEREUM],
- //USDC[ChainId.ETHEREUM]
- //),
+ new BorrowingVault(
+ Address.from('0xC5A93F0EEaB26ef8f6bE7D35451E2f4B55Dfd25d'),
+ WETH9[ChainId.ETHEREUM],
+ USDC[ChainId.ETHEREUM]
+ ),
new BorrowingVault(
Address.from('0xf7a7cf71d9986f7fcBC2A71eE6bcF271ACb3DC7A'),
WSTETH[ChainId.ETHEREUM],
@@ -79,6 +79,16 @@ export const VAULT_LIST: ChainVaultList = {
WSTETH[ChainId.ETHEREUM],
GHO[ChainId.ETHEREUM]
),
+ new BorrowingVault(
+ Address.from('0x442Ff33a7759e3a82AaD380876Ea1B9D26997fCD'),
+ WETH9[ChainId.ETHEREUM],
+ USDT[ChainId.ETHEREUM]
+ ),
+ new BorrowingVault(
+ Address.from('0x997102a0eC576a71B91B673eDfb673B3b2Ee922A'),
+ WETH9[ChainId.ETHEREUM],
+ DAI[ChainId.ETHEREUM]
+ ),
],
[ChainId.GOERLI]: [
new BorrowingVault(
@@ -124,11 +134,31 @@ export const VAULT_LIST: ChainVaultList = {
WETH9[ChainId.MATIC],
DAI[ChainId.MATIC]
),
+ new BorrowingVault(
+ Address.from('0x0660a711812BE76C61ec704A1D39Fc9612dEAff9'),
+ WETH9[ChainId.MATIC],
+ USDT[ChainId.MATIC]
+ ),
new BorrowingVault(
Address.from('0x37F943A180A9E31A0633ad493A52CA18BECD1B5c'),
MATICX,
USDC[ChainId.MATIC]
),
+ new BorrowingVault(
+ Address.from('0xFcA5b6897Aa76e475a69F166c0a738541a0F22a0'),
+ MATICX,
+ WNATIVE[ChainId.MATIC]
+ ),
+ //new BorrowingVault(
+ //Address.from('0x0358734be360822845Db69d41781Bf3f4d71F5E9'),
+ //STMATIC,
+ //WNATIVE[ChainId.MATIC]
+ //),
+ //new BorrowingVault(
+ //Address.from('0x18534C6ed4c46bC1A3755aC8A2B218447f625528'),
+ //STMATIC,
+ //MATICX
+ //),
],
[ChainId.MATIC_MUMBAI]: [
new BorrowingVault(
@@ -191,7 +221,7 @@ export const VAULT_LIST: ChainVaultList = {
USDC[ChainId.ARBITRUM]
),
//new BorrowingVault(
- //Address.from('0xe2A42570C5b0d764f615368A50bE40EfB5D91D9A'),
+ //Address.from('0x404CE931E95Bd8B53433e5f96e0F678f3C8bee9A'),
//WETH9[ChainId.ARBITRUM],
//USDT[ChainId.ARBITRUM]
//),
@@ -248,6 +278,11 @@ export const VAULT_LIST: ChainVaultList = {
WETH9[ChainId.OPTIMISM],
DAI[ChainId.OPTIMISM]
),
+ //new BorrowingVault(
+ //Address.from('0x2EDaEecDA025579be8A0B4E0C77401bB5a56f26A'),
+ //WETH9[ChainId.OPTIMISM],
+ //USDT[ChainId.OPTIMISM]
+ //),
new BorrowingVault(
Address.from('0x24B76CD2693856FaDe3027c4cc69DaC9Fd6f71c4'),
WSTETH[ChainId.OPTIMISM],
@@ -308,6 +343,26 @@ export const VAULT_LIST: ChainVaultList = {
WETH9[ChainId.GNOSIS],
USDC[ChainId.GNOSIS]
),
+ //new BorrowingVault(
+ //Address.from('0x848bE4352c984173D1927239f1c3a2b3FC3baf7b'),
+ //WETH9[ChainId.GNOSIS],
+ //WNATIVE[ChainId.GNOSIS]
+ //),
+ //new BorrowingVault(
+ //Address.from('0x2f4F37f06179d0e969D2350beE8ABe663De0dab7'),
+ //WBTC[ChainId.GNOSIS],
+ //WNATIVE[ChainId.GNOSIS]
+ //),
+ //new BorrowingVault(
+ //Address.from('0xe3298F965553b4aeF40fBe4BBa916DEc12F3d694'),
+ //WBTC[ChainId.GNOSIS],
+ //USDC[ChainId.GNOSIS]
+ //),
+ //new BorrowingVault(
+ //Address.from('0xDbc8904f2931de1549d6e9a369Dc5C75F501f820'),
+ //WSTETH[ChainId.GNOSIS],
+ //USDC[ChainId.GNOSIS]
+ //),
new BorrowingVault(
Address.from('0xa99F739Bd55f95D4F0958B629d3522e64A282c7c'),
WSTETH[ChainId.GNOSIS],
diff --git a/packages/sdk/src/functions/batchLoad.ts b/packages/sdk/src/functions/batchLoad.ts
index 235598ee3..a7f7737d8 100644
--- a/packages/sdk/src/functions/batchLoad.ts
+++ b/packages/sdk/src/functions/batchLoad.ts
@@ -31,6 +31,7 @@ const N_CALLS = 11;
type Detail = BigNumber | string | string[];
type Rate = BigNumber;
+type RateOrNull = Rate | null;
// rates are with 27 decimals
const rateToFloat = (n: BigNumber) =>
@@ -134,7 +135,7 @@ const getProvidersCalls = (v: AbstractVault): FujiResult[]> => {
const setResults = (
v: AbstractVault,
detailsBatch: (Detail | null)[],
- rates: Rate[]
+ rates: RateOrNull[]
): FujiResult => {
if (!v.activeProvider || !v.allProviders) {
return new FujiResultError(
@@ -144,15 +145,24 @@ const setResults = (
const apIndex = v.allProviders.findIndex((addr) => v.activeProvider === addr);
const providers = v.allProviders.map((addr, i) => {
if (v instanceof BorrowingVault) {
+ const depositAprRate = rates[2 * i];
+ const borrowAprRate = rates[2 * i + 1];
+ const depositAprBase =
+ depositAprRate !== null ? rateToFloat(depositAprRate) : undefined;
+ const borrowAprBase =
+ borrowAprRate !== null ? rateToFloat(borrowAprRate) : undefined;
return {
...LENDING_PROVIDERS[v.chainId][addr],
- depositAprBase: rateToFloat(rates[2 * i]),
- borrowAprBase: rateToFloat(rates[2 * i + 1]),
+ depositAprBase,
+ borrowAprBase,
};
} else {
+ const depositAprRate = rates[i];
+ const depositAprBase =
+ depositAprRate !== null ? rateToFloat(depositAprRate) : undefined;
return {
...LENDING_PROVIDERS[v.chainId][addr],
- depositAprBase: rateToFloat(rates[i]),
+ depositAprBase,
};
}
});
@@ -245,7 +255,7 @@ const doBatchLoad = async (
return o;
}
);
- const ratesBatchResults = await multicall.all(
+ const ratesBatchResults = await multicall.tryAll(
// flatten [][] to []
ratesBatch.reduce((acc, v) => acc.concat(...v), [])
);