From a85a9681ac0e0c345fb2cd5307a23814987d54be Mon Sep 17 00:00:00 2001 From: Michelle Fang Date: Tue, 8 Sep 2020 18:52:06 -0400 Subject: [PATCH 1/8] Add WorkLock contract --- README.md | 1 + abis/WorkLock.json | 1 + config/instances.json | 3 +++ examples/WorkLock/bid.ts | 12 ++++++++++++ package.json | 2 +- 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 abis/WorkLock.json create mode 100644 examples/WorkLock/bid.ts diff --git a/README.md b/README.md index a7c012b..b44a649 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ This library supports a limited number of smart contract protocols, as it mainta - Compound -- [Examples](./examples/Compound) - StandardERC20 -- [Examples](./examples/StandardERC20) - MakerDAO -- [Examples](./examples/MakerDAO) +- NuCypher WorkLock -- [Examples](./examples/WorkLock) ## Adding a new ABI type This library is quite extensible to new protocols -- if there are other contract types that you would like to use, diff --git a/abis/WorkLock.json b/abis/WorkLock.json new file mode 100644 index 0000000..ef67dd5 --- /dev/null +++ b/abis/WorkLock.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"contract NuCypherToken","name":"_token","type":"address"},{"internalType":"contract StakingEscrow","name":"_escrow","type":"address"},{"internalType":"uint256","name":"_startBidDate","type":"uint256"},{"internalType":"uint256","name":"_endBidDate","type":"uint256"},{"internalType":"uint256","name":"_endCancellationDate","type":"uint256"},{"internalType":"uint256","name":"_boostingRefund","type":"uint256"},{"internalType":"uint16","name":"_stakingPeriods","type":"uint16"},{"internalType":"uint256","name":"_minAllowedBid","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositedETH","type":"uint256"}],"name":"Bid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"startIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endIndex","type":"uint256"}],"name":"BiddersChecked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Canceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"claimedTokens","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"CompensationWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"bidder","type":"address"},{"indexed":false,"internalType":"uint256","name":"refundETH","type":"uint256"}],"name":"ForceRefund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"refundETH","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"completedWork","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"Shutdown","type":"event"},{"inputs":[],"name":"SLOWING_REFUND","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bid","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"bidders","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bonusETHSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boostingRefund","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelBid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claim","outputs":[{"internalType":"uint256","name":"claimedTokens","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"compensation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endBidDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endCancellationDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"escrow","outputs":[{"internalType":"contract StakingEscrow","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_ethAmount","type":"uint256"}],"name":"ethToTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_ethAmount","type":"uint256"}],"name":"ethToWork","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable[]","name":"_biddersForRefund","type":"address[]"}],"name":"forceRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bidder","type":"address"}],"name":"getAvailableRefund","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBiddersLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_bidder","type":"address"}],"name":"getRemainingWork","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isClaimingAvailable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAllowableLockedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minAllowableLockedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minAllowedBid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextBidderToCheck","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refund","outputs":[{"internalType":"uint256","name":"refundETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shutdown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingPeriods","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startBidDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract NuCypherToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"tokenDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tokenSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_gasToSaveState","type":"uint256"}],"name":"verifyBiddingCorrectness","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawCompensation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"workInfo","outputs":[{"internalType":"uint256","name":"depositedETH","type":"uint256"},{"internalType":"uint256","name":"completedWork","type":"uint256"},{"internalType":"bool","name":"claimed","type":"bool"},{"internalType":"uint128","name":"index","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_completedWork","type":"uint256"},{"internalType":"uint256","name":"_depositedETH","type":"uint256"}],"name":"workToETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] diff --git a/config/instances.json b/config/instances.json index e7d6892..5a3123d 100644 --- a/config/instances.json +++ b/config/instances.json @@ -38,5 +38,8 @@ "default": "0x373238337Bfe1146fb49989fc222523f83081dDb" }, "DSProxy": { + }, + "WorkLock": { + "default": "0xe9778E69a961e64d3cdBB34CF6778281d34667c2" } } diff --git a/examples/WorkLock/bid.ts b/examples/WorkLock/bid.ts new file mode 100644 index 0000000..85ab895 --- /dev/null +++ b/examples/WorkLock/bid.ts @@ -0,0 +1,12 @@ +import { Contract } from '../../src/contract'; + +const workLockContract = new Contract('WorkLock'); + +let { data, amount, address } = workLockContract.methods() + .bid.call({ payableAmount: 20 }); + +console.log(`\nTo bid on WorkLock, send:`); +console.log(`Data: ${data}`); +console.log(`Amount: ${amount} ETH`); +console.log(`To: ${address}`); + diff --git a/package.json b/package.json index 04cfad4..01a7ede 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "typescript": "3.4.5" }, "devDependencies": { - "@types/ethereumjs-abi": "0.6.3", + "@types/ethereumjs-abi": "^0.6.3", "@types/expect": "24.3.0", "@types/mocha": "5.2.7", "bitgo": "11.1.1", From 301ae9c3fe04024925837cbd05b521b481c44da8 Mon Sep 17 00:00:00 2001 From: Michelle Fang Date: Wed, 23 Sep 2020 10:50:54 -0400 Subject: [PATCH 2/8] abis --- abis/StakingEscrow.json | 1 + abis/UniswapRouter.json | 1 + config/instances.json | 6 ++++++ examples/Compound/borrow.ts | 2 +- examples/StakingEscrow/deposit.ts | 11 +++++++++++ examples/Uniswap/add_liquidity_eth.ts | 26 +++++++++++++++++++++++++ examples/WorkLock/bid.ts | 2 +- examples/WorkLock/cancel_bid.ts | 11 +++++++++++ examples/WorkLock/get_bidders_length.ts | 11 +++++++++++ 9 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 abis/StakingEscrow.json create mode 100644 abis/UniswapRouter.json create mode 100644 examples/StakingEscrow/deposit.ts create mode 100644 examples/Uniswap/add_liquidity_eth.ts create mode 100644 examples/WorkLock/cancel_bid.ts create mode 100644 examples/WorkLock/get_bidders_length.ts diff --git a/abis/StakingEscrow.json b/abis/StakingEscrow.json new file mode 100644 index 0000000..2e13d9d --- /dev/null +++ b/abis/StakingEscrow.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"contract NuCypherToken","name":"_token","type":"address"},{"internalType":"uint32","name":"_hoursPerPeriod","type":"uint32"},{"internalType":"uint256","name":"_issuanceDecayCoefficient","type":"uint256"},{"internalType":"uint256","name":"_lockDurationCoefficient1","type":"uint256"},{"internalType":"uint256","name":"_lockDurationCoefficient2","type":"uint256"},{"internalType":"uint16","name":"_maximumRewardedPeriods","type":"uint16"},{"internalType":"uint256","name":"_firstPhaseTotalSupply","type":"uint256"},{"internalType":"uint256","name":"_firstPhaseMaxIssuance","type":"uint256"},{"internalType":"uint16","name":"_minLockedPeriods","type":"uint16"},{"internalType":"uint256","name":"_minAllowableLockedTokens","type":"uint256"},{"internalType":"uint256","name":"_maxAllowableLockedTokens","type":"uint256"},{"internalType":"uint16","name":"_minWorkerPeriods","type":"uint16"},{"internalType":"bool","name":"_isTestContract","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":true,"internalType":"uint16","name":"period","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"CommitmentMade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"periods","type":"uint16"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"lastPeriod","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"periods","type":"uint16"}],"name":"Divided","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Donated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reservedReward","type":"uint256"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"firstPeriod","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"periods","type":"uint16"}],"name":"Locked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"value1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value2","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"lastPeriod","type":"uint16"}],"name":"Merged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":true,"internalType":"uint16","name":"period","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"lastPeriod","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"periods","type":"uint16"}],"name":"Prolonged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint16","name":"lockUntilPeriod","type":"uint16"}],"name":"ReStakeLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"bool","name":"reStake","type":"bool"}],"name":"ReStakeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"penalty","type":"uint256"},{"indexed":true,"internalType":"address","name":"investigator","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"Slashed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"bool","name":"snapshotsEnabled","type":"bool"}],"name":"SnapshotSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"testTarget","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"StateVerified","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"UpgradeFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"bool","name":"windDown","type":"bool"}],"name":"WindDownSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Withdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"bool","name":"measureWork","type":"bool"}],"name":"WorkMeasurementSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":true,"internalType":"address","name":"worker","type":"address"},{"indexed":true,"internalType":"uint16","name":"startPeriod","type":"uint16"}],"name":"WorkerBonded","type":"event"},{"inputs":[],"name":"MAX_SUB_STAKES","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adjudicator","outputs":[{"internalType":"contract AdjudicatorInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"balanceHistory","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_stakers","type":"address[]"},{"internalType":"uint256[]","name":"_numberOfSubStakes","type":"uint256[]"},{"internalType":"uint256[]","name":"_values","type":"uint256[]"},{"internalType":"uint16[]","name":"_periods","type":"uint16[]"},{"internalType":"uint16","name":"_lockReStakeUntilPeriod","type":"uint16"}],"name":"batchDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_worker","type":"address"}],"name":"bondWorker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"commitToNextPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentMintingPeriod","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentPeriodSupply","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint16","name":"_periods","type":"uint16"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"depositAndIncrease","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint16","name":"_periods","type":"uint16"}],"name":"depositFromWorkLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_newValue","type":"uint256"},{"internalType":"uint16","name":"_periods","type":"uint16"}],"name":"divideStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"donate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint16","name":"_period","type":"uint16"}],"name":"findIndexOfPastDowntime","outputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"}],"name":"finishUpgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"firstPhaseMaxIssuance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"firstPhaseTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_periods","type":"uint16"},{"internalType":"uint256","name":"_startIndex","type":"uint256"},{"internalType":"uint256","name":"_maxStakers","type":"uint256"}],"name":"getActiveStakers","outputs":[{"internalType":"uint256","name":"allLockedTokens","type":"uint256"},{"internalType":"uint256[2][]","name":"activeStakers","type":"uint256[2][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getAllTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getCompletedWork","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentPeriod","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getFlags","outputs":[{"internalType":"bool","name":"windDown","type":"bool"},{"internalType":"bool","name":"reStake","type":"bool"},{"internalType":"bool","name":"measureWork","type":"bool"},{"internalType":"bool","name":"snapshots","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getLastCommittedPeriod","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getLastPeriodOfSubStake","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint16","name":"_periods","type":"uint16"}],"name":"getLockedTokens","outputs":[{"internalType":"uint256","name":"lockedValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getPastDowntime","outputs":[{"internalType":"uint16","name":"startPeriod","type":"uint16"},{"internalType":"uint16","name":"endPeriod","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getPastDowntimeLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReservedReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakersLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getSubStakeInfo","outputs":[{"internalType":"uint16","name":"firstPeriod","type":"uint16"},{"internalType":"uint16","name":"lastPeriod","type":"uint16"},{"internalType":"uint16","name":"periods","type":"uint16"},{"internalType":"uint128","name":"lockedValue","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getSubStakesLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getWorkerFromStaker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_reservedReward","type":"uint256"},{"internalType":"address","name":"_sourceOfFunds","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"isReStakeLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTestContract","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isUpgrade","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint16","name":"_periods","type":"uint16"}],"name":"lockAndCreate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"lockAndIncrease","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockDurationCoefficient1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockDurationCoefficient2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_lockReStakeUntilPeriod","type":"uint16"}],"name":"lockReStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"lockedPerPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAllowableLockedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumRewardedPeriods","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index1","type":"uint256"},{"internalType":"uint256","name":"_index2","type":"uint256"}],"name":"mergeStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minAllowableLockedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minLockedPeriods","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minWorkerPeriods","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintingCoefficient","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"policyManager","outputs":[{"internalType":"contract PolicyManagerInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previousPeriodSupply","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previousTarget","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint16","name":"_periods","type":"uint16"}],"name":"prolongStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"address","name":"_tokenContract","type":"address"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"receiveApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"secondsPerPeriod","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract AdjudicatorInterface","name":"_adjudicator","type":"address"}],"name":"setAdjudicator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract PolicyManagerInterface","name":"_policyManager","type":"address"}],"name":"setPolicyManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_reStake","type":"bool"}],"name":"setReStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enableSnapshots","type":"bool"}],"name":"setSnapshots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_windDown","type":"bool"}],"name":"setWindDown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract WorkLockInterface","name":"_workLock","type":"address"}],"name":"setWorkLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"bool","name":"_measureWork","type":"bool"}],"name":"setWorkMeasurement","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint256","name":"_penalty","type":"uint256"},{"internalType":"address","name":"_investigator","type":"address"},{"internalType":"uint256","name":"_reward","type":"uint256"}],"name":"slashStaker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerFromWorker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerInfo","outputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint16","name":"currentCommittedPeriod","type":"uint16"},{"internalType":"uint16","name":"nextCommittedPeriod","type":"uint16"},{"internalType":"uint16","name":"lastCommittedPeriod","type":"uint16"},{"internalType":"uint16","name":"lockReStakeUntilPeriod","type":"uint16"},{"internalType":"uint256","name":"completedWork","type":"uint256"},{"internalType":"uint16","name":"workerStartPeriod","type":"uint16"},{"internalType":"address","name":"worker","type":"address"},{"internalType":"uint256","name":"flags","type":"uint256"},{"internalType":"uint256","name":"reservedSlot1","type":"uint256"},{"internalType":"uint256","name":"reservedSlot2","type":"uint256"},{"internalType":"uint256","name":"reservedSlot3","type":"uint256"},{"internalType":"uint256","name":"reservedSlot4","type":"uint256"},{"internalType":"uint256","name":"reservedSlot5","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"supportsHistory","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"target","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract NuCypherToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_blockNumber","type":"uint256"}],"name":"totalStakedAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_blockNumber","type":"uint256"}],"name":"totalStakedForAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_testTarget","type":"address"}],"name":"verifyState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"workLock","outputs":[{"internalType":"contract WorkLockInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"}] diff --git a/abis/UniswapRouter.json b/abis/UniswapRouter.json new file mode 100644 index 0000000..06fd07b --- /dev/null +++ b/abis/UniswapRouter.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amountADesired","type":"uint256"},{"internalType":"uint256","name":"amountBDesired","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountTokenDesired","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidityETH","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"reserveIn","type":"uint256"},{"internalType":"uint256","name":"reserveOut","type":"uint256"}],"name":"getAmountIn","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"reserveIn","type":"uint256"},{"internalType":"uint256","name":"reserveOut","type":"uint256"}],"name":"getAmountOut","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsIn","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsOut","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"reserveA","type":"uint256"},{"internalType":"uint256","name":"reserveB","type":"uint256"}],"name":"quote","outputs":[{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityETH","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityETHSupportingFeeOnTransferTokens","outputs":[{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityETHWithPermit","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityETHWithPermitSupportingFeeOnTransferTokens","outputs":[{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityWithPermit","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapETHForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactETHForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactETHForTokensSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForETHSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokensSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] diff --git a/config/instances.json b/config/instances.json index 5a3123d..3119b6d 100644 --- a/config/instances.json +++ b/config/instances.json @@ -41,5 +41,11 @@ }, "WorkLock": { "default": "0xe9778E69a961e64d3cdBB34CF6778281d34667c2" + }, + "StakingEscrow": { + "default": "0xbbD3C0C794F40c4f993B03F65343aCC6fcfCb2e2" + }, + "UniswapRouter": { + "default": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d" } } diff --git a/examples/Compound/borrow.ts b/examples/Compound/borrow.ts index ed92d67..58eb4e7 100644 --- a/examples/Compound/borrow.ts +++ b/examples/Compound/borrow.ts @@ -6,7 +6,7 @@ import { Contract } from '../../src/contract'; const collateralTokenName = 'cDAI'; const borrowTokenName = 'USDC'; const compoundTokenName = 'cUSDC'; -const borrowAmount = 1e5; +const borrowAmount = 3e5; const compoundComptroller = new Contract('CompoundComptroller'); // there is only 1, so no need for instance const compoundCollateralTokenContract = new Contract('Compound').instance(collateralTokenName); diff --git a/examples/StakingEscrow/deposit.ts b/examples/StakingEscrow/deposit.ts new file mode 100644 index 0000000..e4fbb22 --- /dev/null +++ b/examples/StakingEscrow/deposit.ts @@ -0,0 +1,11 @@ +import { Contract } from '../../src/contract'; + +const stakingEscrowContract = new Contract('StakingEscrow'); + +let { data, amount, address } = stakingEscrowContract.methods() + .deposit.call({ _staker: '0xD4C5226e2108C722bB86ff8327727410dC120b42', _value: 20, _periods: 1 }); + +console.log(`\nTo deposit on StakingEscrow, send:`); +console.log(`Data: ${data}`); +console.log(`Amount: ${amount} ETH`); +console.log(`To: ${address}`); diff --git a/examples/Uniswap/add_liquidity_eth.ts b/examples/Uniswap/add_liquidity_eth.ts new file mode 100644 index 0000000..5c6c92b --- /dev/null +++ b/examples/Uniswap/add_liquidity_eth.ts @@ -0,0 +1,26 @@ +import { Contract } from '../../src/contract'; + +const uniswapRouterContract = new Contract('UniswapRouter'); + +const usdcToken = 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' +const daiToken = '6b175474e89094c44da98b954eedeac495271d0f' +const tetherToken = 'dac17f958d2ee523a2206206994597c13d831ec7' +const wbtcToken = '2260fac5e5542a773aa44fbcfedf7c193bc2c599' + +let token = usdcToken +let amountTokenDesired = 50000000 +let exchangeRate = 344.69 +let tolerance = 0.9 +let ethAmount = Math.floor(amountTokenDesired * 1e12 / exchangeRate) +let to = '0x793F2aA4Cd841A2a64a8AB928ce6011662f565Fe' +let deadline = Math.floor(Date.now() / 1000) + 3600 +let amountTokenMin = Math.floor(amountTokenDesired * tolerance) +let amountETHMin = Math.floor(ethAmount * tolerance) + +let { data, amount, address } = uniswapRouterContract.methods() + .addLiquidityETH.call({ deadline: deadline, token: token, amountTokenDesired: amountTokenDesired, amountTokenMin: amountTokenMin, amountETHMin: amountETHMin, to: to }); + +console.log(`\nTo addLiquidityETH ${deadline} ${token} ${amountTokenDesired} ${amountTokenMin} ${amountETHMin} ${to}, send:`); +console.log(`Data: ${data}`); +console.log(`Amount: ${ethAmount} ETH`); +console.log(`To: ${address}`); diff --git a/examples/WorkLock/bid.ts b/examples/WorkLock/bid.ts index 85ab895..df13210 100644 --- a/examples/WorkLock/bid.ts +++ b/examples/WorkLock/bid.ts @@ -3,7 +3,7 @@ import { Contract } from '../../src/contract'; const workLockContract = new Contract('WorkLock'); let { data, amount, address } = workLockContract.methods() - .bid.call({ payableAmount: 20 }); + .bid.call({ _value: 20 }); console.log(`\nTo bid on WorkLock, send:`); console.log(`Data: ${data}`); diff --git a/examples/WorkLock/cancel_bid.ts b/examples/WorkLock/cancel_bid.ts new file mode 100644 index 0000000..41df77c --- /dev/null +++ b/examples/WorkLock/cancel_bid.ts @@ -0,0 +1,11 @@ +import { Contract } from '../../src/contract'; + +const workLockContract = new Contract('WorkLock'); + +let { data, amount, address } = workLockContract.methods() + .cancelBid.call({ _value: 20 }); + +console.log(`\nTo cancel bid on WorkLock, send:`); +console.log(`Data: ${data}`); +console.log(`Amount: ${amount} ETH`); +console.log(`To: ${address}`); diff --git a/examples/WorkLock/get_bidders_length.ts b/examples/WorkLock/get_bidders_length.ts new file mode 100644 index 0000000..9a24dbe --- /dev/null +++ b/examples/WorkLock/get_bidders_length.ts @@ -0,0 +1,11 @@ +import { Contract } from '../../src/contract'; + +const workLockContract = new Contract('WorkLock'); + +let { data, amount, address } = workLockContract.methods() + .getBiddersLength.call({ _value: 20 }); + +console.log(`\nTo get bidders count on WorkLock, send:`); +console.log(`Data: ${data}`); +console.log(`Amount: ${amount} ETH`); +console.log(`To: ${address}`); From a8d62a52d23f91a8e69d850f503bd2dc3d4d1450 Mon Sep 17 00:00:00 2001 From: Michelle Fang Date: Wed, 23 Sep 2020 10:52:43 -0400 Subject: [PATCH 3/8] revert --- examples/Compound/borrow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Compound/borrow.ts b/examples/Compound/borrow.ts index 58eb4e7..ed92d67 100644 --- a/examples/Compound/borrow.ts +++ b/examples/Compound/borrow.ts @@ -6,7 +6,7 @@ import { Contract } from '../../src/contract'; const collateralTokenName = 'cDAI'; const borrowTokenName = 'USDC'; const compoundTokenName = 'cUSDC'; -const borrowAmount = 3e5; +const borrowAmount = 1e5; const compoundComptroller = new Contract('CompoundComptroller'); // there is only 1, so no need for instance const compoundCollateralTokenContract = new Contract('Compound').instance(collateralTokenName); From f0307e61e03fe84a072a11623265cb000b4968d6 Mon Sep 17 00:00:00 2001 From: Michelle Fang Date: Wed, 23 Sep 2020 10:55:06 -0400 Subject: [PATCH 4/8] small improvements --- examples/Uniswap/add_liquidity_eth.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Uniswap/add_liquidity_eth.ts b/examples/Uniswap/add_liquidity_eth.ts index 5c6c92b..71ff079 100644 --- a/examples/Uniswap/add_liquidity_eth.ts +++ b/examples/Uniswap/add_liquidity_eth.ts @@ -20,7 +20,7 @@ let amountETHMin = Math.floor(ethAmount * tolerance) let { data, amount, address } = uniswapRouterContract.methods() .addLiquidityETH.call({ deadline: deadline, token: token, amountTokenDesired: amountTokenDesired, amountTokenMin: amountTokenMin, amountETHMin: amountETHMin, to: to }); -console.log(`\nTo addLiquidityETH ${deadline} ${token} ${amountTokenDesired} ${amountTokenMin} ${amountETHMin} ${to}, send:`); +console.log(`\nTo addLiquidityETH ${token} ${amountTokenDesired} ${amountTokenMin} ${amountETHMin} ${to} ${deadline}, send:`); console.log(`Data: ${data}`); -console.log(`Amount: ${ethAmount} ETH`); +console.log(`Amount: ${ethAmount}`); console.log(`To: ${address}`); From 0977ed1333e37fff5e38490b5c3955b384266c97 Mon Sep 17 00:00:00 2001 From: Michelle Fang Date: Tue, 29 Sep 2020 16:37:16 -0700 Subject: [PATCH 5/8] uni stake and exit --- abis/UNIPool.json | 1 + examples/StandardERC20/approve.ts | 6 +++--- examples/StandardERC20/transfer.ts | 6 +++--- examples/Uniswap/add_liquidity_eth.ts | 26 -------------------------- examples/Uniswap/exit_uni.ts | 10 ++++++++++ examples/Uniswap/stake_uni.ts | 12 ++++++++++++ 6 files changed, 29 insertions(+), 32 deletions(-) create mode 100644 abis/UNIPool.json delete mode 100644 examples/Uniswap/add_liquidity_eth.ts create mode 100644 examples/Uniswap/exit_uni.ts create mode 100644 examples/Uniswap/stake_uni.ts diff --git a/abis/UNIPool.json b/abis/UNIPool.json new file mode 100644 index 0000000..84a99c2 --- /dev/null +++ b/abis/UNIPool.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"_rewardsDistribution","type":"address"},{"internalType":"address","name":"_rewardsToken","type":"address"},{"internalType":"address","name":"_stakingToken","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"exit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"getReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getRewardForDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardsDistribution","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"stakeWithPermit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/examples/StandardERC20/approve.ts b/examples/StandardERC20/approve.ts index 96f1c3f..e38c1c1 100644 --- a/examples/StandardERC20/approve.ts +++ b/examples/StandardERC20/approve.ts @@ -1,8 +1,8 @@ import { Contract } from '../../src/contract'; -const tokenName = 'DAI'; -const recipient = '0xadd62287c10d90f65fd3bf8bf94183df115c030a'; -const tokenAmount = 1e18; // 1 DAI +const tokenName = 'UNI-V2-ETH-USDC'; +const recipient = '0x7fba4b8dc5e7616e59622806932dbea72537a56b'; +const tokenAmount = 428043827671; const daiContract = new Contract('StandardERC20').instance(tokenName); diff --git a/examples/StandardERC20/transfer.ts b/examples/StandardERC20/transfer.ts index 352413f..97063a7 100644 --- a/examples/StandardERC20/transfer.ts +++ b/examples/StandardERC20/transfer.ts @@ -1,8 +1,8 @@ import { Contract } from '../../src/contract'; -const tokenName = 'DAI'; -const recipient = '0xadd62287c10d90f65fd3bf8bf94183df115c030a'; -const tokenAmount = 1e18; // 1 DAI +const tokenName = 'UNI-V2-ETH-USDC'; +const recipient = '0x7fba4b8dc5e7616e59622806932dbea72537a56b'; +const tokenAmount = 436985605376 const daiContract = new Contract('StandardERC20').instance(tokenName); diff --git a/examples/Uniswap/add_liquidity_eth.ts b/examples/Uniswap/add_liquidity_eth.ts deleted file mode 100644 index 71ff079..0000000 --- a/examples/Uniswap/add_liquidity_eth.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Contract } from '../../src/contract'; - -const uniswapRouterContract = new Contract('UniswapRouter'); - -const usdcToken = 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' -const daiToken = '6b175474e89094c44da98b954eedeac495271d0f' -const tetherToken = 'dac17f958d2ee523a2206206994597c13d831ec7' -const wbtcToken = '2260fac5e5542a773aa44fbcfedf7c193bc2c599' - -let token = usdcToken -let amountTokenDesired = 50000000 -let exchangeRate = 344.69 -let tolerance = 0.9 -let ethAmount = Math.floor(amountTokenDesired * 1e12 / exchangeRate) -let to = '0x793F2aA4Cd841A2a64a8AB928ce6011662f565Fe' -let deadline = Math.floor(Date.now() / 1000) + 3600 -let amountTokenMin = Math.floor(amountTokenDesired * tolerance) -let amountETHMin = Math.floor(ethAmount * tolerance) - -let { data, amount, address } = uniswapRouterContract.methods() - .addLiquidityETH.call({ deadline: deadline, token: token, amountTokenDesired: amountTokenDesired, amountTokenMin: amountTokenMin, amountETHMin: amountETHMin, to: to }); - -console.log(`\nTo addLiquidityETH ${token} ${amountTokenDesired} ${amountTokenMin} ${amountETHMin} ${to} ${deadline}, send:`); -console.log(`Data: ${data}`); -console.log(`Amount: ${ethAmount}`); -console.log(`To: ${address}`); diff --git a/examples/Uniswap/exit_uni.ts b/examples/Uniswap/exit_uni.ts new file mode 100644 index 0000000..53f1fd4 --- /dev/null +++ b/examples/Uniswap/exit_uni.ts @@ -0,0 +1,10 @@ +import { Contract } from '../../src/contract'; + +const tokenName = 'UNI-USDC'; + +const poolContract = new Contract('UNIPool').instance(tokenName); + +const { data, amount, address } = poolContract.methods().exit.call({}); + +console.log(`Data: ${data}`); +console.log(`To: ${address}`); diff --git a/examples/Uniswap/stake_uni.ts b/examples/Uniswap/stake_uni.ts new file mode 100644 index 0000000..838784b --- /dev/null +++ b/examples/Uniswap/stake_uni.ts @@ -0,0 +1,12 @@ +import { Contract } from '../../src/contract'; + +const tokenName = 'UNI-USDC'; +const tokenAmount = 428043827671 //0.00000044 * 1e18; + +const poolContract = new Contract('UNIPool').instance(tokenName); + +const { data, amount, address } = poolContract.methods().stake.call({ amount: tokenAmount }); + +console.log(`To stake ${tokenAmount}:\n`); +console.log(`Data: ${data}`); +console.log(`To: ${address}`); From 7b583011a3e1e3c3c09c97d81d4fb5c4898a6142 Mon Sep 17 00:00:00 2001 From: Michelle Fang Date: Tue, 29 Sep 2020 16:38:39 -0700 Subject: [PATCH 6/8] more instances --- config/instances.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/instances.json b/config/instances.json index 3119b6d..54563df 100644 --- a/config/instances.json +++ b/config/instances.json @@ -10,7 +10,13 @@ "KNC": "0xdd974d5c2e2928dea5f71b9825b8b646686bd200", "USDC": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "DAI": "0x6b175474e89094c44da98b954eedeac495271d0f", - "SAI": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359" + "SAI": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359", + "NU": "0x4fE83213D56308330EC302a8BD641f1d0113A4Cc", + "UNI-V2-ETH-USDC": "0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc", + "UNI-V2-ETH-USDT": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852", + "UNI-V2-ETH-WBTC": "0xbb2b8038a1640196fbe3e38816f3e67cba72d940", + "UNI-V2-ETH-DAI": "0xa478c2975ab1ea89e8196811f51a7b7ade33eb11", + "UNI": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984" }, "Compound": { "CUSDC": "0x39aa39c021dfbae8fac545936693ac917d5e7563", @@ -47,5 +53,8 @@ }, "UniswapRouter": { "default": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d" + }, + "UNIPool": { + "UNI-USDC": "0x7fba4b8dc5e7616e59622806932dbea72537a56b" } } From 4357d24046436e2d351ca2a4c4aa730f8a18e588 Mon Sep 17 00:00:00 2001 From: Michelle Fang Date: Thu, 1 Oct 2020 16:38:42 -0700 Subject: [PATCH 7/8] improvements and cleanup --- config/instances.json | 5 ++++- examples/StandardERC20/approve.ts | 6 +++--- examples/StandardERC20/transfer.ts | 6 +++--- examples/Uniswap/exit_uni.ts | 27 ++++++++++++++++++++----- examples/Uniswap/stake_uni.ts | 17 ++++++++++------ examples/WorkLock/get_bidders_length.ts | 11 ---------- 6 files changed, 43 insertions(+), 29 deletions(-) delete mode 100644 examples/WorkLock/get_bidders_length.ts diff --git a/config/instances.json b/config/instances.json index 54563df..8726cd1 100644 --- a/config/instances.json +++ b/config/instances.json @@ -55,6 +55,9 @@ "default": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d" }, "UNIPool": { - "UNI-USDC": "0x7fba4b8dc5e7616e59622806932dbea72537a56b" + "UNI-V2-ETH-USDC": "0x7fba4b8dc5e7616e59622806932dbea72537a56b", + "UNI-V2-ETH-USDT": "0x6c3e4cb2e96b01f4b866965a91ed4437839a121a", + "UNI-V2-ETH-WBTC": "0xca35e32e7926b96a9988f61d510e038108d8068e", + "UNI-V2-ETH-DAI": "0xa1484c3aa22a66c62b77e0ae78e15258bd0cb711" } } diff --git a/examples/StandardERC20/approve.ts b/examples/StandardERC20/approve.ts index e38c1c1..96f1c3f 100644 --- a/examples/StandardERC20/approve.ts +++ b/examples/StandardERC20/approve.ts @@ -1,8 +1,8 @@ import { Contract } from '../../src/contract'; -const tokenName = 'UNI-V2-ETH-USDC'; -const recipient = '0x7fba4b8dc5e7616e59622806932dbea72537a56b'; -const tokenAmount = 428043827671; +const tokenName = 'DAI'; +const recipient = '0xadd62287c10d90f65fd3bf8bf94183df115c030a'; +const tokenAmount = 1e18; // 1 DAI const daiContract = new Contract('StandardERC20').instance(tokenName); diff --git a/examples/StandardERC20/transfer.ts b/examples/StandardERC20/transfer.ts index 97063a7..352413f 100644 --- a/examples/StandardERC20/transfer.ts +++ b/examples/StandardERC20/transfer.ts @@ -1,8 +1,8 @@ import { Contract } from '../../src/contract'; -const tokenName = 'UNI-V2-ETH-USDC'; -const recipient = '0x7fba4b8dc5e7616e59622806932dbea72537a56b'; -const tokenAmount = 436985605376 +const tokenName = 'DAI'; +const recipient = '0xadd62287c10d90f65fd3bf8bf94183df115c030a'; +const tokenAmount = 1e18; // 1 DAI const daiContract = new Contract('StandardERC20').instance(tokenName); diff --git a/examples/Uniswap/exit_uni.ts b/examples/Uniswap/exit_uni.ts index 53f1fd4..2270234 100644 --- a/examples/Uniswap/exit_uni.ts +++ b/examples/Uniswap/exit_uni.ts @@ -1,10 +1,27 @@ import { Contract } from '../../src/contract'; -const tokenName = 'UNI-USDC'; +const usdcName = 'UNI-V2-ETH-USDC'; +const usdcPoolContract = new Contract('UNIPool').instance(usdcName); +const exitUsdc = usdcPoolContract.methods().exit.call({}); -const poolContract = new Contract('UNIPool').instance(tokenName); +const usdtName = 'UNI-V2-ETH-USDT'; +const usdtPoolContract = new Contract('UNIPool').instance(usdtName); +const exitUsdt = usdtPoolContract.methods().exit.call({}); -const { data, amount, address } = poolContract.methods().exit.call({}); +const daiName = 'UNI-V2-ETH-DAI'; +const daiPoolContract = new Contract('UNIPool').instance(daiName); +const exitDai = daiPoolContract.methods().exit.call({}); -console.log(`Data: ${data}`); -console.log(`To: ${address}`); +const wbtcName = 'UNI-V2-ETH-WBTC'; +const wbtcPoolContract = new Contract('UNIPool').instance(wbtcName); +const exitWbtc = wbtcPoolContract.methods().exit.call({}); + +console.log(`----`) +console.log(`Data: ${exitUsdc.data}`); +console.log(`To: ${exitUsdc.address}\n`); +console.log(`Data: ${exitUsdt.data}`); +console.log(`To: ${exitUsdt.address}\n`); +console.log(`Data: ${exitDai.data}`); +console.log(`To: ${exitDai.address}\n`); +console.log(`Data: ${exitWbtc.data}`); +console.log(`To: ${exitWbtc.address}\n`); diff --git a/examples/Uniswap/stake_uni.ts b/examples/Uniswap/stake_uni.ts index 838784b..ed76f28 100644 --- a/examples/Uniswap/stake_uni.ts +++ b/examples/Uniswap/stake_uni.ts @@ -1,12 +1,17 @@ import { Contract } from '../../src/contract'; -const tokenName = 'UNI-USDC'; -const tokenAmount = 428043827671 //0.00000044 * 1e18; +const tokenName = 'UNI-V2-ETH-DAI'; +const tokenAmount = 908657350098029009 const poolContract = new Contract('UNIPool').instance(tokenName); +let pool = poolContract.methods().stake.call({ amount: tokenAmount.toString(10) }); -const { data, amount, address } = poolContract.methods().stake.call({ amount: tokenAmount }); +const tokenContract = new Contract('StandardERC20').instance(tokenName); +let approve = tokenContract.methods().approve.call({ _spender: pool.address, _value: tokenAmount.toString(10) }); -console.log(`To stake ${tokenAmount}:\n`); -console.log(`Data: ${data}`); -console.log(`To: ${address}`); +console.log(`---- To approve ${tokenName} ${tokenAmount}:\n`); +console.log(`${approve.data}`); +console.log(`${approve.address}\n`); +console.log(`------ and stake -------\n`); +console.log(`${pool.data}`); +console.log(`${pool.address}`); diff --git a/examples/WorkLock/get_bidders_length.ts b/examples/WorkLock/get_bidders_length.ts deleted file mode 100644 index 9a24dbe..0000000 --- a/examples/WorkLock/get_bidders_length.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Contract } from '../../src/contract'; - -const workLockContract = new Contract('WorkLock'); - -let { data, amount, address } = workLockContract.methods() - .getBiddersLength.call({ _value: 20 }); - -console.log(`\nTo get bidders count on WorkLock, send:`); -console.log(`Data: ${data}`); -console.log(`Amount: ${amount} ETH`); -console.log(`To: ${address}`); From 3f016be96826eff91097c3fd361fb5c3bd127b66 Mon Sep 17 00:00:00 2001 From: Michelle Fang Date: Fri, 2 Oct 2020 14:30:21 -0700 Subject: [PATCH 8/8] changes --- examples/StandardERC20/approve.ts | 6 +++--- examples/StandardERC20/transfer.ts | 6 +++--- examples/Uniswap/stake_uni.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/StandardERC20/approve.ts b/examples/StandardERC20/approve.ts index 96f1c3f..f09587c 100644 --- a/examples/StandardERC20/approve.ts +++ b/examples/StandardERC20/approve.ts @@ -1,8 +1,8 @@ import { Contract } from '../../src/contract'; -const tokenName = 'DAI'; -const recipient = '0xadd62287c10d90f65fd3bf8bf94183df115c030a'; -const tokenAmount = 1e18; // 1 DAI +const tokenName = 'UNI'; +const recipient = '0x793F2aA4Cd841A2a64a8AB928ce6011662f565Fe'; +const tokenAmount = 546345703250364; // 1 DAI const daiContract = new Contract('StandardERC20').instance(tokenName); diff --git a/examples/StandardERC20/transfer.ts b/examples/StandardERC20/transfer.ts index 352413f..392b36e 100644 --- a/examples/StandardERC20/transfer.ts +++ b/examples/StandardERC20/transfer.ts @@ -1,8 +1,8 @@ import { Contract } from '../../src/contract'; -const tokenName = 'DAI'; -const recipient = '0xadd62287c10d90f65fd3bf8bf94183df115c030a'; -const tokenAmount = 1e18; // 1 DAI +const tokenName = 'UNI-V2-ETH-DAI'; +const recipient = '0x793F2aA4Cd841A2a64a8AB928ce6011662f565Fe'; +const tokenAmount = 908657350098029009; const daiContract = new Contract('StandardERC20').instance(tokenName); diff --git a/examples/Uniswap/stake_uni.ts b/examples/Uniswap/stake_uni.ts index ed76f28..f9a5c9b 100644 --- a/examples/Uniswap/stake_uni.ts +++ b/examples/Uniswap/stake_uni.ts @@ -1,7 +1,7 @@ import { Contract } from '../../src/contract'; const tokenName = 'UNI-V2-ETH-DAI'; -const tokenAmount = 908657350098029009 +const tokenAmount = 947074854133647025218 const poolContract = new Contract('UNIPool').instance(tokenName); let pool = poolContract.methods().stake.call({ amount: tokenAmount.toString(10) }); @@ -9,7 +9,7 @@ let pool = poolContract.methods().stake.call({ amount: tokenAmount.toString(10) const tokenContract = new Contract('StandardERC20').instance(tokenName); let approve = tokenContract.methods().approve.call({ _spender: pool.address, _value: tokenAmount.toString(10) }); -console.log(`---- To approve ${tokenName} ${tokenAmount}:\n`); +console.log(`---- To approve ${tokenName} ${tokenAmount.toString(10)}:\n`); console.log(`${approve.data}`); console.log(`${approve.address}\n`); console.log(`------ and stake -------\n`);