global-swap

1.14.4 • Public • Published

Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts

// todo

function defineToken( address _token1, address _token2, uint rate1, uint rate2 ) public onlyRole(DEFAULT_ADMIN_ROLE) { tokenAddress[idToken] = _token1; idToken++;

    tokenAddress[idToken] = _token2;
    idToken++;

    _currencies[_token1];
    _currencies[_token2];

    _rate[_token1][_token2] = rate1;
    _rate[_token2][_token1] = rate2;
}

function getRate(address _from, address _to) public view returns (uint) {
    return _rate[_from][_to];
}

function swapUsdt(
    address _from,
    address _to,
    uint amount
) public view returns (uint) {
    uint unit = 1 * 10 ** 9;
    uint reatePerGnet = getRate(_from, _to);
    uint ratePerUnit = reatePerGnet / unit;
    uint gnetAmount = amount / ratePerUnit;
    return gnetAmount;
    // usdt.transferFrom(msg.sender, address(this), amount);
    // gnet.transfer(msg.sender, gnetAmount);
}

// function swapGnet(uint amount) public view returns (uint) {
//     uint formatAmount = amount * 10 ** 9;
//     uint unit = 1 * 10 ** 18;
//     uint usdtAmount = (formatAmount * unit) / ratePerUsdt;
//     return usdtAmount;
//     // gnet.transferFrom(msg.sender, address(this), amount);
//     // usdt.transfer(msg.sender, usdtAmount);
// }

Readme

Keywords

none

Package Sidebar

Install

npm i global-swap

Weekly Downloads

3

Version

1.14.4

License

MIT

Unpacked Size

7.75 MB

Total Files

174

Last publish

Collaborators

  • mananjabrik