Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addresses/addresses-999.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"fulfillmentVaultAddress": "0x8Bc1F48Ce0D241BB2B7EC05AF202B7dA9aaBd1d9",
"rolloverVaultAddress": "0x5e4A85D1BaD334A2Fdd07856201136bC6eE2e302",
"routerAddress": "0x58B6943Ed3a48981eA58c0918830eFd4febbe5a1"
"routerAddress": "0x2A868EFd3cdF2bE83Ff63dECdfdc07A8dCAda316"
}
253 changes: 253 additions & 0 deletions broadcast/DeployRouter.s.sol/999/run-1766194143046.json

Large diffs are not rendered by default.

192 changes: 96 additions & 96 deletions broadcast/DeployRouter.s.sol/999/run-latest.json

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {PythErrors} from "@pythnetwork/PythErrors.sol";
import {MortgageMath} from "@core/libraries/MortgageMath.sol";
import {MortgagePosition} from "@core/types/MortgagePosition.sol";
import {ILiquidityVault} from "./interfaces/ILiquidityVault/ILiquidityVault.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";

/**
* @title Router
Expand Down Expand Up @@ -466,18 +467,25 @@ contract Router is
* @param usdTokenAmount The amount of usdToken to pull in
*/
function _vaultDeposit(address vault, address usdToken, uint256 usdTokenAmount) internal {
if (
ILiquidityVault(vault).whitelistEnforced()
&& !IAccessControl(vault).hasRole(ILiquidityVault(vault).WHITELIST_ROLE(), _msgSender())
) {
revert VaultWhitelistEnforced(vault, _msgSender());
}

// Convert the usdTokenAmount to USDX
uint256 usdxAmount = convert(usdToken, usdx, usdTokenAmount);

// Pull in the usdToken from the user
_pullUsdToken(usdToken, usdxAmount);

// Deposit the USDX into the rollover vault
// Deposit the USDX into the vault
IUSDX(usdx).approve(vault, usdxAmount);
ILiquidityVault(vault).deposit(usdx, usdxAmount);

// Transfer the vault share tokens to the user
ILiquidityVault(vault).transfer(msg.sender, ILiquidityVault(vault).balanceOf(address(this)));
ILiquidityVault(vault).transfer(_msgSender(), ILiquidityVault(vault).balanceOf(address(this)));
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/interfaces/IRouter/IRouterErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ interface IRouterErrors {
* @param maxColllected The maximum amount that can be collected
*/
error CollectedAmountExceedsMaximum(address token, uint256 collectedAmount, uint256 maxColllected);

/**
* @notice Thrown when the vault's whitelist is enforced and the sender is not whitelisted
* @param vault The address of the vault
* @param sender The address of the sender
*/
error VaultWhitelistEnforced(address vault, address sender);
}
2 changes: 1 addition & 1 deletion verification.json

Large diffs are not rendered by default.

Loading