Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: frax msig #3

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 236 additions & 0 deletions scripts/FraxMultisigWallet-abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
[
{
"inputs": [
{ "internalType": "address[]", "name": "_owners", "type": "address[]" },
{ "internalType": "uint256", "name": "_required", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" },
{ "indexed": true, "internalType": "uint256", "name": "transactionId", "type": "uint256" }
],
"name": "Confirmation",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": true, "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "Execution",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": true, "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "ExecutionFailure",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }],
"name": "OwnerAddition",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }],
"name": "OwnerRemoval",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "uint256", "name": "required", "type": "uint256" }],
"name": "RequirementChange",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" },
{ "indexed": true, "internalType": "uint256", "name": "transactionId", "type": "uint256" }
],
"name": "Revocation",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": true, "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "Submission",
"type": "event"
},
{ "stateMutability": "payable", "type": "fallback" },
{
"inputs": [],
"name": "MAX_OWNER_COUNT",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "owner", "type": "address" }],
"name": "addOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "_required", "type": "uint256" }],
"name": "changeRequirement",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "confirmTransaction",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "", "type": "uint256" },
{ "internalType": "address", "name": "", "type": "address" }
],
"name": "confirmations",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "executeTransaction",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "getConfirmationCount",
"outputs": [{ "internalType": "uint256", "name": "count", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "getConfirmations",
"outputs": [{ "internalType": "address[]", "name": "_confirmations", "type": "address[]" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getOwners",
"outputs": [{ "internalType": "address[]", "name": "", "type": "address[]" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "bool", "name": "pending", "type": "bool" },
{ "internalType": "bool", "name": "executed", "type": "bool" }
],
"name": "getTransactionCount",
"outputs": [{ "internalType": "uint256", "name": "count", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "from", "type": "uint256" },
{ "internalType": "uint256", "name": "to", "type": "uint256" },
{ "internalType": "bool", "name": "pending", "type": "bool" },
{ "internalType": "bool", "name": "executed", "type": "bool" }
],
"name": "getTransactionIds",
"outputs": [{ "internalType": "uint256[]", "name": "_transactionIds", "type": "uint256[]" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "isConfirmed",
"outputs": [{ "internalType": "bool", "name": "yes", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "isOwner",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"name": "owners",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "owner", "type": "address" }],
"name": "removeOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "owner", "type": "address" },
{ "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "replaceOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "required",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"name": "revokeConfirmation",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "destination", "type": "address" },
{ "internalType": "uint256", "name": "value", "type": "uint256" },
{ "internalType": "bytes", "name": "data", "type": "bytes" }
],
"name": "submitTransaction",
"outputs": [{ "internalType": "uint256", "name": "transactionId", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "transactionCount",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"name": "transactions",
"outputs": [
{ "internalType": "address", "name": "destination", "type": "address" },
{ "internalType": "uint256", "name": "value", "type": "uint256" },
{ "internalType": "bytes", "name": "data", "type": "bytes" },
{ "internalType": "bool", "name": "executed", "type": "bool" }
],
"stateMutability": "view",
"type": "function"
},
{ "stateMutability": "payable", "type": "receive" }
]
65 changes: 65 additions & 0 deletions scripts/msig-txs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const BigNumber = require("bignumber.js");
const TronWeb = require("tronweb");
const { ethers } = require("ethers");

// NOTE: "@noble/secp256k1" needs to be @ "1.7.1"
// TODO: RM PK
const tronWeb = new TronWeb({
fullHost: "https://api.trongrid.io",
headers: { "TRON-PRO-API-KEY": process.env.TRONGRID_API_KEY },
privateKey: process.env.TRON_PK, // as hex string without the 0x
});

// let fraxAbi = require("./ERC20PermissionedMint-abi.json");
let msigAbi = require("./FraxMultisigWallet-abi.json");

let fraxAddress = "TQZTkTMbkC9923LtVHZcSrdqcW5rVhkZHP";
let msigAddress = "TWtG5rwf67UUkywcZvF1c24MXXRD8LDBjf";
let deployerAddress = "TLNe6KF1dUSYBcZ4fzTstoKB8bkzQewz42";

async function load() {
// let frax = await tronWeb.contract(fraxAbi, fraxAddress);
let msig = await tronWeb.contract(msigAbi, msigAddress);
return msig;
}

async function transfer() {
let msig = await load();
let abiCoder = ethers.AbiCoder.defaultAbiCoder();
let selector = "0xa9059cbb";

let args = process.argv.slice(2);
if (args.length != 3) {
console.log("arguments passed should be `{token symbol} {amount} {decimals}`");
return;
}

let erc20;
let recipient;

let token = args[0].toUpperCase();
if (token === "FRAX") {
erc20 = fraxAddress;
recipient = deployerAddress; // TODO: should be fraxFerry
} else {
console.log("argument 0 should be one of ['frax', 'sfrx', 'fxs']");
return;
}
let recipientEncoded = "0000000000000000000000".concat(tronWeb.address.toHex(deployerAddress));

// imported values
let amount = parseInt(args[1], 10);
let numZeros = parseInt(args[2], 10);
let amountWithZeros = amount * 10 ** numZeros;

let amountEncoded = abiCoder.encode(["uint"], [amountWithZeros.toString()]).substr(2); // rm the "0x"

let payload = selector.concat(recipientEncoded).concat(amountEncoded);

console.log(`Submit Transfer of ${amount} * 10**${numZeros} ${token} to FraxFerry ${recipient}`);
await msig.submitTransaction(erc20, 0, payload).send();
}

(async function () {
await transfer();
})();
Loading
Loading