Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
created gelato faucet
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarx authored and gitpusha committed Jul 29, 2020
1 parent ec471e0 commit 6f20892
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 213 deletions.
2 changes: 2 additions & 0 deletions buidler.config.js
Expand Up @@ -58,6 +58,7 @@ module.exports = {
"ActionKyberTrade",
// Provider
"FeeHandlerFactory",
"GelatoTokenFaucet",
// === Conditions ===
// Time
"ConditionTimeStateful",
Expand Down Expand Up @@ -86,6 +87,7 @@ module.exports = {
// ===== Provider Modules ====
ProviderModuleGelatoUserProxy:
"0x66a35534126B4B0845A2aa03825b95dFaaE88B0C",
GelatoTokenFaucet: "0xbA7A7187EF22fE2B001bF8e4707B66B3985F5805",
},

// Rinkeby: Filters
Expand Down
28 changes: 28 additions & 0 deletions buidler/tasks/erc20/task.gelato-rinkeby-faucet.js
@@ -0,0 +1,28 @@
import { task } from "@nomiclabs/buidler/config";
import { defaultNetwork } from "../../../buidler.config";

export default task(
"get-tokenFaucet",
`Return (or --log) <erc20address> allowance by <owner> to <spender> on [--network] (default: ${defaultNetwork})`
)
.addPositionalParam(
"address",
"address of desired token to receive 50 from the faucet"
)
.addFlag("log", "Logs return values to stdout")
.setAction(async (taskArgs) => {
const myUserWallet = await getUserWallet();
const myUserAddress = await myUserWallet.getAddress();
const tokenFaucetAbi = ["function mint(address _token)"];

const tokenFaucet = await ethers.getContractAt(
network.config.deployments.GelatoTokenFaucet
);
const tx = await tokenFaucet.mint(taskArgs.address);
console.log(`\n Tx hash: ${tx.hash}\n`);
await tx.wait();
console.log(
`\n Successfully transferred 50 tokens of token ${taskArgs.address} tokenFaucet to your User account: ${myUserAddress}\n`
);
return tx.hash;
});
35 changes: 35 additions & 0 deletions contracts/GelatoTokenFaucet.sol
@@ -0,0 +1,35 @@
// "SPDX-License-Identifier: UNLICENSED"
pragma solidity ^0.6.10;

import {SafeERC20} from "@gelatonetwork/core/contracts/external/SafeERC20.sol";
import {IERC20} from "@gelatonetwork/core/contracts/external/IERC20.sol";

interface IDecimalERC20 {
function decimals() external view returns(uint8);
}

contract GelatoTokenFaucet {

mapping(address => uint256) lastMintingTime;
using SafeERC20 for IERC20;


function mint(address _token) public {
// Users can only mint once per day
require(lastMintingTime[msg.sender] < block.timestamp - 24 hours, "Daily allowance depleted");

IERC20 token = IERC20(_token);
uint256 mintAmount = 50 * 10 ** uint256(IDecimalERC20(_token).decimals());

// Faucet requires sufficient balance
require(token.balanceOf(address(this)) > mintAmount, "Faucet is depleted");

// Effect
lastMintingTime[msg.sender] = block.timestamp;

// Transfer 50 tokens to user
token.transfer(msg.sender, mintAmount);

}

}
207 changes: 0 additions & 207 deletions contracts/gelato_actions/ActionFeeHandler.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/gelato_actions/ActionKyberTrade.sol
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.6.10;

import {GelatoActionsStandard} from "@gelatonetwork/core/contracts/actions/GelatoActionsStandard.sol";
import {IGelatoInFlowAction} from "@gelatonetwork/core/contracts/actions/action_interfaces/IGelatoInFlowAction.sol";
import {IGelatoInFlowAction} from "@gelatonetwork/core/contracts/actions/action_pipeline_interfaces/IGelatoInFlowAction.sol";
import {DataFlow} from "@gelatonetwork/core/contracts/gelato_core/interfaces/IGelatoCore.sol";
import {GelatoBytes} from "@gelatonetwork/core/contracts/libraries/GelatoBytes.sol";
import {SafeERC20} from "@gelatonetwork/core/contracts/external/SafeERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -26,7 +26,7 @@
"@babel/core": "7.7.4",
"@babel/preset-env": "7.7.4",
"@babel/register": "7.7.4",
"@gelatonetwork/core": "^0.1.1",
"@gelatonetwork/core": "^0.3.0",
"@nomiclabs/buidler": "1.3.6",
"@nomiclabs/buidler-ethers": "1.3.3",
"@nomiclabs/buidler-waffle": "1.3.4",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -704,10 +704,10 @@
ethers "^4.0.45"
ganache-core "^2.10.2"

"@gelatonetwork/core@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@gelatonetwork/core/-/core-0.1.1.tgz#144aee0d6d8d13cb35b127028ffb3db541c1ed8e"
integrity sha512-mMirKA0JMbTWbCz6v/nnHH9oTl4XPbHwa4E8hPvzrneDySPGNxBwHWQz59xB4ND7zo46k+gyG1clrwuIngch+g==
"@gelatonetwork/core@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@gelatonetwork/core/-/core-0.3.0.tgz#fb91db19bf1908171f628bbf62b6d6860b77f1a4"
integrity sha512-De8wmzVz+awDeLL17hs/PxzN9ClbMU2fRgf4oC50h2IThj9NGOSkR1D5+197sq1xRIrlna06m9hE52MhQ4NBuA==

"@nomiclabs/buidler-ethers@1.3.3":
version "1.3.3"
Expand Down

0 comments on commit 6f20892

Please sign in to comment.