Skip to content

Commit

Permalink
review fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
FedokDL committed Dec 10, 2024
1 parent 16df1e1 commit 149310a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions smart-contracts/contracts/delegate/ProvidersDelegator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions smart-contracts/contracts/diamond/facets/SessionRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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,
Expand All @@ -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_,
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 149310a

Please sign in to comment.