-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split DMC1 to 2 bridge, gwt rate limit +-20%
- Loading branch information
Showing
2 changed files
with
44 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "./dmc2.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract DMC2Bridge is Ownable { | ||
DMC2 public dmc2; | ||
|
||
// DMC1到2的兑换 | ||
mapping(bytes32 => uint256) public dmc1_to_dmc2; | ||
|
||
constructor(address _dmc2) Ownable(msg.sender) { | ||
dmc2 = DMC2(_dmc2); | ||
} | ||
|
||
function registerDMC1(address recvAddress, string calldata cookie, uint256 dmc1Amount) onlyOwner public { | ||
dmc1_to_dmc2[keccak256(abi.encodePacked(recvAddress, cookie))] = dmc1Amount; | ||
} | ||
|
||
function claimDMC2(string calldata cookie) public { | ||
bytes32 key = keccak256(abi.encodePacked(msg.sender, cookie)); | ||
require(dmc1_to_dmc2[key] > 0, "no dmc1 amount"); | ||
uint256 dmc2Amount = dmc1_to_dmc2[key] * 4 / 5; | ||
|
||
dmc2.transfer(msg.sender, dmc2Amount); | ||
dmc1_to_dmc2[key] = 0; | ||
} | ||
|
||
function claimRemainDMC2() public onlyOwner { | ||
dmc2.transfer(msg.sender, dmc2.balanceOf(address(this))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters