├── .gitmodules ├── .nvmrc ├── .eslintignore ├── packages ├── dai-plugin-mcd │ ├── .npmignore │ ├── contracts │ │ └── abis │ │ │ ├── VoteNo.json │ │ │ ├── VoteYes.json │ │ │ ├── DSMath.json │ │ │ ├── SafeMath.json │ │ │ ├── TestFullAssemblyContract.json │ │ │ ├── CageSpellAction.json │ │ │ ├── UrnHandler.json │ │ │ ├── Hevm.json │ │ │ ├── GemPit.json │ │ │ ├── EndFab.json │ │ │ ├── VatFab.json │ │ │ ├── WithdrawFunds.json │ │ │ ├── DogFab.json │ │ │ ├── SaiTubEvents.json │ │ │ ├── Value.json │ │ │ ├── MockSaiPip.json │ │ │ ├── CatFab.json │ │ │ ├── JugFab.json │ │ │ ├── PotFab.json │ │ │ ├── Abacus.json │ │ │ ├── DaiFab.json │ │ │ ├── SpotFab.json │ │ │ ├── DSAuthEvents.json │ │ │ ├── DSNote.json │ │ │ ├── Common.json │ │ │ ├── Hopeful.json │ │ │ ├── FlapFab.json │ │ │ ├── FlopFab.json │ │ │ ├── ClipperCallee.json │ │ │ ├── DaiJoinFab.json │ │ │ ├── DSChiefFab.json │ │ │ ├── DSAuthority.json │ │ │ ├── VowFab.json │ │ │ ├── FlipFab.json │ │ │ ├── PauseFab.json │ │ │ ├── ClipFab.json │ │ │ ├── Fusspot.json │ │ │ ├── GemInfo.json │ │ │ ├── ESMFab.json │ │ │ ├── DSGuardFactory.json │ │ │ ├── LibNote.json │ │ │ ├── TestUser.json │ │ │ ├── DSTokenAbstract.json │ │ │ ├── Utils.json │ │ │ ├── Kicker.json │ │ │ ├── DSProxyCache.json │ │ │ ├── DSTokenFactory.json │ │ │ ├── DSPauseProxy.json │ │ │ ├── ERC20Events.json │ │ │ ├── DSGuardEvents.json │ │ │ ├── Spotty.json │ │ │ ├── GemLike3.json │ │ │ ├── DSChiefAbstract.json │ │ │ ├── MockGuard.json │ │ │ ├── Auction.json │ │ │ ├── SimpleAuthority.json │ │ │ ├── GemLike4.json │ │ │ ├── MockOtc.json │ │ │ ├── MulticallHelper.json │ │ │ ├── GemLike5.json │ │ │ ├── DSPauseAbstract.json │ │ │ ├── Flippy.json │ │ │ ├── Store.json │ │ │ ├── ProxyRegistry.json │ │ │ ├── GetCdps.json │ │ │ ├── MomCaller.json │ │ │ ├── GovPollingGenerator.json │ │ │ ├── GemBag.json │ │ │ ├── OsmMomCaller.json │ │ │ ├── TestContract.json │ │ │ ├── Spell.json │ │ │ ├── DSAuth.json │ │ │ ├── DssProxyActionsDsr.json │ │ │ ├── GemLike2.json │ │ │ ├── GemLike6.json │ │ │ ├── User.json │ │ │ ├── MockVat.json │ │ │ ├── FaucetUser.json │ │ │ ├── DSProxyFactory.json │ │ │ └── Token6.json │ ├── .yarnrc │ ├── test │ │ ├── integration │ │ │ └── index.js │ │ ├── __mocks__ │ │ │ └── isomorphic-fetch.js │ │ ├── contracts │ │ │ └── deprecatedContracts.json │ │ ├── esm.spec.js │ │ ├── math.spec.js │ │ ├── setup-global.js │ │ ├── config │ │ │ └── jestIntegrationConfig.json │ │ ├── utils.spec.js │ │ ├── setup-test.js │ │ ├── CdpTypeService.spec.js │ │ └── Auction.spec.js │ ├── scripts │ │ ├── copy-files.sh │ │ └── install-testchain-outputs.sh │ ├── tsconfig.json │ ├── CHANGELOG.md │ ├── src │ │ ├── AuctionService.js │ │ ├── constants.ts │ │ ├── schemas │ │ │ ├── end.ts │ │ │ ├── proxyRegistry.ts │ │ │ ├── _validators.ts │ │ │ ├── cat.ts │ │ │ ├── getCdps.ts │ │ │ └── jug.ts │ │ └── Auction.js │ ├── jest.config.js │ ├── LICENSE │ └── typings │ │ └── index.d.ts ├── dai-plugin-scd │ ├── .npmignore │ ├── contracts │ │ ├── abis │ │ │ ├── DSExec.json │ │ │ ├── DSMath.json │ │ │ ├── GemPit.json │ │ │ ├── SaiTubEvents.json │ │ │ ├── DSAuthEvents.json │ │ │ ├── DSAuthority.json │ │ │ ├── DSSpellBook.json │ │ │ ├── SaiTubConstant.json │ │ │ ├── DSGuardFactory.json │ │ │ ├── DSNote.json │ │ │ ├── ERC20Events.json │ │ │ ├── DSGuardEvents.json │ │ │ ├── FakePerson.json │ │ │ ├── ProxyRegistry.json │ │ │ ├── DSAuth.json │ │ │ ├── DSProxyFactory.json │ │ │ ├── DSThing.json │ │ │ ├── DSSpell.json │ │ │ └── CageFree.json │ │ ├── tokens.js │ │ ├── contracts.js │ │ └── abiMap.js │ ├── .yarnrc │ ├── test │ │ ├── integration │ │ │ └── index.js │ │ ├── __mocks__ │ │ │ └── isomorphic-fetch.js │ │ ├── QueryApi.spec.js │ │ ├── setup-global.js │ │ ├── config │ │ │ └── jestIntegrationConfig.json │ │ ├── helpers │ │ │ └── maker.js │ │ ├── setup-test.js │ │ └── Currency.spec.js │ ├── tsconfig.json │ ├── scripts │ │ ├── copy-files.sh │ │ └── install-testchain-outputs.sh │ ├── src │ │ ├── utils │ │ │ ├── conversion.js │ │ │ ├── index.js │ │ │ ├── Web3ServiceList.js │ │ │ ├── getQueryResponse.js │ │ │ └── constants.js │ │ ├── web3 │ │ │ └── ProviderType.js │ │ ├── config │ │ │ ├── index.js │ │ │ └── DefaultServiceProvider.js │ │ ├── tokens │ │ │ ├── WethToken.js │ │ │ └── PethToken.js │ │ └── QueryApiScd.js │ ├── jest.config.js │ └── LICENSE ├── dai │ ├── contracts │ │ ├── abis │ │ │ ├── DSExec.json │ │ │ ├── DSMath.json │ │ │ ├── GemPit.json │ │ │ ├── SaiTubEvents.json │ │ │ ├── DSAuthority.json │ │ │ ├── DSAuthEvents.json │ │ │ ├── DSSpellBook.json │ │ │ ├── DSGuardFactory.json │ │ │ ├── DSNote.json │ │ │ ├── ERC20Events.json │ │ │ ├── DSGuardEvents.json │ │ │ ├── FakePerson.json │ │ │ ├── ProxyRegistry.json │ │ │ ├── DSAuth.json │ │ │ ├── DSProxyFactory.json │ │ │ ├── DSThing.json │ │ │ ├── DSSpell.json │ │ │ └── CageFree.json │ │ ├── tokens.js │ │ ├── addresses │ │ │ └── goerli.json │ │ └── contracts.js │ ├── .yarnrc │ ├── src │ │ ├── bundle │ │ │ ├── index.js │ │ │ └── index.html │ │ ├── config │ │ │ ├── presets │ │ │ │ ├── http.json │ │ │ │ ├── inject.json │ │ │ │ ├── ws.json │ │ │ │ ├── browser.json │ │ │ │ ├── kovan.json │ │ │ │ ├── goerli.json │ │ │ │ ├── mainnet.json │ │ │ │ └── test.json │ │ │ └── index.js │ │ ├── eth │ │ │ ├── TransactionState.js │ │ │ ├── web3 │ │ │ │ ├── ProviderType.js │ │ │ │ └── ShimEthersSigner.js │ │ │ ├── TransactionTransitions.js │ │ │ └── tokens │ │ │ │ ├── WethToken.ts │ │ │ │ └── PethToken.ts │ │ ├── utils │ │ │ ├── constants.js │ │ │ ├── Web3ServiceList.js │ │ │ ├── events │ │ │ │ └── NullEventService.js │ │ │ ├── CacheService.js │ │ │ └── TimerService.js │ │ ├── QueryApi.js │ │ └── index.ts │ ├── test │ │ ├── __mocks__ │ │ │ └── isomorphic-fetch.js │ │ ├── infura.spec.js │ │ ├── config │ │ │ ├── jestBuildConfig.json │ │ │ └── jestIntegrationConfig.json │ │ ├── helpers │ │ │ ├── transactionConfirmation.js │ │ │ └── setupAllowances.js │ │ ├── setup-global.js │ │ ├── build.spec.js │ │ ├── utils │ │ │ ├── conversion.spec.js │ │ │ ├── events │ │ │ │ └── NullEventService.spec.js │ │ │ └── index.spec.js │ │ ├── eth │ │ │ ├── GasService2.spec.js │ │ │ └── Currency.spec.js │ │ └── setup-test.js │ ├── scripts │ │ ├── copy-files.sh │ │ ├── watch-src.js │ │ └── install-testchain-outputs.sh │ ├── tsconfig.json │ ├── .prettierrc │ ├── CHANGELOG.md │ ├── jest.config.js │ └── LICENSE ├── dai-plugin-migrations │ ├── contracts │ │ ├── abiMap.json │ │ ├── abis │ │ │ ├── GetCdps.json │ │ │ └── CageFree.json │ │ ├── addresses │ │ │ ├── mainnet.json │ │ │ └── kovan.json │ │ └── abiMap.js │ ├── .yarnrc │ ├── test │ │ ├── __mocks__ │ │ │ └── isomorphic-fetch.js │ │ ├── setup-global.js │ │ ├── setup-test.js │ │ ├── index.spec.js │ │ └── migrations │ │ │ └── MkrRedeemer.spec.js │ ├── tsconfig.json │ ├── yalc.lock │ ├── scripts │ │ ├── copy-files.sh │ │ └── install-testchain-outputs.sh │ ├── src │ │ ├── tokens.ts │ │ ├── migrations │ │ │ ├── MkrRedeemer.ts │ │ │ ├── RedeemCollateral.ts │ │ │ ├── GlobalSettlementSavingsDai.ts │ │ │ └── RedeemSai.ts │ │ └── constants.ts │ ├── CHANGELOG.md │ ├── jest.config.js │ ├── README.md │ ├── package.json │ └── LICENSE ├── dai-plugin-liquidations │ ├── README.md │ ├── tsconfig.json │ ├── scripts │ │ └── copy-files.sh │ ├── test │ │ ├── setup-global.js │ │ └── setup-test.js │ ├── CHANGELOG.md │ ├── jest.config.js │ ├── .mocki │ │ └── merge-schemas.js │ ├── package.json │ ├── LICENSE │ └── contracts │ │ └── contract-info.json ├── dai-plugin-governance │ ├── .yarnrc │ ├── tsconfig.json │ ├── scripts │ │ ├── copy-files.sh │ │ └── install-testchain-outputs.sh │ ├── test │ │ ├── config │ │ │ ├── original-setup.js │ │ │ ├── jestTestchainConfig.json │ │ │ └── jestIntegrationConfig.json │ │ └── VoteDelegateFactoryService.test.js │ ├── CHANGELOG.md │ ├── jest.config.js │ ├── contracts │ │ ├── addresses │ │ │ ├── kovan.json │ │ │ ├── testnet.json │ │ │ ├── goerli.json │ │ │ └── mainnet.json │ │ └── contract-info.json │ ├── src │ │ ├── VoteDelegate.js │ │ ├── VoteProxy.js │ │ ├── VoteDelegateFactoryService.ts │ │ ├── utils │ │ │ └── constants.js │ │ └── VoteProxyFactoryService.js │ └── LICENSE ├── services-core │ ├── tsconfig.json │ ├── jest.config.js │ ├── src │ │ ├── ServiceState.ts │ │ ├── LocalService.ts │ │ ├── PublicService.ts │ │ ├── PrivateService.ts │ │ └── index.ts │ ├── test │ │ ├── standardizeConfig.spec.js │ │ ├── LocalService.spec.js │ │ ├── PublicService.spec.js │ │ └── PrivateService.spec.js │ ├── README.md │ └── package.json └── test-helpers │ ├── tsconfig.json │ ├── jest.config.js │ ├── src │ ├── index.ts │ ├── callGanache.ts │ └── mineBlocks.ts │ ├── package.json │ ├── LICENSE │ └── scripts │ ├── fundTestAccount.js │ └── generateDai.js ├── .prettierrc ├── .yarnrc ├── lerna.json ├── scripts ├── run-testchain.sh ├── install-dapptools.sh ├── set-polling-interval.sh └── getFunctionSignatures.js ├── .gitignore ├── patches └── jest-environment-jsdom+27.2.0.patch ├── tsconfig.json ├── .eslintrc ├── .circleci └── config.yml └── LICENSE /.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | **/*.scss 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/.npmignore: -------------------------------------------------------------------------------- 1 | .babelrc 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/.npmignore: -------------------------------------------------------------------------------- 1 | .babelrc 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSExec.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSMath.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/VoteNo.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/VoteYes.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/contracts/abiMap.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSMath.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSExec.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSMath.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/SafeMath.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/README.md: -------------------------------------------------------------------------------- 1 | # dai-plugin-liquidations 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "parser": "typescript" 4 | } 5 | -------------------------------------------------------------------------------- /packages/dai/.yarnrc: -------------------------------------------------------------------------------- 1 | version-tag-prefix "dai-v" 2 | version-git-message "dai-v%s" 3 | -------------------------------------------------------------------------------- /packages/dai/src/bundle/index.js: -------------------------------------------------------------------------------- 1 | import Maker from '../index'; 2 | window.Maker = Maker; 3 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/.yarnrc: -------------------------------------------------------------------------------- 1 | version-tag-prefix "dai-plugin-mcd-v" 2 | version-git-message "dai-plugin-mcd-v%s" 3 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/.yarnrc: -------------------------------------------------------------------------------- 1 | version-tag-prefix "dai-plugin-scd-v" 2 | version-git-message "dai-plugin-scd-v%s" 3 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/integration/index.js: -------------------------------------------------------------------------------- 1 | export const infuraProjectId = '406b22e3688c42898054d22555f43271'; 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/test/integration/index.js: -------------------------------------------------------------------------------- 1 | export const infuraProjectId = '406b22e3688c42898054d22555f43271'; 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/tokens.js: -------------------------------------------------------------------------------- 1 | export default { 2 | MKR: 'MKR', 3 | WETH: 'WETH', 4 | PETH: 'PETH', 5 | ETH: 'ETH' 6 | }; 7 | -------------------------------------------------------------------------------- /packages/dai/src/config/presets/http.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3": { 3 | "provider": { 4 | "type": "HTTP" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/dai/src/config/presets/inject.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3": { 3 | "provider": { 4 | "type": "INJECT" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/dai/src/config/presets/ws.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3": { 3 | "provider": { 4 | "type": "WEBSOCKET" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/dai/test/__mocks__/isomorphic-fetch.js: -------------------------------------------------------------------------------- 1 | import fetchMock from 'jest-fetch-mock'; 2 | 3 | export { fetchMock as default }; 4 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/.yarnrc: -------------------------------------------------------------------------------- 1 | version-tag-prefix "dai-plugin-governance-v" 2 | version-git-message "dai-plugin-governance-v%s" 3 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/TestFullAssemblyContract.json: -------------------------------------------------------------------------------- 1 | [{"payable":false,"stateMutability":"nonpayable","type":"fallback"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/.yarnrc: -------------------------------------------------------------------------------- 1 | version-tag-prefix "dai-plugin-migrations-v" 2 | version-git-message "dai-plugin-migrations-v%s" 3 | -------------------------------------------------------------------------------- /packages/dai/src/config/presets/browser.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3": { 3 | "provider": { 4 | "type": "BROWSER" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/__mocks__/isomorphic-fetch.js: -------------------------------------------------------------------------------- 1 | import fetchMock from 'jest-fetch-mock'; 2 | 3 | export { fetchMock as default }; 4 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/test/__mocks__/isomorphic-fetch.js: -------------------------------------------------------------------------------- 1 | import fetchMock from 'jest-fetch-mock'; 2 | 3 | export { fetchMock as default }; 4 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/test/__mocks__/isomorphic-fetch.js: -------------------------------------------------------------------------------- 1 | import fetchMock from 'jest-fetch-mock'; 2 | 3 | export { fetchMock as default }; 4 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | yarn-path ".yarn/releases/yarn-1.19.1.cjs" 6 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/CageSpellAction.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | "packages/*" 4 | ], 5 | "npmClient": "yarn", 6 | "useWorkspaces": true, 7 | "version": "independent" 8 | } 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/tokens.js: -------------------------------------------------------------------------------- 1 | export default { 2 | SAI: 'SAI', 3 | MKR: 'MKR', 4 | WETH: 'WETH', 5 | PETH: 'PETH', 6 | ETH: 'ETH' 7 | }; 8 | -------------------------------------------------------------------------------- /packages/dai/src/config/presets/kovan.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3": { 3 | "provider": { 4 | "type": "INFURA", 5 | "network": "kovan" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/dai/scripts/copy-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | copyfiles contracts/abis/* dist/abis -f 5 | copyfiles contracts/addresses/* dist/addresses -f 6 | -------------------------------------------------------------------------------- /packages/dai/src/config/presets/goerli.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3": { 3 | "provider": { 4 | "type": "INFURA", 5 | "network": "goerli" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/dai/src/config/presets/mainnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3": { 3 | "provider": { 4 | "type": "INFURA", 5 | "network": "mainnet" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/scripts/copy-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | copyfiles contracts/abis/* dist/abis -f 6 | copyfiles contracts/addresses/* dist/addresses -f 7 | -------------------------------------------------------------------------------- /packages/dai/contracts/addresses/goerli.json: -------------------------------------------------------------------------------- 1 | { 2 | "PROXY_REGISTRY": "0x46759093D8158db8BB555aC7C6F98070c56169ce", 3 | "MULTICALL": "0xb8c864B60e9467398800Df34da39BF4f0c459461" 4 | } 5 | -------------------------------------------------------------------------------- /packages/dai/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/UrnHandler.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"vat","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Hevm.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"warp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/dai-plugin-scd/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/dai/contracts/abis/GemPit.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"gem","type":"address"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/services-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/test-helpers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } -------------------------------------------------------------------------------- /scripts/run-testchain.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CWD="${0%/*}" 5 | 6 | #$CWD/set-polling-interval.sh 7 | $CWD/../node_modules/@makerdao/testchain/scripts/launch -s default --fast $@ 8 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/yalc.lock: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v1", 3 | "packages": { 4 | "@makerdao/dai-plugin-migrations": { 5 | "signature": "85f981fce1804c80a15d2ef9ba104810" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/GemPit.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"gem","type":"address"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/SaiTubEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"name":"lad","type":"address"},{"indexed":false,"name":"cup","type":"bytes32"}],"name":"LogNewCup","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/SaiTubEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"name":"lad","type":"address"},{"indexed":false,"name":"cup","type":"bytes32"}],"name":"LogNewCup","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai/src/bundle/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dai.js script tag include demo 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/dai/src/eth/TransactionState.js: -------------------------------------------------------------------------------- 1 | const enums = { 2 | initialized: 'initialized', 3 | pending: 'pending', 4 | mined: 'mined', 5 | error: 'error', 6 | finalized: 'finalized' 7 | }; 8 | export default enums; 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GemPit.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"gem","type":"address"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/scripts/copy-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | copyfiles contracts/abis/* dist/abis -f 6 | copyfiles contracts/addresses/* dist/addresses -f 7 | copyfiles contracts/abiMap.json dist -------------------------------------------------------------------------------- /packages/dai-plugin-governance/scripts/copy-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | copyfiles contracts/abis/* dist/abis -f 6 | copyfiles contracts/addresses/* dist/addresses -f 7 | copyfiles contracts/contract-info.json dist -------------------------------------------------------------------------------- /packages/dai/src/config/presets/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3": { 3 | "provider": { 4 | "type": "HTTP", 5 | "url": "http://localhost:2000" 6 | } 7 | }, 8 | "proxy": true, 9 | "smartContract": true 10 | } 11 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/scripts/copy-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | copyfiles contracts/abis/* dist/abis -f 6 | copyfiles contracts/addresses/* dist/addresses -f 7 | copyfiles contracts/contract-info.json dist -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/EndFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[],"name":"newEnd","outputs":[{"internalType":"contract End","name":"end","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/VatFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[],"name":"newVat","outputs":[{"internalType":"contract Vat","name":"vat","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/WithdrawFunds.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | umd/ 4 | node_modules/ 5 | .idea/ 6 | *.iml 7 | npm-debug.log 8 | *.sw* 9 | /out 10 | .DS_Store 11 | ganache.out 12 | yarn.lock 13 | package-lock.json 14 | .vscode/ 15 | yarn-error.log 16 | .yalc/ 17 | .log/ 18 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/test/config/original-setup.js: -------------------------------------------------------------------------------- 1 | import { takeSnapshotOriginal } from '../helpers'; 2 | 3 | beforeAll(async () => { 4 | global.useOldChain = true; 5 | global.snapshotId = await takeSnapshotOriginal(); 6 | return; 7 | }); 8 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DogFab.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"vat","type":"address"}],"name":"newDog","outputs":[{"internalType":"contract Dog","name":"dog","type":"address"}],"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/SaiTubEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lad","type":"address"},{"indexed":false,"internalType":"bytes32","name":"cup","type":"bytes32"}],"name":"LogNewCup","type":"event"}] -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Value.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"peek","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/MockSaiPip.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"peek","outputs":[{"internalType":"bytes32","name":"val","type":"bytes32"},{"internalType":"bool","name":"zzz","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-scd/scripts/copy-files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | copyfiles contracts/abis/* dist/abis -f 6 | copyfiles contracts/addresses/* dist/addresses -f 7 | copyfiles contracts/presets/* dist/presets -f 8 | copyfiles contracts/abiMap.json dist -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSAuthority.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/utils/conversion.js: -------------------------------------------------------------------------------- 1 | import { BigNumber as EthersBigNumber, utils as ethersUtils } from 'ethers'; 2 | 3 | export function numberToBytes32(num) { 4 | const bn = EthersBigNumber.from(num); 5 | return ethersUtils.hexlify(ethersUtils.zeroPad(bn, 32)); 6 | } 7 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSAuthEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/CatFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"}],"name":"newCat","outputs":[{"internalType":"contract Cat","name":"cat","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/JugFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"}],"name":"newJug","outputs":[{"internalType":"contract Jug","name":"jug","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/PotFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"}],"name":"newPot","outputs":[{"internalType":"contract Pot","name":"pot","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSSpellBook.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"whom","type":"address"},{"name":"mana","type":"uint256"},{"name":"data","type":"bytes"}],"name":"make","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Abacus.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DaiFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"newDai","outputs":[{"internalType":"contract Dai","name":"dai","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSAuthEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSAuthority.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"sig","type":"bytes4"}],"name":"canCall","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSSpellBook.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"whom","type":"address"},{"name":"mana","type":"uint256"},{"name":"data","type":"bytes"}],"name":"make","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/SpotFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"}],"name":"newSpotter","outputs":[{"internalType":"contract Spotter","name":"spotter","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "parser": "typescript", 4 | "overrides": [ 5 | { 6 | "files": [ 7 | "MulticallService.*", 8 | "schemas.js" 9 | ], 10 | "options": { 11 | "printWidth": 100 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /packages/services-core/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | transform: { 4 | '^.+\\.(ts|js)?$': 'ts-jest', 5 | }, 6 | coverageReporters: ['json', 'lcov', 'text-summary'], 7 | collectCoverageFrom: ['src/**/*.js', 'src/**/*.ts'], 8 | testEnvironment : 'jsdom' 9 | }; 10 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/contracts/deprecatedContracts.json: -------------------------------------------------------------------------------- 1 | { 2 | "MIGRATION": "0x2978B18F7c68B2957e701FC6D82C8De5B55833f2", 3 | "MCD_JOIN_SAI": "0x565e5E6d6C43Aff09A5b3C2b33d710d9c2c63e06", 4 | "SAI": "0xC226F3CD13d508bc319F4f4290172748199d6612", 5 | "OLD_MCD_CAT": "0x2125C30dA5DcA0819aEC5e4cdbF58Bfe91918e43" 6 | } -------------------------------------------------------------------------------- /packages/test-helpers/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | transform: { 4 | '^.+\\.(ts|js)?$': 'ts-jest', 5 | }, 6 | coverageReporters: ['json', 'lcov', 'text-summary'], 7 | collectCoverageFrom: ['src/**/*.js', 'src/**/*.ts'], 8 | testEnvironment : 'jsdom' 9 | }; 10 | -------------------------------------------------------------------------------- /packages/dai/test/infura.spec.js: -------------------------------------------------------------------------------- 1 | import Maker from '../src/index'; 2 | 3 | test('use Kovan via Infura without project id throws', async () => { 4 | try { 5 | const maker = await Maker.create('kovan'); 6 | await maker.authenticate(); 7 | } catch (err) { 8 | expect(err).toBeInstanceOf(Error); 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/esm.spec.js: -------------------------------------------------------------------------------- 1 | import { mcdMaker } from './helpers'; 2 | 3 | let maker; 4 | 5 | beforeAll(async () => { 6 | maker = await mcdMaker(); 7 | }); 8 | 9 | test('ESM exists', () => { 10 | const esm = maker.service('smartContract').getContract('MCD_ESM'); 11 | expect(esm.address).toBeTruthy(); 12 | }); 13 | -------------------------------------------------------------------------------- /packages/test-helpers/src/index.ts: -------------------------------------------------------------------------------- 1 | import cGanache from './callGanache'; 2 | import mBlocks from './mineBlocks'; 3 | import tAccountProvider from './TestAccountProvider'; 4 | 5 | export const callGanache = cGanache; 6 | export const mineBlocks = mBlocks; 7 | export * from './snapshot'; 8 | export const TestAccountProvider = tAccountProvider; 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSAuthEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSNote.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"usr","type":"address"},{"indexed":true,"name":"arg1","type":"bytes32"},{"indexed":true,"name":"arg2","type":"bytes32"},{"indexed":false,"name":"data","type":"bytes"}],"name":"LogNote","type":"event"}] -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/src/tokens.ts: -------------------------------------------------------------------------------- 1 | import { createCurrency } from '@makerdao/currency'; 2 | 3 | export const OLD_MKR = createCurrency('OLD_MKR'); 4 | export const SAI = createCurrency('SAI'); 5 | export const DAI = createCurrency('DAI'); 6 | export const MKR = createCurrency('MKR'); 7 | 8 | export const DAI_1 = createCurrency('DAI_1'); 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/test/QueryApi.spec.js: -------------------------------------------------------------------------------- 1 | import QueryApi from '../src/QueryApiScd'; 2 | 3 | test('getCdpIdsForOwner on mainnet', async () => { 4 | const q = new QueryApi(); 5 | const ids = await q.getCdpIdsForOwner( 6 | '0xCd5f8fa45E0cA0937F86006B9eE8fE1eEdEe5FC4' 7 | ); 8 | expect(ids.includes(1)).toBeTruthy(); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Common.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"apt","type":"address"},{"internalType":"address","name":"urn","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"daiJoin_join","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Hopeful.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"","type":"address"}],"name":"hope","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"","type":"address"}],"name":"nope","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/SaiTubConstant.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant":true, 4 | "inputs":[{"name":"cup","type":"bytes32"}], 5 | "name":"tab", 6 | "outputs":[{"name":"","type":"uint256"}], 7 | "payable":false, 8 | "stateMutability":"view", 9 | "type":"function" 10 | } 11 | ] -------------------------------------------------------------------------------- /packages/dai/test/config/jestBuildConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "ts-jest", 3 | "rootDir": "../../", 4 | "transform": { 5 | "^.+\\.(ts|js)?$": "ts-jest" 6 | }, 7 | "testEnvironment": "jsdom", 8 | "testMatch": ["/test/build.spec.js"], 9 | "testPathIgnorePatterns": ["/node_modules/", "/dist/"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/services-core/src/ServiceState.ts: -------------------------------------------------------------------------------- 1 | const ServiceState = { 2 | CREATED: 'CREATED', 3 | INITIALIZING: 'INITIALIZING', 4 | OFFLINE: 'OFFLINE', 5 | CONNECTING: 'CONNECTING', 6 | ONLINE: 'ONLINE', 7 | AUTHENTICATING: 'AUTHENTICATING', 8 | READY: 'READY', 9 | ERROR: 'ERROR' 10 | }; 11 | 12 | export default ServiceState; 13 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/FlapFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"},{"internalType":"address","name":"gov","type":"address"}],"name":"newFlap","outputs":[{"internalType":"contract Flapper","name":"flap","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/FlopFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"},{"internalType":"address","name":"gov","type":"address"}],"name":"newFlop","outputs":[{"internalType":"contract Flopper","name":"flop","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/ClipperCallee.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"clipperCall","outputs":[],"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DaiJoinFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"},{"internalType":"address","name":"dai","type":"address"}],"name":"newDaiJoin","outputs":[{"internalType":"contract DaiJoin","name":"daiJoin","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /scripts/install-dapptools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # run this file with "source" or "." so it can affect the environment 3 | 4 | set -e 5 | 6 | sudo mkdir -m 0755 /nix && sudo chown travis /nix 7 | sudo mount -o bind /home/travis/build/makerdao/dai.js/nix /nix 8 | curl https://dapp.tools/install | sh 9 | . /home/travis/.nix-profile/etc/profile.d/nix.sh 10 | -------------------------------------------------------------------------------- /packages/dai/test/helpers/transactionConfirmation.js: -------------------------------------------------------------------------------- 1 | import { ETH } from '../../src/eth/Currency'; 2 | import TestAccountProvider from '@makerdao/test-helpers/src/TestAccountProvider'; 3 | 4 | export function createOutOfEthTransaction(tokenService) { 5 | const eth = tokenService.getToken(ETH); 6 | return eth.transfer(TestAccountProvider.nextAddress(), 20000); 7 | } 8 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSChiefFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"contract DSToken","name":"gov","type":"address"},{"internalType":"uint256","name":"MAX_YAYS","type":"uint256"}],"name":"newChief","outputs":[{"internalType":"contract DSChief","name":"chief","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSGuardFactory.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isGuard","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"newGuard","outputs":[{"name":"guard","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSNote.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSAuthority.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"canCall","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/math.spec.js: -------------------------------------------------------------------------------- 1 | import { daiAvailable } from '../src/math'; 2 | import { USD, DAI } from '../src'; 3 | 4 | test('daiAvailable', () => { 5 | expect(daiAvailable(USD(10), USD(5), 1)).toEqual(DAI(5)); 6 | }); 7 | 8 | test('daiAvailable handles undercollateralized values', () => { 9 | expect(daiAvailable(USD(10), USD(5), 2.1)).toEqual(DAI(0)); 10 | }); 11 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSGuardFactory.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isGuard","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"newGuard","outputs":[{"name":"guard","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSNote.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.42.4](https://github.com/makerdao/dai.js/compare/@makerdao/dai@0.42.4-alpha.1...@makerdao/dai@0.42.4) (2022-02-07) 7 | 8 | **Note:** Version bump only for package @makerdao/dai 9 | -------------------------------------------------------------------------------- /packages/dai/contracts/contracts.js: -------------------------------------------------------------------------------- 1 | export default { 2 | SAI_PIP: 'SAI_PIP', 3 | SAI_TUB: 'SAI_TUB', 4 | MAKER_OTC: 'MAKER_OTC', 5 | OASIS_PROXY: 'OASIS_PROXY', 6 | SAI_PROXY: 'SAI_PROXY', 7 | PROXY_REGISTRY: 'PROXY_REGISTRY', 8 | DS_PROXY_FACTORY: 'DS_PROXY_FACTORY', 9 | DS_PROXY: 'DS_PROXY', 10 | MULTICALL: 'MULTICALL', 11 | SAI_CAGEFREE: 'SAI_CAGEFREE' 12 | }; 13 | -------------------------------------------------------------------------------- /packages/dai/test/setup-global.js: -------------------------------------------------------------------------------- 1 | let addedLogger = false; 2 | 3 | module.exports = function() { 4 | if (!addedLogger) { 5 | /* eslint-disable */ 6 | process.on('unhandledRejection', err => { 7 | console.error('Unhandled rejection is:', err); 8 | }); 9 | 10 | console.log('\nInstalled unhandledRejection logger.'); 11 | addedLogger = true; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/setup-global.js: -------------------------------------------------------------------------------- 1 | let addedLogger = false; 2 | 3 | module.exports = function() { 4 | if (!addedLogger) { 5 | /* eslint-disable */ 6 | process.on('unhandledRejection', err => { 7 | console.error('Unhandled rejection is:', err); 8 | }); 9 | 10 | console.log('\nInstalled unhandledRejection logger.'); 11 | addedLogger = true; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/test/setup-global.js: -------------------------------------------------------------------------------- 1 | let addedLogger = false; 2 | 3 | module.exports = function() { 4 | if (!addedLogger) { 5 | /* eslint-disable */ 6 | process.on('unhandledRejection', err => { 7 | console.error('Unhandled rejection is:', err); 8 | }); 9 | 10 | console.log('\nInstalled unhandledRejection logger.'); 11 | addedLogger = true; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /packages/dai/test/config/jestIntegrationConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "ts-jest", 3 | "rootDir": "../../", 4 | "transform": { 5 | "^.+\\.(ts|js)?$": "ts-jest" 6 | }, 7 | "testEnvironment": "jsdom", 8 | "testMatch": ["/test/integration/*.spec.js", "/test/integration/*.spec.ts"], 9 | "testPathIgnorePatterns": ["/node_modules/", "/dist/"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/VowFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"},{"internalType":"address","name":"flap","type":"address"},{"internalType":"address","name":"flop","type":"address"}],"name":"newVow","outputs":[{"internalType":"contract Vow","name":"vow","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/test/setup-global.js: -------------------------------------------------------------------------------- 1 | let addedLogger = false; 2 | 3 | module.exports = function() { 4 | if (!addedLogger) { 5 | /* eslint-disable */ 6 | process.on('unhandledRejection', err => { 7 | console.error('Unhandled rejection is:', err); 8 | }); 9 | 10 | console.log('\nInstalled unhandledRejection logger.'); 11 | addedLogger = true; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/test/setup-global.js: -------------------------------------------------------------------------------- 1 | let addedLogger = false; 2 | 3 | module.exports = function() { 4 | if (!addedLogger) { 5 | /* eslint-disable */ 6 | process.on('unhandledRejection', err => { 7 | console.error('Unhandled rejection is:', err); 8 | }); 9 | 10 | console.log('\nInstalled unhandledRejection logger.'); 11 | addedLogger = true; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/FlipFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"vat","type":"address"},{"internalType":"address","name":"cat","type":"address"},{"internalType":"bytes32","name":"ilk","type":"bytes32"}],"name":"newFlip","outputs":[{"internalType":"contract Flipper","name":"flip","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/config/jestIntegrationConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "ts-jest", 3 | "transform": { 4 | "^.+\\.(ts|js)?$": "ts-jest" 5 | }, 6 | "testEnvironment": "jsdom", 7 | "rootDir": "../../", 8 | "testMatch": ["/test/integration/*.spec.js", "/test/integration/*.spec.ts"], 9 | "testPathIgnorePatterns": ["/node_modules/", "/dist/"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/PauseFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"uint256","name":"delay","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"authority","type":"address"}],"name":"newPause","outputs":[{"internalType":"contract DSPause","name":"pause","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/src/migrations/MkrRedeemer.ts: -------------------------------------------------------------------------------- 1 | export default class MkrRedeemer { 2 | _manager; 3 | constructor(manager) { 4 | this._manager = manager; 5 | return this; 6 | } 7 | 8 | check() { 9 | const address = this._manager.get('web3').currentAddress(); 10 | const oldMkr = this._manager.get('token').getToken('OLD_MKR'); 11 | return oldMkr.balanceOf(address); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.8.5](https://github.com/makerdao/dai.js/compare/@makerdao/dai-plugin-mcd@1.8.5-alpha.2...@makerdao/dai-plugin-mcd@1.8.5) (2022-02-07) 7 | 8 | **Note:** Version bump only for package @makerdao/dai-plugin-mcd 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/test/config/jestIntegrationConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "ts-jest", 3 | "rootDir": "../../", 4 | "transform": { 5 | "^.+\\.(ts|js)?$": "ts-jest" 6 | }, 7 | "testEnvironment": "jsdom", 8 | "testMatch": ["/test/integration/*.spec.js", "/test/integration/*.spec.ts"], 9 | "testPathIgnorePatterns": ["/node_modules/", "/dist/"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/ClipFab.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"vat","type":"address"},{"internalType":"address","name":"spotter","type":"address"},{"internalType":"address","name":"dog","type":"address"},{"internalType":"bytes32","name":"ilk","type":"bytes32"}],"name":"newClip","outputs":[{"internalType":"contract Clipper","name":"clip","type":"address"}],"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Fusspot.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"gal","type":"address"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"kick","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"dai","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GemInfo.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/src/eth/web3/ProviderType.js: -------------------------------------------------------------------------------- 1 | export default { 2 | INFURA: 'INFURA', 3 | HTTP: 'HTTP', 4 | 5 | WEBSOCKET: 'WEBSOCKET', 6 | // a browser provider is one that comes from the browser, i.e. `window.web3`, 7 | // or from MetaMask's new "postMessage" method of requesting a provider. 8 | BROWSER: 'BROWSER', 9 | // A provider constructed outside this library and injected as-is 10 | INJECT: 'INJECT' 11 | }; 12 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/web3/ProviderType.js: -------------------------------------------------------------------------------- 1 | export default { 2 | INFURA: 'INFURA', 3 | HTTP: 'HTTP', 4 | 5 | WEBSOCKET: 'WEBSOCKET', 6 | // a browser provider is one that comes from the browser, i.e. `window.web3`, 7 | // or from MetaMask's new "postMessage" method of requesting a provider. 8 | BROWSER: 'BROWSER', 9 | // A provider constructed outside this library and injected as-is 10 | INJECT: 'INJECT' 11 | }; 12 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/ERC20Events.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"guy","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"dst","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Transfer","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSGuardEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"bytes32"},{"indexed":true,"name":"dst","type":"bytes32"},{"indexed":true,"name":"sig","type":"bytes32"}],"name":"LogPermit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"bytes32"},{"indexed":true,"name":"dst","type":"bytes32"},{"indexed":true,"name":"sig","type":"bytes32"}],"name":"LogForbid","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/services-core/src/LocalService.ts: -------------------------------------------------------------------------------- 1 | import ServiceType from './ServiceType'; 2 | import ServiceBase from './ServiceBase'; 3 | 4 | /** 5 | * 6 | */ 7 | class LocalService extends ServiceBase { 8 | /** 9 | * @param {string} name 10 | * @param {string[]} dependencies 11 | */ 12 | constructor(name, dependencies = []) { 13 | super(ServiceType.LOCAL, name, dependencies); 14 | } 15 | } 16 | 17 | export default LocalService; 18 | -------------------------------------------------------------------------------- /packages/services-core/src/PublicService.ts: -------------------------------------------------------------------------------- 1 | import ServiceType from './ServiceType'; 2 | import ServiceBase from './ServiceBase'; 3 | 4 | /** 5 | * 6 | */ 7 | class PublicService extends ServiceBase { 8 | /** 9 | * @param {string} name 10 | * @param {string[]} dependencies 11 | */ 12 | constructor(name, dependencies = []) { 13 | super(ServiceType.PUBLIC, name, dependencies); 14 | } 15 | } 16 | 17 | export default PublicService; 18 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/ESMFab.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"gov","type":"address"},{"internalType":"address","name":"end","type":"address"},{"internalType":"address","name":"pit","type":"address"},{"internalType":"uint256","name":"min","type":"uint256"}],"name":"newESM","outputs":[{"internalType":"contract ESM","name":"esm","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.5.4](https://github.com/makerdao/dai.js/compare/@makerdao/dai-plugin-migrations@1.5.4-alpha.1...@makerdao/dai-plugin-migrations@1.5.4) (2022-02-07) 7 | 8 | **Note:** Version bump only for package @makerdao/dai-plugin-migrations 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/ERC20Events.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"guy","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"dst","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Transfer","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/services-core/src/PrivateService.ts: -------------------------------------------------------------------------------- 1 | import ServiceType from './ServiceType'; 2 | import ServiceBase from './ServiceBase'; 3 | 4 | /** 5 | * 6 | */ 7 | class PrivateService extends ServiceBase { 8 | /** 9 | * @param {string} name 10 | * @param {string[]} dependencies 11 | */ 12 | constructor(name, dependencies = []) { 13 | super(ServiceType.PRIVATE, name, dependencies); 14 | } 15 | } 16 | 17 | export default PrivateService; 18 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/test/config/jestTestchainConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "ts-jest", 3 | "rootDir": "../../", 4 | "transform": { 5 | "^.+\\.(ts|js)?$": "ts-jest" 6 | }, 7 | "roots": ["lib", "src", "test"], 8 | "setupFilesAfterEnv": ["/test/config/setup-test.js"], 9 | "testPathIgnorePatterns": [ 10 | "/node_modules/", 11 | "/test/integration/" 12 | ], 13 | "testEnvironment": "jsdom" 14 | 15 | } 16 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.3.5](https://github.com/makerdao/dai.js/compare/@makerdao/dai-plugin-liquidations@0.3.5-alpha.0...@makerdao/dai-plugin-liquidations@0.3.5) (2022-02-07) 7 | 8 | **Note:** Version bump only for package @makerdao/dai-plugin-liquidations 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSGuardFactory.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isGuard","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"newGuard","outputs":[{"internalType":"contract DSGuard","name":"guard","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/LibNote.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":true,"inputs":[{"indexed":true,"internalType":"bytes4","name":"sig","type":"bytes4"},{"indexed":true,"internalType":"address","name":"usr","type":"address"},{"indexed":true,"internalType":"bytes32","name":"arg1","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"arg2","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"LogNote","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/AuctionService.js: -------------------------------------------------------------------------------- 1 | import { PublicService } from '@makerdao/services-core'; 2 | import Auction from './Auction'; 3 | import { ServiceRoles } from './constants'; 4 | 5 | export default class AuctionService extends PublicService { 6 | constructor(name = ServiceRoles.AUCTION) { 7 | super(name, ['smartContract']); 8 | } 9 | 10 | getAuction(ilk) { 11 | return new Auction(ilk, this.get('smartContract')); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSGuardEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"bytes32"},{"indexed":true,"name":"dst","type":"bytes32"},{"indexed":true,"name":"sig","type":"bytes32"}],"name":"LogPermit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"bytes32"},{"indexed":true,"name":"dst","type":"bytes32"},{"indexed":true,"name":"sig","type":"bytes32"}],"name":"LogForbid","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/utils.spec.js: -------------------------------------------------------------------------------- 1 | import { parseWeiNumeric } from '../src/utils'; 2 | import BigNumber from 'bignumber.js'; 3 | 4 | test('parseWeiNumeric', () => { 5 | expect(typeof parseWeiNumeric(1)).toBe('string'); 6 | expect(typeof parseWeiNumeric('1')).toBe('string'); 7 | expect(typeof parseWeiNumeric(BigNumber('1'))).toBe('string'); 8 | expect(parseWeiNumeric('1e18')).toBe('1'); 9 | expect(parseWeiNumeric('1e0', 'wei')).toBe('1'); 10 | }); 11 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.16.7](https://github.com/makerdao/dai-plugin-governance/compare/@makerdao/dai-plugin-governance@0.16.7-alpha.4...@makerdao/dai-plugin-governance@0.16.7) (2022-02-07) 7 | 8 | **Note:** Version bump only for package @makerdao/dai-plugin-governance 9 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/utils/index.js: -------------------------------------------------------------------------------- 1 | export function promiseWait(ms) { 2 | return new Promise(resolve => setTimeout(resolve, ms)); 3 | } 4 | 5 | // https://stackoverflow.com/a/43963612/56817 6 | export const uniqueId = (() => { 7 | let currentId = 0; 8 | const map = new WeakMap(); 9 | 10 | return object => { 11 | if (!map.has(object)) { 12 | map.set(object, ++currentId); 13 | } 14 | 15 | return map.get(object); 16 | }; 17 | })(); 18 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/test/config/jestIntegrationConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "ts-jest", 3 | "transform": { 4 | "^.+\\.(ts|js)?$": "ts-jest" 5 | }, 6 | "rootDir": "../../", 7 | "testMatch": ["/test/integration/*.js", "/test/integration/*.ts"], 8 | "setupFilesAfterEnv": ["/test/config/original-setup.js"], 9 | "testPathIgnorePatterns": ["/node_modules/", "/dist/"], 10 | "testEnvironment": "jsdom" 11 | } 12 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/TestUser.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"contract DSValue","name":"value","type":"address"},{"internalType":"bytes32","name":"wut","type":"bytes32"}],"name":"doPoke","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract DSValue","name":"value","type":"address"}],"name":"doVoid","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/scripts/watch-src.js: -------------------------------------------------------------------------------- 1 | var chokidar = require('chokidar'); 2 | 3 | var log = console.log.bind(console); 4 | var watcher = chokidar.watch('.', { 5 | ignored: /[\/\\]\./, persistent: true 6 | }); 7 | 8 | watcher 9 | .on('ready', function() { log(`loaded files, watching`); }) 10 | .on('add', function(path) { log(`added ${path}`); }) 11 | .on('change', function(path) { log(`changed ${path}`); }) 12 | .on('unlink', function(path) { log(`deleted ${path}`); }); 13 | 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSTokenAbstract.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Utils.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"address","name":"x","type":"address"}],"name":"toBytesAddress","outputs":[{"internalType":"bytes","name":"b","type":"bytes"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"toBytesUint","outputs":[{"internalType":"bytes","name":"b","type":"bytes"}],"payable":false,"stateMutability":"pure","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/constants.ts: -------------------------------------------------------------------------------- 1 | import BigNumber from 'bignumber.js'; 2 | 3 | export const ServiceRoles = { 4 | CDP_MANAGER: 'mcd:cdpManager', 5 | CDP_TYPE: 'mcd:cdpType', 6 | AUCTION: 'mcd:auction', 7 | SYSTEM_DATA: 'mcd:systemData', 8 | SAVINGS: 'mcd:savings' 9 | }; 10 | 11 | export const WAD = new BigNumber('1e18'); 12 | export const RAY = new BigNumber('1e27'); 13 | export const RAD = new BigNumber('1e45'); 14 | 15 | export const SECONDS_PER_YEAR = 365 * 24 * 60 * 60; 16 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Kicker.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"urn","type":"address"},{"internalType":"address","name":"gal","type":"address"},{"internalType":"uint256","name":"tab","type":"uint256"},{"internalType":"uint256","name":"lot","type":"uint256"},{"internalType":"uint256","name":"bid","type":"uint256"}],"name":"kick","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSProxyCache.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"bytes","name":"_code","type":"bytes"}],"name":"read","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_code","type":"bytes"}],"name":"write","outputs":[{"internalType":"address","name":"target","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/scripts/install-testchain-outputs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CONTRACTS=$DAI/contracts 5 | PLUGIN_ADDRESSES=$CONTRACTS/addresses/testnet.json 6 | 7 | for file in $SCD_ABIS/*.abi; do 8 | cp $file $CONTRACTS/abis/$(basename $file .abi).json 9 | done 10 | 11 | cp $SCD_ADDRESSES $PLUGIN_ADDRESSES 12 | 13 | MULTICALL=`jq ".MULTICALL" "$MCD_ADDRESSES"` 14 | cat $PLUGIN_ADDRESSES | jq_inplace ".MULTICALL = $(echo $MULTICALL)" $PLUGIN_ADDRESSES 15 | 16 | add_prefix $PLUGIN_ADDRESSES 17 | -------------------------------------------------------------------------------- /packages/dai/src/utils/constants.js: -------------------------------------------------------------------------------- 1 | import BigNumber from 'bignumber.js'; 2 | 3 | export const WEI = new BigNumber('1e18'); 4 | export const WAD = new BigNumber('1e18'); 5 | export const RAY = new BigNumber('1e27'); 6 | export const RAD = new BigNumber('1e45'); 7 | 8 | export const UINT256_MAX = 9 | '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'; 10 | 11 | export const AccountType = { 12 | PROVIDER: 'provider', 13 | PRIVATE_KEY: 'privateKey', 14 | BROWSER: 'browser' 15 | }; 16 | -------------------------------------------------------------------------------- /packages/dai/src/utils/Web3ServiceList.js: -------------------------------------------------------------------------------- 1 | class Web3ServiceList { 2 | constructor() { 3 | this._list = []; 4 | } 5 | 6 | push(service) { 7 | //put a warning if this list is length 2 or more 8 | this._list.push(service); 9 | } 10 | 11 | disconnectAll() { 12 | return Promise.all(this._list, s => s.manager()._disconnect()).then( 13 | () => (this._list = []) 14 | ); 15 | } 16 | } 17 | 18 | // eslint-disable-next-line 19 | const l = new Web3ServiceList(); 20 | export default l; 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/scripts/install-testchain-outputs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CONTRACTS=$SCD/contracts 5 | PLUGIN_ADDRESSES=$CONTRACTS/addresses/testnet.json 6 | 7 | for file in $SCD_ABIS/*.abi; do 8 | cp $file $CONTRACTS/abis/$(basename $file .abi).json 9 | done 10 | 11 | cp $SCD_ADDRESSES $PLUGIN_ADDRESSES 12 | 13 | add_prefix $PLUGIN_ADDRESSES 14 | 15 | TUB=`jq ".SAI_TUB" "$PLUGIN_ADDRESSES"` 16 | cat $PLUGIN_ADDRESSES | jq_inplace ".SAI_TUB_CONSTANT = $(echo $TUB)" $PLUGIN_ADDRESSES 17 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/contracts.js: -------------------------------------------------------------------------------- 1 | export default { 2 | SAI_PIP: 'SAI_PIP', 3 | SAI_PEP: 'SAI_PEP', 4 | SAI_PIT: 'SAI_PIT', 5 | SAI_SIN: 'SAI_SIN', 6 | SAI_MOM: 'SAI_MOM', 7 | SAI_VOX: 'SAI_VOX', 8 | SAI_TUB: 'SAI_TUB', 9 | SAI_TAP: 'SAI_TAP', 10 | SAI_TOP: 'SAI_TOP', 11 | SAI_PROXY: 'SAI_PROXY', 12 | PROXY_REGISTRY: 'PROXY_REGISTRY', 13 | DS_PROXY_FACTORY: 'DS_PROXY_FACTORY', 14 | DS_PROXY: 'DS_PROXY', 15 | MULTICALL: 'MULTICALL', 16 | SAI_TUB_CONSTANT: 'SAI_TUB_CONSTANT' 17 | }; 18 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/utils/Web3ServiceList.js: -------------------------------------------------------------------------------- 1 | class Web3ServiceList { 2 | constructor() { 3 | this._list = []; 4 | } 5 | 6 | push(service) { 7 | //put a warning if this list is length 2 or more 8 | this._list.push(service); 9 | } 10 | 11 | disconnectAll() { 12 | return Promise.all(this._list, s => s.manager()._disconnect()).then( 13 | () => (this._list = []) 14 | ); 15 | } 16 | } 17 | 18 | // eslint-disable-next-line 19 | const l = new Web3ServiceList(); 20 | export default l; 21 | -------------------------------------------------------------------------------- /packages/dai/test/build.spec.js: -------------------------------------------------------------------------------- 1 | const Maker = require('../dist/index').default; 2 | 3 | /*These tests are meant to catch errors in the Babel compilation 4 | process and/or package.json, since the other Jest tests run 5 | against the original source.*/ 6 | 7 | async function createMaker() { 8 | return Maker.create('test'); 9 | } 10 | 11 | test('can get a service from maker', async () => { 12 | const maker = await createMaker(); 13 | const proxy = maker.service('proxy'); 14 | expect(proxy).toBeDefined(); 15 | }); 16 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | transform: { 4 | '^.+\\.(ts|js)?$': 'ts-jest', 5 | }, 6 | rootDir: './', 7 | coverageReporters: ['json', 'lcov', 'text-summary'], 8 | collectCoverageFrom: ['src/**/*.js', 'src/**/*.ts'], 9 | globalSetup: '/test/setup-global.js', 10 | roots: ['src', 'test'], 11 | testPathIgnorePatterns: [ 12 | '/node_modules/', 13 | '/test/integration/' 14 | ], 15 | testEnvironment : 'jsdom' 16 | }; 17 | -------------------------------------------------------------------------------- /packages/services-core/test/standardizeConfig.spec.js: -------------------------------------------------------------------------------- 1 | import standardizeConfig from '../src/standardizeConfig'; 2 | 3 | test('accepts a constructor', () => { 4 | class FakeService {} 5 | const config = standardizeConfig('timer', FakeService); 6 | expect(config).toEqual([FakeService, {}]); 7 | }); 8 | 9 | test('accepts a constructor + settings pair', () => { 10 | class FakeService {} 11 | const config = standardizeConfig('timer', [FakeService, { foo: 3 }]); 12 | expect(config).toEqual([FakeService, { foo: 3 }]); 13 | }); 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/test/helpers/maker.js: -------------------------------------------------------------------------------- 1 | import Maker from '../../../dai/src'; 2 | import ScdPlugin from '../../src'; 3 | 4 | export async function scdMaker({ 5 | preset = 'test', 6 | network = 'testnet', 7 | addressOverrides, 8 | ...settings 9 | } = {}) { 10 | const maker = await Maker.create(preset, { 11 | plugins: [[ScdPlugin, { addressOverrides, network }]], 12 | web3: { 13 | pollingInterval: 100 14 | }, 15 | ...settings 16 | }); 17 | await maker.authenticate(); 18 | return maker; 19 | } 20 | -------------------------------------------------------------------------------- /scripts/set-polling-interval.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # speed up ethers.js polling so tests finish faster 3 | # run this from the project root 4 | 5 | CWD="${0%/*}" 6 | INTERVAL=${1:-50} 7 | 8 | function sed_inplace { 9 | # sed's -i argument behaves differently on macOS, hence this hack 10 | sed -i.bak "$1" $2 && rm $2.bak 11 | } 12 | 13 | echo Setting ethers.js polling interval to $INTERVAL ms. 14 | sed_inplace "s/var pollingInterval = [0-9]*/var pollingInterval = $INTERVAL/" \ 15 | $CWD/../node_modules/ethers/providers/provider.js 16 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | transform: { 4 | '^.+\\.(ts|js)?$': 'ts-jest', 5 | }, 6 | rootDir: './', 7 | coverageReporters: ['json', 'lcov', 'text-summary'], 8 | collectCoverageFrom: ['src/**/*.js', 'src/**/*.ts'], 9 | roots: ['src', 'test'], 10 | setupFilesAfterEnv: ['/test/config/original-setup.js'], 11 | testPathIgnorePatterns: [ 12 | '/node_modules/', 13 | '/test/integration/' 14 | ], 15 | testEnvironment : 'jsdom' 16 | }; 17 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/FakePerson.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"sai","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cash","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"tap","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_tap","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] 2 | -------------------------------------------------------------------------------- /packages/services-core/src/index.ts: -------------------------------------------------------------------------------- 1 | export { default as standardizeConfig } from './standardizeConfig'; 2 | export { 3 | default as ServiceProvider 4 | } from './ServiceProvider'; 5 | export { default as Container } from './Container'; 6 | export { default as LocalService } from './LocalService'; 7 | export { default as PublicService } from './PublicService'; 8 | export { default as PrivateService } from './PrivateService'; 9 | export { default as ServiceManager } from './ServiceManager'; 10 | export { default as StateMachine } from './StateMachine'; 11 | -------------------------------------------------------------------------------- /packages/test-helpers/src/callGanache.ts: -------------------------------------------------------------------------------- 1 | import fetch from 'node-fetch'; 2 | 3 | const ganacheAddress = 'http://localhost:2000'; 4 | let requestCount = 0; 5 | 6 | export default function callGanache(method, params = []) { 7 | return fetch(ganacheAddress, { 8 | method: 'POST', 9 | headers: { 10 | Accept: 'application/json', 11 | 'Content-Type': 'application/json' 12 | }, 13 | body: JSON.stringify({ 14 | jsonrpc: '2.0', 15 | method, 16 | params, 17 | id: requestCount++ 18 | }) 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/FakePerson.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"sai","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cash","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"tap","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_tap","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSTokenFactory.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"LogMake","type":"event"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"symbol","type":"bytes32"},{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"make","outputs":[{"internalType":"contract DSToken","name":"result","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSPauseProxy.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"bytes","name":"fax","type":"bytes"}],"name":"exec","outputs":[{"internalType":"bytes","name":"out","type":"bytes"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | transform: { 4 | '^.+\\.(ts|js)?$': 'ts-jest', 5 | }, 6 | rootDir: './', 7 | coverageReporters: ['json', 'lcov', 'text-summary'], 8 | collectCoverageFrom: ['src/**/*.js', 'src/**/*.ts'], 9 | globalSetup: '/test/setup-global.js', 10 | setupFilesAfterEnv: ['/test/setup-test.js'], 11 | roots: ['src', 'test'], 12 | testPathIgnorePatterns: [ 13 | '/node_modules/', 14 | '/test/integration/' 15 | ], 16 | testEnvironment : 'jsdom' 17 | }; 18 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/setup-test.js: -------------------------------------------------------------------------------- 1 | import { takeSnapshot, restoreSnapshot } from '@makerdao/test-helpers'; 2 | import fetch from 'jest-fetch-mock'; 3 | 4 | beforeEach(() => { 5 | jest.setTimeout(10000); 6 | }); 7 | 8 | let snapshotData; 9 | 10 | beforeAll(async () => { 11 | // Mock eth gas station response 12 | fetch.mockIf(/^https?:\/\/ethgasstation.info.*$/, async () => 13 | JSON.stringify({ fast: 1, fastWait: 1 }) 14 | ); 15 | snapshotData = await takeSnapshot(); 16 | }); 17 | 18 | afterAll(async () => { 19 | await restoreSnapshot(snapshotData); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | transform: { 4 | '^.+\\.(ts|js)?$': 'ts-jest', 5 | }, 6 | rootDir: './', 7 | coverageReporters: ['json', 'lcov', 'text-summary'], 8 | collectCoverageFrom: ['src/**/*.js', 'src/**/*.ts'], 9 | globalSetup: '/test/setup-global.js', 10 | setupFilesAfterEnv: ['/test/setup-test.js'], 11 | roots: ['src', 'test'], 12 | testPathIgnorePatterns: [ 13 | '/node_modules/', 14 | '/test/integration/' 15 | ], 16 | testEnvironment : 'jsdom' 17 | }; 18 | -------------------------------------------------------------------------------- /packages/dai/src/QueryApi.js: -------------------------------------------------------------------------------- 1 | import assert from 'assert'; 2 | import fetch from 'isomorphic-fetch'; 3 | 4 | export async function getQueryResponse(serverUrl, query, variables) { 5 | const resp = await fetch(serverUrl, { 6 | method: 'POST', 7 | headers: { 8 | Accept: 'application/json', 9 | 'Content-Type': 'application/json' 10 | }, 11 | body: JSON.stringify({ 12 | query, 13 | variables 14 | }) 15 | }); 16 | 17 | const { data } = await resp.json(); 18 | assert(data, `error fetching data from ${serverUrl}`); 19 | return data; 20 | } 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | transform: { 4 | '^.+\\.(ts|js)?$': 'ts-jest', 5 | }, 6 | rootDir: './', 7 | coverageReporters: ['json', 'lcov', 'text-summary'], 8 | collectCoverageFrom: ['src/**/*.js', 'src/**/*.ts'], 9 | globalSetup: '/test/setup-global.js', 10 | setupFilesAfterEnv: ['/test/setup-test.js'], 11 | roots: ['src', 'test'], 12 | testPathIgnorePatterns: [ 13 | '/node_modules/', 14 | '/test/integration/' 15 | ], 16 | testEnvironment : 'jsdom' 17 | }; 18 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/test/setup-test.js: -------------------------------------------------------------------------------- 1 | import { takeSnapshot, restoreSnapshot } from '@makerdao/test-helpers'; 2 | import fetch from 'jest-fetch-mock'; 3 | 4 | beforeEach(() => { 5 | jest.setTimeout(10000); 6 | }); 7 | 8 | let snapshotData; 9 | 10 | beforeAll(async () => { 11 | // Mock eth gas station response 12 | fetch.mockIf(/^https?:\/\/ethgasstation.info.*$/, async () => 13 | JSON.stringify({ fast: 1, fastWait: 1 }) 14 | ); 15 | snapshotData = await takeSnapshot(); 16 | }); 17 | 18 | afterAll(async () => { 19 | await restoreSnapshot(snapshotData); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/test/setup-test.js: -------------------------------------------------------------------------------- 1 | import { takeSnapshot, restoreSnapshot } from '@makerdao/test-helpers'; 2 | import fetch from 'jest-fetch-mock'; 3 | 4 | beforeEach(() => { 5 | jest.setTimeout(10000); 6 | }); 7 | 8 | let snapshotData; 9 | 10 | beforeAll(async () => { 11 | // Mock eth gas station response 12 | fetch.mockIf(/^https?:\/\/ethgasstation.info.*$/, async () => 13 | JSON.stringify({ fast: 1, fastWait: 1 }) 14 | ); 15 | snapshotData = await takeSnapshot(); 16 | }); 17 | 18 | afterAll(async () => { 19 | await restoreSnapshot(snapshotData); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/ERC20Events.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"src","type":"address"},{"indexed":true,"internalType":"address","name":"guy","type":"address"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"src","type":"address"},{"indexed":true,"internalType":"address","name":"dst","type":"address"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"}],"name":"Transfer","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSGuardEvents.json: -------------------------------------------------------------------------------- 1 | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"src","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"dst","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"sig","type":"bytes32"}],"name":"LogForbid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"src","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"dst","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"sig","type":"bytes32"}],"name":"LogPermit","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/utils/getQueryResponse.js: -------------------------------------------------------------------------------- 1 | import assert from 'assert'; 2 | import fetch from 'isomorphic-fetch'; 3 | 4 | export async function getQueryResponse(serverUrl, query, variables) { 5 | const resp = await fetch(serverUrl, { 6 | method: 'POST', 7 | headers: { 8 | Accept: 'application/json', 9 | 'Content-Type': 'application/json' 10 | }, 11 | body: JSON.stringify({ 12 | query, 13 | variables 14 | }) 15 | }); 16 | 17 | const { data } = await resp.json(); 18 | assert(data, `error fetching data from ${serverUrl}`); 19 | return data; 20 | } 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Spotty.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[],"name":"cage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"ilks","outputs":[{"internalType":"contract PipLike","name":"pip","type":"address"},{"internalType":"uint256","name":"mat","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"par","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | transform: { 4 | '^.+\\.(ts|js)?$': 'ts-jest', 5 | }, 6 | rootDir: './', 7 | coverageReporters: ['json', 'lcov', 'text-summary'], 8 | collectCoverageFrom: ['src/**/*.js', 'src/**/*.ts'], 9 | globalSetup: '/test/setup-global.js', 10 | roots: ['src', 'test'], 11 | setupFilesAfterEnv: ['/test/setup-test.js'], 12 | testPathIgnorePatterns: [ 13 | '/node_modules/', 14 | '/test/build.spec.js', 15 | '/test/integration/' 16 | ], 17 | testEnvironment : 'jsdom' 18 | }; 19 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/README.md: -------------------------------------------------------------------------------- 1 | # dai-plugin-migration 2 | 3 | ## Contract naming convention 4 | 5 | Contract names in `contracts/abis/addresses` are suffixed with a number (e.g. `_1`) to 6 | indicate the **version** of the contract. The version can come from either different 7 | deployments of the entire system (such as what might happen after a global settlement), 8 | or a simple upgrade (as what happened when DsChief was migrated when a vulnerability was found). 9 | 10 | The numbering is totally arbitrary and chosen when we choose to support a new contract. In the future, 11 | they could be renamed more descriptively. 12 | -------------------------------------------------------------------------------- /packages/dai/src/config/index.js: -------------------------------------------------------------------------------- 1 | import { merge } from 'lodash'; 2 | import { standardizeConfig } from '@makerdao/services-core'; 3 | 4 | export function mergeServiceConfig(role, sink, source, resolver) { 5 | sink = standardizeConfig(role, sink, resolver); 6 | source = standardizeConfig(role, source); 7 | if (sink[0] === false || source[0] === false) return source; 8 | 9 | return [ 10 | typeof source[0] != 'boolean' ? source[0] : sink[0], 11 | merge({}, sink[1], source[1]) 12 | ]; 13 | } 14 | 15 | export function getSettings(config) { 16 | if (config instanceof Array) return config[1]; 17 | return config; 18 | } 19 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/utils/constants.js: -------------------------------------------------------------------------------- 1 | import BigNumber from 'bignumber.js'; 2 | 3 | export const WEI = new BigNumber('1e18'); 4 | export const WAD = new BigNumber('1e18'); 5 | export const RAY = new BigNumber('1e27'); 6 | export const RAD = new BigNumber('1e45'); 7 | 8 | export const UINT256_MAX = 9 | '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'; 10 | 11 | export const AccountType = { 12 | PROVIDER: 'provider', 13 | PRIVATE_KEY: 'privateKey', 14 | BROWSER: 'browser' 15 | }; 16 | 17 | export const ServiceRoles = { 18 | CDP: 'cdp', 19 | PRICE: 'price', 20 | CONVERSION: 'conversion' 21 | }; 22 | -------------------------------------------------------------------------------- /packages/dai/src/utils/events/NullEventService.js: -------------------------------------------------------------------------------- 1 | import { LocalService } from '@makerdao/services-core'; 2 | 3 | const _ = () => {}; 4 | 5 | export default class NullEventService extends LocalService { 6 | /** 7 | * @param {string} name 8 | */ 9 | constructor(name = 'event') { 10 | super(name); 11 | } 12 | 13 | on() {} 14 | emit() {} 15 | ping() {} 16 | removeListener() {} 17 | registerPollEvents() {} 18 | buildEmitter() { 19 | return { 20 | emit: _, 21 | on: _, 22 | removeListener: _, 23 | registerPollEvents: _, 24 | ping: _, 25 | dispose: _ 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/dai/test/helpers/setupAllowances.js: -------------------------------------------------------------------------------- 1 | import { buildTestContainer } from './serviceBuilders'; 2 | import tokens from '../../contracts/tokens'; 3 | 4 | export default async function setupAllowances(tokenList = []) { 5 | const container = buildTestContainer({ token: true }); 6 | const tokenService = container.service('token'); 7 | // const cdpService = container.service('cdp'); 8 | await tokenService.manager().authenticate(); 9 | 10 | for (let symbol of tokenList) { 11 | const token = tokenService.getToken(tokens[symbol.toUpperCase()]); 12 | // await token.approve(cdpService._tubContract().address, '0'); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/config/index.js: -------------------------------------------------------------------------------- 1 | import merge from 'lodash/merge'; 2 | import { standardizeConfig } from '@makerdao/services-core'; 3 | 4 | export function mergeServiceConfig(role, sink, source, resolver) { 5 | sink = standardizeConfig(role, sink, resolver); 6 | source = standardizeConfig(role, source); 7 | if (sink[0] === false || source[0] === false) return source; 8 | 9 | return [ 10 | typeof source[0] != 'boolean' ? source[0] : sink[0], 11 | merge({}, sink[1], source[1]) 12 | ]; 13 | } 14 | 15 | export function getSettings(config) { 16 | if (config instanceof Array) return config[1]; 17 | return config; 18 | } 19 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GemLike3.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSChiefAbstract.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"name":"hat","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lift","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"","type":"address[]"}],"name":"vote","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/MockGuard.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"canCall","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"permit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/src/eth/TransactionTransitions.js: -------------------------------------------------------------------------------- 1 | import transactionStatus from '../eth/TransactionState'; 2 | 3 | const TransactionType = { 4 | oasis: 'oasis', 5 | transaction: 'transaction' 6 | }; 7 | 8 | const transactionLifeCycle = { 9 | initialized: [transactionStatus.pending, transactionStatus.error], 10 | pending: [transactionStatus.error, transactionStatus.mined], 11 | mined: [transactionStatus.finalized, transactionStatus.error], 12 | finalized: [], 13 | error: [] 14 | }; 15 | 16 | const transactionTypeTransitions = { 17 | transaction: transactionLifeCycle 18 | }; 19 | 20 | export { TransactionType as default, transactionTypeTransitions }; 21 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/ProxyRegistry.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[],"name":"build","outputs":[{"name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"proxies","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"build","outputs":[{"name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"factory_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/ProxyRegistry.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[],"name":"build","outputs":[{"name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"proxies","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"build","outputs":[{"name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"factory_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/schemas/end.ts: -------------------------------------------------------------------------------- 1 | import { 2 | EMERGENCY_SHUTDOWN_ACTIVE, 3 | EMERGENCY_SHUTDOWN_TIME 4 | } from './_constants'; 5 | 6 | export const endLive = { 7 | generate: () => ({ 8 | id: 'MCD_END.live', 9 | contract: 'MCD_END', 10 | call: ['live()(uint256)'] 11 | }), 12 | returns: [[EMERGENCY_SHUTDOWN_ACTIVE, val => val.eq(0)]] 13 | }; 14 | 15 | export const endWhen = { 16 | generate: () => ({ 17 | id: 'MCD_END.When', 18 | contract: 'MCD_END', 19 | call: ['when()(uint256)'] 20 | }), 21 | returns: [[EMERGENCY_SHUTDOWN_TIME, val => new Date(val.toNumber() * 1000)]] 22 | }; 23 | 24 | export default { 25 | endLive, 26 | endWhen 27 | }; 28 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Auction.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[],"name":"cage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"live","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"cage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"gal","type":"address"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"kick","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /packages/services-core/test/LocalService.spec.js: -------------------------------------------------------------------------------- 1 | import ServiceBase from '../src/ServiceBase'; 2 | import LocalService from '../src/LocalService'; 3 | import ServiceType from '../src/ServiceType'; 4 | 5 | test('should be a service of type LOCAL, with the provided name and dependencies', () => { 6 | const service = new LocalService('MyName', ['X', 'Y', 'Z']); 7 | 8 | expect(service).toBeInstanceOf(ServiceBase); 9 | expect(service.manager().type()).toBe(ServiceType.LOCAL); 10 | expect(service.manager().name()).toBe('MyName'); 11 | expect(service.manager().dependencies()).toEqual(['X', 'Y', 'Z']); 12 | 13 | expect(new LocalService('MyName').manager().dependencies()).toEqual([]); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/SimpleAuthority.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"authorized_caller_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"authorized_caller","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"canCall","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/services-core/test/PublicService.spec.js: -------------------------------------------------------------------------------- 1 | import ServiceBase from '../src/ServiceBase'; 2 | import PublicService from '../src/PublicService'; 3 | import ServiceType from '../src/ServiceType'; 4 | 5 | test('should be a service of type PUBLIC, with the provided name and dependencies', () => { 6 | const service = new PublicService('MyName', ['X', 'Y', 'Z']); 7 | 8 | expect(service).toBeInstanceOf(ServiceBase); 9 | expect(service.manager().type()).toBe(ServiceType.PUBLIC); 10 | expect(service.manager().name()).toBe('MyName'); 11 | expect(service.manager().dependencies()).toEqual(['X', 'Y', 'Z']); 12 | 13 | expect(new PublicService('MyName').manager().dependencies()).toEqual([]); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/dai/src/utils/CacheService.js: -------------------------------------------------------------------------------- 1 | import { LocalService } from '@makerdao/services-core'; 2 | 3 | export default class CacheService extends LocalService { 4 | constructor(name = 'cache') { 5 | super(name); 6 | } 7 | 8 | initialize(settings = {}) { 9 | if (settings.storage) { 10 | this._storage = settings.storage; 11 | } 12 | } 13 | 14 | isEnabled() { 15 | return !!this._storage; 16 | } 17 | 18 | has(key) { 19 | return !!this._storage && key in this._storage; 20 | } 21 | 22 | fetch(key) { 23 | return this._storage ? this._storage[key] : undefined; 24 | } 25 | 26 | store(key, value) { 27 | if (this._storage) this._storage[key] = value; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/services-core/test/PrivateService.spec.js: -------------------------------------------------------------------------------- 1 | import ServiceBase from '../src/ServiceBase'; 2 | import PrivateService from '../src/PrivateService'; 3 | import ServiceType from '../src/ServiceType'; 4 | 5 | test('should be a service of type PRIVATE, with the provided name and dependencies', () => { 6 | const service = new PrivateService('MyName', ['X', 'Y', 'Z']); 7 | 8 | expect(service).toBeInstanceOf(ServiceBase); 9 | expect(service.manager().type()).toBe(ServiceType.PRIVATE); 10 | expect(service.manager().name()).toBe('MyName'); 11 | expect(service.manager().dependencies()).toEqual(['X', 'Y', 'Z']); 12 | 13 | expect(new PrivateService('MyName').manager().dependencies()).toEqual([]); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/contracts/addresses/kovan.json: -------------------------------------------------------------------------------- 1 | { 2 | "MCD_ADM": "0x27E0c9567729Ea6e3241DE74B3dE499b7ddd3fe6", 3 | "VOTE_PROXY_FACTORY": "0x1400798AA746457E467A1eb9b3F3f72C25314429", 4 | "VOTE_DELEGATE_FACTORY": "0x1740F3bD55b1900C816A0071F8972C201566e3a3", 5 | "POLLING": "0x518a0702701BF98b5242E73b2368ae07562BEEA3", 6 | "BATCH_POLLING": "0xD931E7c869618dB6FD30cfE4e89248CAA091Ea5f", 7 | "MCD_ESM": "0xD5D728446275B0A12E4a4038527974b92353B4a9", 8 | "MCD_END": "0x3d9603037FF096af03B83725dFdB1CDA9EA02CE4", 9 | "GOV": "0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd", 10 | "MCD_IOU": "0x41f0b6ecaebfbf85c4eb857116caeeb0bdc212f0", 11 | "PAUSE": "0x8754e6ecb4fe68daa5132c2886ab39297a5c7189" 12 | } 13 | -------------------------------------------------------------------------------- /packages/dai/test/utils/conversion.spec.js: -------------------------------------------------------------------------------- 1 | import { 2 | numberToBytes32, 3 | bytes32ToNumber, 4 | stringToBytes32 5 | } from '../../src/utils/conversion'; 6 | 7 | test('numberToBytes32', () => { 8 | expect(numberToBytes32(92)).toBe( 9 | '0x000000000000000000000000000000000000000000000000000000000000005c' 10 | ); 11 | }); 12 | 13 | test('bytes32ToNumber', () => { 14 | const bytes32 = 15 | '0x000000000000000000000000000000000000000000000000000000000000005c'; 16 | expect(bytes32ToNumber(bytes32)).toBe(92); 17 | }); 18 | 19 | test('stringToBytes32', () => { 20 | expect(stringToBytes32('hello')).toBe( 21 | '0x00000000000000000000000000000000000000000000000000000068656c6c6f' 22 | ); 23 | }); 24 | -------------------------------------------------------------------------------- /packages/services-core/README.md: -------------------------------------------------------------------------------- 1 | # @makerdao/services-core 2 | 3 | A dependency injection framework used in [dai.js](https://github.com/makerdao/dai.js). 4 | 5 | ### TODO 6 | 7 | - [ ] create full usage example 8 | 9 | ### Usage (TODO) 10 | 11 | ```js 12 | class MyService extends PrivateService { 13 | constructor(name = 'serviceRoleName') { 14 | super(name, dependencyRoleNames); 15 | } 16 | 17 | initialize(settings) { 18 | // initialize() for all its dependencies will run first 19 | } 20 | 21 | connect() { 22 | // connect() for all its dependencies will run first 23 | } 24 | 25 | authenticate() { 26 | // authenticate() for all its dependencies will run first 27 | } 28 | } 29 | ``` 30 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/contracts/addresses/testnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "POLLING": "0x9A2810a12197CB844af4BA74a4b81bC1CA727130", 3 | "BATCH_POLLING": "0xa9D33Ce18803b0742460ffb1b33B6c40f95178BC", 4 | "VOTE_PROXY_FACTORY": "0x45204Df60612c9047Ba1cc483a957290De72180f", 5 | "MCD_ESM": "0xBFD5ccf89494B6A4A98c525f4E97f57C44f32CEB", 6 | "MCD_END": "0x4A504460C1ea6c1945D07619B546e4629fd2A5dB", 7 | "PAUSE": "0x6A309d0a82643cf531f6f7c2B21033D2AE7d016C", 8 | "MCD_ADM": "0xAe2f82b48f2C12bA5532879C4A718f8aAbF2f8E6", 9 | "MCD_IOU": "0x9fb9B0CCb0b6bcA8ff7667c1c1733F4469e27Af1", 10 | "SAI_GOV": "0x1c3ac7216250edc5b9daa5598da0579688b9dbd5", 11 | "VOTE_DELEGATE_FACTORY": "0xe95949a8C0373933dfd7110a66705eb7507Cc5Fd" 12 | } 13 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GemLike4.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/schemas/proxyRegistry.ts: -------------------------------------------------------------------------------- 1 | import { PROXY_ADDRESS } from './_constants'; 2 | import { validateAddress } from './_validators'; 3 | 4 | export const proxyRegistryProxies = { 5 | generate: address => ({ 6 | id: `PROXY_REGISTRY.proxies(${address})`, 7 | contract: 'PROXY_REGISTRY', 8 | call: ['proxies(address)(address)', address], 9 | transforms: { 10 | [PROXY_ADDRESS]: v => 11 | v === '0x0000000000000000000000000000000000000000' ? null : v 12 | } 13 | }), 14 | validate: { 15 | args: validateAddress`Invalid address for proxyAddress: ${'address'}` 16 | }, 17 | returns: [[PROXY_ADDRESS]] 18 | }; 19 | 20 | export default { 21 | proxyRegistryProxies 22 | }; 23 | -------------------------------------------------------------------------------- /patches/jest-environment-jsdom+27.2.0.patch: -------------------------------------------------------------------------------- 1 | diff --git a/node_modules/jest-environment-jsdom/build/index.js b/node_modules/jest-environment-jsdom/build/index.js 2 | index 6695225..ae7e9e6 100644 3 | --- a/node_modules/jest-environment-jsdom/build/index.js 4 | +++ b/node_modules/jest-environment-jsdom/build/index.js 5 | @@ -97,6 +97,7 @@ class JSDOMEnvironment { 6 | (0, _jestUtil().installCommonGlobals)(global, config.globals); // TODO: remove this ASAP, but it currently causes tests to run really slow 7 | 8 | global.Buffer = Buffer; // Report uncaught errors. 9 | + global.Uint8Array = Uint8Array; 10 | 11 | this.errorEventListener = event => { 12 | if (userErrorListenerCount === 0 && event.error) { 13 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/test/setup-test.js: -------------------------------------------------------------------------------- 1 | import Web3ServiceList from '../src/utils/Web3ServiceList'; 2 | import { takeSnapshot, restoreSnapshot } from '@makerdao/test-helpers'; 3 | import fetch from 'jest-fetch-mock'; 4 | 5 | beforeEach(() => { 6 | jest.setTimeout(10000); 7 | }); 8 | 9 | afterEach(() => { 10 | return Web3ServiceList.disconnectAll(); 11 | }); 12 | 13 | let snapshotData; 14 | 15 | beforeAll(async () => { 16 | // Mock eth gas station response 17 | fetch.mockIf(/^https?:\/\/ethgasstation.info.*$/, async () => 18 | JSON.stringify({ fast: 1, fastWait: 1 }) 19 | ); 20 | snapshotData = await takeSnapshot(); 21 | }); 22 | 23 | afterAll(async () => { 24 | await restoreSnapshot(snapshotData); 25 | }); 26 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/src/migrations/RedeemCollateral.ts: -------------------------------------------------------------------------------- 1 | export default class RedeemCollateral { 2 | _manager; 3 | 4 | constructor(manager) { 5 | this._manager = manager; 6 | return this; 7 | } 8 | 9 | _contract(name) { 10 | return this._manager.get('smartContract').getContract(name); 11 | } 12 | 13 | cooldown() { 14 | return this._contract('SAI_TOP').cooldown(); 15 | } 16 | 17 | async pethInTap() { 18 | const fog = await this._contract('SAI_TAP').fog(); 19 | return fog / Math.pow(10, 18); 20 | } 21 | 22 | redeemCollateral(cdp, wad) { 23 | // This will be replaced with the new contract method 24 | // that atomically exits/unwraps 25 | return cdp.freePeth(wad); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/dai/test/eth/GasService2.spec.js: -------------------------------------------------------------------------------- 1 | // this is split out from the other GasService tests in order to mock fetching 2 | 3 | import { buildTestService } from '../helpers/serviceBuilders'; 4 | import fetch from 'isomorphic-fetch'; 5 | import { API_URL } from '../../src/eth/GasService'; 6 | 7 | jest.mock('isomorphic-fetch', () => jest.fn()); 8 | 9 | test('apiKey setting', async () => { 10 | fetch.mockReturnValue( 11 | new Promise(res => 12 | res({ 13 | json: () => ({ mock: true }) 14 | }) 15 | ) 16 | ); 17 | const service = buildTestService('gas', { 18 | gas: { 19 | apiKey: 'foo' 20 | } 21 | }); 22 | await service.manager().authenticate(); 23 | expect(fetch).toBeCalledWith(API_URL + 'foo'); 24 | }); 25 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/MockOtc.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"buyGem","type":"address"},{"internalType":"uint256","name":"buyAmt","type":"uint256"},{"internalType":"address","name":"payGem","type":"address"},{"internalType":"uint256","name":"maxPayAmt","type":"uint256"}],"name":"buyAllAmount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"payGem","type":"address"},{"internalType":"address","name":"buyGem","type":"address"},{"internalType":"uint256","name":"buyAmt","type":"uint256"}],"name":"getPayAmount","outputs":[{"internalType":"uint256","name":"payAmt","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-governance/src/VoteDelegate.js: -------------------------------------------------------------------------------- 1 | export default class VoteDelegate { 2 | constructor({ voteDelegateService, voteDelegateAddress }) { 3 | this._voteDelegateService = voteDelegateService; 4 | this._voteDelegateAddress = voteDelegateAddress; 5 | } 6 | 7 | getVoteDelegateAddress() { 8 | return this._voteDelegateAddress; 9 | } 10 | } 11 | 12 | const passthroughMethods = ['lock', 'free', 'voteExec', 'votePoll']; 13 | 14 | Object.assign( 15 | VoteDelegate.prototype, 16 | passthroughMethods.reduce((acc, name) => { 17 | acc[name] = function(...args) { 18 | return this._voteDelegateService[name]( 19 | this._voteDelegateAddress, 20 | ...args 21 | ); 22 | }; 23 | return acc; 24 | }, {}) 25 | ); 26 | -------------------------------------------------------------------------------- /packages/dai/src/eth/tokens/WethToken.ts: -------------------------------------------------------------------------------- 1 | import Erc20Token from './Erc20Token'; 2 | import { ETH, WETH } from '../Currency'; 3 | 4 | export default class WethToken extends Erc20Token { 5 | constructor(contract, web3Service, decimals) { 6 | super(contract, web3Service, decimals, 'WETH'); 7 | } 8 | 9 | name() { 10 | return this._contract.name(); 11 | } 12 | 13 | deposit(amount, { unit = ETH, ...options } = {}) { 14 | return this._contract.deposit({ 15 | value: this._valueForContract(amount, unit), 16 | ...options 17 | }); 18 | } 19 | 20 | withdraw(amount, { unit = WETH, ...options } = {}) { 21 | const value = this._valueForContract(amount, unit); 22 | return this._contract.withdraw(value, options); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/scripts/install-testchain-outputs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CONTRACTS=$GOVERNANCE/contracts 5 | PLUGIN_ADDRESSES=$CONTRACTS/addresses/testnet.json 6 | 7 | # Relevant contracts from SCD: 8 | for CONTRACT in "POLLING","PollingEmitter" "BATCH_POLLING","PollingEmitter" "GOV","DSToken" 9 | do 10 | set_address_and_abi $CONTRACT $SCD_ADDRESSES $SCD_ABIS $PLUGIN_ADDRESSES 11 | done 12 | 13 | # Relevant contracts from MCD: 14 | for CONTRACT in "VOTE_PROXY_FACTORY","VoteProxyFactory" "MCD_ESM","ESM" "MCD_END","End" "MCD_ADM","DSChief" "MCD_IOU","DSToken" 15 | do 16 | set_address_and_abi $CONTRACT $MCD_ADDRESSES $MCD_ABIS $PLUGIN_ADDRESSES 17 | done 18 | 19 | # Add 'SAI_' prefix to relevant contracts 20 | add_prefix $PLUGIN_ADDRESSES -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/src/constants.ts: -------------------------------------------------------------------------------- 1 | import BigNumber from 'bignumber.js'; 2 | 3 | export const ServiceRoles = { 4 | MIGRATION: 'migration' 5 | }; 6 | 7 | export const Migrations = { 8 | SINGLE_TO_MULTI_CDP: 'single-to-multi-cdp', 9 | GLOBAL_SETTLEMENT_SAVINGS_DAI: 'global-settlement-savings-dai', 10 | GLOBAL_SETTLEMENT_COLLATERAL_CLAIMS: 'global-settlement-collateral-claims', 11 | GLOBAL_SETTLEMENT_DAI_REDEEMER: 'global-settlement-dai-redeemer', 12 | MKR_REDEEMER: 'mkr-redeemer', 13 | CHIEF_MIGRATE: 'chief-migrate', 14 | REDEEM_SAI: 'redeem-sai', 15 | REDEEM_COLLATERAL: 'redeem-collateral' 16 | }; 17 | 18 | export const WAD = new BigNumber('1e18'); 19 | export const RAY = new BigNumber('1e27'); 20 | export const RAD = new BigNumber('1e45'); 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/tokens/WethToken.js: -------------------------------------------------------------------------------- 1 | import Erc20Token from './Erc20Token'; 2 | import { ETH, WETH } from '../Currency'; 3 | 4 | export default class WethToken extends Erc20Token { 5 | constructor(contract, web3Service, decimals) { 6 | super(contract, web3Service, decimals, 'WETH'); 7 | } 8 | 9 | name() { 10 | return this._contract.name(); 11 | } 12 | 13 | deposit(amount, { unit = ETH, ...options } = {}) { 14 | return this._contract.deposit({ 15 | value: this._valueForContract(amount, unit), 16 | ...options 17 | }); 18 | } 19 | 20 | withdraw(amount, { unit = WETH, ...options } = {}) { 21 | const value = this._valueForContract(amount, unit); 22 | return this._contract.withdraw(value, options); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "esnext", 5 | "esModuleInterop": true, 6 | "declaration": false, 7 | "noImplicitAny": false, 8 | "removeComments": true, 9 | "noLib": false, 10 | "emitDecoratorMetadata": true, 11 | "sourceMap": true, 12 | "downlevelIteration": true, 13 | "experimentalDecorators": true, 14 | "lib": [ 15 | "esnext", 16 | "dom" 17 | ], 18 | "allowJs": true, 19 | "resolveJsonModule": true, 20 | "moduleResolution": "node", 21 | "types": ["jest", "node"], 22 | }, 23 | "exclude": [ 24 | "node_modules", 25 | "**/*.spec.ts" 26 | ] 27 | } -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/MulticallHelper.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"getLastBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getEthBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-governance/contracts/addresses/goerli.json: -------------------------------------------------------------------------------- 1 | { 2 | "MCD_ADM": "0x33Ed584fc655b08b2bca45E1C5b5f07c98053bC1", 3 | "VOTE_PROXY_FACTORY": "0x1a7c1ee5eE2A3B67778ff1eA8c719A3fA1b02b6f", 4 | "VOTE_DELEGATE_FACTORY": "0xE2d249AE3c156b132C40D07bd4d34e73c1712947", 5 | "POLLING": "0xdbE5d00b2D8C13a77Fb03Ee50C87317dbC1B15fb", 6 | "BATCH_POLLING": "0xdbE5d00b2D8C13a77Fb03Ee50C87317dbC1B15fb", 7 | "MCD_ESM_OLD": "0x105BF37e7D81917b6fEACd6171335B4838e53D5e", 8 | "MCD_ESM": "0x023A960cb9BE7eDE35B433256f4AfE9013334b55", 9 | "MCD_END": "0xDb1d3edb80d3faA1B7257Ab4018A609E327FA50D", 10 | "GOV": "0xc5E4eaB513A7CD12b2335e8a0D57273e13D499f7", 11 | "MCD_IOU": "0x651D1B91e4F657392a51Dba7A6A1A1a72eC6aD1c", 12 | "MCD_PAUSE": "0xefcd235B1f13e7fC5eab1d05C910d3c390b3439F" 13 | } 14 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/contracts/addresses/mainnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "MCD_ADM": "0x0a3f6849f78076aefaDf113F5BED87720274dDC0", 3 | "VOTE_PROXY_FACTORY": "0x6FCD258af181B3221073A96dD90D1f7AE7eEc408", 4 | "VOTE_DELEGATE_FACTORY": "0xD897F108670903D1d6070fcf818f9db3615AF272", 5 | "GOV": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2", 6 | "MCD_IOU": "0xa618e54de493ec29432ebd2ca7f14efbf6ac17f7", 7 | "POLLING": "0xF9be8F0945acDdeeDaA64DFCA5Fe9629D0CF8E5D", 8 | "BATCH_POLLING": "0xD3A9FE267852281a1e6307a1C37CDfD76d39b133", 9 | "MCD_ESM_OLD": "0x29CfBd381043D00a98fD9904a431015Fef07af2f", 10 | "MCD_ESM": "0x09e05fF6142F2f9de8B6B65855A1d56B6cfE4c58", 11 | "MCD_END": "0xBB856d1742fD182a90239D7AE85706C2FE4e5922", 12 | "PAUSE": "0xbe286431454714f511008713973d3b053a2d38f3" 13 | } 14 | -------------------------------------------------------------------------------- /packages/dai/test/setup-test.js: -------------------------------------------------------------------------------- 1 | import Web3ServiceList from '../src/utils/Web3ServiceList'; 2 | import { takeSnapshot, restoreSnapshot } from '@makerdao/test-helpers'; 3 | import fetch from 'jest-fetch-mock'; 4 | 5 | beforeEach(() => { 6 | jest.setTimeout(10000); 7 | }); 8 | 9 | afterEach(() => { 10 | return Web3ServiceList.disconnectAll(); 11 | }); 12 | 13 | let snapshotData; 14 | 15 | beforeAll(async () => { 16 | // Mock eth gas station response 17 | fetch.mockIf(/^https?:\/\/ethgasstation.info.*$/, async () => 18 | JSON.stringify({ fast: 1, fastWait: 1 }) 19 | ); 20 | // Deploy contract as a singleton here to be used for each 21 | snapshotData = await takeSnapshot(); 22 | }); 23 | 24 | afterAll(async () => { 25 | await restoreSnapshot(snapshotData); 26 | }); 27 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GemLike5.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/src/migrations/GlobalSettlementSavingsDai.ts: -------------------------------------------------------------------------------- 1 | export default class GlobalSettlementSavingsDai { 2 | _container; 3 | 4 | constructor(container) { 5 | this._container = container; 6 | return this; 7 | } 8 | 9 | async check() { 10 | const smartContract = this._container.get('smartContract'); 11 | const end = smartContract.getContract('MCD_END_1'); 12 | const isInGlobalSettlement = (await end.live()).eq(0); 13 | if (!isInGlobalSettlement) return false; 14 | 15 | const address = 16 | (await this._container.get('proxy').currentProxy()) || 17 | this._container.get('accounts').currentAddress(); 18 | 19 | const pot = smartContract.getContract('MCD_POT_1'); 20 | const balance = await pot.pie(address); 21 | return balance.gt(0); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSPauseAbstract.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"name":"delay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"exec","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"plot","outputs":[],"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Flippy.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"bids","outputs":[{"internalType":"uint256","name":"bid","type":"uint256"},{"internalType":"uint256","name":"lot","type":"uint256"},{"internalType":"address","name":"guy","type":"address"},{"internalType":"uint48","name":"tic","type":"uint48"},{"internalType":"uint48","name":"end","type":"uint48"},{"internalType":"address","name":"usr","type":"address"},{"internalType":"address","name":"gal","type":"address"},{"internalType":"uint256","name":"tab","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"yank","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Store.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"_val","type":"uint256"}],"name":"getAdd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getAnd10","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_val","type":"uint256"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/src/migrations/RedeemSai.ts: -------------------------------------------------------------------------------- 1 | import { DAI } from '../tokens'; 2 | 3 | export default class RedeemSai { 4 | _manager; 5 | _tap; 6 | 7 | constructor(manager) { 8 | this._manager = manager; 9 | this._tap = this._manager.get('smartContract').getContract('SAI_TAP'); 10 | return this; 11 | } 12 | 13 | off() { 14 | // _tap.off() has a name clash with the ethers Contract listener "BaseContract.off(eventName)" 15 | return this._tap['off()'](); 16 | } 17 | 18 | async getRate() { 19 | const fix = await this._tap.fix(); 20 | return fix / Math.pow(10, 27); 21 | } 22 | 23 | redeemSai(wad) { 24 | const cageFree = this._manager 25 | .get('smartContract') 26 | .getContract('SAI_CAGEFREE'); 27 | return cageFree.freeCash(DAI(wad).toFixed(18)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/test/index.spec.js: -------------------------------------------------------------------------------- 1 | import { migrationMaker } from './helpers'; 2 | import addresses from '../contracts/addresses/testnet.json'; 3 | 4 | let maker; 5 | 6 | beforeAll(async () => { 7 | maker = await migrationMaker(); 8 | }); 9 | 10 | test('contract address mapping', async () => { 11 | const address = maker 12 | .service('smartContract') 13 | .getContractAddressByName('SAI_TUB'); 14 | expect(address).toEqual(addresses.SAI_TUB); 15 | }); 16 | 17 | test('contract address overrides', async () => { 18 | const addr1 = '0x520cca6e73540fa2d483232d7545ee8fadd8a23d'; 19 | 20 | const maker2 = await migrationMaker({ 21 | addressOverrides: { SAI_TUB: addr1 } 22 | }); 23 | 24 | const scs = maker2.service('smartContract'); 25 | expect(scs.getContractAddress('SAI_TUB')).toEqual(addr1); 26 | }); 27 | -------------------------------------------------------------------------------- /packages/test-helpers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@makerdao/test-helpers", 3 | "description": "test helpers for the monorepo", 4 | "version": "0.5.2", 5 | "license": "MIT", 6 | "main": "dist/index.js", 7 | "unpkg": "dist/index.js", 8 | "typings": "dist/index.d.ts", 9 | "module": "dist/test-helpers.umd.production.min.js", 10 | "dependencies": { 11 | "node-fetch": "^2.6.0" 12 | }, 13 | "scripts": { 14 | "build": "yarn clean && tsdx build --format cjs,esm,umd", 15 | "clean": "rm -rf ./dist", 16 | "prepublishOnly": "yarn build", 17 | "test": "jest" 18 | }, 19 | "files": [ 20 | "package.json", 21 | "LICENSE", 22 | "dist/**/*", 23 | "umd/*" 24 | ], 25 | "gitHead": "689f3670142282c9483c74d5658f60161d4287bb", 26 | "peerDependencies": { 27 | "@makerdao/dai": "^0.42.2" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/ProxyRegistry.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"factory_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":false,"inputs":[],"name":"build","outputs":[{"internalType":"address payable","name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"build","outputs":[{"internalType":"address payable","name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"proxies","outputs":[{"internalType":"contract DSProxy","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/src/index.ts: -------------------------------------------------------------------------------- 1 | import Maker from './Maker'; 2 | import { currencies } from './eth/Currency'; 3 | import { 4 | stringToBytes32, 5 | bytes32ToNumber, 6 | numberToBytes32, 7 | stringToBytes, 8 | bytesToString, 9 | padRight, 10 | toHex 11 | } from './utils/conversion'; 12 | import { getQueryResponse } from './QueryApi'; 13 | export * from './eth/Currency'; 14 | 15 | for (let symbol in currencies) { 16 | Maker[symbol] = currencies[symbol]; 17 | } 18 | 19 | Maker.currencies = currencies; 20 | Maker.QueryApi = { getQueryResponse }; 21 | Maker.utils = { stringToBytes32 }; 22 | 23 | export default Maker; 24 | 25 | export const QueryApi = { getQueryResponse }; 26 | export const utils = { 27 | numberToBytes32, 28 | stringToBytes32, 29 | bytes32ToNumber, 30 | stringToBytes, 31 | bytesToString, 32 | padRight, 33 | toHex 34 | }; 35 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/schemas/_validators.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | export const tag = (strings, ...keys) => (...values) => { 3 | const dict = values[values.length - 1] || {}; 4 | const result = [strings[0]]; 5 | keys.forEach((key, i) => 6 | result.push(Number.isInteger(key) ? values[key] : dict[key], strings[i + 1]) 7 | ); 8 | return result.join(''); 9 | }; 10 | 11 | export const validateAddress = (...args) => address => 12 | (!/^0x[0-9a-fA-F]{40}$/.test(address) || 13 | address === '0x0000000000000000000000000000000000000000') && 14 | tag(...args)({ address: address === null ? '(null)' : address }); 15 | 16 | export const validateVaultId = id => 17 | !/^\d+$/.test(id) && 18 | `Invalid vault id: must be a positive integer. Received ${id}`; 19 | 20 | export const validateVaultTypeResult = vaultType => 21 | !vaultType && 'Vault does not exist'; 22 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GetCdps.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"guy","type":"address"}],"name":"getCdpsAsc","outputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address[]","name":"urns","type":"address[]"},{"internalType":"bytes32[]","name":"ilks","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"guy","type":"address"}],"name":"getCdpsDesc","outputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address[]","name":"urns","type":"address[]"},{"internalType":"bytes32[]","name":"ilks","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/contracts/abis/GetCdps.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"guy","type":"address"}],"name":"getCdpsAsc","outputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address[]","name":"urns","type":"address[]"},{"internalType":"bytes32[]","name":"ilks","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"guy","type":"address"}],"name":"getCdpsDesc","outputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address[]","name":"urns","type":"address[]"},{"internalType":"bytes32[]","name":"ilks","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai/test/eth/Currency.spec.js: -------------------------------------------------------------------------------- 1 | // we just do some quick tests of the exports here, since the core functionality 2 | // is being tested in @makerdao/currency 3 | 4 | import { getCurrency, ETH, PETH, WETH, MKR } from '../../src/eth/Currency'; 5 | 6 | test('parses an amount and currency symbol', () => { 7 | expect(getCurrency(1, 'mkr').toString()).toBe('1.00 MKR'); 8 | expect(getCurrency(1, 'weth').toString()).toBe('1.00 WETH'); 9 | expect(getCurrency(1, 'peth').toString()).toBe('1.00 PETH'); 10 | expect(getCurrency(1, 'eth').toString()).toBe('1.00 ETH'); 11 | }); 12 | 13 | test('parses an amount + currency class', () => { 14 | expect(getCurrency(1, ETH).toString()).toBe('1.00 ETH'); 15 | expect(getCurrency(1, PETH).toString()).toBe('1.00 PETH'); 16 | expect(getCurrency(1, WETH).toString()).toBe('1.00 WETH'); 17 | expect(getCurrency(1, MKR).toString()).toBe('1.00 MKR'); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/dai/src/utils/TimerService.js: -------------------------------------------------------------------------------- 1 | import { LocalService } from '@makerdao/services-core'; 2 | 3 | export default class TimerService extends LocalService { 4 | constructor(name = 'timer') { 5 | super(name); 6 | this._timers = {}; 7 | } 8 | 9 | createTimer(name, duration, repeating, callback) { 10 | this.disposeTimer(name); 11 | this._timers[name] = { 12 | repeating, 13 | id: (repeating ? setInterval : setTimeout)(callback, duration) 14 | }; 15 | } 16 | 17 | disposeTimer(name) { 18 | if (this._timers.hasOwnProperty(name)) { 19 | let timer = this._timers[name]; 20 | (timer.repeating ? clearInterval : clearTimeout)(timer.id); 21 | } 22 | } 23 | 24 | disposeAllTimers() { 25 | for (let name of this.listTimers()) { 26 | this.disposeTimer(name); 27 | } 28 | } 29 | 30 | listTimers() { 31 | return Object.keys(this._timers); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/MomCaller.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"contract FlipperMom","name":"mom_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":false,"inputs":[{"internalType":"address","name":"flip","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"flip","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newAuthority","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true, 5 | "es6": true, 6 | "jest": true, 7 | "node": true 8 | }, 9 | "extends": "eslint:recommended", 10 | "parser": "@typescript-eslint/parser", 11 | "parserOptions": { 12 | "ecmaVersion": 8, 13 | "sourceType": "module", 14 | "ecmaFeatures": { 15 | "experimentalObjectRestSpread": true 16 | } 17 | }, 18 | "rules": { 19 | "no-console": "off", 20 | "linebreak-style": [ 21 | "error", 22 | "unix" 23 | ], 24 | "quotes": [ 25 | "error", 26 | "single", 27 | { "avoidEscape": true } 28 | ], 29 | "semi": [ 30 | "error", 31 | "always" 32 | ], 33 | "complexity": [ 34 | "error", 35 | 12 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GovPollingGenerator.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[],"name":"createPoll","outputs":[{"internalType":"uint256","name":"pollId","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"polli","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"polls","outputs":[{"internalType":"address","name":"voteYes","type":"address"},{"internalType":"address","name":"voteNo","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"","type":"uint256"},{"indexed":false,"internalType":"address","name":"","type":"address"},{"indexed":false,"internalType":"address","name":"","type":"address"}],"name":"LogNewPoll","type":"event"}] -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSAuth.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GemBag.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"lad_","type":"address"},{"internalType":"address","name":"gem_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"ada","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"exit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"gem","outputs":[{"internalType":"contract GemLike","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lad","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/schemas/cat.ts: -------------------------------------------------------------------------------- 1 | import { toHex, fromWei, fromRad } from '../utils'; 2 | import BigNumber from 'bignumber.js'; 3 | import { WAD } from '../constants'; 4 | 5 | import { 6 | LIQUIDATOR_ADDRESS, 7 | LIQUIDATION_PENALTY, 8 | MAX_AUCTION_LOT_SIZE 9 | } from './_constants'; 10 | 11 | const validateCollateralTypeName = name => 12 | !name && 'Invalid collateral type name'; 13 | 14 | export const catIlks = { 15 | generate: collateralTypeName => ({ 16 | id: `MCD_CAT.ilks(${collateralTypeName})`, 17 | contract: 'MCD_CAT', 18 | call: ['ilks(bytes32)(address,uint256,uint256)', toHex(collateralTypeName)] 19 | }), 20 | validate: { 21 | args: validateCollateralTypeName 22 | }, 23 | returns: [ 24 | [LIQUIDATOR_ADDRESS], 25 | [LIQUIDATION_PENALTY, v => fromWei(new BigNumber(v).minus(WAD))], 26 | [MAX_AUCTION_LOT_SIZE, v => fromRad(new BigNumber(v))] 27 | ] 28 | }; 29 | 30 | export default { 31 | catIlks 32 | }; 33 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSAuth.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/scripts/install-testchain-outputs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CONTRACTS=$MCD/contracts 5 | 6 | for file in $MCD_ABIS/*.abi; do 7 | cp $file $CONTRACTS/abis/$(basename $file .abi).json 8 | done 9 | 10 | PLUGIN_ADDRESSES=$CONTRACTS/addresses/testnet.json 11 | cp $MCD_ADDRESSES $PLUGIN_ADDRESSES 12 | 13 | # These contracts are not supported on the testchain, but dummy addresses 14 | # must still be set to prevent errors when fetching event history 15 | DEPRECATED_CONTRACTS=$MCD/test/contracts/deprecatedContracts.json 16 | DEPRECATED_ADDRESSES=`jq "." "$DEPRECATED_CONTRACTS"` 17 | cat $PLUGIN_ADDRESSES | jq_inplace ". += $DEPRECATED_ADDRESSES" $PLUGIN_ADDRESSES 18 | 19 | # These contracts are not necessary to deploy on the testchain, e.g. UNI contracts 20 | MOCK_CONTRACTS=$MCD/test/contracts/mockContracts.json 21 | MOCK_ADDRESSES=`jq "." "$MOCK_CONTRACTS"` 22 | cat $PLUGIN_ADDRESSES | jq_inplace ". += $MOCK_ADDRESSES" $PLUGIN_ADDRESSES 23 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/OsmMomCaller.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"contract OsmMom","name":"mom_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":false,"inputs":[{"internalType":"address","name":"newAuthority","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"address","name":"osm","type":"address"}],"name":"setOsm","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"}],"name":"stop","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/TestContract.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"fail","outputs":[],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"get48Bytes","outputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"getBytes32","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"getBytes32AndUint","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getMultipleValues","outputs":[{"internalType":"bytes32[]","name":"result","type":"bytes32[]"}],"payable":false,"stateMutability":"pure","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/src/VoteProxy.js: -------------------------------------------------------------------------------- 1 | export default class VoteProxy { 2 | constructor({ voteProxyService, proxyAddress, coldAddress, hotAddress }) { 3 | this._voteProxyService = voteProxyService; 4 | this._proxyAddress = proxyAddress; 5 | this._coldAddress = coldAddress; 6 | this._hotAddress = hotAddress; 7 | } 8 | 9 | getProxyAddress() { 10 | return this._proxyAddress; 11 | } 12 | 13 | getColdAddress() { 14 | return this._coldAddress; 15 | } 16 | 17 | getHotAddress() { 18 | return this._hotAddress; 19 | } 20 | } 21 | 22 | const passthroughMethods = [ 23 | 'lock', 24 | 'free', 25 | 'voteExec', 26 | 'getNumDeposits', 27 | 'getVotedProposalAddresses' 28 | ]; 29 | 30 | Object.assign( 31 | VoteProxy.prototype, 32 | passthroughMethods.reduce((acc, name) => { 33 | acc[name] = function(...args) { 34 | return this._voteProxyService[name](this._proxyAddress, ...args); 35 | }; 36 | return acc; 37 | }, {}) 38 | ); 39 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/test/VoteDelegateFactoryService.test.js: -------------------------------------------------------------------------------- 1 | import { restoreSnapshotOriginal, setupTestMakerInstance } from './helpers'; 2 | import VoteDelegateFactoryService from '../src/VoteDelegateFactoryService'; 3 | 4 | let maker, vdfs; 5 | 6 | beforeAll(async () => { 7 | maker = await setupTestMakerInstance(); 8 | vdfs = maker.service('voteDelegateFactory'); 9 | }); 10 | 11 | afterAll(async () => { 12 | await restoreSnapshotOriginal(global.snapshotId); 13 | return; 14 | }); 15 | 16 | test('can create vote delegate factory service', async () => { 17 | expect(vdfs).toBeInstanceOf(VoteDelegateFactoryService); 18 | }); 19 | 20 | test('can create a vote delegate contract', async () => { 21 | let isDelegate = await vdfs.isDelegate(maker.currentAccount().address); 22 | expect(isDelegate).toBe(false); 23 | 24 | await vdfs.createDelegateContract(); 25 | 26 | isDelegate = await vdfs.isDelegate(maker.currentAccount().address); 27 | expect(isDelegate).toBe(true); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/services-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@makerdao/services-core", 3 | "description": "Dependency injection framework", 4 | "version": "0.11.4", 5 | "license": "MIT", 6 | "main": "dist/index.js", 7 | "unpkg": "dist/index.js", 8 | "jsdelivr": "dist/services-core.esm.js", 9 | "module": "dist/services-core.umd.production.min.js", 10 | "typings": "dist/index.d.ts", 11 | "scripts": { 12 | "build": "yarn clean && tsdx build --format cjs,esm,umd", 13 | "clean": "rm -rf ./dist", 14 | "prepublishOnly": "yarn build", 15 | "test": "jest", 16 | "coverage": "jest --coverage" 17 | }, 18 | "files": [ 19 | "package.json", 20 | "README.md", 21 | "LICENSE", 22 | "src/**/*.js", 23 | "dist/**/*.js", 24 | "umd/*" 25 | ], 26 | "dependencies": { 27 | "lodash": "^4.17.15", 28 | "toposort": "^2.0.2" 29 | }, 30 | "gitHead": "689f3670142282c9483c74d5658f60161d4287bb", 31 | "peerDependencies": { 32 | "@makerdao/dai": "^0.42.2" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/src/VoteDelegateFactoryService.ts: -------------------------------------------------------------------------------- 1 | import { LocalService } from '@makerdao/services-core'; 2 | import { VOTE_DELEGATE_FACTORY } from './utils/constants'; 3 | import tracksTransactions from './utils/tracksTransactions'; 4 | 5 | export default class VoteDelegateFactoryService extends LocalService { 6 | constructor(name = 'voteDelegateFactory') { 7 | super(name, ['smartContract', 'voteDelegate', 'transactionManager']); 8 | } 9 | 10 | // writes 11 | @tracksTransactions 12 | async createDelegateContract({ promise }) { 13 | return await this._delegateFactoryContract().create({ promise }); 14 | } 15 | 16 | // reads 17 | getVoteDelegate(owner) { 18 | return this.get('voteDelegate').getVoteDelegate(owner); 19 | } 20 | 21 | isDelegate(address) { 22 | return this._delegateFactoryContract().isDelegate(address); 23 | } 24 | 25 | _delegateFactoryContract() { 26 | return this.get('smartContract').getContractByName(VOTE_DELEGATE_FACTORY); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSProxyFactory.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isProxy","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cache","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"build","outputs":[{"name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"build","outputs":[{"name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"proxy","type":"address"},{"indexed":false,"name":"cache","type":"address"}],"name":"Created","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/test/Currency.spec.js: -------------------------------------------------------------------------------- 1 | // we just do some quick tests of the exports here, since the core functionality 2 | // is being tested in @makerdao/currency 3 | 4 | import { getCurrency, ETH, PETH, WETH, SAI, MKR } from '../src/Currency'; 5 | 6 | test('parses an amount and currency symbol', () => { 7 | expect(getCurrency(1, 'sai').toString()).toBe('1.00 SAI'); 8 | expect(getCurrency(1, 'mkr').toString()).toBe('1.00 MKR'); 9 | expect(getCurrency(1, 'weth').toString()).toBe('1.00 WETH'); 10 | expect(getCurrency(1, 'peth').toString()).toBe('1.00 PETH'); 11 | expect(getCurrency(1, 'eth').toString()).toBe('1.00 ETH'); 12 | }); 13 | 14 | test('parses an amount + currency class', () => { 15 | expect(getCurrency(1, ETH).toString()).toBe('1.00 ETH'); 16 | expect(getCurrency(1, PETH).toString()).toBe('1.00 PETH'); 17 | expect(getCurrency(1, WETH).toString()).toBe('1.00 WETH'); 18 | expect(getCurrency(1, SAI).toString()).toBe('1.00 SAI'); 19 | expect(getCurrency(1, MKR).toString()).toBe('1.00 MKR'); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSProxyFactory.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isProxy","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cache","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"build","outputs":[{"name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"build","outputs":[{"name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"proxy","type":"address"},{"indexed":false,"name":"cache","type":"address"}],"name":"Created","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/schemas/getCdps.ts: -------------------------------------------------------------------------------- 1 | import { 2 | USER_VAULT_IDS, 3 | USER_VAULT_ADDRESSES, 4 | USER_VAULT_TYPES 5 | } from './_constants'; 6 | import { validateAddress } from './_validators'; 7 | import { bytesToString } from '../utils'; 8 | 9 | export const getCdps = { 10 | generate: (vaultManagerAddress, proxyAddress, descending) => ({ 11 | id: `GET_CDPS.getCdps${descending ? 'Desc' : 'Asc'}(${proxyAddress})`, 12 | contract: 'GET_CDPS', 13 | call: [ 14 | `getCdps${ 15 | descending ? 'Desc' : 'Asc' 16 | }(address,address)(uint256[],address[],bytes32[])`, 17 | vaultManagerAddress, 18 | proxyAddress 19 | ] 20 | }), 21 | validate: { 22 | args: (_, address) => 23 | validateAddress`Invalid address for getCdps: ${'address'}`(address) 24 | }, 25 | returns: [ 26 | [USER_VAULT_IDS, v => v.map(n => n.toNumber())], 27 | [USER_VAULT_ADDRESSES], 28 | [USER_VAULT_TYPES, v => v.map(bytesToString)] 29 | ] 30 | }; 31 | 32 | export default { 33 | getCdps 34 | }; 35 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: makerdaodux/dapptools-node-circleci-docker 6 | resource_class: large 7 | steps: 8 | - checkout 9 | - run: 10 | name: Install dependencies 11 | command: yarn 12 | - run: 13 | name: Run Mocki GraphQL Server 14 | command: | 15 | echo 'export PATH=$(yarn global bin):$PATH' >> $BASH_ENV 16 | source $BASH_ENV 17 | yarn global add mocki 18 | mocki run --path packages/dai-plugin-liquidations/.mocki/config.yml 19 | background: true 20 | - run: 21 | name: Run tests 22 | command: | 23 | source /home/circleci/setup-env.sh 24 | yarn lerna bootstrap 25 | yarn build 26 | yarn test:build 27 | yarn coverage 28 | - run: 29 | name: codecov 30 | command: | 31 | npm i --no-save codecov 32 | ./node_modules/.bin/codecov 33 | -------------------------------------------------------------------------------- /packages/dai/test/utils/events/NullEventService.spec.js: -------------------------------------------------------------------------------- 1 | import NullEventService from '../../../src/utils/events/NullEventService'; 2 | 3 | test('should have a valid event service interface', () => { 4 | const nullEventService = new NullEventService(); 5 | expect(nullEventService.on({}, '')).toBeFalsy(); 6 | expect(nullEventService.emit({}, '')).toBeFalsy(); 7 | expect(nullEventService.ping({}, '')).toBeFalsy(); 8 | expect(nullEventService.removeListener({}, '')).toBeFalsy(); 9 | expect(nullEventService.registerPollEvents({}, '')).toBeFalsy(); 10 | expect(nullEventService.buildEmitter({}, '')).toBeDefined(); 11 | }); 12 | 13 | test('buildEmitter() should return new emitter with a valid interface', () => { 14 | const nullEventService = new NullEventService(); 15 | const emitterInstance = nullEventService.buildEmitter(); 16 | expect(emitterInstance.emit({}, '')).toBeFalsy(); 17 | expect(emitterInstance.on({}, '')).toBeFalsy(); 18 | expect(emitterInstance.removeListener({}, '')).toBeFalsy(); 19 | expect(emitterInstance.dispose({}, '')).toBeFalsy(); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abiMap.js: -------------------------------------------------------------------------------- 1 | // might not be run through babel in the future, so we must use an ES5-safe export 2 | export default { 3 | SAI_PIP: require('./abis/DSValue.json'), 4 | SAI_PEP: require('./abis/DSValue.json'), 5 | SAI_PIT: require('./abis/GemPit.json'), 6 | SAI_SIN: require('./abis/ERC20.json'), 7 | SAI_MOM: require('./abis/SaiMom.json'), 8 | SAI_VOX: require('./abis/SaiVox.json'), 9 | SAI_TUB: require('./abis/SaiTub.json'), 10 | SAI_TAP: require('./abis/SaiTap.json'), 11 | SAI_TOP: require('./abis/SaiTop.json'), 12 | SAI_SKR: require('./abis/ERC20.json'), 13 | SAI_GEM: require('./abis/WETH9.json'), 14 | SAI_GOV: require('./abis/ERC20.json'), 15 | SAI: require('./abis/ERC20.json'), 16 | SAI_PROXY: require('./abis/SaiProxyCreateAndExecute.json'), 17 | PROXY_REGISTRY: require('./abis/ProxyRegistry.json'), 18 | DS_PROXY_FACTORY: require('./abis/DSProxyFactory.json'), 19 | DS_PROXY: require('./abis/DSProxy.json'), 20 | MULTICALL: require('./abis/Multicall.json'), 21 | SAI_TUB_CONSTANT: require('./abis/SaiTubConstant.json') 22 | }; 23 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/.mocki/merge-schemas.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const yaml = require('js-yaml'); 3 | 4 | const MOCK_SCHEMA_FILE = './mock-schema.json'; 5 | const VDB_SCHEMA_FILE = './vdb-schema.json'; 6 | const MOCKI_CONFIG_FILE = './config.yml'; 7 | 8 | function merge() { 9 | const mocksJSON = fs.readFileSync(MOCK_SCHEMA_FILE); 10 | const mocks = JSON.parse(mocksJSON); 11 | 12 | const vdbSchemaJSON = fs.readFileSync(VDB_SCHEMA_FILE); 13 | const vdbSchema = JSON.parse(vdbSchemaJSON); 14 | 15 | let mergedSchema = vdbSchema; 16 | 17 | // Merge mock queries into the Vulcanize schema 18 | mergedSchema.data.__schema.types[0].fields.push(...mocks.mockQueries); 19 | 20 | // Merge mock types into the Vulcanize schema 21 | mergedSchema.data.__schema.types.push(...mocks.mockTypes); 22 | 23 | const mockiYAML = fs.readFileSync(MOCKI_CONFIG_FILE); 24 | let mockiConfig = yaml.safeLoad(mockiYAML); 25 | mockiConfig.endpoints[0].graphql.schema = mergedSchema.data; 26 | 27 | fs.writeFileSync(MOCKI_CONFIG_FILE, yaml.safeDump(mockiConfig)); 28 | } 29 | 30 | merge(); 31 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@makerdao/dai-plugin-liquidations", 3 | "description": "Plugin to add liquidations to dai.js", 4 | "version": "0.3.5", 5 | "license": "MIT", 6 | "typings": "dist/index.d.ts", 7 | "main": "dist/index.js", 8 | "unpkg": "dist/index.js", 9 | "jsdelivr": "dist/dai-plugin-liquidations.esm.js", 10 | "module": "dist/dai-plugin-liquidations.umd.production.min.js", 11 | "scripts": { 12 | "build": "yarn clean && tsdx build --format cjs,esm,umd && ./scripts/copy-files.sh", 13 | "clean": "rm -rf ./dist", 14 | "prepublishOnly": "yarn build", 15 | "testchain": "../../scripts/run-testchain.sh", 16 | "coverage": "yarn test --coverage", 17 | "test": "yarn testchain --ci jest --runInBand" 18 | }, 19 | "peerDependencies": { 20 | "@makerdao/dai": "^0.42.2" 21 | }, 22 | "dependencies": { 23 | "@makerdao/currency": "^0.9.10", 24 | "@makerdao/services-core": "^0.11.4", 25 | "bignumber.js": "^8.1.1", 26 | "ramda": "^0.27.1" 27 | }, 28 | "gitHead": "689f3670142282c9483c74d5658f60161d4287bb" 29 | } 30 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Spell.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"action","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cast","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"done","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eta","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[{"internalType":"contract DSPauseAbstract","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"schedule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sig","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tag","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@makerdao/dai-plugin-migrations", 3 | "description": "Plugin to add migrations to dai.js", 4 | "version": "1.5.4", 5 | "license": "MIT", 6 | "main": "dist/index.js", 7 | "unpkg": "dist/index.js", 8 | "typings": "dist/index.d.ts", 9 | "module": "dist/dai-plugin-migrations.esm.js", 10 | "jsdelivr": "dist/dai-plugin-migrations.umd.production.min.js", 11 | "scripts": { 12 | "build": "yarn clean && tsdx build --format cjs,esm,umd && ./scripts/copy-files.sh", 13 | "clean": "rm -rf ./dist", 14 | "prepublishOnly": "yarn build", 15 | "testchain": "../../scripts/run-testchain.sh", 16 | "coverage": "yarn test --coverage", 17 | "test": "yarn testchain --ci jest --runInBand" 18 | }, 19 | "peerDependencies": { 20 | "@makerdao/dai": "^0.42.2" 21 | }, 22 | "dependencies": { 23 | "@makerdao/currency": "^0.9.10", 24 | "@makerdao/dai": "^0.42.4", 25 | "@makerdao/services-core": "^0.11.4", 26 | "bignumber.js": "^8.1.1" 27 | }, 28 | "gitHead": "689f3670142282c9483c74d5658f60161d4287bb" 29 | } 30 | -------------------------------------------------------------------------------- /packages/dai/src/eth/web3/ShimEthersSigner.js: -------------------------------------------------------------------------------- 1 | // A simple Ethers Signer built directly from a Web3 provider. 2 | 3 | import { promisify } from '../../utils'; 4 | 5 | export default function makeSigner(web3Service) { 6 | const provider = web3Service.web3Provider(); 7 | const call = promisify(web3Service._web3.eth.call); 8 | return { 9 | getAddress: () => web3Service.currentAddress(), 10 | estimateGas: tx => web3Service.estimateGas(tx), 11 | sendTransaction: tx => { 12 | return web3Service.sendTransaction({ 13 | ...tx, 14 | from: web3Service.currentAddress() 15 | }); 16 | }, 17 | call, 18 | isSigner: () => true, 19 | _isSigner: true, 20 | provider: new Proxy(provider, { 21 | get(target, key) { 22 | switch (key) { 23 | case 'resolveName': 24 | return address => address; 25 | case '_isProvider': 26 | return true; 27 | case 'call': 28 | return call; 29 | default: 30 | return target[key]; 31 | } 32 | } 33 | }) 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/config/DefaultServiceProvider.js: -------------------------------------------------------------------------------- 1 | import { ServiceProvider } from '@makerdao/services-core'; 2 | import EthereumCdpService from '../EthereumCdpService'; 3 | import PriceService from '../PriceService'; 4 | import TokenConversionService from '../TokenConversionService'; 5 | import { getSettings } from './index'; 6 | 7 | export const resolver = { 8 | defaults: { 9 | cdp: 'EthereumCdpService', 10 | price: 'PriceService', 11 | conversion: 'TokenConversionService' 12 | }, 13 | disabled: { 14 | event: 'NullEventService' 15 | } 16 | }; 17 | 18 | export default class DefaultServiceProvider extends ServiceProvider { 19 | constructor(config = {}) { 20 | if (config.web3) { 21 | config = { 22 | ...config, 23 | accounts: { 24 | ...config.accounts, 25 | web3: getSettings(config.web3) 26 | } 27 | }; 28 | } 29 | 30 | super(config, { 31 | services: { 32 | EthereumCdpService, 33 | PriceService, 34 | TokenConversionService 35 | }, 36 | ...resolver 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/tokens/PethToken.js: -------------------------------------------------------------------------------- 1 | import Erc20Token from './Erc20Token'; 2 | import { WETH, PETH } from '../Currency'; 3 | 4 | export default class PethToken extends Erc20Token { 5 | constructor(contract, web3Service, tub) { 6 | super(contract, web3Service, 18, 'PETH'); 7 | this._tub = tub; 8 | } 9 | 10 | join(amount, { unit = WETH, promise } = {}) { 11 | const value = this._valueForContract(amount, unit); 12 | return this._tub.join(value, { promise }); 13 | } 14 | 15 | exit(amount, { unit = PETH, promise } = {}) { 16 | const value = this._valueForContract(amount, unit); 17 | return this._tub.exit(value, { promise }); 18 | } 19 | 20 | async wrapperRatio() { 21 | return WETH.ray(await this._tub.per()); 22 | } 23 | 24 | async joinPrice(amount, unit = WETH) { 25 | const value = this._valueForContract(amount, unit); 26 | return WETH.wei(await this._tub.ask(value)); 27 | } 28 | 29 | async exitPrice(amount, unit = WETH) { 30 | const value = this._valueForContract(amount, unit); 31 | return WETH.wei(await this._tub.bid(value)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/src/utils/constants.js: -------------------------------------------------------------------------------- 1 | import { createCurrency } from '@makerdao/currency'; 2 | 3 | export const MKR = createCurrency('MKR'); 4 | export const IOU = createCurrency('IOU'); 5 | 6 | /* Contracts */ 7 | export const VOTE_PROXY_FACTORY = 'VOTE_PROXY_FACTORY'; 8 | export const VOTE_DELEGATE_FACTORY = 'VOTE_DELEGATE_FACTORY'; 9 | export const POLLING = 'POLLING'; 10 | export const BATCH_POLLING = 'BATCH_POLLING'; 11 | export const CHIEF = 'CHIEF'; 12 | export const ESM_OLD = 'ESM_OLD'; 13 | export const ESM = 'ESM'; 14 | export const END = 'END'; 15 | export const PAUSE = 'PAUSE'; 16 | 17 | /* Addresses */ 18 | export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; 19 | 20 | /* Spock URLs */ 21 | export const LOCAL_URL = 'http://localhost:3001/v1'; 22 | export const KOVAN_URL = 'https://staging-gov-db.makerfoundation.com/api/v1'; 23 | export const GOERLI_URL = 'https://polling-db-goerli.makerdux.com/api/v1'; 24 | export const STAGING_MAINNET_URL = 25 | 'https://polling-db-staging.makerdux.com/api/v1'; 26 | export const MAINNET_URL = 'https://polling-db-prod.makerdux.com/api/v1'; 27 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/src/VoteProxyFactoryService.js: -------------------------------------------------------------------------------- 1 | import { LocalService } from '@makerdao/services-core'; 2 | import { VOTE_PROXY_FACTORY } from './utils/constants'; 3 | import ApproveLinkTransaction from './ApproveLinkTransaction'; 4 | 5 | export default class VoteProxyFactoryService extends LocalService { 6 | constructor(name = 'voteProxyFactory') { 7 | super(name, ['smartContract', 'voteProxy', 'transactionManager']); 8 | } 9 | 10 | initiateLink(hotAddress) { 11 | return this._proxyFactoryContract().initiateLink(hotAddress); 12 | } 13 | 14 | approveLink(coldAddress) { 15 | const tx = new ApproveLinkTransaction( 16 | this._proxyFactoryContract(), 17 | this.get('transactionManager') 18 | ); 19 | return tx.build('approveLink', [coldAddress]); 20 | } 21 | 22 | breakLink() { 23 | return this._proxyFactoryContract().breakLink(); 24 | } 25 | 26 | getVoteProxy(address) { 27 | return this.get('voteProxy').getVoteProxy(address); 28 | } 29 | 30 | _proxyFactoryContract() { 31 | return this.get('smartContract').getContractByName(VOTE_PROXY_FACTORY); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSAuth.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"internalType":"contract DSAuthority","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract DSAuthority","name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/src/QueryApiScd.js: -------------------------------------------------------------------------------- 1 | import utils from 'web3-utils'; 2 | 3 | import { getQueryResponse } from './utils/getQueryResponse'; 4 | import uniq from 'lodash/uniq'; 5 | const MAINNET_SERVER_URL = 'https://sai-mainnet.makerfoundation.com/v1'; 6 | 7 | export default class QueryApi { 8 | constructor(network = 'mainnet') { 9 | switch (network) { 10 | case 'mainnet': 11 | case 1: 12 | default: 13 | this.serverUrl = MAINNET_SERVER_URL; 14 | break; 15 | } 16 | } 17 | 18 | async getCdpIdsForOwner(rawAddress) { 19 | const address = utils.toChecksumAddress(rawAddress); 20 | const query = `query ($lad: String) { 21 | cups1: allCups(condition: { lad: $lad }) { 22 | nodes { 23 | id 24 | } 25 | } 26 | cups2: allCups(condition: { guy: $lad }) { 27 | nodes { 28 | id 29 | } 30 | } 31 | }`; 32 | 33 | const { cups1, cups2 } = await getQueryResponse(this.serverUrl, query, { 34 | lad: address 35 | }); 36 | return uniq(cups1.nodes.map(n => n.id).concat(cups2.nodes.map(n => n.id))); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /scripts/getFunctionSignatures.js: -------------------------------------------------------------------------------- 1 | /* 2 | usage: 3 | node getFunctionSignatures.js [path-with-ABI-files] 4 | node getFunctionSignatures.js [path-with-ABI-files] --match 0x23b872dd 5 | */ 6 | 7 | const fs = require('fs'); 8 | const wea = require('web3-eth-abi'); 9 | const path = require('path'); 10 | const { cyan, green } = require('chalk'); 11 | 12 | const argv = require('minimist')(process.argv, { string: ['match', 'm'] }); 13 | const dir = argv._[argv._.length - 1]; 14 | const match = argv.match || argv.m; 15 | if (match) console.log(`Searching for ${match}...`); 16 | 17 | for (const filename of fs.readdirSync(dir)) { 18 | if (!match) console.log(cyan(filename)); 19 | const abi = JSON.parse(fs.readFileSync(path.join(dir, filename))); 20 | for (const fn of abi.filter(x => x.type === 'function')) { 21 | const sig = wea.encodeFunctionSignature(fn); 22 | const name = `${fn.name}(${fn.inputs.map(i => i.type).join(',')})`; 23 | if (!match) { 24 | console.log(' ', sig, name); 25 | } else if (match === sig) { 26 | console.log(cyan(filename)); 27 | console.log(' ', green(sig), name); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/dai/src/eth/tokens/PethToken.ts: -------------------------------------------------------------------------------- 1 | import Erc20Token from './Erc20Token'; 2 | import { WETH, PETH } from '../Currency'; 3 | 4 | export default class PethToken extends Erc20Token { 5 | _tub; 6 | constructor(contract, web3Service, tub) { 7 | super(contract, web3Service, 18, 'PETH'); 8 | this._tub = tub; 9 | } 10 | 11 | join(amount, { unit = WETH, promise = undefined } = {}) { 12 | const value = this._valueForContract(amount, unit); 13 | return this._tub.join(value, { promise }); 14 | } 15 | 16 | exit(amount, { unit = PETH, promise = undefined } = {}) { 17 | const value = this._valueForContract(amount, unit); 18 | return this._tub.exit(value, { promise }); 19 | } 20 | 21 | async wrapperRatio() { 22 | return WETH.ray(await this._tub.per()); 23 | } 24 | 25 | async joinPrice(amount, unit = WETH) { 26 | const value = this._valueForContract(amount, unit); 27 | return WETH.wei(await this._tub.ask(value)); 28 | } 29 | 30 | async exitPrice(amount, unit = WETH) { 31 | const value = this._valueForContract(amount, unit); 32 | return WETH.wei(await this._tub.bid(value)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maker Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/dai/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maker Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DssProxyActionsDsr.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"apt","type":"address"},{"internalType":"address","name":"urn","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"daiJoin_join","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"daiJoin","type":"address"},{"internalType":"address","name":"pot","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"exit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"daiJoin","type":"address"},{"internalType":"address","name":"pot","type":"address"}],"name":"exitAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"daiJoin","type":"address"},{"internalType":"address","name":"pot","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"join","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/test-helpers/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maker Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maker Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maker Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Maker Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/dai/test/utils/index.spec.js: -------------------------------------------------------------------------------- 1 | import { promisify, getNetworkName } from '../../src/utils'; 2 | 3 | describe('promisify makes async functions return Promises', () => { 4 | test('arguments can be passed and results are resolved', () => { 5 | expect.assertions(1); 6 | 7 | const argVal = 'foobar'; 8 | const promisified = promisify((arg1, cb) => { 9 | cb(null, arg1); 10 | }); 11 | 12 | promisified(argVal).then(val => { 13 | expect(val).toEqual(argVal); 14 | }); 15 | }); 16 | 17 | test('errors are rejected', () => { 18 | expect.assertions(1); 19 | 20 | const errVal = 'foobar'; 21 | const promisified = promisify(cb => { 22 | cb(errVal); 23 | }); 24 | 25 | promisified().catch(val => { 26 | expect(val).toEqual(errVal); 27 | }); 28 | }); 29 | }); 30 | 31 | describe('getNetworkName', () => { 32 | test('should return the name of the matched network', () => { 33 | expect(getNetworkName(42)).toBe('kovan'); 34 | }); 35 | 36 | test('should throw an error if no network is matched', () => { 37 | expect(() => getNetworkName(43)).toThrow('No network with ID 43 found.'); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maker Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maker Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/dai-plugin-liquidations/contracts/contract-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "chief": { 3 | "inception_block": { 4 | "mainnet": "0x487813", 5 | "kovan": "0x649575" 6 | }, 7 | "events": { 8 | "etch": "0x4f0892983790f53eea39a7a496f6cb40e8811b313871337b6a761efc6c67bb1f", 9 | "vote_slate": "0xa69beaba00000000000000000000000000000000000000000000000000000000", 10 | "vote_addresses": "0xed08132900000000000000000000000000000000000000000000000000000000", 11 | "lock": "0xdd46706400000000000000000000000000000000000000000000000000000000", 12 | "free": "0xd8ccd0f300000000000000000000000000000000000000000000000000000000" 13 | } 14 | }, 15 | "pause": { 16 | "inception_block": { 17 | "mainnet": "8928171", 18 | "kovan": "14764552" 19 | }, 20 | "events": { 21 | "exec": "0x168ccd6700000000000000000000000000000000000000000000000000000000", 22 | "plot": "0x46d2fbbb00000000000000000000000000000000000000000000000000000000" 23 | } 24 | }, 25 | "proxy_factory": { 26 | "initiate_link_gas": 45840, 27 | "approve_link_gas": 886503, 28 | "send_mkr_gas": 46471, 29 | "total_link_gas": 1123568 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/contracts/addresses/mainnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "TUB": "0x448a5065aebb8e423f0896e6c5d525c040f59af3", 3 | "REDEEMER": "0x642ae78fafbb8032da552d619ad43f1d81e4dd7c", 4 | "OLD_MKR": "0xC66eA802717bFb9833400264Dd12c2bCeAa34a6d", 5 | "GET_CDPS_1": "0x36a724bd100c39f0ea4d3a20f7097ee01a8ff573", 6 | "CDP_MANAGER_1": "0x5ef30b9986345249bc32d8928b7ee64de9435e39", 7 | "MCD_END_1": "0xab14d3ce3f733cacb76ec2abe7d2fcb00c99f3d5", 8 | "MCD_VAT_1": "0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b", 9 | "MCD_DAI_1": "0x6b175474e89094c44da98b954eedeac495271d0f", 10 | "MCD_POT_1": "0x197e90f9fad81970ba7976f33cbd77088e5d7cf7", 11 | "OLD_CHIEF": "0x8e2a84d6ade1e7fffee039a35ef5f19f13057152", 12 | "OLD_VOTE_PROXY_FACTORY": "0xa63E145309cadaa6A903a19993868Ef7E85058BE", 13 | "PROXY_ACTIONS_END": "0x7AfF9FC9faD225e3c88cDA06BC56d8Aca774bC57", 14 | "MCD_JOIN_ETH_A": "0x2f0b23f53734252bda2277357e97e1517d6b042a", 15 | "MCD_JOIN_DAI": "0x9759a6ac90977b93b58547b4a71c78317f391a28", 16 | "MCD_JOIN_BAT_A": "0x3D0B1912B66114d4096F48A8CEe3A56C231772cA", 17 | "MCD_JOIN_USDC_A": "0xA191e578a6736167326d05c119CE0c90849E84B7", 18 | "SAI_CAGEFREE": "0x9fdc15106da755f9FfD5b0BA9854Cfb89602E0fd" 19 | } 20 | -------------------------------------------------------------------------------- /packages/test-helpers/src/mineBlocks.ts: -------------------------------------------------------------------------------- 1 | import callGanache from './callGanache'; 2 | import assert from 'assert'; 3 | 4 | const WAIT_AFTER_MINE_CALL = 250; 5 | 6 | export default async function mineBlocks(service, count) { 7 | let web3Service; 8 | const serviceName = service.manager().name(); 9 | if (serviceName === 'web3') { 10 | web3Service = service; 11 | } else { 12 | if (serviceName !== 'token') service = service.get('token'); 13 | web3Service = service.get('web3'); 14 | } 15 | if (!count) count = web3Service.confirmedBlockCount() + 2; 16 | 17 | assert( 18 | WAIT_AFTER_MINE_CALL > web3Service._pollingInterval * 2, 19 | 'mineBlocks may not work well; pollingInterval is too long' 20 | ); 21 | 22 | const initialNumber = web3Service.blockNumber(); 23 | 24 | for (let i = 0; i < count; i++) { 25 | await callGanache('evm_mine'); 26 | await new Promise(resolve => setTimeout(resolve, WAIT_AFTER_MINE_CALL)); 27 | } 28 | 29 | const newNumber = web3Service.blockNumber(); 30 | const expectedNumber = initialNumber + count; 31 | assert( 32 | newNumber >= expectedNumber, 33 | `blockNumber should be >= ${expectedNumber}, is ${newNumber}` 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSThing.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GemLike2.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/GemLike6.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | // TODO: move plugin type declaration to @makerdao/dai 4 | 5 | type AfterCreateCallback = () => void; 6 | 7 | type DaiPlugin = { 8 | addConfig?: () => void; 9 | beforeCreate?: () => void; 10 | afterCreate?: AfterCreateCallback; 11 | } | AfterCreateCallback; 12 | 13 | // TODO: move currency type declaration to @makerdao/currency 14 | 15 | export const DAI: Currency; 16 | export const DSR_DAI: Currency; 17 | export const MKR: Currency; 18 | export const USD: Currency; 19 | 20 | export const BAT: Currency; 21 | export const DGD: Currency; 22 | export const ETH: Currency; 23 | export const GNT: Currency; 24 | export const KNC: Currency; 25 | export const MANA: Currency; 26 | export const OMG: Currency; 27 | export const REP: Currency; 28 | export const TUSD: Currency; 29 | export const USDC: Currency; 30 | export const WBTC: Currency; 31 | export const WETH: Currency; 32 | export const ZRX: Currency; 33 | 34 | type CdpTypeInfo = { 35 | currency: Currency; 36 | ilk: string; 37 | decimals?: number; 38 | }; 39 | 40 | export const defaultCdpTypes: CdpTypeInfo[]; 41 | 42 | declare const mcdPlugin: DaiPlugin; 43 | export default mcdPlugin; -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSThing.json: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/DSSpell.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"data","outputs":[{"name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cast","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"done","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"mana","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"whom","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"whom_","type":"address"},{"name":"mana_","type":"uint256"},{"name":"data_","type":"bytes"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/test-helpers/scripts/fundTestAccount.js: -------------------------------------------------------------------------------- 1 | // usage: 2 | // > node_modules/.bin/babel-node scripts/fundTestAccount.js
3 | 4 | import Maker from '../packages/dai/src'; 5 | import McdPlugin from '../packages/dai-plugin-mcd/src'; 6 | import { isAddress } from 'web3-utils'; 7 | import map from 'lodash/map'; 8 | import uniq from 'lodash/uniq'; 9 | 10 | const amount = 5; 11 | 12 | async function main() { 13 | const maker = await Maker.create('test', { plugins: [McdPlugin] }); 14 | const address = process.argv[process.argv.length - 1]; 15 | if (!isAddress(address)) { 16 | console.log('Pass a valid address as the last argument.'); 17 | return; 18 | } 19 | console.log(`Sending to ${address}`); 20 | const { cdpTypes } = maker.service('mcd:cdpType'); 21 | const currencies = uniq(map(cdpTypes, 'currency')); 22 | 23 | for (let cur of currencies) { 24 | process.stdout.write(`Sending ${amount} ${cur.symbol}... `); 25 | await maker.getToken(cur).transfer(address, amount); 26 | console.log('done'); 27 | } 28 | } 29 | 30 | (async fn => { 31 | try { 32 | await fn(); 33 | process.exit(); 34 | } catch (err) { 35 | console.error(err); 36 | process.exit(1); 37 | } 38 | })(main); 39 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/User.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"contract ERC20","name":"mkr_","type":"address"},{"internalType":"contract GemPit","name":"pit_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":false,"inputs":[],"name":"burnPit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"whom","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"doApprove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"doBurn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"whom","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"doBurn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"doMint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/schemas/jug.ts: -------------------------------------------------------------------------------- 1 | import BigNumber from 'bignumber.js'; 2 | import { toHex } from '../utils'; 3 | import { RAY } from '../constants'; 4 | 5 | import { 6 | ANNUAL_STABILITY_FEE, 7 | DATE_STABILITY_FEES_LAST_LEVIED, 8 | BASE_COLLATERAL_FEE 9 | } from './_constants'; 10 | 11 | const secondsPerYear = 60 * 60 * 24 * 365; 12 | 13 | export const jugIlks = { 14 | generate: collateralTypeName => ({ 15 | id: `MCD_JUG.ilks(${collateralTypeName})`, 16 | contract: 'MCD_JUG', 17 | call: ['ilks(bytes32)(uint256,uint48)', toHex(collateralTypeName)] 18 | }), 19 | returns: [ 20 | [ 21 | ANNUAL_STABILITY_FEE, 22 | v => { 23 | v = new BigNumber(v.toString()).dividedBy(RAY); 24 | BigNumber.config({ POW_PRECISION: 100 }); 25 | return v.pow(secondsPerYear).minus(1); 26 | } 27 | ], 28 | [DATE_STABILITY_FEES_LAST_LEVIED, val => new Date(val * 1000)] 29 | ] 30 | }; 31 | 32 | export const jugBase = { 33 | generate: () => ({ 34 | id: 'MCD_JUG.base', 35 | contract: 'MCD_JUG', 36 | call: ['base()(uint256)'] 37 | }), 38 | returns: [[BASE_COLLATERAL_FEE, v => new BigNumber(v)]] 39 | }; 40 | 41 | export default { 42 | jugIlks, 43 | jugBase 44 | }; 45 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/CdpTypeService.spec.js: -------------------------------------------------------------------------------- 1 | import { mcdMaker } from './helpers'; 2 | import { ServiceRoles } from '../src/constants'; 3 | import { ETH } from '../src'; 4 | 5 | let maker, service; 6 | 7 | describe('with default types', () => { 8 | beforeAll(async () => { 9 | maker = await mcdMaker(); 10 | service = maker.service(ServiceRoles.CDP_TYPE); 11 | }); 12 | 13 | test('getCdpType with no matches throws an error', () => { 14 | expect(() => { 15 | service.getCdpType('FOO'); 16 | }).toThrowError(/matches no cdp type/); 17 | }); 18 | 19 | test('prefetch all cdpTypes', async () => { 20 | service.resetAllCdpTypes(); 21 | await service.prefetchAllCdpTypes(); 22 | expect(() => { 23 | service.totalDebtAllCdpTypes; 24 | }).not.toThrowError(); 25 | }); 26 | }); 27 | 28 | test('getCdpType with too many matches throws an error', async () => { 29 | maker = await mcdMaker({ 30 | cdpTypes: [ 31 | { currency: ETH, ilk: 'ETH-A' }, 32 | { currency: ETH, ilk: 'ETH-B' } 33 | ] 34 | }); 35 | service = maker.service(ServiceRoles.CDP_TYPE); 36 | 37 | expect(() => { 38 | service.getCdpType(ETH); 39 | }).toThrowError(/matches more than one cdp type/); 40 | }); 41 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/DSSpell.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"data","outputs":[{"name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cast","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"done","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"mana","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"whom","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"whom_","type":"address"},{"name":"mana_","type":"uint256"},{"name":"data_","type":"bytes"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"}] 2 | -------------------------------------------------------------------------------- /packages/dai/contracts/abis/CageFree.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"_tap","type":"address"},{"internalType":"address","name":"_weth","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FreeCash","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"freeCash","outputs":[{"internalType":"uint256","name":"cashoutBalance","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"sai","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tap","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-governance/contracts/contract-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "chief": { 3 | "inception_block": { 4 | "mainnet": "0x487813", 5 | "kovan": "0x649575", 6 | "goerli": "0x649575" 7 | }, 8 | "events": { 9 | "etch": "0x4f0892983790f53eea39a7a496f6cb40e8811b313871337b6a761efc6c67bb1f", 10 | "vote_slate": "0xa69beaba00000000000000000000000000000000000000000000000000000000", 11 | "vote_addresses": "0xed08132900000000000000000000000000000000000000000000000000000000", 12 | "lock": "0xdd46706400000000000000000000000000000000000000000000000000000000", 13 | "free": "0xd8ccd0f300000000000000000000000000000000000000000000000000000000" 14 | } 15 | }, 16 | "pause": { 17 | "inception_block": { 18 | "mainnet": "8928171", 19 | "kovan": "14764552", 20 | "goerli": "14764552" 21 | }, 22 | "events": { 23 | "exec": "0x168ccd6700000000000000000000000000000000000000000000000000000000", 24 | "plot": "0x46d2fbbb00000000000000000000000000000000000000000000000000000000" 25 | } 26 | }, 27 | "proxy_factory": { 28 | "initiate_link_gas": 45840, 29 | "approve_link_gas": 886503, 30 | "send_mkr_gas": 46471, 31 | "total_link_gas": 1123568 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/MockVat.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"name":"Line","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"bytes32","name":"what","type":"bytes32"},{"internalType":"uint256","name":"data","type":"uint256"}],"name":"file","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"what","type":"bytes32"},{"internalType":"uint256","name":"data","type":"uint256"}],"name":"file","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"ilks","outputs":[{"internalType":"uint256","name":"Art","type":"uint256"},{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"spot","type":"uint256"},{"internalType":"uint256","name":"line","type":"uint256"},{"internalType":"uint256","name":"dust","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"uint256","name":"rad","type":"uint256"}],"name":"setDebt","outputs":[],"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-scd/contracts/abis/CageFree.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"_tap","type":"address"},{"internalType":"address","name":"_weth","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FreeCash","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"freeCash","outputs":[{"internalType":"uint256","name":"cashoutBalance","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"sai","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tap","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/contracts/abis/CageFree.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"_tap","type":"address"},{"internalType":"address","name":"_weth","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FreeCash","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"freeCash","outputs":[{"internalType":"uint256","name":"cashoutBalance","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"sai","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tap","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/test/migrations/MkrRedeemer.spec.js: -------------------------------------------------------------------------------- 1 | import { migrationMaker } from '../helpers'; 2 | import { ServiceRoles, Migrations } from '../../src/constants'; 3 | import { OLD_MKR } from '../../src'; 4 | 5 | let maker, migration; 6 | 7 | describe('MKR migration check', () => { 8 | beforeAll(async () => { 9 | maker = await migrationMaker(); 10 | migration = maker 11 | .service(ServiceRoles.MIGRATION) 12 | .getMigration(Migrations.MKR_REDEEMER); 13 | }); 14 | 15 | test('if the account has no old MKR, return zero', async () => { 16 | await addFreshAccount(); 17 | maker.service('accounts').useAccount('newAccount'); 18 | expect(await migration.check()).toEqual(OLD_MKR(0)); 19 | maker.service('accounts').useAccount('default'); 20 | }); 21 | 22 | test('if the account has old MKR, return balance', async () => { 23 | const amount = await migration.check(); 24 | expect(amount).toEqual(OLD_MKR(400)); 25 | }); 26 | }); 27 | 28 | async function addFreshAccount() { 29 | const newKey = 30 | 'b3ae65f191aac33f3e3f662b8411cabf14f91f2b48cf338151d6021ea1c08541'; 31 | await maker.service('accounts').addAccount('newAccount', { 32 | type: 'privateKey', 33 | key: newKey 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/test/Auction.spec.js: -------------------------------------------------------------------------------- 1 | import { mcdMaker } from './helpers'; 2 | import { ServiceRoles } from '../src/constants'; 3 | 4 | const scenarios = [['ETH-A'], ['DAI'], ['MKR']]; 5 | 6 | /* 7 | The following arrays are expected values for each tested 8 | collateral type. The defined values are: 9 | [max bid lifetime, min bid increase] 10 | */ 11 | const systemData = { 12 | 'ETH-A': [1, 0.01, 0.04], 13 | DAI: [3, 0.05, 2], 14 | MKR: [3, 0.05, 2] 15 | }; 16 | 17 | describe.each(scenarios)('%s', ilk => { 18 | let auction; 19 | 20 | beforeAll(async () => { 21 | const maker = await mcdMaker(); 22 | const service = maker.service(ServiceRoles.AUCTION); 23 | auction = service.getAuction(ilk); 24 | }); 25 | 26 | test('get max bid lifetime', async () => { 27 | const time = await auction.getMaxBidLifetime(); 28 | expect(time).toBe(systemData[ilk][0]); 29 | }); 30 | 31 | test('get min bid increase', async () => { 32 | const time = await auction.getMinBidIncrease(); 33 | expect(time).toBe(systemData[ilk][1]); 34 | }); 35 | 36 | test('get max auction duration', async () => { 37 | const time = await auction.getMaxAuctionDuration(); 38 | expect(time).toBeCloseTo(systemData[ilk][2]); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /packages/test-helpers/scripts/generateDai.js: -------------------------------------------------------------------------------- 1 | // usage: 2 | // > node_modules/.bin/babel-node packages/test-helpers/scripts/generateDai.js
3 | 4 | import { isAddress } from 'web3-utils'; 5 | import { DAI, ETH } from '@makerdao/dai-plugin-mcd/src/index'; 6 | import { mcdMaker } from '@makerdao/dai-plugin-mcd/test/helpers'; 7 | 8 | async function main() { 9 | const maker = await mcdMaker(); 10 | const address = process.argv[process.argv.length - 2]; 11 | const amount = process.argv[process.argv.length - 1]; 12 | if (!isAddress(address)) { 13 | console.log('Pass a valid address as the last argument.'); 14 | return; 15 | } 16 | 17 | maker.service('accounts').useAccountWithAddress(address); 18 | console.log(`Generating ${amount} DAI for ${address}`); 19 | const cdpMgr = maker.service('mcd:cdpManager'); 20 | 21 | await cdpMgr.openLockAndDraw('ETH-A', ETH(1), DAI(amount)); 22 | 23 | const dai = cdpMgr.get('token').getToken(DAI); 24 | const balance = await dai.balanceOf(address) 25 | console.log(`Balance of ${address}: ${balance}`) 26 | 27 | } 28 | 29 | (async fn => { 30 | try { 31 | await fn(); 32 | process.exit(); 33 | } catch (err) { 34 | console.error(err); 35 | process.exit(1); 36 | } 37 | })(main); 38 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/FaucetUser.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"contract DSToken","name":"token_","type":"address"},{"internalType":"contract RestrictedTokenFaucet","name":"faucet_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":false,"inputs":[],"name":"doGulp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"doHope","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"doNope","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"tok","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"}],"name":"doSetAmt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"doShut","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"doUndo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/scripts/install-testchain-outputs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | CONTRACTS=$MIGRATIONS/contracts 5 | PLUGIN_ADDRESSES=$CONTRACTS/addresses/testnet.json 6 | 7 | # Relevant contracts from SCD: 8 | for CONTRACT in "TUB","SaiTub" "TAP","SaiTap" "REDEEMER","Redeemer" "OLD_MKR","DSToken" "OLD_CHIEF","DSChief" "SAI_CAGEFREE","CageFree" "OLD_VOTE_PROXY_FACTORY","VoteProxyFactory" 9 | do 10 | set_address_and_abi $CONTRACT $SCD_ADDRESSES $SCD_ABIS $PLUGIN_ADDRESSES 11 | done 12 | 13 | # Relevant contracts from MCD: 14 | for CONTRACT in "MCD_JOIN_ETH_A","GemJoin" "MCD_JOIN_DAI","DaiJoin" "MCD_JOIN_BAT_A","GemJoin" "MIGRATION","ScdMcdMigration" "MIGRATION_PROXY_ACTIONS","MigrationProxyActions" "PROXY_ACTIONS_END","DssProxyActionsEnd" "MCD_JOIN_USDC_A","GemJoin" "MCD_ESM","ESM" 15 | do 16 | set_address_and_abi $CONTRACT $MCD_ADDRESSES $MCD_ABIS $PLUGIN_ADDRESSES 17 | done 18 | 19 | # Contracts (from MCD) with numbered versions: 20 | for CONTRACT in "MCD_END","END" "MCD_VAT","VAT" "GET_CDPS","GetCdps" "CDP_MANAGER","DssCdpManager" "MCD_DAI","Dai" "MCD_POT","Pot" 21 | do 22 | VERSION="_1" 23 | set_address_and_abi $CONTRACT $MCD_ADDRESSES $MCD_ABIS $PLUGIN_ADDRESSES $VERSION 24 | done 25 | 26 | # Add 'SAI_' prefix to relevant contracts 27 | add_prefix $PLUGIN_ADDRESSES -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/contracts/addresses/kovan.json: -------------------------------------------------------------------------------- 1 | { 2 | "TUB": "0xa71937147b55Deb8a530C7229C442Fd3F31b7db2", 3 | "GET_CDPS_1": "0x592301a23d37c591C5856f28726AF820AF8e7014", 4 | "CDP_MANAGER_1": "0x1476483dD8C35F25e568113C5f70249D3976ba21", 5 | "MCD_END_1": "0x24728AcF2E2C403F5d2db4Df6834B8998e56aA5F", 6 | "MCD_VAT_1": "0xbA987bDB501d131f766fEe8180Da5d81b34b69d9", 7 | "MCD_DAI_1": "0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa", 8 | "MCD_POT_1": "0xEA190DBDC7adF265260ec4dA6e9675Fd4f5A78bb", 9 | "REDEEMER": "0x2c0f31271673cc29927be725104642aad65a253e", 10 | "OLD_MKR": "0x4bb514a7f83fbb13c2b41448208e89fabbcfe2fb", 11 | "MIGRATION": "0x411B2Faa662C8e3E5cF8f01dFdae0aeE482ca7b0", 12 | "MIGRATION_PROXY_ACTIONS": "0xF56765d255463139d3aff1613705a5520764Ab93", 13 | "OLD_CHIEF": "0x27E0c9567729Ea6e3241DE74B3dE499b7ddd3fe6", 14 | "OLD_VOTE_PROXY_FACTORY": null, 15 | "PROXY_ACTIONS_END": "0x7c3f28f174F2b0539C202a5307Ff48efa61De982", 16 | "MCD_JOIN_ETH_A": "0x775787933e92b709f2a3c70aa87999696e74a9f8", 17 | "MCD_JOIN_DAI": "0x5aa71a3ae1c0bd6ac27a1f28e1415fffb6f15b8c", 18 | "MCD_JOIN_BAT_A": "0x2a4C485B1B8dFb46acCfbeCaF75b6188A59dBd0a", 19 | "MCD_JOIN_USDC_A": "0x4c514656E7dB7B859E994322D2b511d99105C1Eb", 20 | "SAI_CAGEFREE": "0xF3095A1822cA8fb3D0955595fA3888b68C4B8124" 21 | } 22 | -------------------------------------------------------------------------------- /packages/dai-plugin-migrations/contracts/abiMap.js: -------------------------------------------------------------------------------- 1 | // not run through babel, so we must use an ES5-safe export 2 | export default { 3 | SAI_TUB: require('./abis/SaiTub.json'), 4 | MCD_END_1: require('./abis/End.json'), 5 | MCD_VAT_1: require('./abis/Vat.json'), 6 | GET_CDPS_1: require('./abis/GetCdps.json'), 7 | CDP_MANAGER_1: require('./abis/DssCdpManager.json'), 8 | MCD_DAI_1: require('./abis/Dai.json'), 9 | MCD_POT_1: require('./abis/Pot.json'), 10 | MCD_END: require('./abis/End.json'), 11 | MCD_VAT: require('./abis/Vat.json'), 12 | GET_CDPS: require('./abis/GetCdps.json'), 13 | CDP_MANAGER: require('./abis/DssCdpManager.json'), 14 | MCD_DAI: require('./abis/Dai.json'), 15 | MCD_POT: require('./abis/Pot.json'), 16 | REDEEMER: require('./abis/Redeemer.json'), 17 | MIGRATION: require('./abis/ScdMcdMigration.json'), 18 | MIGRATION_PROXY_ACTIONS: require('./abis/MigrationProxyActions.json'), 19 | OLD_CHIEF: require('./abis/DSChief.json'), 20 | OLD_VOTE_PROXY_FACTORY: require('./abis/VoteProxyFactory.json'), 21 | OLD_MKR: require('./abis/DSToken.json'), 22 | 'MCD_JOIN_*': require('./abis/GemJoin.json'), 23 | PROXY_ACTIONS_END: require('./abis/DssProxyActionsEnd.json'), 24 | SAI_CAGEFREE: require('./abis/CageFree.json'), 25 | MCD_ESM: require('./abis/ESM.json') 26 | }; 27 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/DSProxyFactory.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"proxy","type":"address"},{"indexed":false,"internalType":"address","name":"cache","type":"address"}],"name":"Created","type":"event"},{"constant":false,"inputs":[],"name":"build","outputs":[{"internalType":"address payable","name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"build","outputs":[{"internalType":"address payable","name":"proxy","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"cache","outputs":[{"internalType":"contract DSProxyCache","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isProxy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/contracts/abis/Token6.json: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"supply","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"dst","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Transfer","type":"event"}] -------------------------------------------------------------------------------- /packages/dai-plugin-mcd/src/Auction.js: -------------------------------------------------------------------------------- 1 | import { WAD } from './constants'; 2 | import BigNumber from 'bignumber.js'; 3 | import { DAI } from './tokens'; 4 | 5 | export default class Auction { 6 | constructor(ilk, smartContractService) { 7 | switch (ilk) { 8 | case DAI.symbol: 9 | this.contract = smartContractService.getContract('MCD_FLAP'); 10 | break; 11 | case 'MKR': 12 | this.contract = smartContractService.getContract('MCD_FLOP'); 13 | break; 14 | default: 15 | this.contract = smartContractService.getContract( 16 | 'MCD_FLIP_' + ilk.replace(/-/g, '_') 17 | ); 18 | } 19 | } 20 | 21 | // returns time in hours 22 | async getMaxBidLifetime() { 23 | return (await this.contract.ttl()) / 3600; 24 | } 25 | 26 | // returns time in days 27 | async getMaxAuctionDuration() { 28 | return (await this.contract.tau()) / 86400; 29 | } 30 | 31 | // returns decimal representation of minimum percentage increase 32 | async getMinBidIncrease() { 33 | const beg = await this.contract.beg(); 34 | // the contract's BigNumber implementation (bn.js) doesn't support decimals, 35 | // so we use bignumber.js instead 36 | return new BigNumber(beg._hex) 37 | .div(WAD) 38 | .minus(1) 39 | .toNumber(); 40 | } 41 | } 42 | --------------------------------------------------------------------------------