🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

global-swap

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

global-swap

token exchange

1.14.4
latest
npm
Version published
Weekly downloads
11
-21.43%
Maintainers
1
Weekly downloads
 
Created
Source

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);
// }

FAQs

Package last updated on 24 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts