Skip to content

Commit

Permalink
all functionality done -- awaiting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonDmoney committed Nov 23, 2024
1 parent d5e089e commit e9949b3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
26 changes: 15 additions & 11 deletions src/Lock.sol
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
pragma solidity ^0.8.20;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {fstMOVE} from "./token/fstMOVE.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "movement/protocol-units/bridge/contracts/src/NativeBridge.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./mock/NativeBridge.sol";

contract Lock is Initializable, OwnableUpgradeable{
IERC20 public fstMOVE;
contract Lock is Initializable, OwnableUpgradeable {
fstMOVE public fstmove;
IERC20 public move;
NativeBridge public bridge;
NativeBridge public movementBridge;

mapping(bytes32 => uint256) public deposits;

function initialize(address fstMOVE_, address move_, address bridge_) {
_Ownable_init(owner_);
event Deposit(address eth, uint256 amount, bytes32 moveAddress);

fstMOVE = IERC20(fstMOVE_);
function initialize(address fstMOVE_, address move_, address bridge_) public initializer {
__Ownable_init(msg.sender);

fstmove = fstMOVE(fstMOVE_);
move = IERC20(move_);
bridge = NativeBridge(bridge_);
movementBridge = NativeBridge(bridge_);
}

function deposit(address to, uint256 amount, bytes32 moveAddress) external {
move.transferFrom(msg.sender, address(this), amount);
fstMOVE.mint(to, amount);
fstmove.mintAssets(to, amount);

deposits[moveAddress] += amount;

Expand All @@ -30,9 +34,9 @@ contract Lock is Initializable, OwnableUpgradeable{

function bridge(bytes32 moveAddress, uint256 amount, bool max) external onlyOwner {
if (max) {
bridge.initiateBridgeTransfer(moveAddress, move.balanceOf(address(this)));
movementBridge.initiateBridgeTransfer(moveAddress, move.balanceOf(address(this)));
} else {
bridge.initiateBridgeTransfer(moveAddress, amount);
movementBridge.initiateBridgeTransfer(moveAddress, amount);
}
}
}
10 changes: 10 additions & 0 deletions src/mock/NativeBridge.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma solidity ^0.8.20;

contract NativeBridge {
mapping(bytes32 => uint256) transfers;

// MOCK OF https://github.com/movementlabsxyz/movement/blob/main/protocol-units/bridge/contracts/src/NativeBridge.sol#L43
function initiateBridgeTransfer(bytes32 recipient, uint256 amount) public {
transfers[recipient] += amount;
}
}
5 changes: 3 additions & 2 deletions src/token/fstMOVE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";


/**
* @dev Non-transferable and rebasing read-only ERC20 token
*/
contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
contract fstMOVE is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _shares;

// Variables uesd for increasing user balances linearly over time
Expand Down Expand Up @@ -53,7 +54,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
/**
* @dev Helper function that returns the share rate at a previous block (must be in between the last two updates)
**/
function shareRate(uint256 time) public view virtual returns {
function shareRate(uint256 time) public view virtual returns (uint256) {
return (nextShareRate - lastShareRate) * BASE / ((time - lastUpdateTime) * BASE / (nextUpdateTime - lastUpdateTime)) + lastShareRate;
}

Expand Down

0 comments on commit e9949b3

Please sign in to comment.