Skip to content

Commit

Permalink
added superfluid
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh11515 committed Feb 17, 2023
1 parent 3a746d0 commit 87ecc46
Show file tree
Hide file tree
Showing 12 changed files with 29,728 additions and 8,819 deletions.
1 change: 1 addition & 0 deletions contracts/.keystore/dinesh2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"address":"e643cf465ede9ad11e152bab8d3cdc6cbc3712e1","id":"a09f0a2d-99bf-458e-b40a-0fb98134efac","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"c5c3fed84464e03f84382a2c6aff2c35"},"ciphertext":"0a39b278309b79ce2296279dd7eae70d878503d22152034f4e1dc63c4780dee1","kdf":"scrypt","kdfparams":{"salt":"8321bc95b52e5243400ab6c08fabcb68f87c97eb041f8087077d47014a003b2b","n":131072,"dklen":32,"p":1,"r":8},"mac":"3f6506991f105be873ef67433e1d4ad76ed4dc8f64990da752c33a96f2aa3202"},"x-ethers":{"client":"ethers.js","gethFilename":"UTC--2023-02-17T05-04-42.0Z--e643cf465ede9ad11e152bab8d3cdc6cbc3712e1","mnemonicCounter":"4046aa91b7178af4ede1f5a69aacd7df","mnemonicCiphertext":"145d31966fcd437f1705de254ce8c840","path":"m/44'/60'/0'/0/0","locale":"en","version":"0.1"}}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
constructor() ERC20("MyToken", "DIN") {
contract USDT is ERC20 {
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_mint(msg.sender, 1000 * 10**decimals());
}
}
3 changes: 3 additions & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const config: HardhatUserConfig = {
mumbai: {
url: "https://dimensional-fabled-patron.matic-testnet.discover.quiknode.pro/52f7211c36c11560b648d2af0576acb8e9fb8062/",
},
mantle: {
url: "https://rpc.testnet.mantle.xyz",
},
},
etherscan: {
apiKey: "USK8S3HV5D9GMWA14TF9WKI4KRBW4Z27C7",
Expand Down
20 changes: 20 additions & 0 deletions contracts/scripts/mockToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ethers, accounts } from "hardhat";

async function main() {
// We get the contract to deploy
const signer = await accounts.getSigners();
const USDT = await ethers.getContractFactory("USDT", signer[0]);

const usdt = await USDT.deploy("USDT", "USDT");

await usdt.deployed();

console.log("USDT deployed to:", usdt.address);
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
65 changes: 65 additions & 0 deletions frontend/components/createFlow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Framework } from "@superfluid-finance/sdk-core";
import { ethers } from "ethers";
export async function createNewFlow(
recipient: any,
flowRate: any,
provider: any,
tokenName: string
) {
const chainId = await provider
.getNetwork()
.then((network: any) => network.chainId);

const sf = await Framework.create({
chainId: Number(chainId),
provider: provider,
});

const signer = provider.getSigner();

const superSigner = sf.createSigner({ signer: signer });

const token = await sf.loadSuperToken(tokenName);

console.log(token);

try {
const createFlowOperation = token.createFlow({
sender: await superSigner.getAddress(),
receiver: recipient,
flowRate: flowRate,
// userData?: string
});

console.log(createFlowOperation);
console.log("Creating your stream...");

const result = await createFlowOperation.exec(superSigner);
console.log(result);

console.log(
`Congrats - you've just created a money stream!
`
);
} catch (error) {
console.log(
"Hmmm, your transaction threw an error. Make sure that this stream does not already exist, and that you've entered a valid Ethereum address!"
);
console.error(error);
}
}

function calculateFlowRate(amount: number) {
if (typeof Number(amount) !== "number" || isNaN(Number(amount)) === true) {
alert("You can only calculate a flowRate based on a number");
return;
} else if (typeof Number(amount) === "number") {
if (Number(amount) === 0) {
return 0;
}
const amountInWei = ethers.BigNumber.from(amount);
const monthlyAmount: any = ethers.utils.formatEther(amountInWei.toString());
const calculatedFlowRate = monthlyAmount * 3600 * 24 * 30;
return calculatedFlowRate;
}
}
229 changes: 228 additions & 1 deletion frontend/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export const contractAddress = "0x367B56C44A598B27f9083EC1DbEfe1B3ea42C377";
export const mumbaiAddress = "0x367B56C44A598B27f9083EC1DbEfe1B3ea42C377";
export const mantleAddress = "0xe9f35F8C12B10b497D2193398805e5D8Cab1f8E2";
export const mantleRPC = "https://rpc.testnet.mantle.xyz";
export const mumbaiRPC =
"https://dimensional-fabled-patron.matic-testnet.discover.quiknode.pro/52f7211c36c11560b648d2af0576acb8e9fb8062/";
export const contractABI = [
{
inputs: [
Expand Down Expand Up @@ -402,3 +406,226 @@ export const contractABI = [
type: "function",
},
];

export const erc20abi = [
{
constant: true,
inputs: [],
name: "name",
outputs: [
{
name: "",
type: "string",
},
],
payable: false,
stateMutability: "view",
type: "function",
},
{
constant: false,
inputs: [
{
name: "_spender",
type: "address",
},
{
name: "_value",
type: "uint256",
},
],
name: "approve",
outputs: [
{
name: "",
type: "bool",
},
],
payable: false,
stateMutability: "nonpayable",
type: "function",
},
{
constant: true,
inputs: [],
name: "totalSupply",
outputs: [
{
name: "",
type: "uint256",
},
],
payable: false,
stateMutability: "view",
type: "function",
},
{
constant: false,
inputs: [
{
name: "_from",
type: "address",
},
{
name: "_to",
type: "address",
},
{
name: "_value",
type: "uint256",
},
],
name: "transferFrom",
outputs: [
{
name: "",
type: "bool",
},
],
payable: false,
stateMutability: "nonpayable",
type: "function",
},
{
constant: true,
inputs: [],
name: "decimals",
outputs: [
{
name: "",
type: "uint8",
},
],
payable: false,
stateMutability: "view",
type: "function",
},
{
constant: true,
inputs: [
{
name: "_owner",
type: "address",
},
],
name: "balanceOf",
outputs: [
{
name: "balance",
type: "uint256",
},
],
payable: false,
stateMutability: "view",
type: "function",
},
{
constant: true,
inputs: [],
name: "symbol",
outputs: [
{
name: "",
type: "string",
},
],
payable: false,
stateMutability: "view",
type: "function",
},
{
constant: false,
inputs: [
{
name: "_to",
type: "address",
},
{
name: "_value",
type: "uint256",
},
],
name: "transfer",
outputs: [
{
name: "",
type: "bool",
},
],
payable: false,
stateMutability: "nonpayable",
type: "function",
},
{
constant: true,
inputs: [
{
name: "_owner",
type: "address",
},
{
name: "_spender",
type: "address",
},
],
name: "allowance",
outputs: [
{
name: "",
type: "uint256",
},
],
payable: false,
stateMutability: "view",
type: "function",
},
{
payable: true,
stateMutability: "payable",
type: "fallback",
},
{
anonymous: false,
inputs: [
{
indexed: true,
name: "owner",
type: "address",
},
{
indexed: true,
name: "spender",
type: "address",
},
{
indexed: false,
name: "value",
type: "uint256",
},
],
name: "Approval",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
name: "from",
type: "address",
},
{
indexed: true,
name: "to",
type: "address",
},
{
indexed: false,
name: "value",
type: "uint256",
},
],
name: "Transfer",
type: "event",
},
];
1 change: 1 addition & 0 deletions frontend/constants/sampleUSDT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const address = "0xeA7a60bC7E14908b69489394dfc322F7E9d16918";
Loading

0 comments on commit 87ecc46

Please sign in to comment.