diff --git a/smart-contracts/contracts/delegate/ProvidersDelegator.sol b/smart-contracts/contracts/delegate/ProvidersDelegator.sol index b20204ce..6f09a9e7 100644 --- a/smart-contracts/contracts/delegate/ProvidersDelegator.sol +++ b/smart-contracts/contracts/delegate/ProvidersDelegator.sol @@ -120,13 +120,15 @@ contract ProvidersDelegator is IProvidersDelegator, OwnableUpgradeable { if (amount_ == 0) { revert InsufficientAmount(); } - + address user_ = _msgSender(); Staker storage staker = stakers[user_]; (uint256 currentRate_, uint256 contractBalance_) = getCurrentRate(); uint256 pendingRewards_ = _getCurrentStakerRewards(currentRate_, staker); + IERC20(token).safeTransferFrom(user_, address(this), amount_); + totalRate = currentRate_; totalStaked += amount_; @@ -136,7 +138,6 @@ contract ProvidersDelegator is IProvidersDelegator, OwnableUpgradeable { staker.staked += amount_; staker.pendingRewards = pendingRewards_; - IERC20(token).safeTransferFrom(user_, address(this), amount_); IProviderRegistry(lumerinDiamond).providerRegister(address(this), amount_, endpoint); emit Staked(user_, staker.staked, staker.pendingRewards, staker.rate); diff --git a/smart-contracts/contracts/diamond/facets/SessionRouter.sol b/smart-contracts/contracts/diamond/facets/SessionRouter.sol index 923ef18e..53e18b79 100644 --- a/smart-contracts/contracts/diamond/facets/SessionRouter.sol +++ b/smart-contracts/contracts/diamond/facets/SessionRouter.sol @@ -2,6 +2,8 @@ pragma solidity ^0.8.24; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; +import {Address} from "@openzeppelin/contracts/utils/Address.sol"; + import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; @@ -19,8 +21,6 @@ import {LibSD} from "../../libs/LibSD.sol"; import {ISessionRouter} from "../../interfaces/facets/ISessionRouter.sol"; -import "hardhat/console.sol"; - contract SessionRouter is ISessionRouter, OwnableDiamondStorage, @@ -34,6 +34,7 @@ contract SessionRouter is using LibSD for LibSD.SD; using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.Bytes32Set; + using Address for address; function __SessionRouter_init( address fundingAccount_, @@ -540,7 +541,7 @@ contract SessionRouter is return true; } - if (provider_.code.length > 0) { + if (provider_.isContract()) { (bool success, bytes memory result) = provider_.staticcall(abi.encodeWithSignature("owner()")); if (success && result.length == 32) { address owner_ = abi.decode(result, (address));