├── .babelrc ├── .prettierignore ├── .gitignore ├── .prettierrc ├── src ├── test │ ├── _utils │ │ ├── formatting.ts │ │ ├── testing.ts │ │ ├── beacon.ts │ │ ├── contract.ts │ │ └── evm.ts │ ├── node │ │ ├── scenario-set-timezone.ts │ │ ├── scenario-register.ts │ │ └── scenario-set-withdrawal-address.ts │ ├── _helpers │ │ ├── deposit.ts │ │ ├── auction.ts │ │ ├── network.ts │ │ ├── tokens.ts │ │ └── settings.ts │ ├── tokens │ │ ├── scenario-rpl-mint.ts │ │ ├── scenario-transfer-reth.ts │ │ ├── scenario-rpl-allow-fixed.ts │ │ ├── scenario-rpl-mint-fixed.ts │ │ ├── scenario-burn-reth.ts │ │ └── scenario-rpl-burn-fixed.ts │ ├── rewards │ │ ├── scenario-rewards-claim.ts │ │ ├── scenario-rewards-claim-node.ts │ │ └── scenario-rewards-claim-dao.ts │ ├── minipool │ │ ├── scenario-dissolve.ts │ │ ├── scenario-refund.ts │ │ ├── scenario-close.ts │ │ ├── scenario-withdraw.ts │ │ ├── scenario-stake.ts │ │ └── scenario-scrub.ts │ ├── deposit │ │ ├── scenario-deposit.ts │ │ └── scenario-assign-deposits.ts │ ├── settings │ │ └── settings-tests.ts │ ├── auction │ │ ├── scenario-recover-rpl.ts │ │ ├── scenario-claim-bid.ts │ │ └── scenario-place-bid.ts │ ├── dao │ │ └── scenario-dao-proposal.ts │ ├── contracts │ │ └── contracts-tests.ts │ └── network │ │ └── scenario-submit-prices.ts ├── utils │ ├── contract.ts │ └── transaction.ts └── rocketpool │ ├── rewards │ ├── claim-dao.ts │ ├── claim-node.ts │ └── claim-trusted-node.ts │ ├── tokens │ └── legacyrpl.ts │ ├── vault │ └── vault.ts │ ├── settings │ ├── node.ts │ ├── auction.ts │ └── deposit.ts │ └── dao │ └── node │ └── trusted │ └── settings.ts ├── tsconfig.json ├── dist ├── utils │ ├── contract.d.ts │ ├── transaction.js.map │ ├── transaction.d.ts │ ├── contract.js.map │ ├── transaction.js │ └── contract.js ├── test │ ├── _utils │ │ ├── beacon.d.ts │ │ ├── contract.d.ts │ │ ├── beacon.js.map │ │ ├── beacon.js │ │ ├── contract.js.map │ │ └── contract.js │ └── _helpers │ │ └── minipool.d.ts └── rocketpool │ ├── rewards │ ├── claim-dao.js.map │ ├── claim-dao.d.ts │ ├── claim-node.js.map │ ├── claim-trusted-node.js.map │ ├── claim-dao.js │ ├── pool.js.map │ ├── claim-node.d.ts │ ├── claim-trusted-node.d.ts │ ├── claim-node.js │ └── claim-trusted-node.js │ ├── tokens │ ├── legacyrpl.js.map │ ├── legacyrpl.d.ts │ ├── rpl.js.map │ ├── reth.js.map │ ├── erc20.js.map │ ├── legacyrpl.js │ ├── rpl.d.ts │ └── reth.d.ts │ ├── vault │ ├── vault.js.map │ ├── vault.d.ts │ └── vault.js │ ├── settings │ ├── node.js.map │ ├── auction.js.map │ ├── deposit.js.map │ ├── node.d.ts │ ├── minipool.js.map │ ├── auction.d.ts │ ├── network.js.map │ ├── deposit.d.ts │ └── node.js │ ├── dao │ ├── node │ │ └── trusted │ │ │ ├── settings.js.map │ │ │ ├── actions.js.map │ │ │ ├── proposals.js.map │ │ │ ├── settings.d.ts │ │ │ └── node.js.map │ ├── proposals.js.map │ └── protocol │ │ └── settings.js │ ├── deposit │ ├── deposit.js.map │ └── deposit.d.ts │ ├── contracts │ ├── contracts.d.ts │ └── contracts.js.map │ ├── rocketpool.js.map │ ├── rocketpool.d.ts │ └── network │ └── network.js.map ├── .eslintrc.json ├── README.md ├── azure-pipelines.yml ├── typedoc.json └── package.json /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env"] 3 | } 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | src/contracts/ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | src/contracts 4 | .idea 5 | docs/ -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": true, 3 | "endOfLine": "lf", 4 | "printWidth": 160, 5 | "tabWidth": 2, 6 | "trailingComma": "es5" 7 | } 8 | -------------------------------------------------------------------------------- /src/test/_utils/formatting.ts: -------------------------------------------------------------------------------- 1 | // Print pretty test title 2 | export function printTitle(user: string, desc: string) { 3 | return "\x1b[33m" + user + "\u001b[00m: \u001b[01;34m" + desc; 4 | } 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2015", 4 | "sourceMap": true, 5 | "strict": true, 6 | "esModuleInterop": true, 7 | "outDir": "build", 8 | "moduleResolution": "node", 9 | "declaration": true 10 | }, 11 | "files": ["src/rocketpool/rocketpool.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /dist/utils/contract.d.ts: -------------------------------------------------------------------------------- 1 | import { AbiItem } from "web3-utils"; 2 | export interface ContractArtifact { 3 | abi: AbiItem[]; 4 | networks: { 5 | [id: string]: { 6 | address: string; 7 | }; 8 | }; 9 | } 10 | export declare function decodeAbi(encodedAbi: string): AbiItem[]; 11 | -------------------------------------------------------------------------------- /dist/utils/transaction.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":";;;AAQA,mCAAmC;AACnC,SAAgB,mBAAmB,CAAC,EAAkC,EAAE,cAAoC;IAC3G,IAAI,cAAc,KAAK,SAAS;QAAE,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACxE,OAAO,EAAE,CAAC;AACX,CAAC;AAHD,kDAGC"} -------------------------------------------------------------------------------- /dist/test/_utils/beacon.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { DepositData } from "@chainsafe/lodestar-types/lib/types"; 3 | export declare function getValidatorPubkey(): Buffer; 4 | export declare function getValidatorSignature(): Buffer; 5 | export declare function getDepositDataRoot(depositData: DepositData): Buffer; 6 | -------------------------------------------------------------------------------- /dist/utils/transaction.d.ts: -------------------------------------------------------------------------------- 1 | import { PromiEvent, TransactionReceipt } from "web3-core"; 2 | export interface ConfirmationHandler { 3 | (confirmationNumber: number, receipt: TransactionReceipt): void; 4 | } 5 | export declare function handleConfirmations(pe: PromiEvent, onConfirmation?: ConfirmationHandler): PromiEvent; 6 | -------------------------------------------------------------------------------- /dist/utils/contract.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/utils/contract.ts"],"names":[],"mappings":";;;;;;AAAA,UAAU;AACV,gDAAwB;AASxB,sBAAsB;AACtB,SAAgB,SAAS,CAAC,UAAkB;IAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAc,CAAC;AACnG,CAAC;AAFD,8BAEC"} -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-dao.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"claim-dao.js","sourceRoot":"","sources":["../../../src/rocketpool/rewards/claim-dao.ts"],"names":[],"mappings":";;AAQA;;GAEG;AACH,MAAM,OAAO;IACZ;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,cAAc;QACzB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC;CACD;AAED,UAAU;AACV,kBAAe,OAAO,CAAC"} -------------------------------------------------------------------------------- /dist/utils/transaction.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.handleConfirmations = handleConfirmations; 7 | // Handle transaction confirmations 8 | function handleConfirmations(pe, onConfirmation) { 9 | if (onConfirmation !== undefined) pe.on("confirmation", onConfirmation); 10 | return pe; 11 | } 12 | //# sourceMappingURL=transaction.js.map -------------------------------------------------------------------------------- /dist/test/_utils/contract.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { TransactionReceipt } from "web3-core"; 3 | import { AbiInput, AbiItem } from "web3-utils"; 4 | export declare function getTxContractEvents(web3: Web3, txReceipt: TransactionReceipt, contractAddress: string, eventName: string, eventParams: AbiInput[]): any; 5 | export declare function compressABI(abi: AbiItem[]): string; 6 | export declare function decompressABI(abi: string): any; 7 | -------------------------------------------------------------------------------- /src/utils/contract.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import pako from "pako"; 3 | import { AbiItem } from "web3-utils"; 4 | 5 | // Contract artifact 6 | export interface ContractArtifact { 7 | abi: AbiItem[]; 8 | networks: { [id: string]: { address: string } }; 9 | } 10 | 11 | // Decode contract ABI 12 | export function decodeAbi(encodedAbi: string): AbiItem[] { 13 | return JSON.parse(pako.inflate(Buffer.from(encodedAbi, "base64"), { to: "string" })) as AbiItem[]; 14 | } 15 | -------------------------------------------------------------------------------- /dist/rocketpool/tokens/legacyrpl.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"legacyrpl.js","sourceRoot":"","sources":["../../../src/rocketpool/tokens/legacyrpl.ts"],"names":[],"mappings":";;;;;AAMA,oDAA4B;AAE5B;;GAEG;AACH,MAAM,SAAU,SAAQ,eAAK;IAC5B;;;;;OAKG;IACH,YAAmB,IAAU,EAAE,SAAoB;QAClD,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,2BAA2B,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;;;OAQG;IACI,UAAU;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAAU,EAAE;YAClE,OAAO,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC;QACtC,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,SAAS,CAAC"} -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true 5 | }, 6 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], 7 | "parser": "@typescript-eslint/parser", 8 | "parserOptions": { 9 | "ecmaVersion": 12, 10 | "sourceType": "module" 11 | }, 12 | "plugins": ["@typescript-eslint"], 13 | "rules": { 14 | "indent": ["error", "tab"], 15 | "linebreak-style": ["error", "unix"], 16 | "quotes": ["error", "double"], 17 | "semi": ["error", "always"] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/utils/transaction.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { PromiEvent, TransactionReceipt } from "web3-core"; 3 | 4 | // Transaction confirmation handler 5 | export interface ConfirmationHandler { 6 | (confirmationNumber: number, receipt: TransactionReceipt): void; 7 | } 8 | 9 | // Handle transaction confirmations 10 | export function handleConfirmations(pe: PromiEvent, onConfirmation?: ConfirmationHandler): PromiEvent { 11 | if (onConfirmation !== undefined) pe.on("confirmation", onConfirmation); 12 | return pe; 13 | } 14 | -------------------------------------------------------------------------------- /dist/utils/contract.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.decodeAbi = decodeAbi; 7 | 8 | var _pako = require("pako"); 9 | 10 | var _pako2 = _interopRequireDefault(_pako); 11 | 12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 13 | 14 | // Decode contract ABI 15 | function decodeAbi(encodedAbi) { 16 | return JSON.parse(_pako2.default.inflate(Buffer.from(encodedAbi, "base64"), { to: "string" })); 17 | } 18 | //# sourceMappingURL=contract.js.map 19 | // Imports -------------------------------------------------------------------------------- /src/test/node/scenario-set-timezone.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Set a node's timezone location 8 | export async function setTimezoneLocation(web3: Web3, rp: RocketPool, timezoneLocation: string, options: SendOptions) { 9 | // Set timezone location 10 | await rp.node.setTimezoneLocation(timezoneLocation, options); 11 | 12 | // Check node's timezone location 13 | const nodeTimezoneLocation = await rp.node.getNodeTimezoneLocation(options.from); 14 | assert.equal(nodeTimezoneLocation, timezoneLocation, "Incorrect updated timezone location"); 15 | } 16 | -------------------------------------------------------------------------------- /src/test/_helpers/deposit.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { SendOptions } from "web3-eth-contract"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | 6 | // Get the deposit pool excess ETH balance 7 | export async function getDepositExcessBalance(web3: Web3, rp: RocketPool) { 8 | const excessBalance = await rp.deposit.getExcessBalance(); 9 | return excessBalance; 10 | } 11 | 12 | // Make a deposit 13 | export async function userDeposit(web3: Web3, rp: RocketPool, options: SendOptions) { 14 | await rp.deposit.deposit(options); 15 | } 16 | 17 | // Assign deposits 18 | export async function assignDeposits(web3: Web3, rp: RocketPool, options: SendOptions) { 19 | await rp.deposit.assignDeposits(options); 20 | } 21 | -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-dao.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import Contracts from "../contracts/contracts"; 3 | /** 4 | * Rocket Pool Rewards 5 | */ 6 | declare class Rewards { 7 | private web3; 8 | private contracts; 9 | /** 10 | * Create a new Rewards instance. 11 | * 12 | * @param web3 A valid Web3 instance 13 | * @param contracts A Rocket Pool contract manager instance 14 | */ 15 | constructor(web3: Web3, contracts: Contracts); 16 | /** 17 | * Private accessor use to retrieve the related contract 18 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimDAO contract 19 | */ 20 | private get rocketClaimDAO(); 21 | } 22 | export default Rewards; 23 | -------------------------------------------------------------------------------- /src/test/_utils/testing.ts: -------------------------------------------------------------------------------- 1 | // Assert that a transaction reverts 2 | import { assert } from "chai"; 3 | 4 | export async function shouldRevert(txPromise: Promise, message: string, expectedErrorMessage: string) { 5 | let txSuccess = false; 6 | try { 7 | await txPromise; 8 | txSuccess = true; 9 | } catch (e: any) { 10 | // If we don't need to match a specific error message 11 | if (!expectedErrorMessage && e.message.indexOf("VM Exception") == -1) throw e; 12 | // If we do 13 | if (expectedErrorMessage && e.message.indexOf(expectedErrorMessage) == -1) 14 | assert.fail("Expected error message not found, error received: " + e.message.replace("Returned error:", "")); 15 | } finally { 16 | if (txSuccess) assert.fail(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /dist/test/_utils/beacon.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"beacon.js","sourceRoot":"","sources":["../../../src/test/_utils/beacon.ts"],"names":[],"mappings":";;;AAAA,UAAU;AACV,MAAM,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACtC,MAAM,KAAK,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC,KAAK,CAAC;AAGjF,uBAAuB;AACvB,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB,gCAAgC;AAChC,SAAgB,kBAAkB;IACjC,MAAM,KAAK,GAAG,EAAE,WAAW,CAAC;IAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC;AAHD,gDAGC;AAED,+BAA+B;AAC/B,mDAAmD;AACnD,SAAgB,qBAAqB;IACpC,OAAO,MAAM,CAAC,IAAI,CACjB,kEAAkE;QACjE,kEAAkE;QAClE,kEAAkE,EACnE,KAAK,CACL,CAAC;AACH,CAAC;AAPD,sDAOC;AAED,qCAAqC;AACrC,SAAgB,kBAAkB,CAAC,WAAwB;IAC1D,OAAO,KAAK,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;AACpD,CAAC;AAFD,gDAEC"} -------------------------------------------------------------------------------- /dist/rocketpool/vault/vault.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"vault.js","sourceRoot":"","sources":["../../../src/rocketpool/vault/vault.ts"],"names":[],"mappings":";;AAKA;;GAEG;AACH,MAAM,KAAK;IACV;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,WAAW;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;OAQG;IACI,UAAU;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAqB,EAAU,EAAE;YAC9D,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;QACpC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACI,cAAc,CAAC,eAAuB,EAAE,YAAoB;QAClE,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAqB,EAAmB,EAAE;YACvE,OAAO,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;QACjF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,KAAK,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/settings/node.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/rocketpool/settings/node.ts"],"names":[],"mappings":";;AAKA;;GAEG;AACH,MAAM,YAAY;IACjB;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,6BAA6B;QACxC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;OAQG;IACI,sBAAsB;QAC5B,OAAO,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC,6BAAuC,EAAoB,EAAE;YAC5G,OAAO,6BAA6B,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9E,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,iBAAiB;QACvB,OAAO,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC,6BAAuC,EAAoB,EAAE;YAC5G,OAAO,6BAA6B,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC;QACzE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,YAAY,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-node.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"claim-node.js","sourceRoot":"","sources":["../../../src/rocketpool/rewards/claim-node.ts"],"names":[],"mappings":";;AAKA,yDAAmF;AAGnF;;GAEG;AACH,MAAM,OAAO;IACZ;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,eAAe;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;;;OAUG;IACI,gBAAgB,CAAC,OAAe;QACtC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,eAAyB,EAAoB,EAAE;YAChF,OAAO,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QACjE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,OAAqB,EAAE,cAAoC;QACvE,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,eAAyB,EAA+B,EAAE;YAC3F,OAAO,IAAA,iCAAmB,EAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QAC3F,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,OAAO,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/tokens/legacyrpl.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import Contracts from "../contracts/contracts"; 3 | import ERC20 from "./erc20"; 4 | /** 5 | * Rocket Pool Legacy RPL Token Manager 6 | */ 7 | declare class LegacyRPL extends ERC20 { 8 | /** 9 | * Create a new LegacyRPL instance. 10 | * 11 | * @param web3 A valid Web3 instance 12 | * @param contracts A Rocket Pool contract manager instance 13 | */ 14 | constructor(web3: Web3, contracts: Contracts); 15 | /** 16 | * Get the contract address 17 | * @returns a Promise that resolves to a string representing the contract address of the token 18 | * 19 | * @example using Typescript 20 | * ```ts 21 | * const address = rp.tokens.legacyrpl.getAddress().then((val: string) => { val }; 22 | * ``` 23 | */ 24 | getAddress(): Promise; 25 | } 26 | export default LegacyRPL; 27 | -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-trusted-node.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"claim-trusted-node.js","sourceRoot":"","sources":["../../../src/rocketpool/rewards/claim-trusted-node.ts"],"names":[],"mappings":";;AAKA,yDAAmF;AAGnF;;GAEG;AACH,MAAM,OAAO;IACZ;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,sBAAsB;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;;;;;OAUG;IACI,qBAAqB,CAAC,OAAe;QAC3C,OAAO,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,sBAAgC,EAAmB,EAAE;YAC7F,OAAO,sBAAsB,CAAC,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7E,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,OAAqB,EAAE,cAAoC;QACvE,OAAO,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,sBAAgC,EAA+B,EAAE;YACzG,OAAO,IAAA,iCAAmB,EAAC,sBAAsB,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QAClG,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,OAAO,CAAC"} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Rocket Pool - Next Generation Decentralised Ethereum Proof-of-Stake (PoS) Infrastructure Service and Pool 3 |

4 | 5 | # rocketpool-js 6 | 7 | A javascript library for interacting with the Rocket Pool network. 8 | 9 | Install the following dependencies: 10 | 11 | ``` 12 | $ npm i -g mocha typescript ts-node && npm i 13 | ``` 14 | 15 | Run Ganache: 16 | 17 | ``` 18 | $ ganache-cli -l 8000000 -e 10000 -i 1337 19 | ``` 20 | 21 | Clone and migrate the Rocket Pool contracts: 22 | 23 | ``` 24 | $ git clone https://github.com/rocket-pool/rocketpool.git 25 | $ truffle migrate --reset 26 | ``` 27 | 28 | In javascript library directory, create symlink to Rocket Pool Truffle contract artifacts: 29 | 30 | ``` 31 | $ ln -s ../../rocketpool/build/contracts/ src/contracts 32 | ``` 33 | 34 | Give the Javascript library a spin: 35 | 36 | ``` 37 | $ npm test 38 | ``` 39 | -------------------------------------------------------------------------------- /src/rocketpool/rewards/claim-dao.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { TransactionReceipt } from "web3-core"; 4 | import { Contract, SendOptions } from "web3-eth-contract"; 5 | import Contracts from "../contracts/contracts"; 6 | import { ConfirmationHandler, handleConfirmations } from "../../utils/transaction"; 7 | import { NodeDetails } from "../node/node"; 8 | 9 | /** 10 | * Rocket Pool Rewards 11 | */ 12 | class Rewards { 13 | /** 14 | * Create a new Rewards instance. 15 | * 16 | * @param web3 A valid Web3 instance 17 | * @param contracts A Rocket Pool contract manager instance 18 | */ 19 | public constructor(private web3: Web3, private contracts: Contracts) {} 20 | 21 | /** 22 | * Private accessor use to retrieve the related contract 23 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimDAO contract 24 | */ 25 | private get rocketClaimDAO(): Promise { 26 | return this.contracts.get("rocketClaimDAO"); 27 | } 28 | } 29 | 30 | // Exports 31 | export default Rewards; 32 | -------------------------------------------------------------------------------- /dist/rocketpool/dao/node/trusted/settings.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../../../src/rocketpool/dao/node/trusted/settings.ts"],"names":[],"mappings":";;AAOA;;GAEG;AACH,MAAM,sBAAsB;IAC3B;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,qCAAqC;QAChD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;IACpE,CAAC;IAED;;;OAGG;IACH,IAAY,mCAAmC;QAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IAClE,CAAC;IAED;;;OAGG;IACH,IAAY,gCAAgC;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACH,IAAY,iCAAiC;QAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;;OAQG;IACI,4BAA4B;QAClC,OAAO,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACjH,OAAO,gCAAgC,CAAC,OAAO,CAAC,4BAA4B,EAAE,CAAC,IAAI,EAAE,CAAC;QACvF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,gBAAgB;QACtB,OAAO,IAAI,CAAC,mCAAmC,CAAC,IAAI,CAAC,CAAC,mCAA6C,EAAmB,EAAE;YACvH,OAAO,mCAAmC,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9E,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,sBAAsB,CAAC"} -------------------------------------------------------------------------------- /src/test/_utils/beacon.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | const ssz = require("@chainsafe/ssz"); 3 | const types = require("@chainsafe/lodestar-types/lib/ssz/presets/mainnet").types; 4 | import { DepositData } from "@chainsafe/lodestar-types/lib/types"; 5 | 6 | // Current pubkey index 7 | let pubkeyIndex = 0; 8 | 9 | // Create a new validator pubkey 10 | export function getValidatorPubkey(): Buffer { 11 | const index = ++pubkeyIndex; 12 | return Buffer.from(index.toString(16).padStart(96, "0"), "hex"); 13 | } 14 | 15 | // Create a validator signature 16 | // TODO: implement correctly once BLS library found 17 | export function getValidatorSignature(): Buffer { 18 | return Buffer.from( 19 | "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + 20 | "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + 21 | "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 22 | "hex" 23 | ); 24 | } 25 | 26 | // Create validator deposit data root 27 | export function getDepositDataRoot(depositData: DepositData): Buffer { 28 | return types.DepositData.hashTreeRoot(depositData); 29 | } 30 | -------------------------------------------------------------------------------- /src/test/tokens/scenario-rpl-mint.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import RocketPool from "../../rocketpool/rocketpool"; 4 | import { mintDummyRPL } from "./scenario-rpl-mint-fixed"; 5 | import { allowDummyRPL } from "./scenario-rpl-allow-fixed"; 6 | import { burnFixedRPL } from "./scenario-rpl-burn-fixed"; 7 | 8 | export async function mintRPL(web3: Web3, rp: RocketPool, _account: string, _amount: string, _owner: string) { 9 | // Load contracts 10 | const rocketTokenRPL = await rp.contracts.get("rocketTokenRPL"); 11 | // Convert 12 | _amount = web3.utils.toWei(_amount.toString(), "ether"); 13 | // Mint RPL fixed supply for the users to simulate current users having RPL 14 | await mintDummyRPL(web3, rp, _account, _amount, { from: _owner }); 15 | // Mint a large amount of dummy RPL to owner, who then burns it for real RPL which is sent to nodes for testing below 16 | await allowDummyRPL(web3, rp, rocketTokenRPL.options.address, _amount, { 17 | from: _account, 18 | }); 19 | // Burn existing fixed supply RPL for new RPL 20 | await burnFixedRPL(web3, rp, _amount, { from: _account }); 21 | } 22 | -------------------------------------------------------------------------------- /src/test/_helpers/auction.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import RocketPool from "../../rocketpool/rocketpool"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | 6 | // Get lot end blocks 7 | export async function getLotStartBlock(web3: Web3, rp: RocketPool, lotIndex: number) { 8 | return await rp.auction.getLotStartBlock(lotIndex); 9 | } 10 | 11 | // Get lot end blocks 12 | export async function getLotEndBlock(web3: Web3, rp: RocketPool, lotIndex: number) { 13 | return await rp.auction.getLotEndBlock(lotIndex); 14 | } 15 | 16 | // Get lot price at a block 17 | export async function getLotPriceAtBlock(web3: Web3, rp: RocketPool, lotIndex: number, block: number) { 18 | return await rp.auction.getLotPriceAtBlock(lotIndex, block); 19 | } 20 | 21 | // Create a new lot for auction 22 | export async function auctionCreateLot(web3: Web3, rp: RocketPool, options: SendOptions) { 23 | await rp.auction.createLot(options); 24 | } 25 | 26 | // Place a bid on a lot 27 | export async function auctionPlaceBid(web3: Web3, rp: RocketPool, lotIndex: number, options: SendOptions) { 28 | await rp.auction.placeBid(lotIndex, options); 29 | } 30 | -------------------------------------------------------------------------------- /dist/rocketpool/settings/auction.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"auction.js","sourceRoot":"","sources":["../../../src/rocketpool/settings/auction.ts"],"names":[],"mappings":";;AAKA;;GAEG;AACH,MAAM,eAAe;IACpB;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,gCAAgC;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;OAQG;IACI,qBAAqB;QAC3B,OAAO,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACjH,OAAO,gCAAgC,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,IAAI,EAAE,CAAC;QAChF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,cAAc;QACpB,OAAO,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACjH,OAAO,gCAAgC,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,CAAC;QACzE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,qBAAqB;QAC3B,OAAO,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACjH,OAAO,gCAAgC,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,IAAI,EAAE,CAAC;QAChF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,oBAAoB;QAC1B,OAAO,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACjH,OAAO,gCAAgC,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,CAAC;QAC/E,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,eAAe,CAAC"} -------------------------------------------------------------------------------- /src/test/rewards/scenario-rewards-claim.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { SendOptions } from "web3-eth-contract"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | 6 | // Get the current rewards claim period in blocks 7 | export async function rewardsClaimIntervalTimeGet(web3: Web3, rp: RocketPool, options: SendOptions) { 8 | // Load contracts 9 | const rocketDAOProtocolSettingsRewards = await rp.contracts.get("rocketDAOProtocolSettingsRewards"); 10 | return await rocketDAOProtocolSettingsRewards.methods.getClaimIntervalTime().call(); 11 | } 12 | 13 | // Get the current rewards claimers total 14 | export async function rewardsClaimersPercTotalGet(web3: Web3, rp: RocketPool, options: SendOptions) { 15 | // Load contracts 16 | const rocketDAOProtocolSettingsRewards = await rp.contracts.get("rocketDAOProtocolSettingsRewards"); 17 | return await rocketDAOProtocolSettingsRewards.methods.getRewardsClaimersPercTotal().call(); 18 | } 19 | 20 | // Get how many seconds needed until the next claim interval 21 | export async function rewardsClaimIntervalsPassedGet(web3: Web3, rp: RocketPool, options: SendOptions) { 22 | return await rp.rewards.pool.getClaimIntervalsPassed(); 23 | } 24 | -------------------------------------------------------------------------------- /dist/test/_utils/beacon.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.getValidatorPubkey = getValidatorPubkey; 7 | exports.getValidatorSignature = getValidatorSignature; 8 | exports.getDepositDataRoot = getDepositDataRoot; 9 | // Imports 10 | var ssz = require("@chainsafe/ssz"); 11 | var types = require("@chainsafe/lodestar-types/lib/ssz/presets/mainnet").types; 12 | // Current pubkey index 13 | var pubkeyIndex = 0; 14 | // Create a new validator pubkey 15 | function getValidatorPubkey() { 16 | var index = ++pubkeyIndex; 17 | return Buffer.from(index.toString(16).padStart(96, "0"), "hex"); 18 | } 19 | // Create a validator signature 20 | // TODO: implement correctly once BLS library found 21 | function getValidatorSignature() { 22 | return Buffer.from("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "hex"); 23 | } 24 | // Create validator deposit data root 25 | function getDepositDataRoot(depositData) { 26 | return types.DepositData.hashTreeRoot(depositData); 27 | } 28 | //# sourceMappingURL=beacon.js.map -------------------------------------------------------------------------------- /src/test/tokens/scenario-transfer-reth.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | import { SendOptions } from "web3-eth-contract"; 6 | 7 | export async function transferReth(web3: Web3, rp: RocketPool, to: string, amount: string, options: SendOptions) { 8 | // Get balances 9 | function getBalances() { 10 | return Promise.all([ 11 | rp.tokens.reth.balanceOf(options.from).then((value: any) => web3.utils.toBN(value)), 12 | rp.tokens.reth.balanceOf(to).then((value: any) => web3.utils.toBN(value)), 13 | ]).then(([userFromTokenBalance, userToTokenBalance]) => ({ 14 | userFromTokenBalance, 15 | userToTokenBalance, 16 | })); 17 | } 18 | 19 | // Get initial balances 20 | const balances1 = await getBalances(); 21 | 22 | // Transfer tokens 23 | await rp.tokens.reth.transfer(to, amount, options); 24 | 25 | // Get updated balances 26 | const balances2 = await getBalances(); 27 | 28 | // Check balances 29 | assert(balances2.userFromTokenBalance.eq(balances1.userFromTokenBalance.sub(web3.utils.toBN(amount))), "Incorrect updated user token balance"); 30 | assert(balances2.userToTokenBalance.eq(balances1.userToTokenBalance.add(web3.utils.toBN(amount))), "Incorrect updated user token balance"); 31 | } 32 | -------------------------------------------------------------------------------- /src/rocketpool/tokens/legacyrpl.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { TransactionReceipt } from "web3-core"; 4 | import { Contract, SendOptions } from "web3-eth-contract"; 5 | import Contracts from "../contracts/contracts"; 6 | import { ConfirmationHandler, handleConfirmations } from "../../utils/transaction"; 7 | import ERC20 from "./erc20"; 8 | 9 | /** 10 | * Rocket Pool Legacy RPL Token Manager 11 | */ 12 | class LegacyRPL extends ERC20 { 13 | /** 14 | * Create a new LegacyRPL instance. 15 | * 16 | * @param web3 A valid Web3 instance 17 | * @param contracts A Rocket Pool contract manager instance 18 | */ 19 | public constructor(web3: Web3, contracts: Contracts) { 20 | super(web3, contracts, "rocketTokenRPLFixedSupply"); 21 | } 22 | 23 | /** 24 | * Get the contract address 25 | * @returns a Promise that resolves to a string representing the contract address of the token 26 | * 27 | * @example using Typescript 28 | * ```ts 29 | * const address = rp.tokens.legacyrpl.getAddress().then((val: string) => { val }; 30 | * ``` 31 | */ 32 | public getAddress(): Promise { 33 | return this.tokenContract.then((tokenContract: Contract): string => { 34 | return tokenContract.options.address; 35 | }); 36 | } 37 | } 38 | 39 | // Exports 40 | export default LegacyRPL; 41 | -------------------------------------------------------------------------------- /dist/rocketpool/tokens/rpl.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"rpl.js","sourceRoot":"","sources":["../../../src/rocketpool/tokens/rpl.ts"],"names":[],"mappings":";;;;;AAKA,yDAAmF;AACnF,oDAA4B;AAE5B;;GAEG;AACH,MAAM,GAAI,SAAQ,eAA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A,iCAAmB,EAAC,aAAa,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QACvG,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,GAAG,CAAC"} -------------------------------------------------------------------------------- /src/test/minipool/scenario-dissolve.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | import MinipoolContract from "../../rocketpool/minipool/minipool-contract"; 7 | 8 | // Dissolve a minipool 9 | export async function dissolve(web3: Web3, rp: RocketPool, minipool: MinipoolContract, options: SendOptions) { 10 | // Get minipool details 11 | function getMinipoolDetails() { 12 | return Promise.all([ 13 | minipool.getStatus().then((value: any) => web3.utils.toBN(value)), 14 | minipool.getUserDepositBalance().then((value: any) => web3.utils.toBN(value)), 15 | ]).then(([status, userDepositBalance]) => ({ status, userDepositBalance })); 16 | } 17 | 18 | // Get initial minipool details 19 | const details1 = await getMinipoolDetails(); 20 | 21 | // Dissolve 22 | await minipool.dissolve(options); 23 | 24 | // Get updated minipool details 25 | const details2 = await getMinipoolDetails(); 26 | 27 | // Check minipool details 28 | const dissolved = web3.utils.toBN(4); 29 | assert(!details1.status.eq(dissolved), "Incorrect initial minipool status"); 30 | assert(details2.status.eq(dissolved), "Incorrect updated minipool status"); 31 | assert(details2.userDepositBalance.eq(web3.utils.toBN(0)), "Incorrect updated minipool user deposit balance"); 32 | } 33 | -------------------------------------------------------------------------------- /dist/rocketpool/settings/deposit.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"deposit.js","sourceRoot":"","sources":["../../../src/rocketpool/settings/deposit.ts"],"names":[],"mappings":";;AAKA;;GAEG;AACH,MAAM,eAAe;IACpB;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAA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,CAAC,IAAI,EAAE,CAAC;QACvF,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,KAAa,EAAU,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;CACD;AAED,UAAU;AACV,kBAAe,eAAe,CAAC"} -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | branches: 3 | include: 4 | - "*" 5 | - refs/tags/* 6 | 7 | pool: 8 | vmImage: ubuntu-latest 9 | 10 | steps: 11 | - task: DownloadSecureFile@1 12 | name: githubPEM 13 | displayName: "Download Github PEM" 14 | inputs: 15 | secureFile: "rp-azure-pipeline-github.pem" 16 | - bash: | 17 | eval $(ruby -e "require 'openssl'; require 'jwt'; private_pem = File.read(ENV['GITHUB_PEM_PATH']); private_key = OpenSSL::PKey::RSA.new(private_pem); payload = { iat: Time.now.to_i - 60, exp: Time.now.to_i + (10 * 60), iss: ENV['GITHUB_APP_ID'] }; jwt = JWT.encode(payload, private_key, 'RS256'); puts 'PUSH_JWT='+jwt;") 18 | TOKEN=$(curl -s -X POST \ 19 | -H "Authorization: Bearer $PUSH_JWT" \ 20 | -H "Accept: application/vnd.github.v3+json" \ 21 | https://api.github.com/app/installations/$GITHUB_APP_INSTALLATION_ID/access_tokens \ 22 | | jq -r '.token') 23 | git remote add github https://x-access-token:$TOKEN@github.com/rocket-pool/$REPO_NAME 24 | git fetch github 25 | git push github HEAD:$(Build.SourceBranch) --verbose 26 | git push github HEAD:$(Build.SourceBranch) --tags --verbose 27 | displayName: "Push to Github" 28 | env: 29 | GITHUB_PEM_PATH: $(githubPEM.secureFilePath) 30 | GITHUB_APP_ID: $(GITHUB_APP_ID) 31 | GITHUB_APP_INSTALLATION_ID: $(GITHUB_APP_INSTALLATION_ID) 32 | -------------------------------------------------------------------------------- /src/test/tokens/scenario-rpl-allow-fixed.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | import { SendOptions } from "web3-eth-contract"; 6 | 7 | export async function allowDummyRPL(web3: Web3, rp: RocketPool, to: string, amount: string, options: SendOptions) { 8 | // Load contracts 9 | const rocketTokenDummyRPL = await rp.contracts.get("rocketTokenRPLFixedSupply"); 10 | 11 | // Get balances 12 | function getBalances() { 13 | return Promise.all([rp.tokens.legacyrpl.allowance(options.from, to)]).then(([tokenAllowance]) => ({ 14 | tokenAllowance: web3.utils.toBN(tokenAllowance), 15 | })); 16 | } 17 | 18 | // Get initial balances 19 | const balances1 = await getBalances(); 20 | 21 | // Set gas price 22 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 23 | options.gasPrice = gasPrice.toString(); 24 | 25 | // Mint tokens 26 | const txReceipt = await rocketTokenDummyRPL.methods.approve(to, amount).send(options); 27 | const txFee = gasPrice.mul(web3.utils.toBN(txReceipt.gasUsed)); 28 | 29 | // Get updated balances 30 | const balances2 = await getBalances(); 31 | 32 | // Calculate values 33 | const allowanceAmount = web3.utils.toBN(amount); 34 | 35 | // Check balances 36 | assert(balances2.tokenAllowance.eq(balances1.tokenAllowance.add(allowanceAmount)), "Incorrect allowance for token"); 37 | } 38 | -------------------------------------------------------------------------------- /dist/rocketpool/deposit/deposit.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"deposit.js","sourceRoot":"","sources":["../../../src/rocketpool/deposit/deposit.ts"],"names":[],"mappings":";;AAKA,yDAAmF;AAEnF;;GAEG;AACH,MAAM,OAAO;IACZ;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,iBAAiB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;;;;;OAUG;IACI,UAAU;QAChB,OAA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AC;QACtG,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,OAAO,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/dao/node/trusted/actions.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../../src/rocketpool/dao/node/trusted/actions.ts"],"names":[],"mappings":";;AAKA,+DAAyF;AAEzF;;GAEG;AACH,MAAM,qBAAqB;IAC1B;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,2BAA2B;QACtC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,UAAU,CAAC,OAAqB,EAAE,cAAoC;QAC5E,OAAO,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,2BAAqC,EAA+B,EAAE;YACnH,OAAO,IAAA,iCAAmB,EAAC,2BAA2B,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QAC5G,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,WAAW,CAAC,aAAqB,EAAE,OAAqB,EAAE,cAAoC;QACpG,OAAO,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,2BAAqC,EAA+B,EAAE;YACnH,OAAO,IAAA,iCAAmB,EAAC,2BAA2B,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QAC1H,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,mBAAmB,CAAC,OAAe,EAAE,OAAqB,EAAE,cAAoC;QACtG,OAAO,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,2BAAqC,EAA+B,EAAE;YACnH,OAAO,IAAA,iCAAmB,EAAC,2BAA2B,CAAC,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QAC5H,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,qBAAqB,CAAC,OAAe,EAAE,OAAqB,EAAE,cAAoC;QACxG,OAAO,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,2BAAqC,EAA+B,EAAE;YACnH,OAAO,IAAA,iCAAmB,EAAC,2BAA2B,CAAC,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9H,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,qBAAqB,CAAC"} -------------------------------------------------------------------------------- /src/test/node/scenario-register.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Register a node 8 | export async function register(web3: Web3, rp: RocketPool, timezoneLocation: string, options: SendOptions) { 9 | // Get node details 10 | function getNodeDetails(nodeAddress: string) { 11 | return Promise.all([rp.node.getNodeExists(nodeAddress), rp.node.getNodeTimezoneLocation(nodeAddress)]).then(([exists, timezoneLocation]) => ({ 12 | exists, 13 | timezoneLocation, 14 | })); 15 | } 16 | 17 | // Get initial node index 18 | const nodeCount1 = await rp.node.getNodeCount().then((value: any) => web3.utils.toBN(value)); 19 | 20 | // Register 21 | await rp.node.registerNode(timezoneLocation, options); 22 | 23 | // Get updated node index & node details 24 | const nodeCount2 = await rp.node.getNodeCount().then((value: any) => web3.utils.toBN(value)); 25 | 26 | const [lastNodeAddress, details] = await Promise.all([rp.node.getNodeAt(nodeCount2.sub(web3.utils.toBN(1)).toNumber()), getNodeDetails(options.from)]); 27 | 28 | // Check details 29 | assert(nodeCount2.eq(nodeCount1.add(web3.utils.toBN(1))), "Incorrect updated node count"); 30 | assert.equal(lastNodeAddress.toLowerCase(), options.from, "Incorrect updated node index"); 31 | assert.isTrue(details.exists, "Incorrect node exists flag"); 32 | assert.equal(details.timezoneLocation, timezoneLocation, "Incorrect node timezone location"); 33 | } 34 | -------------------------------------------------------------------------------- /dist/test/_helpers/minipool.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { SendOptions } from "web3-eth-contract"; 3 | import RocketPool from "../../rocketpool/rocketpool"; 4 | import MinipoolContract from "../../rocketpool/minipool/minipool-contract"; 5 | export declare function getNodeMinipoolCount(web3: Web3, rp: RocketPool, nodeAddress: string): Promise; 6 | export declare function getNodeStakingMinipoolCount(web3: Web3, rp: RocketPool, nodeAddress: string): Promise; 7 | export declare function getNodeActiveMinipoolCount(web3: Web3, rp: RocketPool, nodeAddress: string): Promise; 8 | export declare function getMinipoolMinimumRPLStake(web3: Web3, rp: RocketPool): Promise; 9 | export declare function createMinipool(web3: Web3, rp: RocketPool, options: SendOptions, salt?: number | null): Promise; 10 | export declare function stakeMinipool(web3: Web3, rp: RocketPool, minipool: MinipoolContract, options: SendOptions): Promise; 11 | export declare function submitMinipoolWithdrawable(web3: Web3, rp: RocketPool, minipoolAddress: string, options: SendOptions): Promise; 12 | export declare function payoutMinipool(minipool: MinipoolContract, confirm: boolean | undefined, options: SendOptions): Promise; 13 | export declare function withdrawMinipool(minipool: MinipoolContract, options: SendOptions): Promise; 14 | export declare function dissolveMinipool(minipool: MinipoolContract, options: SendOptions): Promise; 15 | export declare function closeMinipool(minipool: MinipoolContract, options: SendOptions): Promise; 16 | -------------------------------------------------------------------------------- /dist/rocketpool/dao/node/trusted/proposals.js.map: --------------------------------------------------------------------------------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,CAAC,IAAI,CAAC,CAAC,6BAAuC,EAA+B,EAAE;YACvH,OAAO,IAAA,iCAAmB,EAAC,6BAA6B,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QACrH,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACI,MAAM,CAAC,UAAkB,EAAE,OAAqB,EAAE,cAAoC;QAC5F,OAAO,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC,6BAAuC,EAA+B,EAAE;YACvH,OAAO,IAAA,iCAAmB,EAAC,6BAA6B,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QACpH,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,uBAAuB,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/settings/node.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import Contracts from "../contracts/contracts"; 3 | /** 4 | * Rocket Pool Node Settings Manager 5 | */ 6 | declare class NodeSettings { 7 | private web3; 8 | private contracts; 9 | /** 10 | * Create a new Node Settings instance. 11 | * 12 | * @param web3 A valid Web3 instance 13 | * @param contracts A Rocket Pool contract manager instance 14 | */ 15 | constructor(web3: Web3, contracts: Contracts); 16 | /** 17 | * Private accessor use to retrieve the related contract 18 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsNode contract 19 | */ 20 | private get rocketDAOProtocolSettingsNode(); 21 | /** 22 | * Return if node registrations are currently enabled 23 | * @returns a Promise that resolves to a boolean representing if node registrations are enabled 24 | * 25 | * @example using Typescript 26 | * ```ts 27 | * const enabled = rp.settings.node.getRegistrationEnabled().then((val: boolean) => { val }; 28 | * ``` 29 | */ 30 | getRegistrationEnabled(): Promise; 31 | /** 32 | * Return if node deposits are currently enabled 33 | * @returns a Promise that resolves to a boolean representing if node deposits are enabled 34 | * 35 | * @example using Typescript 36 | * ```ts 37 | * const enabled = rp.settings.node.getDepositEnabled().then((val: boolean) => { val }; 38 | * ``` 39 | */ 40 | getDepositEnabled(): Promise; 41 | } 42 | export default NodeSettings; 43 | -------------------------------------------------------------------------------- /dist/test/_utils/contract.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/test/_utils/contract.ts"],"names":[],"mappings":";;;AAIA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B,0DAA0D;AAC1D,8DAA8D;AAC9D,wEAAwE;AACxE,iDAAiD;AACjD,8GAA8G;AAC9G,SAAgB,mBAAmB,CAAC,IAAU,EAAE,SAA6B,EAAE,eAAuB,EAAE,SAAiB,EAAE,WAAuB;IACjJ,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAI,SAAS,CAAC,MAAM;QAAE,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,MAAM;YAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,OAAO,MAAM;SACX,MAAM,CAAC,CAAC,GAAa,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,eAAe,CAAC,WAAW,EAAE,CAAC;SACrF,MAAM,CAAC,CAAC,GAAa,EAAE,EAAE,CAAC,GAAG,CAAC,GAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,GAAG,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;SAClJ,GAAG,CAAC,CAAC,GAAa,EAAE,EAAE,CACtB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CACrB,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACzB,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAC7C,IAAI,WAAW,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,QAAQ,IAAI,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC;YAAE,WAAW,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,sDAAsD;QAC9K,OAAO,WAAW,CAAC;IACpB,CAAC,CAAC,EACF,GAAG,CAAC,GAAI,CAAC,IAAI,EACb,GAAG,CAAC,GAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACxB,CACD,CAAC;AACJ,CAAC;AAjBD,kDAiBC;AAED,sCAAsC;AACtC,SAAgB,WAAW,CAAC,GAAc;IACzC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1E,CAAC;AAFD,kCAEC;AAED,SAAgB,aAAa,CAAC,GAAW;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC;AAFD,sCAEC"} -------------------------------------------------------------------------------- /src/test/tokens/scenario-rpl-mint-fixed.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | import { SendOptions } from "web3-eth-contract"; 6 | 7 | export async function mintDummyRPL(web3: Web3, rp: RocketPool, _account: string, _amount: string, options: SendOptions) { 8 | // Load contracts 9 | const rocketTokenDummyRPL = await rp.contracts.get("rocketTokenRPLFixedSupply"); 10 | 11 | // Get balances 12 | function getBalances() { 13 | return Promise.all([rocketTokenDummyRPL.methods.totalSupply().call(), rocketTokenDummyRPL.methods.balanceOf(_account).call()]).then( 14 | ([tokenSupply, userTokenBalance]) => ({ 15 | tokenSupply: web3.utils.toBN(tokenSupply), 16 | userTokenBalance: web3.utils.toBN(userTokenBalance), 17 | }) 18 | ); 19 | } 20 | 21 | // Get initial balances 22 | const balances1 = await getBalances(); 23 | 24 | // Set gas price 25 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 26 | options.gasPrice = gasPrice.toString(); 27 | 28 | // Mint tokens 29 | const txReceipt = await rocketTokenDummyRPL.methods.mint(_account, _amount).send(options); 30 | const txFee = gasPrice.mul(web3.utils.toBN(txReceipt.gasUsed)); 31 | 32 | // Get updated balances 33 | const balances2 = await getBalances(); 34 | 35 | // Calculate values 36 | const mintAmount = web3.utils.toBN(_amount); 37 | 38 | // Check balances 39 | assert(balances2.tokenSupply.eq(balances1.tokenSupply.add(mintAmount)), "Incorrect updated token supply"); 40 | assert(balances2.userTokenBalance.eq(balances1.userTokenBalance.add(mintAmount)), "Incorrect updated user token balance"); 41 | } 42 | -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "entryPoints": [ 3 | "./src/rocketpool/rocketpool.ts", 4 | "./src/rocketpool/auction/auction.ts", 5 | "./src/rocketpool/contracts/contracts.ts", 6 | "./src/rocketpool/dao/proposals.ts", 7 | "./src/rocketpool/dao/node/trusted/actions.ts", 8 | "./src/rocketpool/dao/node/trusted/node.ts", 9 | "./src/rocketpool/dao/node/trusted/proposals.ts", 10 | "./src/rocketpool/dao/node/trusted/settings.ts", 11 | "./src/rocketpool/deposit/deposit.ts", 12 | "./src/rocketpool/minipool/minipool.ts", 13 | "./src/rocketpool/minipool/minipool-contract.ts", 14 | "./src/rocketpool/network/network.ts", 15 | "./src/rocketpool/node/node.ts", 16 | "./src/rocketpool/rewards/claim-dao.ts", 17 | "./src/rocketpool/rewards/claim-node.ts", 18 | "./src/rocketpool/rewards/claim-trusted-node.ts", 19 | "./src/rocketpool/rewards/pool.ts", 20 | "./src/rocketpool/settings/auction.ts", 21 | "./src/rocketpool/settings/deposit.ts", 22 | "./src/rocketpool/settings/minipool.ts", 23 | "./src/rocketpool/settings/network.ts", 24 | "./src/rocketpool/settings/node.ts", 25 | "./src/rocketpool/tokens/erc20.ts", 26 | "./src/rocketpool/tokens/legacyrpl.ts", 27 | "./src/rocketpool/tokens/reth.ts", 28 | "./src/rocketpool/tokens/rpl.ts", 29 | "./src/rocketpool/vault/vault.ts" 30 | ], 31 | "out": "docs", 32 | "readme": false, 33 | "githubPages": false, 34 | "hideGenerator": true, 35 | "hideLegend": true, 36 | "categorizeByGroup": true, 37 | "name": "Rocket Pool Javascript API", 38 | "hideInPageTOC": true, 39 | "hideBreadcrumbs": true, 40 | "excludeExternals": true, 41 | "mergeModulesMergeMode": "project", 42 | "filenameSeparator": "/", 43 | "sort": "source-order" 44 | } 45 | -------------------------------------------------------------------------------- /dist/rocketpool/vault/vault.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import Contracts from "../contracts/contracts"; 3 | /** 4 | * Rocket Pool Vault 5 | */ 6 | declare class Vault { 7 | private web3; 8 | private contracts; 9 | /** 10 | * Create a new Vault instance. 11 | * 12 | * @param web3 A valid Web3 instance 13 | * @param contracts A Rocket Pool contract manager instance 14 | */ 15 | constructor(web3: Web3, contracts: Contracts); 16 | /** 17 | * Private accessor use to retrieve the related contract 18 | * @returns a Promise with a web3.eth.contract instance of the rocketVault contract 19 | */ 20 | private get rocketVault(); 21 | /** 22 | * Retrieve the RocketVault contract address 23 | * @returns a Promise that resolves to the Rocket Vault contract address 24 | * 25 | * @example using Typescript 26 | * ```ts 27 | * const rocketVault = rp.vault.getAddress().then((val: string) => { val }; 28 | * ``` 29 | */ 30 | getAddress(): Promise; 31 | /** 32 | * Retrieve the balance of a token when providing a contract & token address 33 | * @param contractAddress A string representing the contract address 34 | * @param tokenAddress A string representing the token address 35 | * @returns a Promise that resolves to the Rocket Vault contract address 36 | * 37 | * @example using Typescript 38 | * ```ts 39 | * const rplBalance = rp.vault.balanceOfToken("rocketClaimDAO", rocketTokenRPLAddress).then((val: string) => { val } 40 | * ``` 41 | */ 42 | balanceOfToken(contractAddress: string, tokenAddress: string): Promise; 43 | } 44 | export default Vault; 45 | -------------------------------------------------------------------------------- /dist/rocketpool/tokens/reth.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"reth.js","sourceRoot":"","sources":["../../../src/rocketpool/tokens/reth.ts"],"names":[],"mappings":";;;;;AAKA,yDAAmF;AACnF,oDAA4B;AAE5B;;GAEG;AACH,MAAM,IAAK,SAAQ,eAAK;IACvB;;;;;OAKG;IACH,YAAmB,IAAU,EAAE,SAAoB;QAClD,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;OAUG;IACI,WAAW,CAAC,aAAqB;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAAmB,EAAE;YAC3E,OAAO,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACI,YAAY,CAAC,YAAoB;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAAmB,EAAE;YAC3E,OAAO,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,eAAe;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAAmB,EAAE;YAC3E,OAAO,aAAa,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,CAAC;QACvD,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,kBAAkB;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAAmB,EAAE;YAC3E,OAAO,aAAa,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,IAAI,EAAE,CAAC;QAC1D,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,iBAAiB;QACvB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAAmB,EAAE;YAC3E,OAAO,aAAa,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC;QACzD,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,cAAc;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAAmB,EAAE;YAC3E,OAAO,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;QACnD,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,IAAI,CAAC,SAAiB,EAAE,OAAqB,EAAE,cAAoC;QACzF,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAA+B,EAAE;YACvF,OAAO,IAAA,iCAAmB,EAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QACjG,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,IAAI,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/contracts/contracts.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { Contract } from "web3-eth-contract"; 3 | import { AbiItem } from "web3-utils"; 4 | import { ContractArtifact } from "../../utils/contract"; 5 | /** 6 | * Rocket Pool Contract Manager 7 | */ 8 | declare class Contracts { 9 | private web3; 10 | private RocketStorage; 11 | readonly rocketStorage: Promise; 12 | private addresses; 13 | private abis; 14 | private contracts; 15 | /** 16 | * Create a new Contract instance. 17 | * 18 | * @param web3 A valid Web3 instance 19 | * @param RocketStorage a RocketStorage address as a string or ContractArtifact (JSON ABI file) 20 | */ 21 | constructor(web3: Web3, RocketStorage: ContractArtifact | string); 22 | address(name: string): Promise; 23 | address(names: string[]): Promise; 24 | abi(name: string): Promise; 25 | abi(names: string[]): Promise; 26 | get(name: string): Promise; 27 | get(names: string[]): Promise; 28 | /** 29 | * Create a new contract instance with the specified ABI name and address 30 | * @param name A string representing the name of the contract 31 | * @param address A string representing the address of the specific instance 32 | * @returns a Promise that resolves to a web3.eth.contract instance of the contract 33 | * 34 | * @example using Typescript 35 | * ```ts 36 | * const minipool = await rp.contracts.make("rocketMinipoolDelegate", "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"); 37 | * ``` 38 | */ 39 | make(name: string, address: string): Promise; 40 | } 41 | export default Contracts; 42 | -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-dao.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10 | 11 | /** 12 | * Rocket Pool Rewards 13 | */ 14 | var Rewards = function () { 15 | /** 16 | * Create a new Rewards instance. 17 | * 18 | * @param web3 A valid Web3 instance 19 | * @param contracts A Rocket Pool contract manager instance 20 | */ 21 | function Rewards(web3, contracts) { 22 | _classCallCheck(this, Rewards); 23 | 24 | this.web3 = web3; 25 | this.contracts = contracts; 26 | } 27 | /** 28 | * Private accessor use to retrieve the related contract 29 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimDAO contract 30 | */ 31 | 32 | 33 | _createClass(Rewards, [{ 34 | key: "rocketClaimDAO", 35 | get: function get() { 36 | return this.contracts.get("rocketClaimDAO"); 37 | } 38 | }]); 39 | 40 | return Rewards; 41 | }(); 42 | // Exports 43 | 44 | 45 | exports.default = Rewards; 46 | //# sourceMappingURL=claim-dao.js.map -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rocketpool/api", 3 | "version": "0.0.15", 4 | "description": "A javascript library for interacting with the Rocket Pool network", 5 | "main": "dist/rocketpool/rocketpool.js", 6 | "license": "MIT", 7 | "scripts": { 8 | "build": "tsc && npx babel build -d dist && rm -rf build", 9 | "test": "mocha --require ts-node/register --timeout 30000 src/test/index.ts", 10 | "format": "prettier --write .", 11 | "docs": "typedoc --options typedoc.json --tsconfig tsconfig.json" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/rocket-pool/rocketpool-js.git" 16 | }, 17 | "author": "Rocket Pool", 18 | "bugs": { 19 | "url": "https://github.com/rocket-pool/rocketpool-js/issues" 20 | }, 21 | "homepage": "https://github.com/rocket-pool/rocketpool-js#readme", 22 | "dependencies": { 23 | "@types/node": "^14.14.37", 24 | "pako": "^1.0.11", 25 | "web3": "^1.3.6" 26 | }, 27 | "devDependencies": { 28 | "@babel/runtime": "^7.10.4", 29 | "@chainsafe/lodestar-types": "^0.9.0", 30 | "@chainsafe/ssz": "^0.6.7", 31 | "@types/chai": "^4.2.11", 32 | "@types/mocha": "^5.2.7", 33 | "@types/pako": "^1.0.1", 34 | "@typescript-eslint/eslint-plugin": "^4.29.2", 35 | "@typescript-eslint/parser": "^4.29.2", 36 | "babel-cli": "^6.18.0", 37 | "babel-preset-env": "^1.7.0", 38 | "bn.js": "^4.11.8", 39 | "chai": "^4.2.0", 40 | "eslint": "^7.32.0", 41 | "eslint-config-prettier": "^8.3.0", 42 | "prettier": "^2.3.2", 43 | "ts-node": "^8.10.2", 44 | "typedoc": "^0.22.5", 45 | "typedoc-plugin-markdown": "^3.11.3", 46 | "typedoc-plugin-merge-modules": "^3.0.2", 47 | "typedoc-plugin-missing-exports": "^0.22.3", 48 | "typedoc-plugin-rename-defaults": "^0.4.0", 49 | "typescript": "^4.4.3" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /dist/rocketpool/tokens/erc20.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../../src/rocketpool/tokens/erc20.ts"],"names":[],"mappings":";;AAKA,yDAAmF;AAEnF;;GAEG;AACH,MAAe,KAAK;IACnB;;;;;;OAMG;IACH,YAA6B,IAAU,EAAY,SAAoB,EAAY,iBAAyB;QAA/E,SAAI,GAAJ,IAAI,CAAM;QAAY,cAAS,GAAT,SAAS,CAAW;QAAY,sBAAiB,GAAjB,iBAAiB,CAAQ;IAAG,CAAC;IAEhH;;;OAGG;IACH,IAAc,aAAa;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;;;;OAUG;IACI,SAAS,CAAC,OAAe;QAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,aAAuB,EAAmB,EAAE;YAC3E,OAAO,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QACxD,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,SAAS,CAAC,OAAe,EAAE,OAAe;QAChD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AC,EAAE,cAAc,CAAC,CAAC;QACnH,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,KAAK,CAAC"} -------------------------------------------------------------------------------- /src/test/node/scenario-set-withdrawal-address.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Set a node's withdrawal address 8 | export async function setWithdrawalAddress(web3: Web3, rp: RocketPool, nodeAddress: string, withdrawalAddress: string, confirm: boolean, options: SendOptions) { 9 | // Set withdrawal address 10 | await rp.node.setWithdrawalAddress(nodeAddress, withdrawalAddress, confirm, options); 11 | 12 | // Get withdrawal address 13 | const nodeWithdrawalAddress = await rp.node.getNodeWithdrawalAddress(nodeAddress); 14 | const nodePendingWithdrawalAddress = await rp.node.getNodePendingWithdrawalAddress(nodeAddress); 15 | 16 | // Check 17 | if (confirm) { 18 | assert.equal(nodeWithdrawalAddress, withdrawalAddress, "Incorrect updated withdrawal address"); 19 | } else { 20 | assert.equal(nodePendingWithdrawalAddress, withdrawalAddress, "Incorrect updated pending withdrawal address"); 21 | } 22 | } 23 | 24 | export async function confirmWithdrawalAddress(web3: Web3, rp: RocketPool, nodeAddress: string, options: SendOptions) { 25 | // Confirm withdrawal address 26 | await rp.node.confirmWithdrawalAddress(nodeAddress, options); 27 | 28 | // Get current & pending withdrawal addresses 29 | const nodeWithdrawalAddress = await rp.node.getNodeWithdrawalAddress(nodeAddress); 30 | const nodePendingWithdrawalAddress = await rp.node.getNodePendingWithdrawalAddress(nodeAddress); 31 | 32 | // Check 33 | assert.equal(nodeWithdrawalAddress, web3.utils.toChecksumAddress(options.from), "Incorrect updated withdrawal address"); 34 | assert.equal(nodePendingWithdrawalAddress, "0x0000000000000000000000000000000000000000", "Incorrect pending withdrawal address"); 35 | } 36 | -------------------------------------------------------------------------------- /src/test/deposit/scenario-deposit.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Make a deposit 8 | export async function deposit(web3: Web3, rp: RocketPool, options: SendOptions) { 9 | // Load contracts 10 | const rocketVault = await rp.contracts.get("rocketVault"); 11 | 12 | // Get parameters 13 | const rethExchangeRate = await rp.tokens.reth.getExchangeRate().then((value: any) => web3.utils.toBN(value)); 14 | 15 | // Get balances 16 | function getBalances() { 17 | return Promise.all([ 18 | rp.deposit.getBalance().then((value: any) => web3.utils.toBN(value)), 19 | web3.eth.getBalance(rocketVault.options.address).then((value: any) => web3.utils.toBN(value)), 20 | rp.tokens.reth.balanceOf(options.from).then((value: any) => web3.utils.toBN(value)), 21 | ]).then(([depositPoolEth, vaultEth, userReth]) => ({ 22 | depositPoolEth, 23 | vaultEth, 24 | userReth, 25 | })); 26 | } 27 | 28 | // Get initial balances 29 | const balances1 = await getBalances(); 30 | 31 | // Deposit 32 | await rp.deposit.deposit(options); 33 | 34 | // Get updated balances 35 | const balances2 = await getBalances(); 36 | 37 | // Calculate values 38 | const txValue = web3.utils.toBN(options.value as string); 39 | const calcBase = web3.utils.toBN(web3.utils.toWei("1", "ether")); 40 | const expectedRethMinted = txValue.mul(calcBase).div(rethExchangeRate); 41 | 42 | // Check balances 43 | assert(balances2.depositPoolEth.eq(balances1.depositPoolEth.add(txValue)), "Incorrect updated deposit pool ETH balance"); 44 | assert(balances2.vaultEth.eq(balances1.vaultEth.add(txValue)), "Incorrect updated vault ETH balance"); 45 | assert(balances2.userReth.eq(balances1.userReth.add(expectedRethMinted)), "Incorrect updated user rETH balance"); 46 | } 47 | -------------------------------------------------------------------------------- /src/test/_utils/contract.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { EventLog, TransactionReceipt } from "web3-core"; 4 | import { AbiInput, AbiItem } from "web3-utils"; 5 | const pako = require("pako"); 6 | 7 | // Get arbitrary contract events from a transaction result 8 | // txReceipt is the receipt returned from the transaction call 9 | // contractAddress is the address of the contract to retrieve events for 10 | // eventName is the name of the event to retrieve 11 | // eventParams is an array of objects with string 'type' and 'name' keys and an optional boolean 'indexed' key 12 | export function getTxContractEvents(web3: Web3, txReceipt: TransactionReceipt, contractAddress: string, eventName: string, eventParams: AbiInput[]): any { 13 | const events = []; 14 | if (txReceipt.events) for (const p in txReceipt.events) events.push(txReceipt.events[p]); 15 | return events 16 | .filter((log: EventLog) => log.address.toLowerCase() == contractAddress.toLowerCase()) 17 | .filter((log: EventLog) => log.raw!.topics[0] == web3.utils.soliditySha3(eventName + "(" + eventParams.map((param) => param.type).join(",") + ")")) 18 | .map((log: EventLog) => 19 | web3.eth.abi.decodeLog( 20 | eventParams.map((param) => { 21 | const decodeParam = Object.assign({}, param); 22 | if (decodeParam.indexed && (decodeParam.type == "string" || decodeParam.type == "bytes")) decodeParam.type = "bytes32"; // Issues decoding indexed string and bytes parameters 23 | return decodeParam; 24 | }), 25 | log.raw!.data, 26 | log.raw!.topics.slice(1) 27 | ) 28 | ); 29 | } 30 | 31 | // Compress / decompress contract ABIs 32 | export function compressABI(abi: AbiItem[]) { 33 | return Buffer.from(pako.deflate(JSON.stringify(abi))).toString("base64"); 34 | } 35 | 36 | export function decompressABI(abi: string) { 37 | return JSON.parse(pako.inflate(Buffer.from(abi, "base64"), { to: "string" })); 38 | } 39 | -------------------------------------------------------------------------------- /src/test/_helpers/network.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import RocketPool from "../../rocketpool/rocketpool"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | 6 | // Get the network total ETH balance 7 | export async function getTotalETHBalance(web3: Web3, rp: RocketPool) { 8 | await rp.network.getTotalETHBalance(); 9 | } 10 | 11 | // Get the network staking ETH balance 12 | export async function getStakingETHBalance(web3: Web3, rp: RocketPool) { 13 | await rp.network.getStakingETHBalance(); 14 | } 15 | 16 | // Get the network ETH utilization rate 17 | export async function getETHUtilizationRate(web3: Web3, rp: RocketPool) { 18 | await rp.network.getETHUtilizationRate(); 19 | } 20 | 21 | // Submit network balances 22 | export async function submitBalances( 23 | web3: Web3, 24 | rp: RocketPool, 25 | block: number, 26 | totalEth: string, 27 | stakingEth: string, 28 | rethSupply: string, 29 | options: SendOptions 30 | ) { 31 | await rp.network.submitBalances(block, totalEth, stakingEth, rethSupply, options); 32 | } 33 | 34 | // Submit network token prices 35 | export async function submitPrices(web3: Web3, rp: RocketPool, block: number, rplPrice: string, effectiveRplStake: string, options: SendOptions) { 36 | await rp.network.submitPrices(block, rplPrice, effectiveRplStake, options); 37 | } 38 | 39 | // Get network RPL price 40 | export async function getRPLPrice(web3: Web3, rp: RocketPool) { 41 | return await rp.network.getRPLPrice(); 42 | } 43 | 44 | // Get the network node demand 45 | export async function getNodeDemand(web3: Web3, rp: RocketPool) { 46 | await rp.network.getNodeDemand(); 47 | } 48 | 49 | // Get the current network node fee 50 | export async function getNodeFee(web3: Web3, rp: RocketPool) { 51 | return await rp.network.getNodeFee(); 52 | } 53 | 54 | // Get the network node fee for a node demand value 55 | export async function getNodeFeeByDemand(web3: Web3, rp: RocketPool, nodeDemand: string) { 56 | return await rp.network.getNodeFeeByDemand(nodeDemand); 57 | } 58 | -------------------------------------------------------------------------------- /src/test/_helpers/tokens.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { SendOptions } from "web3-eth-contract"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | 6 | // Get the RPL balance of an address 7 | export async function getRplBalance(web3: Web3, rp: RocketPool, address: string) { 8 | return await rp.tokens.rpl.balanceOf(address); 9 | } 10 | 11 | // Get the rETH balance of an address 12 | export async function getRethBalance(web3: Web3, rp: RocketPool, address: string) { 13 | return await rp.tokens.reth.balanceOf(address); 14 | } 15 | 16 | // Get the current rETH exchange rate 17 | export async function getRethExchangeRate(web3: Web3, rp: RocketPool) { 18 | return rp.tokens.reth.getExchangeRate(); 19 | } 20 | 21 | // Get the current rETH token supply 22 | export async function getRethTotalSupply(web3: Web3, rp: RocketPool) { 23 | return await rp.tokens.reth.getTotalSupply(); 24 | } 25 | 26 | // Mint RPL to an address 27 | export async function mintRPL(web3: Web3, rp: RocketPool, owner: string, toAddress: string, amount: string) { 28 | const rocketTokenRPL = await rp.contracts.get("rocketTokenRPL"); 29 | const rocketTokenDummyRPL = await rp.contracts.get("rocketTokenRPLFixedSupply"); 30 | 31 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")).toString(); 32 | const gas = 10000000; 33 | 34 | // Mint dummy RPL to address 35 | await rocketTokenDummyRPL.methods.mint(toAddress, amount).send({ from: owner, gasPrice: gasPrice, gas: gas }); 36 | 37 | // Swap dummy RPL for RPL 38 | await rocketTokenDummyRPL.methods.approve(rocketTokenRPL.options.address, amount).send({ from: toAddress, gasPrice: gasPrice, gas: gas }); 39 | await rocketTokenRPL.methods.swapTokens(amount).send({ from: toAddress, gasPrice: gasPrice, gas: gas }); 40 | } 41 | 42 | // Approve RPL to be spend by an address 43 | export async function approveRPL(web3: Web3, rp: RocketPool, spender: string, amount: string, options: SendOptions) { 44 | await rp.tokens.rpl.approve(spender, amount, options); 45 | } 46 | -------------------------------------------------------------------------------- /src/test/settings/settings-tests.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import RocketPool from "../../rocketpool/rocketpool"; 4 | import { printTitle } from "../_utils/formatting"; 5 | 6 | // Tests 7 | export default function runSettingsTests(web3: Web3, rp: RocketPool) { 8 | describe("Settings", () => { 9 | describe("Deposit", () => { 10 | it(printTitle("User", "Can get deposit settings"), async () => { 11 | const settings = await Promise.all([ 12 | rp.settings.deposit.getDepositEnabled(), 13 | rp.settings.deposit.getAssignDepositsEnabled(), 14 | rp.settings.deposit.getMinimumDeposit(), 15 | rp.settings.deposit.getMaximumDepositPoolSize(), 16 | rp.settings.deposit.getMaximumDepositAssignments(), 17 | ]); 18 | }); 19 | }); 20 | 21 | describe("Minipool", () => { 22 | it(printTitle("User", "Can get minipool settings"), async () => { 23 | const settings = await Promise.all([ 24 | rp.settings.minipool.getLaunchBalance(), 25 | rp.settings.minipool.getSubmitWithdrawableEnabled(), 26 | rp.settings.minipool.getLaunchTimeout(), 27 | ]); 28 | }); 29 | }); 30 | 31 | describe("Network", () => { 32 | it(printTitle("User", "Can get network settings"), async () => { 33 | const settings = await Promise.all([ 34 | rp.settings.network.getNodeConsensusThreshold(), 35 | rp.settings.network.getSubmitBalancesEnabled(), 36 | rp.settings.network.getSubmitBalancesFrequency(), 37 | rp.settings.network.getMinimumNodeFee(), 38 | rp.settings.network.getTargetNodeFee(), 39 | rp.settings.network.getMaximumNodeFee(), 40 | rp.settings.network.getNodeFeeDemandRange(), 41 | rp.settings.network.getTargetRethCollateralRate(), 42 | ]); 43 | }); 44 | }); 45 | 46 | describe("Node", () => { 47 | it(printTitle("User", "Can get node settings"), async () => { 48 | const settings = await Promise.all([rp.settings.node.getRegistrationEnabled(), rp.settings.node.getDepositEnabled()]); 49 | }); 50 | }); 51 | }); 52 | } 53 | -------------------------------------------------------------------------------- /dist/test/_utils/contract.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.getTxContractEvents = getTxContractEvents; 7 | exports.compressABI = compressABI; 8 | exports.decompressABI = decompressABI; 9 | var pako = require("pako"); 10 | // Get arbitrary contract events from a transaction result 11 | // txReceipt is the receipt returned from the transaction call 12 | // contractAddress is the address of the contract to retrieve events for 13 | // eventName is the name of the event to retrieve 14 | // eventParams is an array of objects with string 'type' and 'name' keys and an optional boolean 'indexed' key 15 | function getTxContractEvents(web3, txReceipt, contractAddress, eventName, eventParams) { 16 | var events = []; 17 | if (txReceipt.events) for (var p in txReceipt.events) { 18 | events.push(txReceipt.events[p]); 19 | }return events.filter(function (log) { 20 | return log.address.toLowerCase() == contractAddress.toLowerCase(); 21 | }).filter(function (log) { 22 | return log.raw.topics[0] == web3.utils.soliditySha3(eventName + "(" + eventParams.map(function (param) { 23 | return param.type; 24 | }).join(",") + ")"); 25 | }).map(function (log) { 26 | return web3.eth.abi.decodeLog(eventParams.map(function (param) { 27 | var decodeParam = Object.assign({}, param); 28 | if (decodeParam.indexed && (decodeParam.type == "string" || decodeParam.type == "bytes")) decodeParam.type = "bytes32"; // Issues decoding indexed string and bytes parameters 29 | return decodeParam; 30 | }), log.raw.data, log.raw.topics.slice(1)); 31 | }); 32 | } 33 | // Compress / decompress contract ABIs 34 | function compressABI(abi) { 35 | return Buffer.from(pako.deflate(JSON.stringify(abi))).toString("base64"); 36 | } 37 | function decompressABI(abi) { 38 | return JSON.parse(pako.inflate(Buffer.from(abi, "base64"), { to: "string" })); 39 | } 40 | //# sourceMappingURL=contract.js.map -------------------------------------------------------------------------------- /dist/rocketpool/dao/proposals.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"proposals.js","sourceRoot":"","sources":["../../../src/rocketpool/dao/proposals.ts"],"names":[],"mappings":";;AAOA;;GAEG;AACH,MAAM,WAAW;IAChB;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,iBAAiB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;;;OAQG;IACI,QAAQ;QACd,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAA2B,EAAmB,EAAE;YACnF,OAAO,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QACpD,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACI,QAAQ,CAAC,UAAkB;QACjC,OAAO,IAAI,CAAC,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O,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAA2B,EAAmB,EAAE;YACnF,OAAO,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QACrE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACI,UAAU,CAAC,UAAkB;QACnC,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAA2B,EAAmB,EAAE;YACnF,OAAO,iBAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,WAAW,CAAC"} -------------------------------------------------------------------------------- /src/test/auction/scenario-recover-rpl.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | import { SendOptions } from "web3-eth-contract"; 6 | 7 | // Recover unclaimed RPL from a lot 8 | export async function recoverUnclaimedRPL(web3: Web3, rp: RocketPool, lotIndex: number, options: SendOptions) { 9 | // Get auction contract details 10 | function getContractDetails() { 11 | return Promise.all([ 12 | rp.auction.getAllottedRPLBalance().then((value: any) => web3.utils.toBN(value)), 13 | rp.auction.getRemainingRPLBalance().then((value: any) => web3.utils.toBN(value)), 14 | ]).then(([allottedRplBalance, remainingRplBalance]) => ({ 15 | allottedRplBalance, 16 | remainingRplBalance, 17 | })); 18 | } 19 | 20 | // Get lot details 21 | function getLotDetails() { 22 | return Promise.all([ 23 | rp.auction.getLotRPLRecovered(lotIndex), 24 | rp.auction.getLotRemainingRPLAmount(lotIndex).then((value: any) => web3.utils.toBN(value)), 25 | ]).then(([rplRecovered, remainingRplAmount]) => ({ 26 | rplRecovered, 27 | remainingRplAmount, 28 | })); 29 | } 30 | 31 | // Get initial details 32 | const [details1, lot1] = await Promise.all([getContractDetails(), getLotDetails()]); 33 | 34 | // Set gas price 35 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 36 | options.gasPrice = gasPrice.toString(); 37 | 38 | // Recover RPL 39 | await rp.auction.recoverUnclaimedRPL(lotIndex, options); 40 | 41 | // Get updated details 42 | const [details2, lot2] = await Promise.all([getContractDetails(), getLotDetails()]); 43 | 44 | // Check details 45 | assert(details2.allottedRplBalance.eq(details1.allottedRplBalance.sub(lot1.remainingRplAmount)), "Incorrect updated contract allotted RPL balance"); 46 | assert(details2.remainingRplBalance.eq(details1.remainingRplBalance.add(lot1.remainingRplAmount)), "Incorrect updated contract remaining RPL balance"); 47 | assert.isTrue(lot2.rplRecovered, "Incorrect updated lot RPL recovered status"); 48 | } 49 | -------------------------------------------------------------------------------- /src/test/dao/scenario-dao-proposal.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import RocketPool from "../../rocketpool/rocketpool"; 4 | 5 | // Possible states that a proposal may be in 6 | export const proposalStates = { 7 | Pending: 0, 8 | Active: 1, 9 | Cancelled: 2, 10 | Defeated: 3, 11 | Succeeded: 4, 12 | Expired: 5, 13 | Executed: 6, 14 | }; 15 | 16 | // Get the status of a proposal 17 | export async function getDAOProposalState(web3: Web3, rp: RocketPool, proposalID: number) { 18 | return await rp.dao.proposals.getState(proposalID); 19 | } 20 | 21 | // Get the block a proposal can start being voted on 22 | export async function getDAOProposalStartBlock(web3: Web3, rp: RocketPool, proposalID: number) { 23 | return await rp.dao.proposals.getStart(proposalID); 24 | } 25 | 26 | // Get the block a proposal can end being voted on 27 | export async function getDAOProposalEndBlock(web3: Web3, rp: RocketPool, proposalID: number) { 28 | return await rp.dao.proposals.getEnd(proposalID); 29 | } 30 | 31 | // Get the block a proposal can start being voted on 32 | export async function getDAOProposalStartTime(web3: Web3, rp: RocketPool, proposalID: number) { 33 | return await rp.dao.proposals.getStart(proposalID); 34 | } 35 | 36 | // Get the block a proposal can end being voted on 37 | export async function getDAOProposalEndTime(web3: Web3, rp: RocketPool, proposalID: number) { 38 | return await rp.dao.proposals.getEnd(proposalID); 39 | } 40 | 41 | // Get the block a proposal expires 42 | export async function getDAOProposalExpires(web3: Web3, rp: RocketPool, proposalID: number) { 43 | return await rp.dao.proposals.getExpires(proposalID); 44 | } 45 | 46 | // Get the vote count for a proposal 47 | export async function getDAOProposalVotesFor(web3: Web3, rp: RocketPool, proposalID: number) { 48 | return await rp.dao.proposals.getVotesFor(proposalID); 49 | } 50 | 51 | // Get the vote count against a proposal 52 | export async function getDAOProposalVotesAgainst(web3: Web3, rp: RocketPool, proposalID: number) { 53 | return await rp.dao.proposals.getVotesAgainst(proposalID); 54 | } 55 | -------------------------------------------------------------------------------- /src/test/tokens/scenario-burn-reth.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Burn rETH for ETH 8 | export async function burnReth(web3: Web3, rp: RocketPool, amount: string, options: SendOptions) { 9 | // Get parameters 10 | const rethExchangeRate = await rp.tokens.reth.getExchangeRate().then((value) => web3.utils.toBN(value)); 11 | 12 | // Get balances 13 | function getBalances() { 14 | return Promise.all([ 15 | rp.tokens.reth.getTotalSupply().then((value) => web3.utils.toBN(value)), 16 | rp.tokens.reth.balanceOf(options.from).then((value) => web3.utils.toBN(value)), 17 | web3.eth.getBalance(options.from).then((value) => web3.utils.toBN(value)), 18 | ]).then(([tokenSupply, userTokenBalance, userEthBalance]) => ({ 19 | tokenSupply, 20 | userTokenBalance, 21 | userEthBalance, 22 | })); 23 | } 24 | 25 | // Get initial balances 26 | const balances1 = await getBalances(); 27 | 28 | // Set gas price 29 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 30 | options.gasPrice = gasPrice.toString(); 31 | 32 | // Burn tokens & get tx fee 33 | const txReceipt = await rp.tokens.reth.burn(amount, options); 34 | const txFee = gasPrice.mul(web3.utils.toBN(txReceipt.gasUsed)); 35 | 36 | // Get updated balances 37 | const balances2 = await getBalances(); 38 | 39 | // Calculate values 40 | const burnAmount = web3.utils.toBN(amount); 41 | const calcBase = web3.utils.toBN(web3.utils.toWei("1", "ether")); 42 | const expectedEthTransferred = burnAmount.mul(rethExchangeRate).div(calcBase); 43 | 44 | // Check balances 45 | assert(balances2.tokenSupply.eq(balances1.tokenSupply.sub(burnAmount)), "Incorrect updated token supply"); 46 | assert(balances2.userTokenBalance.eq(balances1.userTokenBalance.sub(burnAmount)), "Incorrect updated user token balance"); 47 | assert(balances2.userEthBalance.eq(balances1.userEthBalance.add(expectedEthTransferred).sub(txFee)), "Incorrect updated user ETH balance"); 48 | } 49 | -------------------------------------------------------------------------------- /src/rocketpool/vault/vault.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { Contract } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | 6 | /** 7 | * Rocket Pool Vault 8 | */ 9 | class Vault { 10 | /** 11 | * Create a new Vault instance. 12 | * 13 | * @param web3 A valid Web3 instance 14 | * @param contracts A Rocket Pool contract manager instance 15 | */ 16 | public constructor(private web3: Web3, private contracts: Contracts) {} 17 | 18 | /** 19 | * Private accessor use to retrieve the related contract 20 | * @returns a Promise with a web3.eth.contract instance of the rocketVault contract 21 | */ 22 | private get rocketVault(): Promise { 23 | return this.contracts.get("rocketVault"); 24 | } 25 | 26 | /** 27 | * Retrieve the RocketVault contract address 28 | * @returns a Promise that resolves to the Rocket Vault contract address 29 | * 30 | * @example using Typescript 31 | * ```ts 32 | * const rocketVault = rp.vault.getAddress().then((val: string) => { val }; 33 | * ``` 34 | */ 35 | public getAddress(): Promise { 36 | return this.rocketVault.then((rocketVault: Contract): string => { 37 | return rocketVault.options.address; 38 | }); 39 | } 40 | 41 | /** 42 | * Retrieve the balance of a token when providing a contract & token address 43 | * @param contractAddress A string representing the contract address 44 | * @param tokenAddress A string representing the token address 45 | * @returns a Promise that resolves to the Rocket Vault contract address 46 | * 47 | * @example using Typescript 48 | * ```ts 49 | * const rplBalance = rp.vault.balanceOfToken("rocketClaimDAO", rocketTokenRPLAddress).then((val: string) => { val } 50 | * ``` 51 | */ 52 | public balanceOfToken(contractAddress: string, tokenAddress: string): Promise { 53 | return this.rocketVault.then((rocketVault: Contract): Promise => { 54 | return rocketVault.methods.balanceOfToken(contractAddress, tokenAddress).call(); 55 | }); 56 | } 57 | } 58 | 59 | // Exports 60 | export default Vault; 61 | -------------------------------------------------------------------------------- /src/rocketpool/settings/node.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { Contract } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | 6 | /** 7 | * Rocket Pool Node Settings Manager 8 | */ 9 | class NodeSettings { 10 | /** 11 | * Create a new Node Settings instance. 12 | * 13 | * @param web3 A valid Web3 instance 14 | * @param contracts A Rocket Pool contract manager instance 15 | */ 16 | public constructor(private web3: Web3, private contracts: Contracts) {} 17 | 18 | /** 19 | * Private accessor use to retrieve the related contract 20 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsNode contract 21 | */ 22 | private get rocketDAOProtocolSettingsNode(): Promise { 23 | return this.contracts.get("rocketDAOProtocolSettingsNode"); 24 | } 25 | 26 | /** 27 | * Return if node registrations are currently enabled 28 | * @returns a Promise that resolves to a boolean representing if node registrations are enabled 29 | * 30 | * @example using Typescript 31 | * ```ts 32 | * const enabled = rp.settings.node.getRegistrationEnabled().then((val: boolean) => { val }; 33 | * ``` 34 | */ 35 | public getRegistrationEnabled(): Promise { 36 | return this.rocketDAOProtocolSettingsNode.then((rocketDAOProtocolSettingsNode: Contract): Promise => { 37 | return rocketDAOProtocolSettingsNode.methods.getRegistrationEnabled().call(); 38 | }); 39 | } 40 | 41 | /** 42 | * Return if node deposits are currently enabled 43 | * @returns a Promise that resolves to a boolean representing if node deposits are enabled 44 | * 45 | * @example using Typescript 46 | * ```ts 47 | * const enabled = rp.settings.node.getDepositEnabled().then((val: boolean) => { val }; 48 | * ``` 49 | */ 50 | public getDepositEnabled(): Promise { 51 | return this.rocketDAOProtocolSettingsNode.then((rocketDAOProtocolSettingsNode: Contract): Promise => { 52 | return rocketDAOProtocolSettingsNode.methods.getDepositEnabled().call(); 53 | }); 54 | } 55 | } 56 | 57 | // Exports 58 | export default NodeSettings; 59 | -------------------------------------------------------------------------------- /src/test/minipool/scenario-refund.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | import MinipoolContract from "../../rocketpool/minipool/minipool-contract"; 7 | 8 | // Refund a minipool 9 | export async function refund(web3: Web3, rp: RocketPool, minipool: MinipoolContract, options: SendOptions) { 10 | // Get parameters 11 | const nodeAddress = await minipool.getNodeAddress(); 12 | const nodeWithdrawalAddress = await rp.node.getNodeWithdrawalAddress(nodeAddress); 13 | 14 | // Get balances 15 | function getBalances() { 16 | return Promise.all([ 17 | minipool.getNodeRefundBalance().then((value: any) => web3.utils.toBN(value)), 18 | web3.eth.getBalance(minipool.address).then((value: any) => web3.utils.toBN(value)), 19 | web3.eth.getBalance(nodeWithdrawalAddress).then((value: any) => web3.utils.toBN(value)), 20 | ]).then(([nodeRefund, minipoolEth, nodeEth]) => ({ 21 | nodeRefund, 22 | minipoolEth, 23 | nodeEth, 24 | })); 25 | } 26 | 27 | // Get initial balances 28 | const balances1 = await getBalances(); 29 | 30 | // Set gas price 31 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 32 | options.gasPrice = gasPrice.toString(); 33 | 34 | // Refund & get tx fee 35 | const txReceipt = await minipool.refund(options); 36 | const txFee = gasPrice.mul(web3.utils.toBN(txReceipt.gasUsed)); 37 | 38 | // Get updated balances 39 | const balances2 = await getBalances(); 40 | 41 | // Check balances 42 | const zero = web3.utils.toBN(0); 43 | let expectedNodeBalance = balances1.nodeEth.add(balances1.nodeRefund); 44 | if (nodeWithdrawalAddress == nodeAddress) expectedNodeBalance = expectedNodeBalance.sub(txFee); 45 | assert(balances1.nodeRefund.gt(zero), "Incorrect initial node refund balance"); 46 | assert(balances2.nodeRefund.eq(zero), "Incorrect updated node refund balance"); 47 | assert(balances2.minipoolEth.eq(balances1.minipoolEth.sub(balances1.nodeRefund)), "Incorrect updated minipool ETH balance"); 48 | assert(balances2.nodeEth.eq(expectedNodeBalance), "Incorrect updated node ETH balance"); 49 | } 50 | -------------------------------------------------------------------------------- /dist/rocketpool/rewards/pool.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"pool.js","sourceRoot":"","sources":["../../../src/rocketpool/rewards/pool.ts"],"names":[],"mappings":";;AAKA;;GAEG;AACH,MAAM,IAAI;IACT;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,iBAAiB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;;;OAQG;IACI,uBAAuB;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAA2B,EAAmB,EAAE;YACnF,OAAO,iBAAiB,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC,IAAI,EAAE,CAAC;QACnE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,yBAAyB;QAC/B,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAA2B,EAAmB,EAAE;YACnF,OAAO,iBAAiB,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,CAAC;QACrE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;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,eAAuB,EAAE,kBAA0B;QACxF,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAA2B,EAAmB,EAAE;YACnF,OAAO,iBAAiB,CAAC,OAAO,CAAC,8BAA8B,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7G,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACI,mCAAmC,CAAC,QAAgB;QAC1D,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAA2B,EAAmB,EAAE;YACnF,OAAO,iBAAiB,CAAC,OAAO,CAAC,mCAAmC,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACvF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,IAAI,CAAC"} -------------------------------------------------------------------------------- /src/test/minipool/scenario-close.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | import MinipoolContract from "../../rocketpool/minipool/minipool-contract"; 7 | 8 | // Close a minipool 9 | export async function close(web3: Web3, rp: RocketPool, minipool: MinipoolContract, options: SendOptions) { 10 | // Get parameters 11 | const nodeAddress = await minipool.getNodeAddress(); 12 | const nodeWithdrawalAddress = await rp.node.getNodeWithdrawalAddress(nodeAddress); 13 | 14 | // Get minipool balances 15 | function getMinipoolBalances() { 16 | return Promise.all([ 17 | minipool.getNodeDepositBalance().then((value: any) => web3.utils.toBN(value)), 18 | minipool.getNodeRefundBalance().then((value: any) => web3.utils.toBN(value)), 19 | ]).then(([nodeDeposit, nodeRefund]) => ({ nodeDeposit, nodeRefund })); 20 | } 21 | 22 | // Get initial node balance & minipool balances 23 | const [nodeBalance1, minipoolBalances] = await Promise.all([ 24 | web3.eth.getBalance(nodeWithdrawalAddress).then((value: any) => web3.utils.toBN(value)), 25 | getMinipoolBalances(), 26 | ]); 27 | 28 | // Set gas price 29 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 30 | options.gasPrice = gasPrice.toString(); 31 | 32 | // Close & get tx fee 33 | const txReceipt = await minipool.close(options); 34 | const txFee = gasPrice.mul(web3.utils.toBN(txReceipt.gasUsed)); 35 | 36 | // Get updated node balance & minipool contract code 37 | const [nodeBalance2, minipoolCode] = await Promise.all([ 38 | web3.eth.getBalance(nodeWithdrawalAddress).then((value: any) => web3.utils.toBN(value)), 39 | web3.eth.getCode(minipool.address), 40 | ]); 41 | 42 | // Check balances 43 | let expectedNodeBalance = nodeBalance1.add(minipoolBalances.nodeDeposit).add(minipoolBalances.nodeRefund); 44 | if (nodeWithdrawalAddress == nodeAddress) expectedNodeBalance = expectedNodeBalance.sub(txFee); 45 | assert(nodeBalance2.eq(expectedNodeBalance), "Incorrect updated node nETH balance"); 46 | 47 | // Check minipool contract code 48 | assert.equal(minipoolCode, "0x", "Minipool contract was not destroyed"); 49 | } 50 | -------------------------------------------------------------------------------- /dist/rocketpool/dao/protocol/settings.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10 | 11 | /** 12 | * Rocket Pool DAO Protocol Settings 13 | */ 14 | var DAOProtocolSettings = function () { 15 | // Constructor 16 | function DAOProtocolSettings(web3, contracts) { 17 | _classCallCheck(this, DAOProtocolSettings); 18 | 19 | this.web3 = web3; 20 | this.contracts = contracts; 21 | } 22 | // Contract accessors 23 | 24 | 25 | _createClass(DAOProtocolSettings, [{ 26 | key: "getRethDepositDelay", 27 | 28 | /** 29 | * Getters 30 | */ 31 | // Get member id given an address 32 | value: function getRethDepositDelay() { 33 | return this.rocketDAOProtocolSettingsNetwork.then(function (rocketDAOProtocolSettingsNetwork) { 34 | return rocketDAOProtocolSettingsNetwork.methods.getRethDepositDelay().call(); 35 | }); 36 | } 37 | }, { 38 | key: "rocketDAOProtocolSettings", 39 | get: function get() { 40 | return this.contracts.get("rocketDAOProtocolSettings"); 41 | } 42 | }, { 43 | key: "rocketDAOProtocolSettingsNetwork", 44 | get: function get() { 45 | return this.contracts.get("rocketDAOProtocolSettingsNetwork"); 46 | } 47 | }]); 48 | 49 | return DAOProtocolSettings; 50 | }(); 51 | // Exports 52 | 53 | 54 | exports.default = DAOProtocolSettings; 55 | //# sourceMappingURL=settings.js.map -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-node.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { TransactionReceipt } from "web3-core"; 3 | import { SendOptions } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | import { ConfirmationHandler } from "../../utils/transaction"; 6 | /** 7 | * Rocket Pool Rewards 8 | */ 9 | declare class Rewards { 10 | private web3; 11 | private contracts; 12 | /** 13 | * Create a new Rewards instance. 14 | * 15 | * @param web3 A valid Web3 instance 16 | * @param contracts A Rocket Pool contract manager instance 17 | */ 18 | constructor(web3: Web3, contracts: Contracts); 19 | /** 20 | * Private accessor use to retrieve the related contract 21 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimNode contract 22 | */ 23 | private get rocketClaimNode(); 24 | /** 25 | * Determine if the claim is possible 26 | * @params address a string representing the node address 27 | * @returns a Promise that resolves to a boolean representing if a claim is possible 28 | * 29 | * @example using Typescript 30 | * ```ts 31 | * const address = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 32 | * const claimPossible = rp.rewards.claimNode.getClaimPossible(address).then((val: bool) => { val }; 33 | * ``` 34 | */ 35 | getClaimPossible(address: string): Promise; 36 | /** 37 | * Make a node claim 38 | * @param options An optional object of web3.eth.Contract SendOptions 39 | * @param onConfirmation An optional confirmation handler object 40 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 41 | * 42 | * @example using Typescript 43 | * ```ts 44 | * const nodeAddress = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 45 | * const options = { 46 | * from: nodeAddress, 47 | * gas: 1000000 48 | * }; 49 | * const txReceipt = rp.rewards.claimNode(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 50 | * ``` 51 | */ 52 | claim(options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise; 53 | } 54 | export default Rewards; 55 | -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-trusted-node.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { TransactionReceipt } from "web3-core"; 3 | import { SendOptions } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | import { ConfirmationHandler } from "../../utils/transaction"; 6 | /** 7 | * Rocket Pool Rewards 8 | */ 9 | declare class Rewards { 10 | private web3; 11 | private contracts; 12 | /** 13 | * Create a new Rewards instance. 14 | * 15 | * @param web3 A valid Web3 instance 16 | * @param contracts A Rocket Pool contract manager instance 17 | */ 18 | constructor(web3: Web3, contracts: Contracts); 19 | /** 20 | * Private accessor use to retrieve the related contract 21 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimTrustedNode contract 22 | */ 23 | private get rocketClaimTrustedNode(); 24 | /** 25 | * Get claim rewards amount 26 | * @params address a string representing the node address 27 | * @returns a Promise that resolves to a string representing the claim rewards amount in Wei 28 | * 29 | * @example using Typescript 30 | * ```ts 31 | * const address = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 32 | * const claimPossible = rp.rewards.claimTrustedNode.getClaimRewardsAmount(address).then((val: string) => { val }; 33 | * ``` 34 | */ 35 | getClaimRewardsAmount(address: string): Promise; 36 | /** 37 | * Claim from a trusted node 38 | * @param options An optional object of web3.eth.Contract SendOptions 39 | * @param onConfirmation An optional confirmation handler object 40 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 41 | * 42 | * @example using Typescript 43 | * ```ts 44 | * const trustedNode = "0x421433c3f99529A704Ec2270E1A68fa66DD8bD79"; 45 | * const options = { 46 | * from: trustedNode, 47 | * gas: 1000000 48 | * }; 49 | * const txReceipt = rp.rewards.claimTrustedNode(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 50 | * ``` 51 | */ 52 | claim(options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise; 53 | } 54 | export default Rewards; 55 | -------------------------------------------------------------------------------- /dist/rocketpool/rocketpool.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"rocketpool.js","sourceRoot":"","sources":["../../src/rocketpool/rocketpool.ts"],"names":[],"mappings":";;;;;AAGA,sEAA8C;AAC9C,gEAAwC;AACxC,gEAA0C;AAC1C,mEAAqD;AACrD,yEAA+D;AAC/D,6EAAmE;AACnE,2EAAiE;AACjE,gEAAwC;AACxC,mEAA2C;AAC3C,gEAAwC;AACxC,uDAA+B;AAC/B,iEAAiD;AACjD,iEAAiD;AACjD,mEAAmD;AACnD,iEAAiD;AACjD,2DAA2C;AAC3C,yDAAiC;AACjC,uDAA+B;AAC/B,mEAA2C;AAC3C,0DAAkC;AAClC,sEAA6C;AAC7C,oEAA2C;AAC3C,sFAA4D;AAC5D,0DAAkC;AAElC;;GAEG;AACH,MAAM,UAAU;IAkCf;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAmC,IAAU,EAAkB,aAAwC;QAApE,SAAI,GAAJ,IAAI,CAAM;QAAkB,kBAAa,GAAb,aAAa,CAA2B;QACtG,sBAAsB;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAS,CA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I,iBAAe,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YAClD,IAAI,EAAE,IAAI,cAAY,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;SAC5C,CAAC;QACF,IAAI,CAAC,MAAM,GAAG;YACb,IAAI,EAAE,IAAI,cAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACpC,GAAG,EAAE,IAAI,aAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YAClC,SAAS,EAAE,IAAI,mBAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;SAC9C,CAAC;QACF,IAAI,CAAC,OAAO,GAAG;YACd,IAAI,EAAE,IAAI,cAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACpC,SAAS,EAAE,IAAI,oBAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YAC9C,QAAQ,EAAE,IAAI,mBAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YAC5C,gBAAgB,EAAE,IAAI,4BAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;SAC5D,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,IAAI,eAAK,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;CACD;AAED,UAAU;AACV,kBAAe,UAAU,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/settings/minipool.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"minipool.js","sourceRoot":"","sources":["../../../src/rocketpool/settings/minipool.ts"],"names":[],"mappings":";;AAKA;;GAEG;AACH,MAAM,gBAAgB;IACrB;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,iCAAiC;QAC5C,OAAO,IAAI,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CAAC;CACD;AAED,UAAU;AACV,kBAAe,gBAAgB,CAAC"} -------------------------------------------------------------------------------- /src/test/rewards/scenario-rewards-claim-node.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Perform rewards claims for a regular node 8 | export async function rewardsClaimNode(web3: Web3, rp: RocketPool, options: SendOptions) { 9 | // Get node withdrawal address 10 | const nodeWithdrawalAddress = await rp.node.getNodeWithdrawalAddress(options.from); 11 | 12 | // Get details 13 | function getDetails() { 14 | return Promise.all([ 15 | rp.rewards.pool.getClaimingContractAllowance("rocketClaimNode").then((value: any) => web3.utils.toBN(value)), 16 | rp.node.getNodeTotalEffectiveRPLStake().then((value: any) => web3.utils.toBN(value)), 17 | rp.node.getNodeEffectiveRPLStake(options.from).then((value: any) => web3.utils.toBN(value)), 18 | ]).then(([nodesRplShare, totalRplStake, nodeRplStake]) => ({ 19 | nodesRplShare, 20 | totalRplStake, 21 | nodeRplStake, 22 | })); 23 | } 24 | 25 | // Get balances 26 | function getBalances() { 27 | return Promise.all([ 28 | rp.rewards.pool.getClaimIntervalTimeStart(), 29 | rp.tokens.rpl.balanceOf(nodeWithdrawalAddress).then((value: any) => web3.utils.toBN(value)), 30 | ]).then(([claimIntervalTimeStart, nodeRpl]) => ({ 31 | claimIntervalTimeStart, 32 | nodeRpl, 33 | })); 34 | } 35 | 36 | // Get initial details & balances 37 | const [details1, balances1] = await Promise.all([getDetails(), getBalances()]); 38 | 39 | // Claim rewards 40 | await rp.rewards.claimNode.claim(options); 41 | 42 | // Get updated balances 43 | // Get updated balances 44 | const [details2, balances2] = await Promise.all([getDetails(), getBalances()]); 45 | 46 | // Calculate expected RPL claim amount 47 | const calcBase = web3.utils.toBN(web3.utils.toWei("1", "ether")); 48 | const claimPerc = calcBase.mul(details2.nodeRplStake).div(details2.totalRplStake); 49 | const expectedClaimAmount = details2.nodesRplShare.mul(claimPerc).div(calcBase); 50 | 51 | // console.log(Number(balances1.claimIntervalTimeStart), Number(balances2.claimIntervalTimeStart)); 52 | // console.log(web3.utils.fromWei(balances2.nodeRpl.sub(balances1.nodeRpl)), web3.utils.fromWei(expectedClaimAmount)); 53 | 54 | // Check balances 55 | assert(balances2.nodeRpl.sub(balances1.nodeRpl).eq(expectedClaimAmount), "Incorrect updated node RPL balance"); 56 | } 57 | -------------------------------------------------------------------------------- /dist/rocketpool/settings/auction.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import Contracts from "../contracts/contracts"; 3 | /** 4 | * Rocket Pool Auction Settings Manager 5 | */ 6 | declare class AuctionSettings { 7 | private web3; 8 | private contracts; 9 | /** 10 | * Create a new AuctionSettings instance. 11 | * 12 | * @param web3 A valid Web3 instance 13 | * @param contracts A Rocket Pool contract manager instance 14 | */ 15 | constructor(web3: Web3, contracts: Contracts); 16 | /** 17 | * Private accessor use to retrieve the related contract 18 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsAuction contract 19 | */ 20 | private get rocketDAOProtocolSettingsAuction(); 21 | /** 22 | * Return the lot maximum ETH value setting 23 | * @returns a Promise that resolves to a number representing the lot maximum ETH value setting 24 | * 25 | * @example using Typescript 26 | * ```ts 27 | * const lotMaximumEthValue = rp.settings.auction.getLotMaximumEthValue().then((val: number) => { val }; 28 | * ``` 29 | */ 30 | getLotMaximumEthValue(): Promise; 31 | /** 32 | * Return the lot duration setting 33 | * @returns a Promise that resolves to a number representing the lot duration setting 34 | * 35 | * @example using Typescript 36 | * ```ts 37 | * const lotMaximumEthValue = rp.settings.auction.getLotDuration().then((val: number) => { val }; 38 | * ``` 39 | */ 40 | getLotDuration(): Promise; 41 | /** 42 | * Return the starting price ratio setting 43 | * @returns a Promise that resolves to a number representing the starting price ratio setting 44 | * 45 | * @example using Typescript 46 | * ```ts 47 | * const startingPriceRatio = rp.settings.auction.getStartingPriceRatio().then((val: number) => { val }; 48 | * ``` 49 | */ 50 | getStartingPriceRatio(): Promise; 51 | /** 52 | * Return the reserve price ratio setting 53 | * @returns a Promise that resolves to a number representing the reserve price ratio setting 54 | * 55 | * @example using Typescript 56 | * ```ts 57 | * const reservePriceRatio = rp.settings.auction.getReservePriceRatio().then((val: number) => { val }; 58 | * ``` 59 | */ 60 | getReservePriceRatio(): Promise; 61 | } 62 | export default AuctionSettings; 63 | -------------------------------------------------------------------------------- /dist/rocketpool/dao/node/trusted/settings.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import Contracts from "../../../contracts/contracts"; 3 | /** 4 | * Rocket Pool DAO Trusted Node Settings 5 | */ 6 | declare class DAONodeTrustedSettings { 7 | private web3; 8 | private contracts; 9 | /** 10 | * Create a new DAONodeTrustedSettings instance. 11 | * 12 | * @param web3 A valid Web3 instance 13 | * @param contracts A Rocket Pool contract manager instance 14 | */ 15 | constructor(web3: Web3, contracts: Contracts); 16 | /** 17 | * Private accessor use to retrieve the related contract 18 | * @returns a Promise with a web3.eth.contract instance of the rocketDAONodeTrustedSettingsProposals contract 19 | */ 20 | private get rocketDAONodeTrustedSettingsProposals(); 21 | /** 22 | * Private accessor use to retrieve the related contract 23 | * @returns a Promise with a web3.eth.contract instance of the rocketDAONodeTrustedSettingsMembers contract 24 | */ 25 | private get rocketDAONodeTrustedSettingsMembers(); 26 | /** 27 | * Private accessor use to retrieve the related contract 28 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsDeposit contract 29 | */ 30 | private get rocketDAOProtocolSettingsDeposit(); 31 | /** 32 | * Private accessor use to retrieve the related contract 33 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsMinipool contract 34 | */ 35 | private get rocketDAOProtocolSettingsMinipool(); 36 | /** 37 | * Get the maximum deposit assignments 38 | * @returns a Promise that resolves to a string representing the maximum deposit assignments 39 | * 40 | * @example using Typescript 41 | * ```ts 42 | * const maxDepositsAssignments = rp.dao.node.trusted.getMaximumDepositAssignments().then((val: string) => { val }; 43 | * ``` 44 | */ 45 | getMaximumDepositAssignments(): Promise; 46 | /** 47 | * Get the cost of a challenge (How much it costs a non-member to challenge a members node. It's free for current members to challenge other members.) 48 | * @returns a Promise that resolves to a string representing the inflation intervals that have passed (in time) 49 | * 50 | * @example using Typescript 51 | * ```ts 52 | * const maxDepositsAssignments = rp.dao.node.trusted.getMaximumDepositAssignments().then((val: string) => { val }; 53 | * ``` 54 | */ 55 | getChallengeCost(): Promise; 56 | } 57 | export default DAONodeTrustedSettings; 58 | -------------------------------------------------------------------------------- /src/test/_helpers/settings.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { SendOptions } from "web3-eth-contract"; 3 | import RocketPool from "../../rocketpool/rocketpool"; 4 | 5 | // Deposit settings 6 | export async function getDepositSetting(rp: RocketPool, setting: string) { 7 | const rocketDAOProtocolSettingsDeposit = await rp.contracts.get("rocketDAOProtocolSettingsDeposit"); 8 | const value = await rocketDAOProtocolSettingsDeposit.methods["get" + setting]().call(); 9 | return value; 10 | } 11 | 12 | export async function setDepositSetting(rp: RocketPool, setting: string, value: any, options: SendOptions) { 13 | const rocketDAOProtocolSettingsDeposit = await rp.contracts.get("rocketDAOProtocolSettingsDeposit"); 14 | await rocketDAOProtocolSettingsDeposit.methods["set" + setting](value).send(options); 15 | } 16 | 17 | // Minipool settings 18 | export async function getMinipoolSetting(rp: RocketPool, setting: string) { 19 | const rocketDAOProtocolSettingsMinipool = await rp.contracts.get("rocketDAOProtocolSettingsMinipool"); 20 | const value = await rocketDAOProtocolSettingsMinipool.methods["get" + setting]().call(); 21 | return value; 22 | } 23 | 24 | export async function setMinipoolSetting(rp: RocketPool, setting: string, value: any, options: SendOptions) { 25 | const rocketDAOProtocolSettingsMinipool = await rp.contracts.get("rocketDAOProtocolSettingsMinipool"); 26 | await rocketDAOProtocolSettingsMinipool.methods["set" + setting](value).send(options); 27 | } 28 | 29 | // Network settings 30 | export async function getNetworkSetting(rp: RocketPool, setting: string) { 31 | const rocketDAOProtocolSettingsNetwork = await rp.contracts.get("rocketDAOProtocolSettingsNetwork"); 32 | const value = await rocketDAOProtocolSettingsNetwork.methods["get" + setting]().call(); 33 | return value; 34 | } 35 | 36 | export async function setNetworkSetting(rp: RocketPool, setting: string, value: any, options: SendOptions) { 37 | const rocketDAOProtocolSettingsNetwork = await rp.contracts.get("rocketDAOProtocolSettingsNetwork"); 38 | await rocketDAOProtocolSettingsNetwork.methods["set" + setting](value).send(options); 39 | } 40 | 41 | // Node settings 42 | export async function getNodeSetting(rp: RocketPool, setting: string) { 43 | const rocketDAOProtocolSettingsNode = await rp.contracts.get("rocketDAOProtocolSettingsNode"); 44 | const value = await rocketDAOProtocolSettingsNode.methods["get" + setting]().call(); 45 | return value; 46 | } 47 | 48 | export async function setNodeSetting(rp: RocketPool, setting: string, value: any, options: SendOptions) { 49 | const rocketDAOProtocolSettingsNode = await rp.contracts.get("rocketDAOProtocolSettingsNode"); 50 | await rocketDAOProtocolSettingsNode.methods["set" + setting](value).send(options); 51 | } 52 | -------------------------------------------------------------------------------- /src/test/tokens/scenario-rpl-burn-fixed.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | import { SendOptions } from "web3-eth-contract"; 6 | 7 | export async function burnFixedRPL(web3: Web3, rp: RocketPool, amount: string, options: SendOptions) { 8 | // Load contracts 9 | const rocketTokenRPL = await rp.contracts.get("rocketTokenRPL"); 10 | const rocketTokenDummyRPL = await rp.contracts.get("rocketTokenRPLFixedSupply"); 11 | 12 | // Get balances 13 | function getBalances() { 14 | return Promise.all([ 15 | rocketTokenDummyRPL.methods.balanceOf(options.from).call(), 16 | rocketTokenRPL.methods.totalSupply().call(), 17 | rocketTokenRPL.methods.balanceOf(options.from).call(), 18 | rocketTokenDummyRPL.methods.balanceOf(rocketTokenDummyRPL.options.address).call(), 19 | rocketTokenRPL.methods.balanceOf(rocketTokenRPL.options.address).call(), 20 | ]).then(([rplFixedUserBalance, rplTokenSupply, rplUserBalance, rplContractBalanceOfFixedSupply, rplContractBalanceOfSelf]) => ({ 21 | rplFixedUserBalance: rplFixedUserBalance, 22 | rplTokenSupply: rplTokenSupply, 23 | rplUserBalance: web3.utils.toBN(rplUserBalance), 24 | rplContractBalanceOfFixedSupply: rplContractBalanceOfFixedSupply, 25 | rplContractBalanceOfSelf: web3.utils.toBN(rplContractBalanceOfSelf), 26 | })); 27 | } 28 | 29 | // Get initial balances 30 | const balances1 = await getBalances(); 31 | 32 | //console.log(web3.utils.fromWei(amount)); 33 | //console.log(web3.utils.fromWei(balances1.rplFixedUserBalance), web3.utils.fromWei(balances1.rplContractBalanceOfSelf), web3.utils.fromWei(balances1.rplUserBalance)); 34 | 35 | // Set gas price 36 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 37 | options.gasPrice = gasPrice.toString(); 38 | options.gas = 1000000; 39 | 40 | // Burn tokens & get tx fee 41 | const txReceipt = await rp.tokens.rpl.swapTokens(amount, options); 42 | const txFee = gasPrice.mul(web3.utils.toBN(txReceipt.gasUsed)); 43 | 44 | // Get updated balances 45 | const balances2 = await getBalances(); 46 | 47 | //console.log(web3.utils.fromWei(amount)); 48 | //console.log(web3.utils.fromWei(balances2.rplFixedUserBalance), web3.utils.fromWei(balances2.rplContractBalanceOfSelf), web3.utils.fromWei(balances2.rplUserBalance)); 49 | 50 | // Calculate values 51 | const mintAmount = web3.utils.toBN(amount); 52 | 53 | // Check balances 54 | assert(balances2.rplUserBalance.eq(balances1.rplUserBalance.add(mintAmount)), "Incorrect updated user token balance"); 55 | assert(balances2.rplContractBalanceOfSelf.eq(balances1.rplContractBalanceOfSelf.sub(mintAmount)), "RPL contract has not sent the RPL to the user address"); 56 | } 57 | -------------------------------------------------------------------------------- /src/rocketpool/rewards/claim-node.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { TransactionReceipt } from "web3-core"; 4 | import { Contract, SendOptions } from "web3-eth-contract"; 5 | import Contracts from "../contracts/contracts"; 6 | import { ConfirmationHandler, handleConfirmations } from "../../utils/transaction"; 7 | import { NodeDetails } from "../node/node"; 8 | 9 | /** 10 | * Rocket Pool Rewards 11 | */ 12 | class Rewards { 13 | /** 14 | * Create a new Rewards instance. 15 | * 16 | * @param web3 A valid Web3 instance 17 | * @param contracts A Rocket Pool contract manager instance 18 | */ 19 | public constructor(private web3: Web3, private contracts: Contracts) {} 20 | 21 | /** 22 | * Private accessor use to retrieve the related contract 23 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimNode contract 24 | */ 25 | private get rocketClaimNode(): Promise { 26 | return this.contracts.get("rocketClaimNode"); 27 | } 28 | 29 | /** 30 | * Determine if the claim is possible 31 | * @params address a string representing the node address 32 | * @returns a Promise that resolves to a boolean representing if a claim is possible 33 | * 34 | * @example using Typescript 35 | * ```ts 36 | * const address = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 37 | * const claimPossible = rp.rewards.claimNode.getClaimPossible(address).then((val: bool) => { val }; 38 | * ``` 39 | */ 40 | public getClaimPossible(address: string): Promise { 41 | return this.rocketClaimNode.then((rocketClaimNode: Contract): Promise => { 42 | return rocketClaimNode.methods.getClaimPossible(address).call(); 43 | }); 44 | } 45 | 46 | /** 47 | * Make a node claim 48 | * @param options An optional object of web3.eth.Contract SendOptions 49 | * @param onConfirmation An optional confirmation handler object 50 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 51 | * 52 | * @example using Typescript 53 | * ```ts 54 | * const nodeAddress = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 55 | * const options = { 56 | * from: nodeAddress, 57 | * gas: 1000000 58 | * }; 59 | * const txReceipt = rp.rewards.claimNode(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 60 | * ``` 61 | */ 62 | public claim(options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise { 63 | return this.rocketClaimNode.then((rocketClaimNode: Contract): Promise => { 64 | return handleConfirmations(rocketClaimNode.methods.claim().send(options), onConfirmation); 65 | }); 66 | } 67 | } 68 | 69 | // Exports 70 | export default Rewards; 71 | -------------------------------------------------------------------------------- /dist/rocketpool/settings/network.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/rocketpool/settings/network.ts"],"names":[],"mappings":";;AAKA;;GAEG;AACH,MAAM,eAAe;IACpB;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,gCAAgC;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;OAQG;IACI,yBAAyB;QAC/B,OAAO,IAAI,CAAC,gCAAgC;aAC1C,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACrE,OAAO,gCAAgC,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,CAAC;QACpF,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,KAAa,EAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;OAQG;IACI,wBAAwB;QAC9B,OAAO,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,gCAA0C,EAAoB,EAAE;YAClH,OAAO,gCAAgC,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC,IAAI,EAAE,CAAC;QACnF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,0BAA0B;QAChC,OAAO,IAAI,CAAC,gCAAgC;aAC1C,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAA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AC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;OAQG;IACI,qBAAqB;QAC3B,OAAO,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACjH,OAAO,gCAAgC,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,IAAI,EAAE,CAAC;QAChF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,2BAA2B;QACjC,OAAO,IAAI,CAAC,gCAAgC;aAC1C,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACrE,OAAO,gCAAgC,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,IAAI,EAAE,CAAC;QACtF,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,KAAa,EAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;OAQG;IACI,oBAAoB;QAC1B,OAAO,IAAI,CAAC,gCAAgC;aAC1C,IAAI,CAAC,CAAC,gCAA0C,EAAmB,EAAE;YACrE,OAAO,gCAAgC,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9E,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,KAAa,EAAU,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IACtD,CAAC;CACD;AAED,UAAU;AACV,kBAAe,eAAe,CAAC"} -------------------------------------------------------------------------------- /src/test/contracts/contracts-tests.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | import { printTitle } from "../_utils/formatting"; 6 | 7 | // Tests 8 | export default function runContractsTests(web3: Web3, rp: RocketPool) { 9 | describe("Contracts", () => { 10 | describe("Addresses", () => { 11 | it(printTitle("User", "Can load a single address"), async () => { 12 | const minipoolManagerAddress = await rp.contracts.address("rocketMinipoolManager"); 13 | assert.notEqual(minipoolManagerAddress, "0x0000000000000000000000000000000000000000", "Loaded address is invalid"); 14 | }); 15 | 16 | it(printTitle("User", "Can load multiple addresses"), async () => { 17 | const [rocketMinipoolQueueAddress, rocketMinipoolStatusAddress] = await rp.contracts.address(["rocketMinipoolQueue", "rocketMinipoolStatus"]); 18 | assert.notEqual(rocketMinipoolQueueAddress, "0x0000000000000000000000000000000000000000", "Loaded address is invalid"); 19 | assert.notEqual(rocketMinipoolStatusAddress, "0x0000000000000000000000000000000000000000", "Loaded address is invalid"); 20 | }); 21 | }); 22 | 23 | describe("ABIs", () => { 24 | it(printTitle("User", "Can load single ABIs"), async () => { 25 | const minipoolManagerAbi = await rp.contracts.abi("rocketMinipoolManager"); 26 | assert.isArray(minipoolManagerAbi, "Loaded ABI is invalid"); 27 | }); 28 | 29 | it(printTitle("User", "Can load multiple ABIs"), async () => { 30 | const [rocketMinipoolQueueAbi, rocketMinipoolStatusAbi] = await rp.contracts.abi(["rocketMinipoolQueue", "rocketMinipoolStatus"]); 31 | assert.isArray(rocketMinipoolQueueAbi, "Loaded ABI is invalid"); 32 | assert.isArray(rocketMinipoolStatusAbi, "Loaded ABI is invalid"); 33 | }); 34 | }); 35 | 36 | describe("Contracts", () => { 37 | it(printTitle("User", "Can load a single contract"), async () => { 38 | const rocketNetworkBalances = await rp.contracts.get("rocketNetworkBalances"); 39 | assert.property(rocketNetworkBalances, "methods", "Loaded contract is invalid"); 40 | }); 41 | 42 | it(printTitle("User", "Can load multiple contracts"), async () => { 43 | const [rocketNetworkFees, rocketNetworkPrices] = await rp.contracts.get(["rocketNetworkFees", "rocketNetworkPrices"]); 44 | assert.property(rocketNetworkFees, "methods", "Loaded contract is invalid"); 45 | assert.property(rocketNetworkPrices, "methods", "Loaded contract is invalid"); 46 | }); 47 | 48 | it(printTitle("User", "Can create a new contract instance"), async () => { 49 | const minipool = await rp.contracts.make("rocketMinipoolDelegate", "0x1111111111111111111111111111111111111111"); 50 | assert.property(minipool, "methods", "Created contract is invalid"); 51 | }); 52 | }); 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /src/test/_utils/evm.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { HttpProvider } from "web3-core"; 4 | import { JsonRpcResponse } from "web3-core-helpers"; 5 | 6 | // Take a snapshot of the EVM state 7 | export function takeSnapshot(web3: Web3): Promise { 8 | return new Promise((resolve, reject) => { 9 | (web3.currentProvider as HttpProvider).send( 10 | { 11 | jsonrpc: "2.0", 12 | method: "evm_snapshot", 13 | params: [], 14 | id: new Date().getTime(), 15 | }, 16 | function (err: Error | null, response: JsonRpcResponse | undefined) { 17 | if (err) { 18 | reject(err); 19 | } else if (response && response.result) { 20 | resolve(response.result); 21 | } else { 22 | reject("Unknown error"); 23 | } 24 | } 25 | ); 26 | }); 27 | } 28 | 29 | // Restore a snapshot of EVM state 30 | export function revertSnapshot(web3: Web3, snapshotId: string) { 31 | return new Promise((resolve, reject) => { 32 | (web3.currentProvider as HttpProvider).send( 33 | { 34 | jsonrpc: "2.0", 35 | method: "evm_revert", 36 | params: [snapshotId], 37 | id: new Date().getTime(), 38 | }, 39 | function (err: Error | null, response: JsonRpcResponse | undefined) { 40 | if (err) { 41 | reject(err); 42 | } else { 43 | resolve(); 44 | } 45 | } 46 | ); 47 | }); 48 | } 49 | 50 | // Mine a number of blocks 51 | export async function mineBlocks(web3: Web3, numBlocks: number) { 52 | for (let i = 0; i < numBlocks; ++i) { 53 | await new Promise((resolve, reject) => { 54 | (web3.currentProvider as HttpProvider).send( 55 | { 56 | jsonrpc: "2.0", 57 | method: "evm_mine", 58 | params: [], 59 | id: new Date().getTime(), 60 | }, 61 | function (err: Error | null, response: JsonRpcResponse | undefined) { 62 | if (err) { 63 | reject(err); 64 | } else { 65 | resolve(); 66 | } 67 | } 68 | ); 69 | }); 70 | } 71 | } 72 | 73 | // Fast-forward time 74 | export async function increaseTime(web3: Web3, seconds: number) { 75 | await new Promise((resolve, reject) => { 76 | (web3.currentProvider as HttpProvider).send( 77 | { 78 | jsonrpc: "2.0", 79 | method: "evm_increaseTime", 80 | params: [seconds], 81 | id: new Date().getTime(), 82 | }, 83 | function (err: Error | null, response: JsonRpcResponse | undefined) { 84 | if (err) { 85 | reject(err); 86 | } else { 87 | resolve(); 88 | } 89 | } 90 | ); 91 | }); 92 | // Mine a block using the new time 93 | await mineBlocks(web3, 1); 94 | } 95 | 96 | // Retrieve current time on block chain 97 | export async function getCurrentTime(web3: Web3) { 98 | return Number((await web3.eth.getBlock("latest")).timestamp); 99 | } 100 | -------------------------------------------------------------------------------- /src/rocketpool/rewards/claim-trusted-node.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { TransactionReceipt } from "web3-core"; 4 | import { Contract, SendOptions } from "web3-eth-contract"; 5 | import Contracts from "../contracts/contracts"; 6 | import { ConfirmationHandler, handleConfirmations } from "../../utils/transaction"; 7 | import { NodeDetails } from "../node/node"; 8 | 9 | /** 10 | * Rocket Pool Rewards 11 | */ 12 | class Rewards { 13 | /** 14 | * Create a new Rewards instance. 15 | * 16 | * @param web3 A valid Web3 instance 17 | * @param contracts A Rocket Pool contract manager instance 18 | */ 19 | public constructor(private web3: Web3, private contracts: Contracts) {} 20 | 21 | /** 22 | * Private accessor use to retrieve the related contract 23 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimTrustedNode contract 24 | */ 25 | private get rocketClaimTrustedNode(): Promise { 26 | return this.contracts.get("rocketClaimTrustedNode"); 27 | } 28 | 29 | /** 30 | * Get claim rewards amount 31 | * @params address a string representing the node address 32 | * @returns a Promise that resolves to a string representing the claim rewards amount in Wei 33 | * 34 | * @example using Typescript 35 | * ```ts 36 | * const address = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 37 | * const claimPossible = rp.rewards.claimTrustedNode.getClaimRewardsAmount(address).then((val: string) => { val }; 38 | * ``` 39 | */ 40 | public getClaimRewardsAmount(address: string): Promise { 41 | return this.rocketClaimTrustedNode.then((rocketClaimTrustedNode: Contract): Promise => { 42 | return rocketClaimTrustedNode.methods.getClaimRewardsAmount(address).call(); 43 | }); 44 | } 45 | 46 | /** 47 | * Claim from a trusted node 48 | * @param options An optional object of web3.eth.Contract SendOptions 49 | * @param onConfirmation An optional confirmation handler object 50 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 51 | * 52 | * @example using Typescript 53 | * ```ts 54 | * const trustedNode = "0x421433c3f99529A704Ec2270E1A68fa66DD8bD79"; 55 | * const options = { 56 | * from: trustedNode, 57 | * gas: 1000000 58 | * }; 59 | * const txReceipt = rp.rewards.claimTrustedNode(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 60 | * ``` 61 | */ 62 | public claim(options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise { 63 | return this.rocketClaimTrustedNode.then((rocketClaimTrustedNode: Contract): Promise => { 64 | return handleConfirmations(rocketClaimTrustedNode.methods.claim().send(options), onConfirmation); 65 | }); 66 | } 67 | } 68 | 69 | // Exports 70 | export default Rewards; 71 | -------------------------------------------------------------------------------- /src/test/minipool/scenario-withdraw.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | import MinipoolContract from "../../rocketpool/minipool/minipool-contract"; 7 | 8 | // Withdraw a minipool 9 | export async function withdraw(web3: Web3, rp: RocketPool, minipool: MinipoolContract, options: SendOptions) { 10 | // Load contracts 11 | const rocketTokenNETH = await rp.contracts.get("rocketTokenNETH"); 12 | 13 | // Get parameters 14 | const nodeAddress = await minipool.getNodeAddress(); 15 | const nodeWithdrawalAddress = await rp.node.getNodeWithdrawalAddress(nodeAddress); 16 | 17 | // Get minipool balances 18 | function getMinipoolBalances() { 19 | return Promise.all([ 20 | rocketTokenNETH.methods 21 | .balanceOf(minipool.contract.options.address) 22 | .call() 23 | .then((value: any) => web3.utils.toBN(value)), 24 | minipool.getNodeRefundBalance().then((value: any) => web3.utils.toBN(value)), 25 | ]).then(([neth, nodeRefund]) => ({ neth, nodeRefund })); 26 | } 27 | 28 | // Get node balances 29 | function getNodeBalances() { 30 | return Promise.all([ 31 | rocketTokenNETH.methods 32 | .balanceOf(nodeWithdrawalAddress) 33 | .call() 34 | .then((value: any) => web3.utils.toBN(value)), 35 | web3.eth.getBalance(nodeWithdrawalAddress).then((value: any) => web3.utils.toBN(value)), 36 | ]).then(([neth, eth]) => ({ neth, eth })); 37 | } 38 | 39 | // Get initial node balances, minipool balances & node withdrawn status 40 | const [nodeBalances1, minipoolBalances, nodeWithdrawn1] = await Promise.all([getNodeBalances(), getMinipoolBalances(), minipool.getNodeWithdrawn()]); 41 | 42 | // Set gas price 43 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 44 | options.gasPrice = gasPrice.toString(); 45 | 46 | // Withdraw & get tx fee 47 | const txReceipt = await minipool.withdraw(options); 48 | const txFee = gasPrice.mul(web3.utils.toBN(txReceipt.gasUsed)); 49 | 50 | // Get updated node balances & node withdrawn status 51 | const [nodeBalances2, nodeWithdrawn2] = await Promise.all([getNodeBalances(), minipool.getNodeWithdrawn()]); 52 | 53 | // Check minipool node withdrawn status 54 | assert.isFalse(nodeWithdrawn1, "Incorrect initial minipool node withdrawn status"); 55 | assert.isTrue(nodeWithdrawn2, "Incorrect updated minipool node withdrawn status"); 56 | 57 | // Check balances 58 | let expectedNodeEthBalance = nodeBalances1.eth.add(minipoolBalances.nodeRefund); 59 | if (nodeWithdrawalAddress == nodeAddress) expectedNodeEthBalance = expectedNodeEthBalance.sub(txFee); 60 | assert(nodeBalances2.neth.eq(nodeBalances1.neth.add(minipoolBalances.neth)), "Incorrect updated node nETH balance"); 61 | assert(nodeBalances2.eth.eq(expectedNodeEthBalance), "Incorrect updated node ETH balance"); 62 | } 63 | -------------------------------------------------------------------------------- /dist/rocketpool/settings/deposit.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import Contracts from "../contracts/contracts"; 3 | /** 4 | * Rocket Pool Deposit Settings Manager 5 | */ 6 | declare class DepositSettings { 7 | private web3; 8 | private contracts; 9 | /** 10 | * Create a new Deposit Settings instance. 11 | * 12 | * @param web3 A valid Web3 instance 13 | * @param contracts A Rocket Pool contract manager instance 14 | */ 15 | constructor(web3: Web3, contracts: Contracts); 16 | /** 17 | * Private accessor use to retrieve the related contract 18 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsDeposit contract 19 | */ 20 | private get rocketDAOProtocolSettingsDeposit(); 21 | /** 22 | * Check to see if deposits are enabled 23 | * @returns a Promise that resolves to a boolean representing if deposits are enabled 24 | * 25 | * @example using Typescript 26 | * ```ts 27 | * const enabled = rp.settings.deposit.getDepositsEnabled().then((val: boolean) => { val }; 28 | * ``` 29 | */ 30 | getDepositEnabled(): Promise; 31 | /** 32 | * Check to see if deposit assignments are enabled 33 | * @returns a Promise that resolves to a boolean representing if deposit assignments are enabled 34 | * 35 | * @example using Typescript 36 | * ```ts 37 | * const enabled = rp.settings.deposit.getAssignDepositsEnabled().then((val: boolean) => { val }; 38 | * ``` 39 | */ 40 | getAssignDepositsEnabled(): Promise; 41 | /** 42 | * Return the minimum deposit amount setting in wei 43 | * @returns a Promise that resolves to a string representing the minimum deposit amount setting 44 | * 45 | * @example using Typescript 46 | * ```ts 47 | * const minimumDeposit = rp.settings.deposit.getMinimumDeposit().then((val: string) => { val }; 48 | * ``` 49 | */ 50 | getMinimumDeposit(): Promise; 51 | /** 52 | * Return the maximum deposit pool size setting in Wei 53 | * @returns a Promise that resolves to a string representing the maximum deposit pool size setting 54 | * 55 | * @example using Typescript 56 | * ```ts 57 | * const maximumDepositPoolSize = rp.settings.deposit.getMaximumDepositPoolSize().then((val: string) => { val }; 58 | * ``` 59 | */ 60 | getMaximumDepositPoolSize(): Promise; 61 | /** 62 | * Return the maximum number of deposit assignments to perform at once 63 | * @returns a Promise that resolves to a number representing the maximum number of deposit assignments to perform at once 64 | * 65 | * @example using Typescript 66 | * ```ts 67 | * const maxDepositAssignments = rp.settings.deposit.getMaximumDepositAssignments().then((val: string) => { val }; 68 | * ``` 69 | */ 70 | getMaximumDepositAssignments(): Promise; 71 | } 72 | export default DepositSettings; 73 | -------------------------------------------------------------------------------- /dist/rocketpool/tokens/legacyrpl.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | var _erc = require("./erc20"); 10 | 11 | var _erc2 = _interopRequireDefault(_erc); 12 | 13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 14 | 15 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 16 | 17 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 18 | 19 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 20 | 21 | /** 22 | * Rocket Pool Legacy RPL Token Manager 23 | */ 24 | var LegacyRPL = function (_ERC) { 25 | _inherits(LegacyRPL, _ERC); 26 | 27 | /** 28 | * Create a new LegacyRPL instance. 29 | * 30 | * @param web3 A valid Web3 instance 31 | * @param contracts A Rocket Pool contract manager instance 32 | */ 33 | function LegacyRPL(web3, contracts) { 34 | _classCallCheck(this, LegacyRPL); 35 | 36 | return _possibleConstructorReturn(this, (LegacyRPL.__proto__ || Object.getPrototypeOf(LegacyRPL)).call(this, web3, contracts, "rocketTokenRPLFixedSupply")); 37 | } 38 | /** 39 | * Get the contract address 40 | * @returns a Promise that resolves to a string representing the contract address of the token 41 | * 42 | * @example using Typescript 43 | * ```ts 44 | * const address = rp.tokens.legacyrpl.getAddress().then((val: string) => { val }; 45 | * ``` 46 | */ 47 | 48 | 49 | _createClass(LegacyRPL, [{ 50 | key: "getAddress", 51 | value: function getAddress() { 52 | return this.tokenContract.then(function (tokenContract) { 53 | return tokenContract.options.address; 54 | }); 55 | } 56 | }]); 57 | 58 | return LegacyRPL; 59 | }(_erc2.default); 60 | // Exports 61 | 62 | 63 | exports.default = LegacyRPL; 64 | //# sourceMappingURL=legacyrpl.js.map -------------------------------------------------------------------------------- /src/test/minipool/scenario-stake.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | import MinipoolContract from "../../rocketpool/minipool/minipool-contract"; 7 | import { getValidatorSignature, getDepositDataRoot } from "../_utils/beacon"; 8 | 9 | // Stake a minipool 10 | export async function stake( 11 | web3: Web3, 12 | rp: RocketPool, 13 | minipool: MinipoolContract, 14 | validatorPubkey: string | null, 15 | withdrawalCredentials: string | null, 16 | options: SendOptions 17 | ) { 18 | const rocketDAOProtocolSettingsMinipool = await rp.contracts.get("rocketDAOProtocolSettingsMinipool"); 19 | 20 | // Get parameters 21 | const launchBalance = await rocketDAOProtocolSettingsMinipool.methods 22 | .getLaunchBalance() 23 | .call() 24 | .then((value: any) => web3.utils.toBN(value)); 25 | 26 | // Get minipool validator pubkey 27 | if (!validatorPubkey) validatorPubkey = await rp.minipool.getMinipoolPubkey(minipool.address); 28 | 29 | // Get minipool withdrawal credentials 30 | if (!withdrawalCredentials) withdrawalCredentials = await rp.minipool.getMinipoolWithdrawalCredentials(minipool.address); 31 | 32 | // Get validator deposit data 33 | const depositData = { 34 | pubkey: Buffer.from(validatorPubkey.substr(2), "hex"), 35 | withdrawalCredentials: Buffer.from(withdrawalCredentials.substr(2), "hex"), 36 | amount: BigInt(16000000000), // gwei 37 | signature: getValidatorSignature(), 38 | }; 39 | const depositDataRoot = getDepositDataRoot(depositData); 40 | 41 | // Get minipool details 42 | function getMinipoolDetails() { 43 | return Promise.all([ 44 | minipool.getStatus().then((value: any) => web3.utils.toBN(value)), 45 | web3.eth.getBalance(minipool.contract.options.address).then((value: any) => web3.utils.toBN(value)), 46 | ]).then(([status, balance]) => ({ status, balance })); 47 | } 48 | 49 | // Get initial minipool details & minipool by validator pubkey 50 | const [details1, validatorMinipool1] = await Promise.all([getMinipoolDetails(), rp.minipool.getMinipoolByPubkey(validatorPubkey)]); 51 | 52 | // Stake 53 | // console.log("====================="); 54 | // console.log(validatorPubkey); 55 | // console.log(depositData.pubkey); 56 | // console.log(depositData.signature); 57 | // console.log(depositDataRoot); 58 | // console.log(options); 59 | // console.log("====================="); 60 | await minipool.stake(depositData.signature, depositDataRoot, options); 61 | 62 | // Get updated minipool details & minipool by validator pubkey 63 | const [details2, validatorMinipool2] = await Promise.all([getMinipoolDetails(), rp.minipool.getMinipoolByPubkey(validatorPubkey)]); 64 | 65 | // Check minpool details 66 | const staking = web3.utils.toBN(2); 67 | assert(!details1.status.eq(staking), "Incorrect initial minipool status"); 68 | assert(details2.status.eq(staking), "Incorrect updated minipool status"); 69 | assert(details2.balance.eq(details1.balance.sub(web3.utils.toBN(web3.utils.toWei("16", "ether")))), "Incorrect updated minipool ETH balance"); 70 | 71 | // Check minipool by validator pubkey 72 | assert.equal(validatorMinipool2, minipool.address, "Incorrect updated minipool by validator pubkey"); 73 | } 74 | -------------------------------------------------------------------------------- /dist/rocketpool/vault/vault.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10 | 11 | /** 12 | * Rocket Pool Vault 13 | */ 14 | var Vault = function () { 15 | /** 16 | * Create a new Vault instance. 17 | * 18 | * @param web3 A valid Web3 instance 19 | * @param contracts A Rocket Pool contract manager instance 20 | */ 21 | function Vault(web3, contracts) { 22 | _classCallCheck(this, Vault); 23 | 24 | this.web3 = web3; 25 | this.contracts = contracts; 26 | } 27 | /** 28 | * Private accessor use to retrieve the related contract 29 | * @returns a Promise with a web3.eth.contract instance of the rocketVault contract 30 | */ 31 | 32 | 33 | _createClass(Vault, [{ 34 | key: "getAddress", 35 | 36 | /** 37 | * Retrieve the RocketVault contract address 38 | * @returns a Promise that resolves to the Rocket Vault contract address 39 | * 40 | * @example using Typescript 41 | * ```ts 42 | * const rocketVault = rp.vault.getAddress().then((val: string) => { val }; 43 | * ``` 44 | */ 45 | value: function getAddress() { 46 | return this.rocketVault.then(function (rocketVault) { 47 | return rocketVault.options.address; 48 | }); 49 | } 50 | /** 51 | * Retrieve the balance of a token when providing a contract & token address 52 | * @param contractAddress A string representing the contract address 53 | * @param tokenAddress A string representing the token address 54 | * @returns a Promise that resolves to the Rocket Vault contract address 55 | * 56 | * @example using Typescript 57 | * ```ts 58 | * const rplBalance = rp.vault.balanceOfToken("rocketClaimDAO", rocketTokenRPLAddress).then((val: string) => { val } 59 | * ``` 60 | */ 61 | 62 | }, { 63 | key: "balanceOfToken", 64 | value: function balanceOfToken(contractAddress, tokenAddress) { 65 | return this.rocketVault.then(function (rocketVault) { 66 | return rocketVault.methods.balanceOfToken(contractAddress, tokenAddress).call(); 67 | }); 68 | } 69 | }, { 70 | key: "rocketVault", 71 | get: function get() { 72 | return this.contracts.get("rocketVault"); 73 | } 74 | }]); 75 | 76 | return Vault; 77 | }(); 78 | // Exports 79 | 80 | 81 | exports.default = Vault; 82 | //# sourceMappingURL=vault.js.map -------------------------------------------------------------------------------- /dist/rocketpool/dao/node/trusted/node.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../../../src/rocketpool/dao/node/trusted/node.ts"],"names":[],"mappings":";;AAKA,+DAAyF;AAEzF;;GAEG;AACH,MAAM,cAAc;IACnB;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,oBAAoB;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;;;;OAUG;IACI,WAAW,CAAC,OAAe;QACjC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,oBAA8B,EAAmB,EAAE;YACzF,OAAO,oBAAoB,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QACjE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,cAAc;QACpB,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,oBAA8B,EAA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,cAAc,CAAC,CAAC;QAC1J,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,gBAAgB,CAAC,KAAc,EAAE,OAAqB,EAAE,cAAoC;QAClG,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,oBAA8B,EAA+B,EAAE;YACrG,OAAO,IAAA,iCAAmB,EAAC,oBAAoB,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QAChH,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,kBAAkB,CAAC,EAAU,EAAE,GAAW,EAAE,OAAqB,EAAE,cAAoC;QAC7G,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,oBAA8B,EAA+B,EAAE;YACrG,OAAO,IAAA,iCAAmB,EAAC,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QACpH,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,cAAc,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/settings/node.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10 | 11 | /** 12 | * Rocket Pool Node Settings Manager 13 | */ 14 | var NodeSettings = function () { 15 | /** 16 | * Create a new Node Settings instance. 17 | * 18 | * @param web3 A valid Web3 instance 19 | * @param contracts A Rocket Pool contract manager instance 20 | */ 21 | function NodeSettings(web3, contracts) { 22 | _classCallCheck(this, NodeSettings); 23 | 24 | this.web3 = web3; 25 | this.contracts = contracts; 26 | } 27 | /** 28 | * Private accessor use to retrieve the related contract 29 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsNode contract 30 | */ 31 | 32 | 33 | _createClass(NodeSettings, [{ 34 | key: "getRegistrationEnabled", 35 | 36 | /** 37 | * Return if node registrations are currently enabled 38 | * @returns a Promise that resolves to a boolean representing if node registrations are enabled 39 | * 40 | * @example using Typescript 41 | * ```ts 42 | * const enabled = rp.settings.node.getRegistrationEnabled().then((val: boolean) => { val }; 43 | * ``` 44 | */ 45 | value: function getRegistrationEnabled() { 46 | return this.rocketDAOProtocolSettingsNode.then(function (rocketDAOProtocolSettingsNode) { 47 | return rocketDAOProtocolSettingsNode.methods.getRegistrationEnabled().call(); 48 | }); 49 | } 50 | /** 51 | * Return if node deposits are currently enabled 52 | * @returns a Promise that resolves to a boolean representing if node deposits are enabled 53 | * 54 | * @example using Typescript 55 | * ```ts 56 | * const enabled = rp.settings.node.getDepositEnabled().then((val: boolean) => { val }; 57 | * ``` 58 | */ 59 | 60 | }, { 61 | key: "getDepositEnabled", 62 | value: function getDepositEnabled() { 63 | return this.rocketDAOProtocolSettingsNode.then(function (rocketDAOProtocolSettingsNode) { 64 | return rocketDAOProtocolSettingsNode.methods.getDepositEnabled().call(); 65 | }); 66 | } 67 | }, { 68 | key: "rocketDAOProtocolSettingsNode", 69 | get: function get() { 70 | return this.contracts.get("rocketDAOProtocolSettingsNode"); 71 | } 72 | }]); 73 | 74 | return NodeSettings; 75 | }(); 76 | // Exports 77 | 78 | 79 | exports.default = NodeSettings; 80 | //# sourceMappingURL=node.js.map -------------------------------------------------------------------------------- /src/rocketpool/settings/auction.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { Contract } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | 6 | /** 7 | * Rocket Pool Auction Settings Manager 8 | */ 9 | class AuctionSettings { 10 | /** 11 | * Create a new AuctionSettings instance. 12 | * 13 | * @param web3 A valid Web3 instance 14 | * @param contracts A Rocket Pool contract manager instance 15 | */ 16 | public constructor(private web3: Web3, private contracts: Contracts) {} 17 | 18 | /** 19 | * Private accessor use to retrieve the related contract 20 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsAuction contract 21 | */ 22 | private get rocketDAOProtocolSettingsAuction(): Promise { 23 | return this.contracts.get("rocketDAOProtocolSettingsAuction"); 24 | } 25 | 26 | /** 27 | * Return the lot maximum ETH value setting 28 | * @returns a Promise that resolves to a number representing the lot maximum ETH value setting 29 | * 30 | * @example using Typescript 31 | * ```ts 32 | * const lotMaximumEthValue = rp.settings.auction.getLotMaximumEthValue().then((val: number) => { val }; 33 | * ``` 34 | */ 35 | public getLotMaximumEthValue(): Promise { 36 | return this.rocketDAOProtocolSettingsAuction.then((rocketDAOProtocolSettingsAuction: Contract): Promise => { 37 | return rocketDAOProtocolSettingsAuction.methods.getLotMaximumEthValue().call(); 38 | }); 39 | } 40 | 41 | /** 42 | * Return the lot duration setting 43 | * @returns a Promise that resolves to a number representing the lot duration setting 44 | * 45 | * @example using Typescript 46 | * ```ts 47 | * const lotMaximumEthValue = rp.settings.auction.getLotDuration().then((val: number) => { val }; 48 | * ``` 49 | */ 50 | public getLotDuration(): Promise { 51 | return this.rocketDAOProtocolSettingsAuction.then((rocketDAOProtocolSettingsAuction: Contract): Promise => { 52 | return rocketDAOProtocolSettingsAuction.methods.getLotDuration().call(); 53 | }); 54 | } 55 | 56 | /** 57 | * Return the starting price ratio setting 58 | * @returns a Promise that resolves to a number representing the starting price ratio setting 59 | * 60 | * @example using Typescript 61 | * ```ts 62 | * const startingPriceRatio = rp.settings.auction.getStartingPriceRatio().then((val: number) => { val }; 63 | * ``` 64 | */ 65 | public getStartingPriceRatio(): Promise { 66 | return this.rocketDAOProtocolSettingsAuction.then((rocketDAOProtocolSettingsAuction: Contract): Promise => { 67 | return rocketDAOProtocolSettingsAuction.methods.getStartingPriceRatio().call(); 68 | }); 69 | } 70 | 71 | /** 72 | * Return the reserve price ratio setting 73 | * @returns a Promise that resolves to a number representing the reserve price ratio setting 74 | * 75 | * @example using Typescript 76 | * ```ts 77 | * const reservePriceRatio = rp.settings.auction.getReservePriceRatio().then((val: number) => { val }; 78 | * ``` 79 | */ 80 | public getReservePriceRatio(): Promise { 81 | return this.rocketDAOProtocolSettingsAuction.then((rocketDAOProtocolSettingsAuction: Contract): Promise => { 82 | return rocketDAOProtocolSettingsAuction.methods.getReservePriceRatio().call(); 83 | }); 84 | } 85 | } 86 | 87 | // Exports 88 | export default AuctionSettings; 89 | -------------------------------------------------------------------------------- /dist/rocketpool/contracts/contracts.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/rocketpool/contracts/contracts.ts"],"names":[],"mappings":";;AAIA,mDAAmE;AAEnE;;GAEG;AACH,MAAM,SAAS;IAOd;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,aAAwC;QAA5D,SAAI,GAAJ,IAAI,CAAM;QAAU,kBAAa,GAAb,aAAa,CAA2B;QAV/E,cAAS,GAAwC,EAAE,CAAC;QACpD,SAAI,GAA2C,EAAE,CAAC;QAClD,cAAS,GAA0C,EAAE,CAAC;QAS7D,4CAA4C;QAC5C,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;YACtC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC,CAAC;SAClG;aAAM;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,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YACpG,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC5B;aAAM;YACN,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC5B;QAED,oCAAoC;IACrC,CAAC;IAED;;;;;;;;;;OAUG;IACI,IAAI,CAAC,IAAY,EAAE,OAAe;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAc,EAAY,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IACpG,CAAC;CACD;AAED,MAAM,gBAAgB,GAAc;IACnC;QACC,MAAM,EAAE;YACP;gBACC,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,SAAS;aACf;SACD;QACD,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE;YACR;gBACC,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,SAAS;aACf;SACD;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,IAAI;KACd;IACD;QACC,MAAM,EAAE;YACP;gBACC,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,SAAS;aACf;SACD;QACD,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE;YACR;gBACC,YAAY,EAAE,QAAQ;gBACtB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,QAAQ;aACd;SACD;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,IAAI;KACd;CACD,CAAC;AAEF,UAAU;AACV,kBAAe,SAAS,CAAC"} -------------------------------------------------------------------------------- /src/test/auction/scenario-claim-bid.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | import { SendOptions } from "web3-eth-contract"; 6 | 7 | // Claim RPL from a lot 8 | export async function claimBid(web3: Web3, rp: RocketPool, lotIndex: number, options: SendOptions) { 9 | // Load contracts 10 | const rocketTokenRPL = await rp.contracts.get("rocketTokenRPL"); 11 | const rocketVault = await rp.contracts.get("rocketVault"); 12 | 13 | // Get auction contract details 14 | function getContractDetails() { 15 | return Promise.all([ 16 | rp.auction.getAllottedRPLBalance().then((value: any) => web3.utils.toBN(value)), 17 | rp.auction.getRemainingRPLBalance().then((value: any) => web3.utils.toBN(value)), 18 | ]).then(([allottedRplBalance, remainingRplBalance]) => ({ 19 | allottedRplBalance, 20 | remainingRplBalance, 21 | })); 22 | } 23 | 24 | // Get lot details 25 | function getLotDetails(bidderAddress: string) { 26 | return Promise.all([ 27 | rp.auction.getLotAddressBidAmount(lotIndex, bidderAddress).then((value: any) => web3.utils.toBN(value)), 28 | rp.auction.getLotCurrentPrice(lotIndex).then((value: any) => web3.utils.toBN(value)), 29 | ]).then(([addressBidAmount, currentPrice]) => ({ 30 | addressBidAmount, 31 | currentPrice, 32 | })); 33 | } 34 | 35 | // Get balances 36 | function getBalances(bidderAddress: string) { 37 | return Promise.all([ 38 | rp.tokens.rpl.balanceOf(bidderAddress).then((value: any) => web3.utils.toBN(value)), 39 | rp.tokens.rpl.balanceOf(rocketVault.options.address).then((value: any) => web3.utils.toBN(value)), 40 | rocketVault.methods 41 | .balanceOfToken("rocketAuctionManager", rocketTokenRPL.options.address) 42 | .call() 43 | .then((value: any) => web3.utils.toBN(value)), 44 | ]).then(([bidderRpl, vaultRpl, contractRpl]) => ({ 45 | bidderRpl, 46 | vaultRpl, 47 | contractRpl, 48 | })); 49 | } 50 | 51 | // Get initial details & balances 52 | const [details1, lot1, balances1] = await Promise.all([getContractDetails(), getLotDetails(options.from), getBalances(options.from)]); 53 | 54 | // Set gas price 55 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 56 | options.gasPrice = gasPrice.toString(); 57 | 58 | // Claim RPL 59 | await rp.auction.claimBid(lotIndex, options); 60 | 61 | // Get updated details & balances 62 | const [details2, lot2, balances2] = await Promise.all([getContractDetails(), getLotDetails(options.from), getBalances(options.from)]); 63 | 64 | // Get expected values 65 | const calcBase = web3.utils.toBN(web3.utils.toWei("1", "ether")); 66 | const expectedRplAmount = calcBase.mul(lot1.addressBidAmount).div(lot1.currentPrice); 67 | 68 | // Check details 69 | assert(details2.allottedRplBalance.eq(details1.allottedRplBalance.sub(expectedRplAmount)), "Incorrect updated contract allotted RPL balance"); 70 | assert(details2.remainingRplBalance.eq(details1.remainingRplBalance), "Contract remaining RPL balance updated and should not have"); 71 | assert(lot2.addressBidAmount.eq(web3.utils.toBN(0)), "Incorrect updated address bid amount"); 72 | 73 | // Check balances 74 | assert(balances2.bidderRpl.eq(balances1.bidderRpl.add(expectedRplAmount)), "Incorrect updated address RPL balance"); 75 | assert(balances2.contractRpl.eq(balances1.contractRpl.sub(expectedRplAmount)), "Incorrect updated auction contract RPL balance"); 76 | assert(balances2.vaultRpl.eq(balances1.vaultRpl.sub(expectedRplAmount)), "Incorrect updated vault RPL balance"); 77 | } 78 | -------------------------------------------------------------------------------- /dist/rocketpool/rocketpool.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { ContractArtifact } from "../utils/contract"; 3 | import Contracts from "./contracts/contracts"; 4 | import Auction from "./auction/auction"; 5 | import DAOProposal from "./dao/proposals"; 6 | import DAONodeTrusted from "./dao/node/trusted/node"; 7 | import DAONodeTrustedActions from "./dao/node/trusted/actions"; 8 | import DAONodeTrustedProposals from "./dao/node/trusted/proposals"; 9 | import DAONodeTrustedSettings from "./dao/node/trusted/settings"; 10 | import Deposit from "./deposit/deposit"; 11 | import Minipool from "./minipool/minipool"; 12 | import Network from "./network/network"; 13 | import Node from "./node/node"; 14 | import AuctionSettings from "./settings/auction"; 15 | import DepositSettings from "./settings/deposit"; 16 | import MinipoolSettings from "./settings/minipool"; 17 | import NetworkSettings from "./settings/network"; 18 | import NodeSettings from "./settings/node"; 19 | import RETH from "./tokens/reth"; 20 | import RPL from "./tokens/rpl"; 21 | import LegacyRPL from "./tokens/legacyrpl"; 22 | import Pool from "./rewards/pool"; 23 | import ClaimNode from "./rewards/claim-node"; 24 | import ClaimDAO from "./rewards/claim-dao"; 25 | import ClaimTrustedNode from "./rewards/claim-trusted-node"; 26 | import Vault from "./vault/vault"; 27 | /** 28 | * RocketPool 29 | */ 30 | declare class RocketPool { 31 | readonly web3: Web3; 32 | readonly RocketStorage: ContractArtifact | string; 33 | readonly contracts: Contracts; 34 | readonly auction: Auction; 35 | readonly dao: { 36 | node: { 37 | trusted: { 38 | actions: DAONodeTrustedActions; 39 | node: DAONodeTrusted; 40 | proposals: DAONodeTrustedProposals; 41 | settings: DAONodeTrustedSettings; 42 | }; 43 | }; 44 | proposals: DAOProposal; 45 | }; 46 | readonly deposit: Deposit; 47 | readonly minipool: Minipool; 48 | readonly network: Network; 49 | readonly node: Node; 50 | readonly settings: { 51 | auction: AuctionSettings; 52 | deposit: DepositSettings; 53 | minipool: MinipoolSettings; 54 | network: NetworkSettings; 55 | node: NodeSettings; 56 | }; 57 | readonly tokens: { 58 | reth: RETH; 59 | rpl: RPL; 60 | legacyrpl: LegacyRPL; 61 | }; 62 | readonly rewards: { 63 | pool: Pool; 64 | claimNode: ClaimNode; 65 | claimDAO: ClaimDAO; 66 | claimTrustedNode: ClaimTrustedNode; 67 | }; 68 | readonly vault: Vault; 69 | /** 70 | * Create a new Rocket Pool instance. 71 | * 72 | * @param web3 A Web3 instance 73 | * @param RocketStorage a RocketStorage address as a string or ContractArtifact (JSON ABI file) 74 | * @returns a RocketPool API object for use in your project 75 | * 76 | * Example using RocketStorage contract address 77 | * ```ts 78 | * // Using a RocketStorage address as a string 79 | * const RocketStorage = "0xd8Cd47263414aFEca62d6e2a3917d6600abDceB3"; // Current Testnet Storage Contract 80 | * const rp = new RocketPool(web3, RocketStorage); 81 | * ``` 82 | * 83 | * Example using Contract Artifact (ABI JSON file) 84 | * ```ts 85 | * // Using a Contract Artifact (ABI JSON file) 86 | * import RocketStorage from './contracts/RocketStorage.json'; 87 | * const rp = new RocketPool(web3, RocketStorage); 88 | * ``` 89 | */ 90 | constructor(web3: Web3, RocketStorage: ContractArtifact | string); 91 | } 92 | export default RocketPool; 93 | -------------------------------------------------------------------------------- /src/rocketpool/dao/node/trusted/settings.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { TransactionReceipt } from "web3-core"; 4 | import { Contract, SendOptions } from "web3-eth-contract"; 5 | import Contracts from "../../../contracts/contracts"; 6 | import { ConfirmationHandler, handleConfirmations } from "../../../../utils/transaction"; 7 | 8 | /** 9 | * Rocket Pool DAO Trusted Node Settings 10 | */ 11 | class DAONodeTrustedSettings { 12 | /** 13 | * Create a new DAONodeTrustedSettings instance. 14 | * 15 | * @param web3 A valid Web3 instance 16 | * @param contracts A Rocket Pool contract manager instance 17 | */ 18 | public constructor(private web3: Web3, private contracts: Contracts) {} 19 | 20 | /** 21 | * Private accessor use to retrieve the related contract 22 | * @returns a Promise with a web3.eth.contract instance of the rocketDAONodeTrustedSettingsProposals contract 23 | */ 24 | private get rocketDAONodeTrustedSettingsProposals(): Promise { 25 | return this.contracts.get("rocketDAONodeTrustedSettingsProposals"); 26 | } 27 | 28 | /** 29 | * Private accessor use to retrieve the related contract 30 | * @returns a Promise with a web3.eth.contract instance of the rocketDAONodeTrustedSettingsMembers contract 31 | */ 32 | private get rocketDAONodeTrustedSettingsMembers(): Promise { 33 | return this.contracts.get("rocketDAONodeTrustedSettingsMembers"); 34 | } 35 | 36 | /** 37 | * Private accessor use to retrieve the related contract 38 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsDeposit contract 39 | */ 40 | private get rocketDAOProtocolSettingsDeposit(): Promise { 41 | return this.contracts.get("rocketDAOProtocolSettingsDeposit"); 42 | } 43 | 44 | /** 45 | * Private accessor use to retrieve the related contract 46 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsMinipool contract 47 | */ 48 | private get rocketDAOProtocolSettingsMinipool(): Promise { 49 | return this.contracts.get("rocketDAOProtocolSettingsMinipool"); 50 | } 51 | 52 | /** 53 | * Get the maximum deposit assignments 54 | * @returns a Promise that resolves to a string representing the maximum deposit assignments 55 | * 56 | * @example using Typescript 57 | * ```ts 58 | * const maxDepositsAssignments = rp.dao.node.trusted.getMaximumDepositAssignments().then((val: string) => { val }; 59 | * ``` 60 | */ 61 | public getMaximumDepositAssignments(): Promise { 62 | return this.rocketDAOProtocolSettingsDeposit.then((rocketDAOProtocolSettingsDeposit: Contract): Promise => { 63 | return rocketDAOProtocolSettingsDeposit.methods.getMaximumDepositAssignments().call(); 64 | }); 65 | } 66 | 67 | /** 68 | * Get the cost of a challenge (How much it costs a non-member to challenge a members node. It's free for current members to challenge other members.) 69 | * @returns a Promise that resolves to a string representing the inflation intervals that have passed (in time) 70 | * 71 | * @example using Typescript 72 | * ```ts 73 | * const maxDepositsAssignments = rp.dao.node.trusted.getMaximumDepositAssignments().then((val: string) => { val }; 74 | * ``` 75 | */ 76 | public getChallengeCost(): Promise { 77 | return this.rocketDAONodeTrustedSettingsMembers.then((rocketDAONodeTrustedSettingsMembers: Contract): Promise => { 78 | return rocketDAONodeTrustedSettingsMembers.methods.getChallengeCost().call(); 79 | }); 80 | } 81 | } 82 | 83 | // Exports 84 | export default DAONodeTrustedSettings; 85 | -------------------------------------------------------------------------------- /dist/rocketpool/tokens/rpl.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { TransactionReceipt } from "web3-core"; 3 | import { SendOptions } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | import { ConfirmationHandler } from "../../utils/transaction"; 6 | import ERC20 from "./erc20"; 7 | /** 8 | * Rocket Pool RPL Token Manager 9 | */ 10 | declare class RPL extends ERC20 { 11 | /** 12 | * Create a new RPL instance. 13 | * 14 | * @param web3 A valid Web3 instance 15 | * @param contracts A Rocket Pool contract manager instance 16 | */ 17 | constructor(web3: Web3, contracts: Contracts); 18 | /** 19 | * Get the contract address 20 | * @returns a Promise that resolves to a string representing the contract address of the token 21 | * 22 | * @example using Typescript 23 | * ```ts 24 | * const address = rp.tokens.rpl.getAddress().then((val: string) => { val }; 25 | * ``` 26 | */ 27 | getAddress(): Promise; 28 | /** 29 | * Get the inflation intervals that have passed 30 | * @returns a Promise that resolves to a number representing the inflation intervals that have passed (in time) 31 | * 32 | * @example using Typescript 33 | * ```ts 34 | * const address = rp.tokens.rpl.getInflationIntervalsPassed().then((val: number) => { val }; 35 | * ``` 36 | */ 37 | getInflationIntervalsPassed(): Promise; 38 | /** 39 | * Get the total supply 40 | * @returns a Promise that resolves to a number representing the total supply 41 | * 42 | * @example using Typescript 43 | * ```ts 44 | * const address = rp.tokens.rpl.totalSupply().then((val: number) => { val }; 45 | * ``` 46 | */ 47 | totalSupply(): Promise; 48 | /** 49 | * Swap current RPL fixed supply tokens for new RPL 50 | * @param amountWei A string representing the amount to swap in Wei 51 | * @param options An optional object of web3.eth.Contract SendOptions 52 | * @param onConfirmation An optional confirmation handler object 53 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 54 | * 55 | * @example using Typescript 56 | * ```ts 57 | * const toAddress = "0x421433c3f99529A704Ec2270E1A68fa66DD8bD79"; 58 | * const amountWei = web3.utils.toWei("20", "ether"); 59 | * const options = { 60 | * from: fromAddress, 61 | * gas: 1000000 62 | * }; 63 | * const txReceipt = rp.tokens.rpl.swapTokens(amountWei, options).then((txReceipt: TransactionReceipt) => { txReceipt }; 64 | * ``` 65 | */ 66 | swapTokens(amountWei: any, options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise; 67 | /** 68 | * Inflation mint tokens 69 | * @param options An optional object of web3.eth.Contract SendOptions 70 | * @param onConfirmation An optional confirmation handler object 71 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 72 | * 73 | * @example using Typescript 74 | * ```ts 75 | * const toAddress = "0x421433c3f99529A704Ec2270E1A68fa66DD8bD79"; 76 | * const options = { 77 | * from: toAddress, 78 | * gas: 1000000 79 | * }; 80 | * const txReceipt = rp.tokens.rpl.inflationMintTokens(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 81 | * ``` 82 | */ 83 | inflationMintTokens(options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise; 84 | } 85 | export default RPL; 86 | -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-node.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | var _transaction = require("../../utils/transaction"); 10 | 11 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 12 | 13 | /** 14 | * Rocket Pool Rewards 15 | */ 16 | var Rewards = function () { 17 | /** 18 | * Create a new Rewards instance. 19 | * 20 | * @param web3 A valid Web3 instance 21 | * @param contracts A Rocket Pool contract manager instance 22 | */ 23 | function Rewards(web3, contracts) { 24 | _classCallCheck(this, Rewards); 25 | 26 | this.web3 = web3; 27 | this.contracts = contracts; 28 | } 29 | /** 30 | * Private accessor use to retrieve the related contract 31 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimNode contract 32 | */ 33 | 34 | 35 | _createClass(Rewards, [{ 36 | key: "getClaimPossible", 37 | 38 | /** 39 | * Determine if the claim is possible 40 | * @params address a string representing the node address 41 | * @returns a Promise that resolves to a boolean representing if a claim is possible 42 | * 43 | * @example using Typescript 44 | * ```ts 45 | * const address = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 46 | * const claimPossible = rp.rewards.claimNode.getClaimPossible(address).then((val: bool) => { val }; 47 | * ``` 48 | */ 49 | value: function getClaimPossible(address) { 50 | return this.rocketClaimNode.then(function (rocketClaimNode) { 51 | return rocketClaimNode.methods.getClaimPossible(address).call(); 52 | }); 53 | } 54 | /** 55 | * Make a node claim 56 | * @param options An optional object of web3.eth.Contract SendOptions 57 | * @param onConfirmation An optional confirmation handler object 58 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 59 | * 60 | * @example using Typescript 61 | * ```ts 62 | * const nodeAddress = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 63 | * const options = { 64 | * from: nodeAddress, 65 | * gas: 1000000 66 | * }; 67 | * const txReceipt = rp.rewards.claimNode(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 68 | * ``` 69 | */ 70 | 71 | }, { 72 | key: "claim", 73 | value: function claim(options, onConfirmation) { 74 | return this.rocketClaimNode.then(function (rocketClaimNode) { 75 | return (0, _transaction.handleConfirmations)(rocketClaimNode.methods.claim().send(options), onConfirmation); 76 | }); 77 | } 78 | }, { 79 | key: "rocketClaimNode", 80 | get: function get() { 81 | return this.contracts.get("rocketClaimNode"); 82 | } 83 | }]); 84 | 85 | return Rewards; 86 | }(); 87 | // Exports 88 | 89 | 90 | exports.default = Rewards; 91 | //# sourceMappingURL=claim-node.js.map -------------------------------------------------------------------------------- /src/test/network/scenario-submit-prices.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Submit network prices 8 | export async function submitPrices(web3: Web3, rp: RocketPool, block: number, rplPrice: string, options: SendOptions) { 9 | // Load contracts 10 | const rocketDAONodeTrusted = await rp.contracts.get("rocketDAONodeTrusted"); 11 | const rocketStorage = await rp.contracts.get("rocketStorage"); 12 | 13 | // Get parameters 14 | const trustedNodeCount = await rocketDAONodeTrusted.methods 15 | .getMemberCount() 16 | .call() 17 | .then((value: any) => web3.utils.toBN(value)); 18 | 19 | // Get submission keys 20 | const nodeSubmissionKey = web3.utils.soliditySha3("network.prices.submitted.node.key", options.from, block, rplPrice, web3.utils.toBN("0")); 21 | const submissionCountKey = web3.utils.soliditySha3("network.prices.submitted.count", block, rplPrice, web3.utils.toBN("0")); 22 | 23 | // Get submission details 24 | function getSubmissionDetails() { 25 | return Promise.all([ 26 | rocketStorage.methods.getBool(nodeSubmissionKey).call(), 27 | rocketStorage.methods 28 | .getUint(submissionCountKey) 29 | .call() 30 | .then((value: any) => web3.utils.toBN(value)), 31 | ]).then(([nodeSubmitted, count]) => ({ nodeSubmitted, count })); 32 | } 33 | 34 | // Get prices 35 | function getPrices() { 36 | return Promise.all([ 37 | rp.network.getPricesBlock().then((value: any) => web3.utils.toBN(value)), 38 | rp.network.getRPLPrice().then((value: any) => web3.utils.toBN(value)), 39 | ]).then(([block, rplPrice]) => ({ 40 | block, 41 | rplPrice, 42 | })); 43 | } 44 | 45 | // Get initial submission details 46 | const submission1 = await getSubmissionDetails(); 47 | 48 | // Submit prices 49 | await rp.network.submitPrices(block, rplPrice, "0", options); 50 | 51 | // Get updated submission details & prices 52 | const [submission2, prices] = await Promise.all([getSubmissionDetails(), getPrices()]); 53 | 54 | // Check if prices should be updated 55 | const expectUpdatedPrices = submission2.count.mul(web3.utils.toBN(2)).gt(trustedNodeCount); 56 | 57 | // Check submission details 58 | assert.isFalse(submission1.nodeSubmitted, "Incorrect initial node submitted status"); 59 | assert.isTrue(submission2.nodeSubmitted, "Incorrect updated node submitted status"); 60 | assert(submission2.count.eq(submission1.count.add(web3.utils.toBN(1))), "Incorrect updated submission count"); 61 | 62 | // Check prices 63 | if (expectUpdatedPrices) { 64 | assert(prices.block.eq(web3.utils.toBN(block)), "Incorrect updated network prices block"); 65 | assert(prices.rplPrice.eq(web3.utils.toBN(rplPrice)), "Incorrect updated network RPL price"); 66 | } else { 67 | assert(!prices.block.eq(web3.utils.toBN(block)), "Incorrectly updated network prices block"); 68 | assert(!prices.rplPrice.eq(web3.utils.toBN(rplPrice)), "Incorrectly updated network RPL price"); 69 | } 70 | } 71 | 72 | // Execute price update 73 | export async function executeUpdatePrices(web3: Web3, rp: RocketPool, block: number, rplPrice: string, options: SendOptions) { 74 | // Get prices 75 | function getPrices() { 76 | return Promise.all([ 77 | rp.network.getPricesBlock().then((value: any) => web3.utils.toBN(value)), 78 | rp.network.getRPLPrice().then((value: any) => web3.utils.toBN(value)), 79 | ]).then(([block, rplPrice]) => ({ 80 | block, 81 | rplPrice, 82 | })); 83 | } 84 | 85 | // Submit prices 86 | await rp.network.executeUpdatePrices(block, rplPrice, "0", options); 87 | 88 | // Get updated submission details & prices 89 | const prices = await getPrices(); 90 | 91 | // Check the prices 92 | assert(prices.block.eq(web3.utils.toBN(block)), "Incorrect updated network prices block"); 93 | assert(prices.rplPrice.eq(web3.utils.toBN(rplPrice)), "Incorrect updated network RPL price"); 94 | } 95 | -------------------------------------------------------------------------------- /dist/rocketpool/rewards/claim-trusted-node.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | var _transaction = require("../../utils/transaction"); 10 | 11 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 12 | 13 | /** 14 | * Rocket Pool Rewards 15 | */ 16 | var Rewards = function () { 17 | /** 18 | * Create a new Rewards instance. 19 | * 20 | * @param web3 A valid Web3 instance 21 | * @param contracts A Rocket Pool contract manager instance 22 | */ 23 | function Rewards(web3, contracts) { 24 | _classCallCheck(this, Rewards); 25 | 26 | this.web3 = web3; 27 | this.contracts = contracts; 28 | } 29 | /** 30 | * Private accessor use to retrieve the related contract 31 | * @returns a Promise with a web3.eth.contract instance of the rocketClaimTrustedNode contract 32 | */ 33 | 34 | 35 | _createClass(Rewards, [{ 36 | key: "getClaimRewardsAmount", 37 | 38 | /** 39 | * Get claim rewards amount 40 | * @params address a string representing the node address 41 | * @returns a Promise that resolves to a string representing the claim rewards amount in Wei 42 | * 43 | * @example using Typescript 44 | * ```ts 45 | * const address = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 46 | * const claimPossible = rp.rewards.claimTrustedNode.getClaimRewardsAmount(address).then((val: string) => { val }; 47 | * ``` 48 | */ 49 | value: function getClaimRewardsAmount(address) { 50 | return this.rocketClaimTrustedNode.then(function (rocketClaimTrustedNode) { 51 | return rocketClaimTrustedNode.methods.getClaimRewardsAmount(address).call(); 52 | }); 53 | } 54 | /** 55 | * Claim from a trusted node 56 | * @param options An optional object of web3.eth.Contract SendOptions 57 | * @param onConfirmation An optional confirmation handler object 58 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 59 | * 60 | * @example using Typescript 61 | * ```ts 62 | * const trustedNode = "0x421433c3f99529A704Ec2270E1A68fa66DD8bD79"; 63 | * const options = { 64 | * from: trustedNode, 65 | * gas: 1000000 66 | * }; 67 | * const txReceipt = rp.rewards.claimTrustedNode(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 68 | * ``` 69 | */ 70 | 71 | }, { 72 | key: "claim", 73 | value: function claim(options, onConfirmation) { 74 | return this.rocketClaimTrustedNode.then(function (rocketClaimTrustedNode) { 75 | return (0, _transaction.handleConfirmations)(rocketClaimTrustedNode.methods.claim().send(options), onConfirmation); 76 | }); 77 | } 78 | }, { 79 | key: "rocketClaimTrustedNode", 80 | get: function get() { 81 | return this.contracts.get("rocketClaimTrustedNode"); 82 | } 83 | }]); 84 | 85 | return Rewards; 86 | }(); 87 | // Exports 88 | 89 | 90 | exports.default = Rewards; 91 | //# sourceMappingURL=claim-trusted-node.js.map -------------------------------------------------------------------------------- /src/test/minipool/scenario-scrub.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | import MinipoolContract from "../../rocketpool/minipool/minipool-contract"; 7 | 8 | // Scrub a minipool 9 | export async function voteScrub(web3: Web3, rp: RocketPool, minipool: MinipoolContract, options: SendOptions) { 10 | // Get minipool owner 11 | const nodeAddress = await minipool.getNodeAddress(); 12 | // Get contracts 13 | const rocketVault = await rp.contracts.get("rocketVault"); 14 | const rocketTokenRPL = await rp.contracts.get("rocketTokenRPL"); 15 | const rocketDAONodeTrustedSettingsMinipool = await rp.contracts.get("rocketDAONodeTrustedSettingsMinipool"); 16 | const rocketDAOProtocolSettingsNode = await rp.contracts.get("rocketDAOProtocolSettingsNode"); 17 | 18 | // Get minipool details 19 | function getMinipoolDetails() { 20 | return Promise.all([ 21 | minipool.getStatus().then((value: any) => web3.utils.toBN(value)), 22 | minipool.getUserDepositBalance().then((value: any) => web3.utils.toBN(value)), 23 | minipool.getTotalScrubVotes().then((value: any) => web3.utils.toBN(value)), 24 | rp.node.getNodeRPLStake(nodeAddress).then((value: any) => web3.utils.toBN(value)), 25 | rocketVault.methods 26 | .balanceOfToken("rocketAuctionManager", rocketTokenRPL.options.address) 27 | .call() 28 | .then((value: any) => web3.utils.toBN(value)), 29 | rocketDAONodeTrustedSettingsMinipool.methods.getScrubPenaltyEnabled().call(), 30 | ]).then(([status, userDepositBalance, votes, nodeRPLStake, auctionBalance, penaltyEnabled]) => ({ 31 | status, 32 | userDepositBalance, 33 | votes, 34 | nodeRPLStake, 35 | auctionBalance, 36 | penaltyEnabled, 37 | })); 38 | } 39 | 40 | // Get initial minipool details 41 | const details1 = await getMinipoolDetails(); 42 | 43 | // Dissolve 44 | await minipool.voteScrub(options); 45 | 46 | // Get updated minipool details 47 | const details2 = await getMinipoolDetails(); 48 | 49 | // Get member count 50 | const memberCount = web3.utils.toBN(await rp.dao.node.trusted.node.getMemberCount()); 51 | const quorum = memberCount.div(web3.utils.toBN(2)); 52 | 53 | // Check state 54 | const dissolved = web3.utils.toBN(4); 55 | if (details1.votes.add(web3.utils.toBN(1)).gt(quorum)) { 56 | assert(details2.status.eq(dissolved), "Incorrect updated minipool status"); 57 | assert(details2.userDepositBalance.eq(web3.utils.toBN(0)), "Incorrect updated minipool user deposit balance"); 58 | // Check slashing if penalties are enabled 59 | if (details1.penaltyEnabled) { 60 | // Calculate amount slashed 61 | const slashAmount = details1.nodeRPLStake.sub(details2.nodeRPLStake); 62 | // Get current RPL price 63 | 64 | const rplPrice = await rp.network.getRPLPrice().then((value: any) => web3.utils.toBN(value)); 65 | // Calculate amount slashed in ETH 66 | const slashAmountEth = slashAmount.mul(rplPrice).div(web3.utils.toBN(web3.utils.toWei("1", "ether"))); 67 | // Calculate expected slash amount 68 | const minimumStake = await rocketDAOProtocolSettingsNode.methods 69 | .getMinimumPerMinipoolStake() 70 | .call() 71 | .then((value: any) => web3.utils.toBN(value)); 72 | const expectedSlash = web3.utils 73 | .toBN(web3.utils.toWei("16", "ether")) 74 | .mul(minimumStake) 75 | .div(web3.utils.toBN(web3.utils.toWei("1", "ether"))); 76 | // Perform checks 77 | assert(slashAmountEth.eq(expectedSlash), "Amount of RPL slashed is incorrect"); 78 | assert(details2.auctionBalance.sub(details1.auctionBalance).eq(slashAmount), "RPL was not sent to auction manager"); 79 | } 80 | } else { 81 | assert(details2.votes.sub(details1.votes).eq(web3.utils.toBN(1)), "Vote count not incremented"); 82 | assert(!details2.status.eq(dissolved), "Incorrect updated minipool status"); 83 | assert(details2.nodeRPLStake.eq(details1.nodeRPLStake), "RPL was slashed"); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /dist/rocketpool/deposit/deposit.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { TransactionReceipt } from "web3-core"; 3 | import { SendOptions } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | import { ConfirmationHandler } from "../../utils/transaction"; 6 | /** 7 | * Rocket Pool Deposit Pool Manager 8 | */ 9 | declare class Deposit { 10 | private web3; 11 | private contracts; 12 | /** 13 | * Create a new Deposit instance. 14 | * 15 | * @param web3 A valid Web3 instance 16 | * @param contracts A Rocket Pool contract manager instance 17 | */ 18 | constructor(web3: Web3, contracts: Contracts); 19 | /** 20 | * Private accessor use to retrieve the related contract 21 | * @returns a Promise with a web3.eth.contract instance of the rocketDepositPool contract 22 | */ 23 | private get rocketDepositPool(); 24 | /** 25 | * Get the current deposit pool balance in Wei 26 | * @returns a Promise that resolves to a string representing the current deposit pool balance in Wei 27 | * 28 | * @example using Typescript 29 | * ```ts 30 | * const balanceInWei = rp.deposit.getBalance().then((val: string) => { val }; 31 | * // convert to Ether if needed 32 | * const balanceInEth = web3.utils.fromWei(balanceInWei, 'ether') 33 | * ``` 34 | */ 35 | getBalance(): Promise; 36 | /** 37 | * Get the excess balance in Wei 38 | * @returns a Promise that resolves to a string representing the current excess balance in Wei 39 | * 40 | * @example using Typescript 41 | * ```ts 42 | * const balanceInWei = rp.deposit.getExcessBalance().then((val: string) => { val }; 43 | * // convert to Ether if needed 44 | * const balanceInEth = web3.utils.fromWei(balanceInWei, 'ether') 45 | * ``` 46 | */ 47 | getExcessBalance(): Promise; 48 | /** 49 | * Get the block of the last user deposit 50 | * @returns a Promise that resolves to a number representing the block of the last user deposit 51 | * 52 | * @example using Typescript 53 | * ```ts 54 | * const block = rp.deposit.getUserLastDepositBlock().then((val: number) => { val }; 55 | * ``` 56 | */ 57 | getUserLastDepositBlock(address: string): Promise; 58 | /** 59 | * Make a deposit 60 | * @param options An optional object of web3.eth.Contract SendOptions 61 | * @param onConfirmation An optional confirmation handler object 62 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 63 | * 64 | * @example using Typescript 65 | * ```ts 66 | * const nodeAddress = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 67 | * const options = { 68 | * from: nodeAddress, 69 | * value: web3.utils.toWei("10", "ether"), 70 | * gas: 1000000 71 | * } 72 | * const txReceipt = rp.deposit.deposit(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 73 | * ``` 74 | */ 75 | deposit(options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise; 76 | /** 77 | * Assign Deposits 78 | * @param options An optional object of web3.eth.Contract SendOptions 79 | * @param onConfirmation An optional confirmation handler object 80 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 81 | * 82 | * @example using Typescript 83 | * ```ts 84 | * const nodeAddress = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 85 | * const options = { 86 | * from: nodeAddress, 87 | * gas: 1000000 88 | * } 89 | * const txReceipt = rp.deposit.assignDeposits(options).then((txReceipt: TransactionReceipt) => { txReceipt }; 90 | * ``` 91 | */ 92 | assignDeposits(options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise; 93 | } 94 | export default Deposit; 95 | -------------------------------------------------------------------------------- /src/test/deposit/scenario-assign-deposits.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Assign deposits 8 | export async function assignDeposits(web3: Web3, rp: RocketPool, options: SendOptions) { 9 | // Load contracts 10 | const rocketDAOProtocolSettingsDeposit = await rp.contracts.get("rocketDAOProtocolSettingsDeposit"); 11 | const rocketDAOProtocolSettingsMinipool = await rp.contracts.get("rocketDAOProtocolSettingsMinipool"); 12 | const rocketVault = await rp.contracts.get("rocketVault"); 13 | 14 | // Get parameters 15 | const [ 16 | depositPoolBalance, 17 | maxDepositAssignments, 18 | fullMinipoolQueueLength, 19 | halfMinipoolQueueLength, 20 | emptyMinipoolQueueLength, 21 | fullDepositUserAmount, 22 | halfDepositUserAmount, 23 | emptyDepositUserAmount, 24 | ] = await Promise.all([ 25 | rp.deposit.getBalance(), 26 | rocketDAOProtocolSettingsDeposit.methods.getMaximumDepositAssignments().call(), 27 | rp.minipool.getQueueLength(1), 28 | rp.minipool.getQueueLength(2), 29 | rp.minipool.getQueueLength(3), 30 | rocketDAOProtocolSettingsMinipool.methods.getDepositUserAmount(1).call(), 31 | rocketDAOProtocolSettingsMinipool.methods.getDepositUserAmount(2).call(), 32 | rocketDAOProtocolSettingsMinipool.methods.getDepositUserAmount(3).call(), 33 | ]); 34 | 35 | // Get queued minipool capacities 36 | const minipoolCapacities = []; 37 | for (let i = 0; i < halfMinipoolQueueLength; ++i) minipoolCapacities.push(halfDepositUserAmount); 38 | for (let i = 0; i < fullMinipoolQueueLength; ++i) minipoolCapacities.push(fullDepositUserAmount); 39 | for (let i = 0; i < emptyMinipoolQueueLength; ++i) minipoolCapacities.push(emptyDepositUserAmount); 40 | 41 | // Get expected deposit assignment parameters 42 | let expectedDepositAssignments = 0; 43 | let expectedEthAssigned = web3.utils.toBN(0); 44 | let depositBalanceRemaining = web3.utils.toBN(depositPoolBalance); 45 | const depositAssignmentsRemaining = web3.utils.toBN(maxDepositAssignments); 46 | while (minipoolCapacities.length > 0 && depositBalanceRemaining.gte(minipoolCapacities[0]) && depositAssignmentsRemaining.gt(web3.utils.toBN(0))) { 47 | const capacity = web3.utils.toBN(minipoolCapacities.shift()); 48 | ++expectedDepositAssignments; 49 | expectedEthAssigned = expectedEthAssigned.add(capacity); 50 | depositBalanceRemaining = depositBalanceRemaining.sub(capacity); 51 | depositAssignmentsRemaining.sub(depositAssignmentsRemaining); 52 | } 53 | 54 | // Get balances 55 | function getBalances() { 56 | return Promise.all([ 57 | rp.deposit.getBalance().then((value: any) => web3.utils.toBN(value)), 58 | web3.eth.getBalance(rocketVault.options.address).then((value: any) => web3.utils.toBN(value)), 59 | ]).then(([depositPoolEth, vaultEth]) => ({ depositPoolEth, vaultEth })); 60 | } 61 | 62 | // Get minipool queue details 63 | function getMinipoolQueueDetails() { 64 | return Promise.all([ 65 | rp.minipool.getQueueTotalLength().then((value: any) => web3.utils.toBN(value)), 66 | rp.minipool.getQueueTotalCapacity().then((value: any) => web3.utils.toBN(value)), 67 | ]).then(([totalLength, totalCapacity]) => ({ totalLength, totalCapacity })); 68 | } 69 | 70 | // Get initial balances & minipool queue details 71 | const [balances1, queue1] = await Promise.all([getBalances(), getMinipoolQueueDetails()]); 72 | 73 | // Assign deposits 74 | await rp.deposit.assignDeposits(options); 75 | 76 | // Get updated balances & minipool queue details 77 | const [balances2, queue2] = await Promise.all([getBalances(), getMinipoolQueueDetails()]); 78 | 79 | // Check balances 80 | assert(balances2.depositPoolEth.eq(balances1.depositPoolEth.sub(expectedEthAssigned)), "Incorrect updated deposit pool ETH balance"); 81 | assert(balances2.vaultEth.eq(balances1.vaultEth.sub(expectedEthAssigned)), "Incorrect updated vault ETH balance"); 82 | 83 | // Check minipool queues 84 | assert(queue2.totalLength.eq(queue1.totalLength.sub(web3.utils.toBN(expectedDepositAssignments))), "Incorrect updated minipool queue length"); 85 | assert(queue2.totalCapacity.eq(queue1.totalCapacity.sub(expectedEthAssigned)), "Incorrect updated minipool queue capacity"); 86 | } 87 | -------------------------------------------------------------------------------- /src/rocketpool/settings/deposit.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import Web3 from "web3"; 3 | import { Contract } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | 6 | /** 7 | * Rocket Pool Deposit Settings Manager 8 | */ 9 | class DepositSettings { 10 | /** 11 | * Create a new Deposit Settings instance. 12 | * 13 | * @param web3 A valid Web3 instance 14 | * @param contracts A Rocket Pool contract manager instance 15 | */ 16 | public constructor(private web3: Web3, private contracts: Contracts) {} 17 | 18 | /** 19 | * Private accessor use to retrieve the related contract 20 | * @returns a Promise with a web3.eth.contract instance of the rocketDAOProtocolSettingsDeposit contract 21 | */ 22 | private get rocketDAOProtocolSettingsDeposit(): Promise { 23 | return this.contracts.get("rocketDAOProtocolSettingsDeposit"); 24 | } 25 | 26 | /** 27 | * Check to see if deposits are enabled 28 | * @returns a Promise that resolves to a boolean representing if deposits are enabled 29 | * 30 | * @example using Typescript 31 | * ```ts 32 | * const enabled = rp.settings.deposit.getDepositsEnabled().then((val: boolean) => { val }; 33 | * ``` 34 | */ 35 | public getDepositEnabled(): Promise { 36 | return this.rocketDAOProtocolSettingsDeposit.then((rocketDAOProtocolSettingsDeposit: Contract): Promise => { 37 | return rocketDAOProtocolSettingsDeposit.methods.getDepositEnabled().call(); 38 | }); 39 | } 40 | 41 | /** 42 | * Check to see if deposit assignments are enabled 43 | * @returns a Promise that resolves to a boolean representing if deposit assignments are enabled 44 | * 45 | * @example using Typescript 46 | * ```ts 47 | * const enabled = rp.settings.deposit.getAssignDepositsEnabled().then((val: boolean) => { val }; 48 | * ``` 49 | */ 50 | public getAssignDepositsEnabled(): Promise { 51 | return this.rocketDAOProtocolSettingsDeposit.then((rocketDAOProtocolSettingsDeposit: Contract): Promise => { 52 | return rocketDAOProtocolSettingsDeposit.methods.getAssignDepositsEnabled().call(); 53 | }); 54 | } 55 | 56 | /** 57 | * Return the minimum deposit amount setting in wei 58 | * @returns a Promise that resolves to a string representing the minimum deposit amount setting 59 | * 60 | * @example using Typescript 61 | * ```ts 62 | * const minimumDeposit = rp.settings.deposit.getMinimumDeposit().then((val: string) => { val }; 63 | * ``` 64 | */ 65 | public getMinimumDeposit(): Promise { 66 | return this.rocketDAOProtocolSettingsDeposit.then((rocketDAOProtocolSettingsDeposit: Contract): Promise => { 67 | return rocketDAOProtocolSettingsDeposit.methods.getMinimumDeposit().call(); 68 | }); 69 | } 70 | 71 | /** 72 | * Return the maximum deposit pool size setting in Wei 73 | * @returns a Promise that resolves to a string representing the maximum deposit pool size setting 74 | * 75 | * @example using Typescript 76 | * ```ts 77 | * const maximumDepositPoolSize = rp.settings.deposit.getMaximumDepositPoolSize().then((val: string) => { val }; 78 | * ``` 79 | */ 80 | public getMaximumDepositPoolSize(): Promise { 81 | return this.rocketDAOProtocolSettingsDeposit.then((rocketDAOProtocolSettingsDeposit: Contract): Promise => { 82 | return rocketDAOProtocolSettingsDeposit.methods.getMaximumDepositPoolSize().call(); 83 | }); 84 | } 85 | 86 | /** 87 | * Return the maximum number of deposit assignments to perform at once 88 | * @returns a Promise that resolves to a number representing the maximum number of deposit assignments to perform at once 89 | * 90 | * @example using Typescript 91 | * ```ts 92 | * const maxDepositAssignments = rp.settings.deposit.getMaximumDepositAssignments().then((val: string) => { val }; 93 | * ``` 94 | */ 95 | public getMaximumDepositAssignments(): Promise { 96 | return this.rocketDAOProtocolSettingsDeposit 97 | .then((rocketDAOProtocolSettingsDeposit: Contract): Promise => { 98 | return rocketDAOProtocolSettingsDeposit.methods.getMaximumDepositAssignments().call(); 99 | }) 100 | .then((value: string): number => parseInt(value)); 101 | } 102 | } 103 | 104 | // Exports 105 | export default DepositSettings; 106 | -------------------------------------------------------------------------------- /src/test/rewards/scenario-rewards-claim-dao.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import { SendOptions } from "web3-eth-contract"; 5 | import RocketPool from "../../rocketpool/rocketpool"; 6 | 7 | // Set the address the DAO can receive rewards at 8 | export async function getRewardsDAOTreasuryBalance(web3: Web3, rp: RocketPool, options: SendOptions) { 9 | const rocketTokenRPLAddress = await rp.tokens.rpl.getAddress(); 10 | return rp.vault.balanceOfToken("rocketClaimDAO", rocketTokenRPLAddress); 11 | } 12 | 13 | // Set the address the DAO can receive rewards at 14 | export async function rewardsClaimDAO(web3: Web3, rp: RocketPool, options: SendOptions) { 15 | // Get the RPL token contract address 16 | const rocketTokenRPLAddress = await rp.tokens.rpl.getAddress(); 17 | 18 | // Call the mint function on RPL to mint any before we begin so we have accurate figures to work with 19 | if ((await rp.tokens.rpl.getInflationIntervalsPassed()) > 0) { 20 | await rp.tokens.rpl.inflationMintTokens(options); 21 | } 22 | 23 | // Get data about the tx 24 | function getTxData() { 25 | return Promise.all([ 26 | rp.rewards.pool.getClaimIntervalsPassed().then((value: any) => web3.utils.toBN(value)), 27 | rp.rewards.pool.getClaimIntervalTimeStart().then((value: any) => web3.utils.toBN(value)), 28 | rp.rewards.pool.getRPLBalance().then((value: any) => web3.utils.toBN(value)), 29 | rp.rewards.pool.getClaimingContractPerc("rocketClaimDAO").then((value: any) => web3.utils.toBN(value)), 30 | rp.rewards.pool.getClaimingContractAllowance("rocketClaimDAO").then((value: any) => web3.utils.toBN(value)), 31 | rp.rewards.pool.getClaimingContractTotalClaimed("rocketClaimDAO").then((value: any) => web3.utils.toBN(value)), 32 | rp.rewards.pool.getClaimIntervalRewardsTotal().then((value: any) => web3.utils.toBN(value)), 33 | rp.vault.balanceOfToken("rocketClaimDAO", rocketTokenRPLAddress).then((value: any) => web3.utils.toBN(value)), 34 | ]).then( 35 | ([ 36 | intervalsPassed, 37 | intervalTimeStart, 38 | poolRPLBalance, 39 | daoClaimPerc, 40 | daoClaimAllowance, 41 | daoContractClaimTotal, 42 | intervalRewardsTotal, 43 | daoRewardsAddressBalance, 44 | ]) => ({ 45 | intervalsPassed, 46 | intervalTimeStart, 47 | poolRPLBalance, 48 | daoClaimPerc, 49 | daoClaimAllowance, 50 | daoContractClaimTotal, 51 | intervalRewardsTotal, 52 | daoRewardsAddressBalance, 53 | }) 54 | ); 55 | } 56 | 57 | // Capture data 58 | const ds1 = await getTxData(); 59 | 60 | // Perform tx 61 | await rp.rewards.claimTrustedNode.claim(options); 62 | 63 | // Capture data 64 | const ds2 = await getTxData(); 65 | 66 | //console.log(Number(ds1.intervalsPassed), Number(ds1.intervalTimeStart), Number(web3.utils.fromWei(ds1.daoClaimAllowance)).toFixed(4), Number(web3.utils.fromWei(ds1.daoClaimPerc)), (Number(web3.utils.fromWei(ds1.daoClaimPerc)) * Number(web3.utils.fromWei((ds1.intervalRewardsTotal)))).toFixed(4)); 67 | //console.log(Number(ds2.intervalsPassed), Number(ds2.intervalTimeStart), Number(web3.utils.fromWei(ds2.daoClaimAllowance)).toFixed(4), Number(web3.utils.fromWei(ds2.daoClaimPerc)), (Number(web3.utils.fromWei(ds2.daoClaimPerc)) * Number(web3.utils.fromWei((ds2.intervalRewardsTotal)))).toFixed(4)); 68 | 69 | // Verify the claim allowance is correct 70 | assert( 71 | Number(web3.utils.fromWei(ds2.daoClaimAllowance)).toFixed(4) == 72 | Number(Number(web3.utils.fromWei(ds2.daoClaimPerc)) * Number(web3.utils.fromWei(ds2.intervalRewardsTotal))).toFixed(4), 73 | "Contract claim amount total does not equal the expected claim amount" 74 | ); 75 | // Should be 1 collect per interval 76 | assert(ds2.daoContractClaimTotal.eq(ds2.daoClaimAllowance), "Amount claimed exceeds allowance for interval"); 77 | // Now test various outcomes depending on if a claim interval happened or not 78 | if (Number(ds1.intervalTimeStart) < Number(ds2.intervalTimeStart)) { 79 | // Dao can only receive rewards on the first claim of a claim period 80 | assert( 81 | ds2.daoRewardsAddressBalance.eq(ds1.daoRewardsAddressBalance.add(ds2.daoContractClaimTotal)), 82 | "DAO rewards address does not contain the correct balance" 83 | ); 84 | } else { 85 | // Claim interval has not passed, dao should not have claimed anything 86 | assert(ds2.daoRewardsAddressBalance.eq(ds1.daoRewardsAddressBalance), "DAO rewards address balance has changed on same interval claim"); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/test/auction/scenario-place-bid.ts: -------------------------------------------------------------------------------- 1 | // Imports 2 | import { assert } from "chai"; 3 | import Web3 from "web3"; 4 | import RocketPool from "../../rocketpool/rocketpool"; 5 | import { SendOptions } from "web3-eth-contract"; 6 | 7 | // Place a bid on a lot 8 | export async function placeBid(web3: Web3, rp: RocketPool, lotIndex: number, options: SendOptions) { 9 | // Load contracts 10 | const rocketVault = await rp.contracts.get("rocketVault"); 11 | 12 | // Calculation base value 13 | const calcBase = web3.utils.toBN(web3.utils.toWei("1", "ether")); 14 | 15 | // Get lot details 16 | function getLotDetails(bidderAddress: string) { 17 | return Promise.all([ 18 | rp.auction.getLotTotalRPLAmount(lotIndex).then((value: any) => web3.utils.toBN(value)), 19 | rp.auction.getLotTotalBidAmount(lotIndex).then((value: any) => web3.utils.toBN(value)), 20 | rp.auction.getLotAddressBidAmount(lotIndex, bidderAddress).then((value: any) => web3.utils.toBN(value)), 21 | rp.auction.getLotPriceByTotalBids(lotIndex).then((value: any) => web3.utils.toBN(value)), 22 | rp.auction.getLotCurrentPrice(lotIndex).then((value: any) => web3.utils.toBN(value)), 23 | rp.auction.getLotClaimedRPLAmount(lotIndex).then((value: any) => web3.utils.toBN(value)), 24 | rp.auction.getLotRemainingRPLAmount(lotIndex).then((value: any) => web3.utils.toBN(value)), 25 | ]).then(([totalRplAmount, totalBidAmount, addressBidAmount, priceByTotalBids, currentPrice, claimedRplAmount, remainingRplAmount]) => ({ 26 | totalRplAmount, 27 | totalBidAmount, 28 | addressBidAmount, 29 | priceByTotalBids, 30 | currentPrice, 31 | claimedRplAmount, 32 | remainingRplAmount, 33 | })); 34 | } 35 | 36 | // Get balances 37 | function getBalances(bidderAddress: string) { 38 | return Promise.all([ 39 | web3.eth.getBalance(bidderAddress).then((value: any) => web3.utils.toBN(value)), 40 | web3.eth.getBalance(rocketVault.options.address).then((value: any) => web3.utils.toBN(value)), 41 | rocketVault.methods 42 | .balanceOf("rocketDepositPool") 43 | .call() 44 | .then((value: any) => web3.utils.toBN(value)), 45 | ]).then(([bidderEth, vaultEth, depositPoolEth]) => ({ 46 | bidderEth, 47 | vaultEth, 48 | depositPoolEth, 49 | })); 50 | } 51 | 52 | // Get lot price at block 53 | function getLotPriceAtBlock() { 54 | return web3.eth.getBlock("latest").then((block: any) => rp.auction.getLotPriceAtBlock(lotIndex, block.number)); 55 | } 56 | 57 | // Get initial lot details & balances 58 | const [lot1, balances1] = await Promise.all([getLotDetails(options.from), getBalances(options.from)]); 59 | 60 | // Set gas price 61 | const gasPrice = web3.utils.toBN(web3.utils.toWei("20", "gwei")); 62 | options.gasPrice = gasPrice.toString(); 63 | 64 | // Place bid 65 | const txReceipt = await rp.auction.placeBid(lotIndex, options); 66 | const txFee = gasPrice.mul(web3.utils.toBN(txReceipt.gasUsed)); 67 | 68 | // Get updated lot details & balances 69 | const [lot2, balances2] = await Promise.all([getLotDetails(options.from), getBalances(options.from)]); 70 | 71 | // Get parameters 72 | const lotBlockPrice = web3.utils.toBN(await getLotPriceAtBlock()); 73 | const lotRemainingRplAmount = lot1.totalRplAmount.sub(calcBase.mul(lot1.totalBidAmount).div(lotBlockPrice)); 74 | 75 | // Get expected values 76 | const maxBidAmount = lotRemainingRplAmount.mul(lotBlockPrice).div(calcBase); 77 | 78 | const txValue = web3.utils.toBN(options.value as string); 79 | const bidAmount = txValue.gt(maxBidAmount) ? maxBidAmount : txValue; 80 | 81 | // Check lot details 82 | assert(lot2.totalBidAmount.eq(lot1.totalBidAmount.add(bidAmount)), "Incorrect updated total bid amount"); 83 | assert(lot2.addressBidAmount.eq(lot1.addressBidAmount.add(bidAmount)), "Incorrect updated address bid amount"); 84 | assert(lot2.priceByTotalBids.eq(calcBase.mul(lot2.totalBidAmount).div(lot2.totalRplAmount)), "Incorrect updated price by total bids"); 85 | assert(lot2.claimedRplAmount.eq(calcBase.mul(lot2.totalBidAmount).div(lot2.currentPrice)), "Incorrect updated claimed RPL amount"); 86 | assert(lot2.totalRplAmount.eq(lot2.claimedRplAmount.add(lot2.remainingRplAmount)), "Incorrect updated RPL amounts"); 87 | 88 | // Check balances 89 | assert(balances2.bidderEth.eq(balances1.bidderEth.sub(bidAmount).sub(txFee)), "Incorrect updated address ETH balance"); 90 | assert(balances2.depositPoolEth.eq(balances1.depositPoolEth.add(bidAmount)), "Incorrect updated deposit pool ETH balance"); 91 | assert(balances2.vaultEth.eq(balances1.vaultEth.add(bidAmount)), "Incorrect updated vault ETH balance"); 92 | } 93 | -------------------------------------------------------------------------------- /dist/rocketpool/network/network.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/rocketpool/network/network.ts"],"names":[],"mappings":";;AAKA,yDAAmF;AAEnF;;GAEG;AACH,MAAM,OAAO;IACZ;;;;;OAKG;IACH,YAA2B,IAAU,EAAU,SAAoB;QAAxC,SAAI,GAAJ,IAAI,CAAM;QAAU,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAEvE;;;OAGG;IACH,IAAY,qBAAqB;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,IAAY,iBAAiB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACH,IAAY,mBAAmB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;;OASG;IACI,gBAAgB;QACtB,OAAO,IAAI,CAAC,qBAAqB;aAC/B,IAAI,CAAC,CAAC,qBAA+B,EAAmB,EAAE;YAC1D,OAAO,qBAAqB,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,IAAI,EAAE,CAAC;QAChE,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,KAAa,EAAU,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;;;;OAUG;IACI,kBAAkB;QACxB,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,qBAA+B,EAAmB,EAAE;YAC3F,OAAO,qBAAqB,CAAC,OAAO,CAAC,kBAAkB,EAAE,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E;YACnG,OAAO,IAAA,iCAAmB,EAAC,mBAAmB,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/I,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACI,qBAAqB,CAC3B,KAAa,EACb,QAAgB,EAChB,UAAkB,EAClB,UAAkB,EAClB,OAAqB,EACrB,cAAoC;QAEpC,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,qBAA+B,EAA+B,EAAE;YACvG,OAAO,IAAA,iCAAmB,EAAC,qBAAqB,CAAC,OAAO,CAAC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;QACxJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,UAAU;AACV,kBAAe,OAAO,CAAC"} -------------------------------------------------------------------------------- /dist/rocketpool/tokens/reth.d.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { TransactionReceipt } from "web3-core"; 3 | import { SendOptions } from "web3-eth-contract"; 4 | import Contracts from "../contracts/contracts"; 5 | import { ConfirmationHandler } from "../../utils/transaction"; 6 | import ERC20 from "./erc20"; 7 | /** 8 | * Rocket Pool RETH Token Manager 9 | */ 10 | declare class RETH extends ERC20 { 11 | /** 12 | * Create a new rETH instance. 13 | * 14 | * @param web3 A valid Web3 instance 15 | * @param contracts A Rocket Pool contract manager instance 16 | */ 17 | constructor(web3: Web3, contracts: Contracts); 18 | /** 19 | * Get the amount of ETH backing an amount of rETH 20 | * @params rethAmountWei a string representing the rETH amount in Wei 21 | * @returns a Promise that resolves to a string representing the amount amount of rETH backing an amount of ETH 22 | * 23 | * @example using Typescript 24 | * ```ts 25 | * const rethAmountWei = web3.utils.toWei("1", "ether"); 26 | * const ethValue = rp.tokens.reth.getEthValue(rethAmountWei).then((val: string) => { val }; 27 | * ``` 28 | */ 29 | getEthValue(rethAmountWei: string): Promise; 30 | /** 31 | * Get the amount of rETH backing an amount of ETH 32 | * @params ethAmountWei a string representing the ETH amount in Wei 33 | * @returns a Promise that resolves to a string representing the amount amount of rETH backing an amount of ETH 34 | * 35 | * @example using Typescript 36 | * ```ts 37 | * const ethAmountWei = web3.utils.toWei("1", "ether"); 38 | * const rethValue = rp.tokens.reth.getRethValue(ethAmountWei).then((val: string) => { val }; 39 | * ``` 40 | */ 41 | getRethValue(ethAmountWei: string): Promise; 42 | /** 43 | * Get the current ETH to rETH exchange rate 44 | * @returns a Promise that resolves to a number representing the amount of ETH backing 1 rETH 45 | * 46 | * @example using Typescript 47 | * ```ts 48 | * const exchangeRate = rp.tokens.reth.getTotalCollateral().then((val: number) => { val }; 49 | * ``` 50 | */ 51 | getExchangeRate(): Promise; 52 | /** 53 | * Get the total amount of ETH collateral available 54 | * @returns a Promise that resolves to a string representing the portion of rETH backed by ETH in the contract as a fraction 55 | * 56 | * @example using Typescript 57 | * ```ts 58 | * const totalCollateral = rp.tokens.reth.getTotalCollateral().then((val: string) => { val }; 59 | * ``` 60 | */ 61 | getTotalCollateral(): Promise; 62 | /** 63 | * Get the current ETH collateral rate 64 | * @returns a Promise that resolves to a number representing the portion of rETH backed by ETH in the contract as a fraction 65 | * 66 | * @example using Typescript 67 | * ```ts 68 | * const rate = rp.tokens.reth.getCollateralRate().then((val: number) => { val }; 69 | * ``` 70 | */ 71 | getCollateralRate(): Promise; 72 | /** 73 | * Get the total supply 74 | * @returns a Promise that resolves to a number representing the total supply 75 | * 76 | * @example using Typescript 77 | * ```ts 78 | * const supply = rp.tokens.reth.totalSupply().then((val: number) => { val }; 79 | * ``` 80 | */ 81 | getTotalSupply(): Promise; 82 | /** 83 | * Burn rETH for ETH 84 | * @param amountWei A string representing the amount to burn in Wei 85 | * @param options An optional object of web3.eth.Contract SendOptions 86 | * @param onConfirmation An optional confirmation handler object 87 | * @returns a Promise that resolves to a TransactionReceipt object representing the receipt of the transaction 88 | * 89 | * @example using Typescript 90 | * ```ts 91 | * const fromAddress = "0x24fBeD7Ecd625D3f0FD19a6c9113DEd436172294"; 92 | * const amountWei = web3.utils.toWei("1", "ether"); 93 | * const options = { 94 | * from: fromAddress, 95 | * gas: 1000000 96 | * }; 97 | * const txReceipt = rp.tokens.reth.burn(amountWei, options).then((txReceipt: TransactionReceipt) => { txReceipt }; 98 | * ``` 99 | */ 100 | burn(amountWei: string, options?: SendOptions, onConfirmation?: ConfirmationHandler): Promise; 101 | } 102 | export default RETH; 103 | --------------------------------------------------------------------------------