├── .circleci └── config.yml ├── .dockerignore ├── .eslintignore ├── .eslintrc.js ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── task.md ├── PULL_REQUEST_TEMPLATE.md └── dco.yml ├── .gitignore ├── .gitmodules ├── .prettierignore ├── .prettierrc ├── .yarnrc ├── CODEOWNERS ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── MAINTAINING.md ├── README.md ├── STYLE.md ├── ci ├── check_lerna_packages.sh ├── coverage.sh ├── dockerhub.sh ├── dockerhub_workflow.sh ├── false_positive.sh ├── generate_lerna_config.sh ├── install_node_npm.sh ├── lint.sh ├── run_slither.sh └── tests │ ├── test-financial-templates-lib.sh │ ├── test-integration.sh │ ├── test-liquidator.sh │ ├── test-not-required.sh │ ├── test-packages.sh │ └── test-required.sh ├── hardhat.config.js ├── lerna.json ├── package.json ├── packages ├── affiliates │ ├── .gitignore │ ├── .mocharc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── gas-rebate │ │ ├── FindBlockAtTimeStamp.js │ │ ├── VoterGasRebate.js │ │ ├── VoterGasRebateV2.ts │ │ └── rebates │ │ │ ├── Rebate_1.json │ │ │ ├── Rebate_10.json │ │ │ ├── Rebate_11.json │ │ │ ├── Rebate_12.json │ │ │ ├── Rebate_13.json │ │ │ ├── Rebate_14.json │ │ │ ├── Rebate_15.json │ │ │ ├── Rebate_16.json │ │ │ ├── Rebate_17.json │ │ │ ├── Rebate_18.json │ │ │ ├── Rebate_19.json │ │ │ ├── Rebate_2.json │ │ │ ├── Rebate_20.json │ │ │ ├── Rebate_21.json │ │ │ ├── Rebate_22.json │ │ │ ├── Rebate_23.json │ │ │ ├── Rebate_24.json │ │ │ ├── Rebate_25.json │ │ │ ├── Rebate_26.json │ │ │ ├── Rebate_27.json │ │ │ ├── Rebate_28.json │ │ │ ├── Rebate_29.json │ │ │ ├── Rebate_3.json │ │ │ ├── Rebate_30.json │ │ │ ├── Rebate_31.json │ │ │ ├── Rebate_32.json │ │ │ ├── Rebate_33.json │ │ │ ├── Rebate_34.json │ │ │ ├── Rebate_35.json │ │ │ ├── Rebate_36.json │ │ │ ├── Rebate_37.json │ │ │ ├── Rebate_38.json │ │ │ ├── Rebate_39.json │ │ │ ├── Rebate_4.json │ │ │ ├── Rebate_40.json │ │ │ ├── Rebate_41.json │ │ │ ├── Rebate_42.json │ │ │ ├── Rebate_43.json │ │ │ ├── Rebate_44.json │ │ │ ├── Rebate_45.json │ │ │ ├── Rebate_46.json │ │ │ ├── Rebate_47.json │ │ │ ├── Rebate_48.json │ │ │ ├── Rebate_49.json │ │ │ ├── Rebate_5.json │ │ │ ├── Rebate_50.json │ │ │ ├── Rebate_51.json │ │ │ ├── Rebate_52.json │ │ │ ├── Rebate_53.json │ │ │ ├── Rebate_54.json │ │ │ ├── Rebate_55.json │ │ │ ├── Rebate_56.json │ │ │ ├── Rebate_6.json │ │ │ ├── Rebate_7.json │ │ │ ├── Rebate_8.json │ │ │ └── Rebate_9.json │ ├── hardhat.config.js │ ├── package.json │ ├── test │ │ └── mocha-local │ │ │ └── gas-rebate │ │ │ └── VoterGasRebate.js │ └── tsconfig.json ├── api │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── apps │ │ │ ├── README.md │ │ │ ├── api │ │ │ │ ├── README.md │ │ │ │ ├── app.ts │ │ │ │ └── index.ts │ │ │ ├── datastore_api │ │ │ │ ├── README.md │ │ │ │ ├── app.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── lsp_api │ │ │ │ ├── README.md │ │ │ │ ├── app.ts │ │ │ │ └── index.ts │ │ │ ├── serverless_read │ │ │ │ ├── README.md │ │ │ │ ├── app.ts │ │ │ │ └── index.ts │ │ │ └── serverless_write │ │ │ │ ├── README.md │ │ │ │ ├── app.ts │ │ │ │ └── index.ts │ │ ├── examples │ │ │ ├── README.md │ │ │ ├── action-client.e2e.ts │ │ │ ├── action-client.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── libs │ │ │ ├── index.ts │ │ │ ├── osnap │ │ │ │ ├── index.ts │ │ │ │ ├── interfaces.ts │ │ │ │ └── utils.ts │ │ │ ├── queries │ │ │ │ ├── emp.ts │ │ │ │ ├── global.ts │ │ │ │ ├── index.ts │ │ │ │ └── lsp.ts │ │ │ ├── utils.test.ts │ │ │ ├── utils.ts │ │ │ ├── zrx.e2e.ts │ │ │ └── zrx.ts │ │ ├── services │ │ │ ├── README.md │ │ │ ├── actions │ │ │ │ ├── emp.ts │ │ │ │ ├── global.ts │ │ │ │ ├── index.ts │ │ │ │ ├── lsp.ts │ │ │ │ ├── osnap.ts │ │ │ │ └── scheduler.ts │ │ │ ├── contracts.ts │ │ │ ├── emp-registry.ts │ │ │ ├── emp-state.ts │ │ │ ├── erc20-state.ts │ │ │ ├── express-channels.ts │ │ │ ├── express.ts │ │ │ ├── index.ts │ │ │ ├── lsp-creator.ts │ │ │ ├── lsp-state.e2e.ts │ │ │ ├── lsp-state.ts │ │ │ └── multi-lsp-creator.ts │ │ ├── start.ts │ │ ├── tables │ │ │ ├── addresses │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── app-stats │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── emp-stats-history │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── emp-stats │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── index.ts │ │ │ ├── lsps │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── price-samples │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── registered-contracts │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── stores-factory.ts │ │ │ └── tvl │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ └── types.ts │ └── tsconfig.json ├── common │ ├── .mocharc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── hardhat.config.js │ ├── package.json │ ├── src │ │ ├── AdminUtils.ts │ │ ├── AncillaryDataParser.ts │ │ ├── AxiosRetry.ts │ │ ├── Constants.ts │ │ ├── ContractUtils.ts │ │ ├── Crypto.ts │ │ ├── EmpUtils.ts │ │ ├── EncryptionHelper.ts │ │ ├── Enums.ts │ │ ├── EthersProviderUtils.ts │ │ ├── EthersSignerUtils.ts │ │ ├── EventUtils.ts │ │ ├── FileHelpers.ts │ │ ├── FormattingUtils.ts │ │ ├── HardhatConfig.ts │ │ ├── MerkleTree.ts │ │ ├── MultiDecimalTestHelper.ts │ │ ├── MultiVersionTestHelpers.ts │ │ ├── ObjectUtils.ts │ │ ├── PriceIdentifierUtils.ts │ │ ├── ProviderUtils.ts │ │ ├── PublicNetworks.ts │ │ ├── Random.ts │ │ ├── RetryProvider.ts │ │ ├── RoundingUtils.ts │ │ ├── SolidityTestUtils.ts │ │ ├── TenderlyFork.ts │ │ ├── TenderlySimulation.ts │ │ ├── TimeUtils.ts │ │ ├── TransactionUtils.ts │ │ ├── UniswapV3Helpers.ts │ │ ├── browser.ts │ │ ├── gckms │ │ │ ├── GckmsConfig.ts │ │ │ ├── KeyInjectorPlugin.ts │ │ │ ├── ManagedSecretProvider.ts │ │ │ └── utils.ts │ │ ├── hardhat │ │ │ ├── fixtures │ │ │ │ ├── VotingV2.ts │ │ │ │ ├── default.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── plugins │ │ │ │ └── ExtendedWeb3.ts │ │ │ └── tasks │ │ │ │ ├── artifacts.ts │ │ │ │ ├── bridge.ts │ │ │ │ ├── collateralWhitelist.ts │ │ │ │ ├── compile.ts │ │ │ │ ├── dvmv2Testnet.ts │ │ │ │ ├── finder.ts │ │ │ │ ├── identifiers.ts │ │ │ │ ├── oracle.ts │ │ │ │ ├── ownership.ts │ │ │ │ ├── registry.ts │ │ │ │ ├── test.ts │ │ │ │ ├── types.ts │ │ │ │ └── xchainSetup.ts │ │ ├── index.ts │ │ └── types.ts │ ├── test │ │ ├── AncillaryDataParser.js │ │ ├── RoundingUtils.js │ │ ├── SolidityTestUtils.js │ │ └── TransactionUtils.js │ ├── tsconfig.json │ └── types │ │ ├── node-metamask │ │ └── index.d.ts │ │ ├── umaprotocol__truffle-ledger-provider │ │ └── index.d.ts │ │ └── umaprotocol__ynatm │ │ └── index.d.ts ├── contract-notifier │ ├── CHANGELOG.md │ ├── README.md │ ├── index.js │ ├── package.json │ └── src │ │ └── ContractNotifier.js ├── contracts-frontend │ ├── CHANGELOG.md │ ├── README.md │ ├── hardhat.config.cjs │ ├── package.json │ └── tsconfig.json ├── contracts-node │ ├── CHANGELOG.md │ ├── README.md │ ├── hardhat.config.js │ ├── package.json │ └── tsconfig.json ├── core │ ├── .gitignore │ ├── .mocharc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── config │ │ ├── adapters │ │ │ └── defiLlama │ │ │ │ └── oSnap.json │ │ ├── identifiers.json │ │ └── identifiersTest.json │ ├── contracts │ │ ├── common │ │ │ ├── implementation │ │ │ │ ├── AddressWhitelist.sol │ │ │ │ ├── AncillaryData.sol │ │ │ │ ├── ExpandedERC20.sol │ │ │ │ ├── FixedPoint.sol │ │ │ │ ├── HasFinder.sol │ │ │ │ ├── Lockable.sol │ │ │ │ ├── MultiCaller.sol │ │ │ │ ├── MultiRole.sol │ │ │ │ ├── Multicall3.sol │ │ │ │ ├── Stakeable.sol │ │ │ │ ├── Testable.sol │ │ │ │ ├── TestnetERC20.sol │ │ │ │ ├── Timer.sol │ │ │ │ ├── Withdrawable.sol │ │ │ │ └── dsproxy │ │ │ │ │ ├── DSGuardFactory.sol │ │ │ │ │ └── DSProxyFactory.sol │ │ │ ├── interfaces │ │ │ │ ├── AddressWhitelistInterface.sol │ │ │ │ ├── Balancer.sol │ │ │ │ ├── ExpandedIERC20.sol │ │ │ │ ├── HarvestVaultInterface.sol │ │ │ │ ├── IERC20Standard.sol │ │ │ │ ├── Multicall.sol │ │ │ │ ├── Multicall2.sol │ │ │ │ ├── TransactionBatcher.sol │ │ │ │ ├── UniswapV2.sol │ │ │ │ ├── UniswapV3.sol │ │ │ │ └── VaultInterface.sol │ │ │ └── test │ │ │ │ ├── AncillaryDataTest.sol │ │ │ │ ├── BalancerMock.sol │ │ │ │ ├── BasicERC20.sol │ │ │ │ ├── HarvestVaultMock.sol │ │ │ │ ├── MintableERC721.sol │ │ │ │ ├── MultiCallerTest.sol │ │ │ │ ├── MultiRoleTest.sol │ │ │ │ ├── MulticallMock.sol │ │ │ │ ├── PerpetualMock.sol │ │ │ │ ├── ReentrancyAttack.sol │ │ │ │ ├── ReentrancyChecker.sol │ │ │ │ ├── ReentrancyMock.sol │ │ │ │ ├── SignedFixedPointTest.sol │ │ │ │ ├── TestableTest.sol │ │ │ │ ├── UniswapV2Mock.sol │ │ │ │ ├── UniswapV3Mock.sol │ │ │ │ ├── UnsignedFixedPointTest.sol │ │ │ │ ├── VaultMock.sol │ │ │ │ └── WithdrawableTest.sol │ │ ├── cross-chain-oracle │ │ │ ├── AncillaryDataCompression.sol │ │ │ ├── GovernorHub.sol │ │ │ ├── GovernorSpoke.sol │ │ │ ├── OracleBase.sol │ │ │ ├── OracleHub.sol │ │ │ ├── OracleSpoke.sol │ │ │ ├── README.md │ │ │ ├── SpokeBase.sol │ │ │ ├── chain-adapters │ │ │ │ ├── Admin_ChildMessenger.sol │ │ │ │ ├── Arbitrum_ChildMessenger.sol │ │ │ │ ├── Arbitrum_ParentMessenger.sol │ │ │ │ ├── Optimism_ChildMessenger.sol │ │ │ │ ├── Optimism_ParentMessenger.sol │ │ │ │ ├── ParentMessengerBase.sol │ │ │ │ ├── Polygon_ChildMessenger.sol │ │ │ │ ├── Polygon_ParentMessenger.sol │ │ │ │ └── test │ │ │ │ │ ├── Arbitrum_inboxMock.sol │ │ │ │ │ ├── OVM_L1CrossDomainMessengerMock.sol │ │ │ │ │ ├── ParentMessengerBaseMock.sol │ │ │ │ │ ├── Polygon_ChildMessengerMock.sol │ │ │ │ │ └── Polygon_ParentMessengerMock.sol │ │ │ ├── interfaces │ │ │ │ ├── ChildMessengerConsumerInterface.sol │ │ │ │ ├── ChildMessengerInterface.sol │ │ │ │ ├── ParentMessengerConsumerInterface.sol │ │ │ │ └── ParentMessengerInterface.sol │ │ │ └── test │ │ │ │ ├── GovernorMessengerMock.sol │ │ │ │ ├── OracleBaseMock.sol │ │ │ │ └── OracleMessengerMock.sol │ │ ├── data-verification-mechanism │ │ │ ├── README.md │ │ │ ├── implementation │ │ │ │ ├── AdminIdentifierLib.sol │ │ │ │ ├── Constants.sol │ │ │ │ ├── ContractCreator.sol │ │ │ │ ├── DesignatedVoting.sol │ │ │ │ ├── DesignatedVotingFactory.sol │ │ │ │ ├── DesignatedVotingV2.sol │ │ │ │ ├── DesignatedVotingV2Factory.sol │ │ │ │ ├── EmergencyProposer.sol │ │ │ │ ├── FinancialContractsAdmin.sol │ │ │ │ ├── Finder.sol │ │ │ │ ├── FixedSlashSlashingLibrary.sol │ │ │ │ ├── Governor.sol │ │ │ │ ├── GovernorV2.sol │ │ │ │ ├── IdentifierWhitelist.sol │ │ │ │ ├── Proposer.sol │ │ │ │ ├── ProposerV2.sol │ │ │ │ ├── Registry.sol │ │ │ │ ├── ResultComputation.sol │ │ │ │ ├── ResultComputationV2.sol │ │ │ │ ├── Staker.sol │ │ │ │ ├── Store.sol │ │ │ │ ├── TokenMigrator.sol │ │ │ │ ├── VoteTiming.sol │ │ │ │ ├── Voting.sol │ │ │ │ ├── VotingToken.sol │ │ │ │ ├── VotingV2.sol │ │ │ │ └── test │ │ │ │ │ ├── EmergencyProposerTest.sol │ │ │ │ │ ├── GovernorTest.sol │ │ │ │ │ ├── GovernorV2Test.sol │ │ │ │ │ ├── MockAdministratee.sol │ │ │ │ │ ├── PriceIdentifierSlashingLibaryTest.sol │ │ │ │ │ ├── ProposerV2Test.sol │ │ │ │ │ ├── PunitiveSlashingLibraryTest.sol │ │ │ │ │ ├── ResultComputationTest.sol │ │ │ │ │ ├── StakerTest.sol │ │ │ │ │ ├── VoteTimingTest.sol │ │ │ │ │ ├── VotingTest.sol │ │ │ │ │ ├── VotingV2Test.sol │ │ │ │ │ └── ZeroedSlashingLibaryTest.sol │ │ │ ├── interfaces │ │ │ │ ├── AdministrateeInterface.sol │ │ │ │ ├── FinderInterface.sol │ │ │ │ ├── IdentifierWhitelistInterface.sol │ │ │ │ ├── MinimumVotingAncillaryInterface.sol │ │ │ │ ├── OracleAncillaryInterface.sol │ │ │ │ ├── OracleGovernanceInterface.sol │ │ │ │ ├── OracleInterface.sol │ │ │ │ ├── RegistryInterface.sol │ │ │ │ ├── SlashingLibraryInterface.sol │ │ │ │ ├── StakerInterface.sol │ │ │ │ ├── StoreInterface.sol │ │ │ │ ├── VotingAncillaryInterface.sol │ │ │ │ ├── VotingInterface.sol │ │ │ │ └── VotingV2Interface.sol │ │ │ └── test │ │ │ │ ├── MockOracle.sol │ │ │ │ ├── MockOracleAncillary.sol │ │ │ │ ├── MockOracleCombined.sol │ │ │ │ ├── MockOracleGovernance.sol │ │ │ │ ├── VotingAncillaryInterfaceTest.sol │ │ │ │ └── VotingInterfaceTest.sol │ │ ├── external │ │ │ ├── README.md │ │ │ ├── avm │ │ │ │ ├── AVM_CrossDomainEnabled.sol │ │ │ │ ├── Arbitrum_CrossDomainEnabled.sol │ │ │ │ ├── Arbitrum_Messenger.sol │ │ │ │ ├── CHANGELOG.md │ │ │ │ └── interfaces │ │ │ │ │ ├── ArbSys.sol │ │ │ │ │ ├── iArbitrum_Inbox.sol │ │ │ │ │ └── iArbitrum_Outbox.sol │ │ │ ├── boba │ │ │ │ └── BobaAddressManager.sol │ │ │ ├── chainbridge │ │ │ │ ├── Bridge.sol │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── handlers │ │ │ │ │ └── GenericHandler.sol │ │ │ │ └── interfaces │ │ │ │ │ ├── IBridge.sol │ │ │ │ │ ├── IDepositExecute.sol │ │ │ │ │ ├── IERCHandler.sol │ │ │ │ │ └── IGenericHandler.sol │ │ │ └── optimism-bridge │ │ │ │ └── interfaces │ │ │ │ ├── OptimismL1StandardBridge.sol │ │ │ │ ├── OptimismL2StandardBridge.sol │ │ │ │ └── OptimismL2StandardERC20.sol │ │ ├── financial-templates │ │ │ ├── common │ │ │ │ ├── EmergencyShutdownable.sol │ │ │ │ ├── FeePayer.sol │ │ │ │ ├── FundingRateApplier.sol │ │ │ │ ├── SyntheticToken.sol │ │ │ │ ├── TokenFactory.sol │ │ │ │ ├── WETH9.sol │ │ │ │ └── financial-product-libraries │ │ │ │ │ ├── expiring-multiparty-libraries │ │ │ │ │ ├── CoveredCallFinancialProductLibrary.sol │ │ │ │ │ ├── FinancialProductLibrary.sol │ │ │ │ │ ├── KpiOptionsFinancialProductLibrary.sol │ │ │ │ │ ├── PostExpirationIdentifierTransformationFinancialProductLibrary.sol │ │ │ │ │ ├── PreExpirationIdentifierTransformationFinancialProductLibrary.sol │ │ │ │ │ └── StructuredNoteFinancialProductLibrary.sol │ │ │ │ │ └── long-short-pair-libraries │ │ │ │ │ ├── BinaryOptionLongShortPairFinancialProductLibrary.sol │ │ │ │ │ ├── CappedYieldDollarLongShortPairFinancialProductLibrary.sol │ │ │ │ │ ├── CoveredCallLongShortPairFinancialProductLibrary.sol │ │ │ │ │ ├── FlooredLinearLongShortPairFinancialProductLibrary.sol │ │ │ │ │ ├── LinearLongShortPairFinancialProductLibrary.sol │ │ │ │ │ ├── LongShortPairFinancialProductLibrary.sol │ │ │ │ │ ├── RangeBondLongShortPairFinancialProductLibrary.sol │ │ │ │ │ ├── SimpleSuccessTokenLongShortPairFinancialProductLibrary.sol │ │ │ │ │ └── SuccessTokenLongShortPairFinancialProductLibrary.sol │ │ │ ├── expiring-multiparty │ │ │ │ ├── ExpiringMultiParty.sol │ │ │ │ ├── ExpiringMultiPartyCreator.sol │ │ │ │ ├── ExpiringMultiPartyLib.sol │ │ │ │ ├── Liquidatable.sol │ │ │ │ └── PricelessPositionManager.sol │ │ │ ├── long-short-pair │ │ │ │ ├── LongShortPair.sol │ │ │ │ └── LongShortPairCreator.sol │ │ │ ├── optimistic-distributor │ │ │ │ └── OptimisticDistributor.sol │ │ │ ├── optimistic-rewarder │ │ │ │ ├── OptimisticRewarder.sol │ │ │ │ ├── OptimisticRewarderBase.sol │ │ │ │ ├── OptimisticRewarderCreator.sol │ │ │ │ ├── OptimisticRewarderToken.sol │ │ │ │ ├── OptimisticStaker.sol │ │ │ │ └── test │ │ │ │ │ └── OptimisticRewarderTest.sol │ │ │ ├── perpetual-multiparty │ │ │ │ ├── ConfigStore.sol │ │ │ │ ├── ConfigStoreInterface.sol │ │ │ │ ├── Perpetual.sol │ │ │ │ ├── PerpetualCreator.sol │ │ │ │ ├── PerpetualLib.sol │ │ │ │ ├── PerpetualLiquidatable.sol │ │ │ │ └── PerpetualPositionManager.sol │ │ │ └── test │ │ │ │ ├── ExpiringMultiPartyMock.sol │ │ │ │ ├── FinancialProductLibraryTest.sol │ │ │ │ ├── FundingRateApplierTest.sol │ │ │ │ ├── LongShortPairFinancialProjectLibraryTest.sol │ │ │ │ └── LongShortPairMock.sol │ │ ├── merkle-distributor │ │ │ └── implementation │ │ │ │ ├── MerkleDistributor.sol │ │ │ │ └── MerkleDistributorInterface.sol │ │ ├── optimistic-governor │ │ │ ├── implementation │ │ │ │ └── OptimisticGovernor.sol │ │ │ └── test │ │ │ │ ├── OptimisticGovernorTest.sol │ │ │ │ ├── TestAvatar.sol │ │ │ │ └── TestModuleProxyFactory.sol │ │ ├── optimistic-oracle-v2 │ │ │ ├── implementation │ │ │ │ ├── OptimisticOracleV2.sol │ │ │ │ └── SkinnyOptimisticOracleV2.sol │ │ │ ├── interfaces │ │ │ │ ├── OptimisticOracleInterface.sol │ │ │ │ ├── OptimisticOracleV2Interface.sol │ │ │ │ ├── SkinnyOptimisticOracleInterface.sol │ │ │ │ └── SkinnyOptimisticOracleV2Interface.sol │ │ │ ├── previous-versions │ │ │ │ ├── OptimisticOracle.sol │ │ │ │ └── SkinnyOptimisticOracle.sol │ │ │ └── test │ │ │ │ ├── OptimisticRequesterTest.sol │ │ │ │ ├── SkinnyOptimisticRequesterTest.sol │ │ │ │ └── SkinnyOptimisticV2RequesterTest.sol │ │ ├── optimistic-oracle-v3 │ │ │ ├── implementation │ │ │ │ ├── ClaimData.sol │ │ │ │ ├── OptimisticOracleV3.sol │ │ │ │ ├── escalation-manager │ │ │ │ │ ├── BaseEscalationManager.sol │ │ │ │ │ ├── DisputeLimitingEscalationManager.sol │ │ │ │ │ ├── FullPolicyEscalationManager.sol │ │ │ │ │ ├── OwnerDiscardOracleEscalationManager.sol │ │ │ │ │ ├── OwnerSelectOracleEscalationManager.sol │ │ │ │ │ ├── SuperbondEscalationManager.sol │ │ │ │ │ ├── WhitelistAsserterEscalationManager.sol │ │ │ │ │ ├── WhitelistCallerEscalationManager.sol │ │ │ │ │ └── WhitelistDisputerEscalationManager.sol │ │ │ │ ├── examples │ │ │ │ │ ├── DataAsserter.sol │ │ │ │ │ ├── Insurance.sol │ │ │ │ │ └── PredictionMarket.sol │ │ │ │ └── test │ │ │ │ │ ├── AssertingCallerTest.sol │ │ │ │ │ └── OptimisticOracleV3Test.sol │ │ │ └── interfaces │ │ │ │ ├── EscalationManagerInterface.sol │ │ │ │ ├── OptimisticOracleV3CallbackRecipientInterface.sol │ │ │ │ └── OptimisticOracleV3Interface.sol │ │ ├── polygon-cross-chain-oracle │ │ │ ├── GovernorChildTunnel.sol │ │ │ ├── GovernorRootTunnel.sol │ │ │ ├── OracleBaseTunnel.sol │ │ │ ├── OracleChildTunnel.sol │ │ │ ├── OracleRootTunnel.sol │ │ │ ├── README.md │ │ │ └── test │ │ │ │ ├── FxChildMock.sol │ │ │ │ ├── FxRootMock.sol │ │ │ │ ├── OracleBaseTunnelMock.sol │ │ │ │ ├── OracleRootTunnelMock.sol │ │ │ │ └── StateSyncMock.sol │ │ ├── proxy-scripts │ │ │ ├── atomic-disputer │ │ │ │ └── ReserveCurrencyDisputer.sol │ │ │ ├── atomic-liquidator │ │ │ │ └── ReserveCurrencyLiquidator.sol │ │ │ ├── bot-action-wrappers │ │ │ │ ├── LiquidationWithdrawer.sol │ │ │ │ ├── PositionSettler.sol │ │ │ │ ├── TokenRedeemer.sol │ │ │ │ └── TokenSender.sol │ │ │ ├── lsp-broker │ │ │ │ └── LspUniswapV2Broker.sol │ │ │ └── uniswap-broker │ │ │ │ ├── UniswapV2Broker.sol │ │ │ │ └── UniswapV3Broker.sol │ │ ├── snapshot-helpers │ │ │ └── SnapshotVotingPower.sol │ │ └── umip-helpers │ │ │ ├── OriginValidator.sol │ │ │ ├── Umip3Upgrader.sol │ │ │ ├── VotingUpgrader.sol │ │ │ └── VotingUpgraderV2.sol │ ├── deploy │ │ ├── 001_deploy_finder.js │ │ ├── 002_deploy_timer.js │ │ ├── 003_deploy_registry.js │ │ ├── 004_deploy_voting_token.js │ │ ├── 005_deploy_identifier_whitelist.js │ │ ├── 006_deploy_voting.js │ │ ├── 007_deploy_financial_contracts_admin.js │ │ ├── 008_deploy_store.js │ │ ├── 009_deploy_governor.js │ │ ├── 010_deploy_designated_voting_factory.js │ │ ├── 011_deploy_address_whitelist.js │ │ ├── 012_deploy_optimistic_oracle.js │ │ ├── 013_deploy_mock_oracle.js │ │ ├── 014_deploy_token_factory.js │ │ ├── 015_deploy_emp_creator.js │ │ ├── 016_deploy_perpetual_creator.js │ │ ├── 017_deploy_bridge.js │ │ ├── 018_deploy_generic_handler.js │ │ ├── 019_deploy_sink_oracle.js │ │ ├── 020_deploy_source_oracle.js │ │ ├── 021_deploy_sink_governor.js │ │ ├── 022_deploy_source_governor.js │ │ ├── 023_deploy_state_sync_mock.js │ │ ├── 024_deploy_fx_root_mock.js │ │ ├── 025_deploy_fx_child_mock.js │ │ ├── 026_deploy_oracle_root_tunnel.js │ │ ├── 027_deploy_oracle_child_tunnel.js │ │ ├── 028_deploy_governor_child_tunnel.js │ │ ├── 029_deploy_governor_root_tunnel.js │ │ ├── 030_deploy_long_short_pair_creator.js │ │ ├── 031_deploy_long_short_pair_libraries_covered_call.js │ │ ├── 032_deploy_long_short_pair_libraries_range_bond.js │ │ ├── 033_deploy_long_short_pair_library_binary.js │ │ ├── 034_deploy_long_short_pair_library_linear.js │ │ ├── 035_deploy_skinny_optimistic_oracle.js │ │ ├── 036_deploy_arbitrum_parent_messenger.js │ │ ├── 037_deploy_arbitrum_child_messenger.js │ │ ├── 038_deploy_oracle_spoke.js │ │ ├── 039_deploy_oracle_hub.js │ │ ├── 040_deploy_governor_spoke.js │ │ ├── 041_deploy_governor_hub.js │ │ ├── 042_deploy_boba_parent_messenger.js │ │ ├── 043_deploy_boba_child_messenger.js │ │ ├── 044_deploy_optimism_parent_messenger.js │ │ ├── 045_deploy_optimism_child_messenger.js │ │ ├── 046_deploy_admin_child_messenger.js │ │ ├── 047_deploy_proposer.js │ │ ├── 048_deploy_long_short_pair_libraries_simple_success_token.js │ │ ├── 049_deploy_long_short_pair_libraries_success_token.js │ │ ├── 050_deploy_long_short_pair_libraries_capped_yield_dollar.js │ │ ├── 051_deploy_optimistic_oracle_V2.js │ │ ├── 052_deploy_fixed_slash_slashing_library.js │ │ ├── 053_deploy_votingV2.js │ │ ├── 054_deploy_designated_votingV2_factory.js │ │ ├── 055_deploy_governor_V2.js │ │ ├── 056_deploy_skinny_optimistic_oracle_V2.js │ │ ├── 057_deploy_optimistic_oracle_V3.js │ │ ├── 058_deploy_optimistic_governor.js │ │ ├── 059_deploy_snapshot_helper.js │ │ ├── 060_deploy_proposer_v2.js │ │ ├── 061_deploy_emergency_proposer.js │ │ ├── 062_deploy_base_parent_messenger.js │ │ ├── 063_deploy_base_child_messenger.js │ │ ├── 064_deploy_blast_parent_messenger.js │ │ └── 065_deploy_blast_child_messenger.js │ ├── deprecated_truffle_scripts │ │ ├── CheckDeploymentValidity.js │ │ ├── CommandlineUtil.js │ │ ├── DeployDesignatedVoting.js │ │ ├── DeploySyntheticTokens.js │ │ ├── IntegrationTests.js │ │ ├── PrecisionErrors.js │ │ ├── TransferPermissions.js │ │ ├── local │ │ │ ├── AddMemberToRole.js │ │ │ ├── AdvanceEMP.js │ │ │ ├── AdvanceToCommitPhase.js │ │ │ ├── ApproveIdentifiers.js │ │ │ ├── ApproveTokens.js │ │ │ ├── BatchGasEstimation.js │ │ │ ├── ClaimAllRewards.js │ │ │ ├── ConvertWeth.js │ │ │ ├── CreateTokens.js │ │ │ ├── DeployBalancerMock.js │ │ │ ├── DeployEMP.js │ │ │ ├── DeployUniswapMock.js │ │ │ ├── DepositCollateral.js │ │ │ ├── DisputeEMP.js │ │ │ ├── EncodeParams.js │ │ │ ├── GetUniswapAddress.js │ │ │ ├── HistoricalPriceRequests.js │ │ │ ├── MintNewTokens.js │ │ │ ├── ProposePriceEMP.js │ │ │ ├── PushPriceEMP.js │ │ │ ├── RedeemTokens.js │ │ │ ├── RevealVote.js │ │ │ ├── SettleTokens.js │ │ │ ├── SnapshotCurrentRound.js │ │ │ ├── TransferCollateral.js │ │ │ ├── TransferSynthetic.js │ │ │ ├── VoteGasEstimation.js │ │ │ ├── WithdrawCollateral.js │ │ │ ├── getPrivateKeyFromMnemonic.js │ │ │ ├── liquidateEMP.js │ │ │ └── withdrawLiquidationEMP.js │ │ ├── mainnet │ │ │ ├── CancelPendingTransaction.js │ │ │ ├── GetAllSponsors.js │ │ │ └── WithdrawTokens.ts │ │ ├── optimistic-oracle-umip │ │ │ ├── 1_Propose.js │ │ │ ├── 2_VoteSimulate.js │ │ │ └── 3_Verify.js │ │ ├── remove-collateral-upp │ │ │ ├── 1_Propose.js │ │ │ ├── 2_VoteSimulate.js │ │ │ └── 3_Verify.js │ │ ├── umip-3 │ │ │ ├── 1_Propose.js │ │ │ ├── 2_VoteSimulate.js │ │ │ ├── 3_Verify.js │ │ │ └── 4_ExecuteSimulate.js │ │ ├── umip-8 │ │ │ ├── 1_Propose.js │ │ │ ├── 2_VoteSimulate.js │ │ │ └── 3_Verify.js │ │ └── voting-upgrade-umip │ │ │ ├── 1_Propose.js │ │ │ ├── 2_VoteSimulate.js │ │ │ └── 3_Verify.js │ ├── foundry.toml │ ├── hardhat.config.js │ ├── index.ts │ ├── networks │ │ ├── 1.json │ │ ├── 10.json │ │ ├── 100.json │ │ ├── 1115.json │ │ ├── 11155111.json │ │ ├── 1116.json │ │ ├── 137.json │ │ ├── 1513.json │ │ ├── 1514.json │ │ ├── 1516.json │ │ ├── 168587773.json │ │ ├── 288.json │ │ ├── 4.json │ │ ├── 416.json │ │ ├── 42.json │ │ ├── 42161.json │ │ ├── 421611.json │ │ ├── 421614.json │ │ ├── 43114.json │ │ ├── 5.json │ │ ├── 80001.json │ │ ├── 80002.json │ │ ├── 81457.json │ │ ├── 82.json │ │ ├── 8453.json │ │ ├── 84531.json │ │ ├── 84532.json │ │ └── 9001.json │ ├── package.json │ ├── remappings.txt │ ├── scripts │ │ ├── BuildContractVersionHashes.js │ │ └── SetUpFoundryWithHardhat.sh │ ├── src │ │ └── FindContractVersion.ts │ ├── test │ │ ├── foundry │ │ │ ├── data-verification-mechanism │ │ │ │ └── fork-tests │ │ │ │ │ ├── CommonDataVerificationMechanismForkTest.sol │ │ │ │ │ └── FakeLifeCycle.ft.sol │ │ │ ├── fixtures │ │ │ │ ├── common │ │ │ │ │ ├── CommonTestBase.sol │ │ │ │ │ ├── TestAddress.sol │ │ │ │ │ └── TimerFixture.sol │ │ │ │ ├── dvm │ │ │ │ │ ├── BaseDvmFixture.sol │ │ │ │ │ └── MockDvmFixture.sol │ │ │ │ └── optimistic-oracle-v3 │ │ │ │ │ └── OptimisticOracleV3Fixture.sol │ │ │ └── optimistic-oracle-v3 │ │ │ │ ├── CommonOptimisticOracleV3Test.sol │ │ │ │ ├── OptimisticOracleV3.Callbacks.t.sol │ │ │ │ ├── OptimisticOracleV3.EdgeCases.t.sol │ │ │ │ ├── OptimisticOracleV3.Events.t.sol │ │ │ │ ├── OptimisticOracleV3.Lifecycle.t.sol │ │ │ │ ├── OptimisticOracleV3.Maintenance.t.sol │ │ │ │ ├── OptimisticOracleV3.SsPolicy.t.sol │ │ │ │ ├── escalation-manager │ │ │ │ ├── BaseEscalationManager.t.sol │ │ │ │ ├── DisputeLimitingEscalationManager.t.sol │ │ │ │ ├── FullPolicyEscalationManager.t.sol │ │ │ │ ├── OwnerDiscardOracleEscalationManager.t.sol │ │ │ │ ├── OwnerSelectOracleEscalationManager.t.sol │ │ │ │ ├── SuperbondEscalationManager.t.sol │ │ │ │ ├── WhitelistAsserterEscalationManager.t.sol │ │ │ │ ├── WhitelistCallerEscalationManager.t.sol │ │ │ │ └── WhitelistDisputerEscalationManager.t.sol │ │ │ │ ├── examples │ │ │ │ ├── DataAsserter.t.sol │ │ │ │ ├── Insurance.t.sol │ │ │ │ ├── PredictionMarket.Assertion.t.sol │ │ │ │ ├── PredictionMarket.Common.sol │ │ │ │ ├── PredictionMarket.Initialize.t.sol │ │ │ │ ├── PredictionMarket.Position.t.sol │ │ │ │ └── PredictionMarket.Resolve.t.sol │ │ │ │ └── integration-tests │ │ │ │ ├── BaseEscalationManager.t.sol │ │ │ │ ├── FullPolicyEscalationManager.Arbitrate.t.sol │ │ │ │ ├── FullPolicyEscalationManager.BlockAssertion.t.sol │ │ │ │ ├── FullPolicyEscalationManager.BlockDispute.t.sol │ │ │ │ ├── FullPolicyEscalationManager.Common.t.sol │ │ │ │ └── FullPolicyEscalationManager.DiscardOracle.t.sol │ │ └── hardhat │ │ │ ├── common │ │ │ ├── AncillaryData.js │ │ │ ├── Lockable.js │ │ │ ├── MultiRole.js │ │ │ ├── SignedFixedPoint.js │ │ │ ├── Testable.js │ │ │ ├── UnsignedFixedPoint.js │ │ │ └── Withdrawable.js │ │ │ ├── cross-chain-oracle │ │ │ ├── GovernorHub.js │ │ │ ├── GovernorSpoke.js │ │ │ ├── OracleBase.js │ │ │ ├── OracleHub.js │ │ │ ├── OracleSpoke.js │ │ │ └── chain-adapters │ │ │ │ ├── Admin_ChildMessenger.js │ │ │ │ ├── Arbitrum_ChildMessenger.js │ │ │ │ ├── Arbitrum_ParentMessenger.js │ │ │ │ ├── Optimism_ChildMessenger.js │ │ │ │ ├── Optimism_ParentMessenger.js │ │ │ │ ├── ParentMessengerBase.js │ │ │ │ ├── Polygon_ChildMessenger.js │ │ │ │ └── Polygon_ParentMessenger.js │ │ │ ├── data-verification-mechanism │ │ │ ├── DesignatedVoting.js │ │ │ ├── DesignatedVotingFactory.js │ │ │ ├── DesignatedVotingV2.js │ │ │ ├── DesignatedVotingV2Factory.js │ │ │ ├── EmergencyProposer.js │ │ │ ├── FinancialContractsAdmin.js │ │ │ ├── Finder.js │ │ │ ├── FixedSlashSlashingLibrary.js │ │ │ ├── Governor.js │ │ │ ├── GovernorV2.js │ │ │ ├── IdentifierWhitelist.js │ │ │ ├── Proposer.js │ │ │ ├── ProposerV2.js │ │ │ ├── Registry.js │ │ │ ├── ResultComputation.js │ │ │ ├── Staker.js │ │ │ ├── Store.js │ │ │ ├── TokenMigrator.js │ │ │ ├── VoteTiming.js │ │ │ ├── Voting.js │ │ │ ├── VotingGas.js │ │ │ ├── VotingToken.js │ │ │ ├── VotingV2.js │ │ │ └── VotingV2Gas.js │ │ │ ├── financial-templates │ │ │ ├── TokenFactory.js │ │ │ ├── common │ │ │ │ ├── FundingRateApplier.js │ │ │ │ └── financial-product-libraries │ │ │ │ │ ├── expiring-multiparty-libraries │ │ │ │ │ ├── CoveredCallFinancialProductLibrary.js │ │ │ │ │ ├── KpiOptionsFinancialProductLibrary.js │ │ │ │ │ ├── PreExpirationIdentifierTransformationFinancialProductLibrary.js │ │ │ │ │ └── StructuredNoteFinancialProductLibrary.js │ │ │ │ │ └── long-short-pair-libraries │ │ │ │ │ ├── BinaryOptionLongShortPairFinancialProductLibrary.js │ │ │ │ │ ├── CappedYieldDollarLongShortPairFinancialProductLibrary.js │ │ │ │ │ ├── CoveredCallLongShortPairFinancialProductLibrary.js │ │ │ │ │ ├── FlooredLinearLongShortPairFinancialProductLibrary.js │ │ │ │ │ ├── LinearLongShortPairFinancialProductLibrary.js │ │ │ │ │ ├── RangeBondLongShortPairFinancialProductLibrary.js │ │ │ │ │ ├── SimpleSuccessTokenLongShortPairFinancialProductLibrary.js │ │ │ │ │ └── SuccessTokenLongShortPairFinancialProductLibrary.js │ │ │ ├── expiring-multiparty │ │ │ │ ├── ExpiringMultiParty.js │ │ │ │ ├── ExpiringMultiPartyCreator.js │ │ │ │ ├── Liquidatable.js │ │ │ │ └── PricelessPositionManager.js │ │ │ ├── long-short-pair │ │ │ │ ├── LongShortPair.js │ │ │ │ └── LongShortPairCreator.js │ │ │ ├── optimistic-distributor │ │ │ │ └── OptimisticDistributor.js │ │ │ ├── optimistic-rewarder │ │ │ │ ├── OptimisticRewarder.js │ │ │ │ ├── OptimisticRewarderNoToken.js │ │ │ │ └── OptimisticStaker.js │ │ │ └── perpetual-multiparty │ │ │ │ ├── ConfigStore.js │ │ │ │ ├── Perpetual.js │ │ │ │ ├── PerpetualCreator.js │ │ │ │ ├── PerpetualLiquidatable.js │ │ │ │ └── PerpetualPositionManager.js │ │ │ ├── helpers │ │ │ ├── ArbitrumHelper.js │ │ │ └── SmockitHelper.js │ │ │ ├── merkle-distributor │ │ │ ├── MerkleDistributor.js │ │ │ └── SamplePayout.json │ │ │ ├── optimistic-governor │ │ │ └── OptimisticGovernor.js │ │ │ ├── optimistic-oracle-v2 │ │ │ ├── OptimisticOracleV2.js │ │ │ └── SkinnyOptimisticOracle.js │ │ │ ├── polygon │ │ │ ├── OracleBaseTunnel.js │ │ │ ├── OracleChildTunnel.js │ │ │ └── e2e.js │ │ │ ├── proxy-scripts │ │ │ ├── atomic-disputer │ │ │ │ └── ReserveCurrencyDisputer.js │ │ │ ├── atomic-liquidator │ │ │ │ └── ReserveCurrencyLiquidator.js │ │ │ ├── lsp-broker │ │ │ │ └── LspUniswapV2Broker.js │ │ │ └── uniswap-broker │ │ │ │ ├── UniswapV2Broker.js │ │ │ │ └── UniswapV3Broker.js │ │ │ └── utils │ │ │ └── Voting.js │ └── tsconfig.json ├── financial-templates-lib │ ├── .mocharc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── hardhat.config.js │ ├── package.json │ ├── src │ │ ├── clients │ │ │ ├── FinancialContractClient.ts │ │ │ ├── FinancialContractEventClient.ts │ │ │ ├── FinancialContractFactoryClient.ts │ │ │ ├── OptimisticOracleClient.ts │ │ │ ├── OptimisticOracleEventClient.ts │ │ │ └── TokenBalanceClient.ts │ │ ├── helpers │ │ │ ├── AbiUtils.ts │ │ │ ├── GasEstimator.ts │ │ │ ├── allowances.ts │ │ │ ├── math.ts │ │ │ └── multicall.ts │ │ ├── index.ts │ │ ├── price-feed │ │ │ ├── BalancerPriceFeed.ts │ │ │ ├── BasketSpreadPriceFeed.ts │ │ │ ├── CoinGeckoPriceFeed.ts │ │ │ ├── CoinMarketCapPriceFeed.ts │ │ │ ├── CreatePriceFeed.ts │ │ │ ├── CryptoWatchPriceFeed.ts │ │ │ ├── DefaultPriceFeedConfigs.ts │ │ │ ├── DefiPulsePriceFeed.ts │ │ │ ├── DominationFinancePriceFeed.ts │ │ │ ├── EthVixPriceFeed.ts │ │ │ ├── ExpressionPriceFeed.ts │ │ │ ├── FallBackPriceFeed.ts │ │ │ ├── ForexDailyPriceFeed.ts │ │ │ ├── FundingRateMultiplierPriceFeed.ts │ │ │ ├── InvalidPriceFeedMock.ts │ │ │ ├── LPPriceFeed.ts │ │ │ ├── MedianizerPriceFeed.ts │ │ │ ├── Networker.ts │ │ │ ├── NetworkerMock.ts │ │ │ ├── PriceFeedInterface.ts │ │ │ ├── PriceFeedMock.ts │ │ │ ├── PriceFeedMockScaled.ts │ │ │ ├── QuandlPriceFeed.ts │ │ │ ├── TraderMadePriceFeed.ts │ │ │ ├── USPACPriceFeed.ts │ │ │ ├── UniswapPriceFeed.ts │ │ │ ├── VaultPriceFeed.ts │ │ │ └── utils.ts │ │ ├── proxy-transaction-handler │ │ │ └── DSProxyManager.ts │ │ └── types.ts │ ├── test │ │ ├── clients │ │ │ ├── FinancialContractClient.js │ │ │ ├── FinancialContractEventClient.js │ │ │ ├── FinancialContractFactoryClient.js │ │ │ ├── OptimisticOracleClient.js │ │ │ ├── OptimisticOracleEventClient.js │ │ │ └── TokenBalanceClient.js │ │ ├── helpers │ │ │ └── GasEstimator.js │ │ ├── price-feed │ │ │ ├── BalancerPriceFeed.js │ │ │ ├── BasketSpreadPriceFeed.js │ │ │ ├── CoinGeckoPriceFeed.js │ │ │ ├── CoinMarketCapPriceFeed.js │ │ │ ├── CreatePriceFeed.js │ │ │ ├── CryptoWatchPriceFeed.js │ │ │ ├── DefiPulsePriceFeed.js │ │ │ ├── DominationFinancePriceFeed.js │ │ │ ├── EthVixPriceFeed.js │ │ │ ├── ExpressionPriceFeed.js │ │ │ ├── FallBackPriceFeed.js │ │ │ ├── ForexDailyPriceFeed.js │ │ │ ├── FundingRateMultiplierPriceFeed.js │ │ │ ├── HarvestVaultPriceFeed.js │ │ │ ├── LPPriceFeed.js │ │ │ ├── MedianizerPriceFeed.js │ │ │ ├── QuandlPriceFeed.js │ │ │ ├── TraderMadePriceFeed.js │ │ │ ├── USPACPriceFeed.js │ │ │ ├── UniswapV2PriceFeed.js │ │ │ ├── UniswapV3PriceFeed.js │ │ │ ├── VaultPriceFeed.js │ │ │ └── utils.js │ │ └── proxy-transaction-handler │ │ │ └── DSProxyManager.js │ ├── tsconfig.json │ └── types │ │ ├── abi-decoder │ │ └── index.d.ts │ │ └── node-pagerduty │ │ └── index.d.ts ├── fx-tunnel-relayer │ ├── CHANGELOG.md │ ├── README.md │ ├── hardhat.config.ts │ ├── package.json │ ├── src │ │ ├── Relayer.ts │ │ ├── RelayerConfig.ts │ │ ├── constants.ts │ │ ├── index.ts │ │ ├── timeUtils.ts │ │ └── tsconfig.json │ ├── test │ │ ├── Relayer.ts │ │ └── index.ts │ └── tsconfig.json ├── llm-bot │ ├── CHANGELOG.md │ ├── hardhat.config.ts │ ├── package.json │ ├── src │ │ ├── core │ │ │ ├── OptimisticOracleV2.ts │ │ │ ├── common.ts │ │ │ └── examples.ts │ │ ├── dispute-bot │ │ │ ├── DisputeDisputableRequests.ts │ │ │ ├── README.md │ │ │ ├── common.ts │ │ │ └── index.ts │ │ └── utils │ │ │ ├── constants.ts │ │ │ └── contracts.ts │ ├── test │ │ ├── DisputeRequests.ts │ │ ├── OptimisticOracleV2LLM.ts │ │ ├── constants.ts │ │ ├── fixtures │ │ │ ├── DVM2.Fixture.ts │ │ │ ├── OptimisticGovernor.Fixture.ts │ │ │ ├── OptimisticOracleV2.Fixture.ts │ │ │ ├── OptimisticOracleV3.Fixture.ts │ │ │ └── UmaEcosystem.Fixture.ts │ │ └── utils.ts │ └── tsconfig.json ├── logger │ ├── .mocharc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── constants.ts │ │ ├── helpers │ │ │ ├── delay.ts │ │ │ └── typeGuards.ts │ │ ├── index.ts │ │ ├── logger │ │ │ ├── ConsoleTransport.ts │ │ │ ├── DiscordTicketTransport.ts │ │ │ ├── DiscordTransport.ts │ │ │ ├── Formatters.ts │ │ │ ├── JsonTransport.ts │ │ │ ├── Logger.ts │ │ │ ├── PagerDutyTransport.ts │ │ │ ├── PagerDutyV2Transport.ts │ │ │ ├── PersistentTransport.ts │ │ │ ├── SlackTransport.ts │ │ │ ├── SpyTransport.ts │ │ │ ├── TransportError.ts │ │ │ └── Transports.ts │ │ └── types.ts │ ├── test │ │ └── logger │ │ │ ├── BigNumberFormatter.js │ │ │ ├── DiscordTicketTransport.truncateMessage.js │ │ │ └── SlackTransport.splitByNewLine.js │ ├── tsconfig.json │ └── types │ │ └── node-pagerduty │ │ └── index.d.ts ├── monitor-v2 │ ├── .gitignore │ ├── CHANGELOG.md │ ├── hardhat.config.ts │ ├── package.json │ ├── src │ │ ├── balance-monitor │ │ │ ├── BalanceMonitor.ts │ │ │ ├── README.md │ │ │ ├── common.ts │ │ │ └── index.ts │ │ ├── bot-oo-v3 │ │ │ ├── BotLogger.ts │ │ │ ├── README.md │ │ │ ├── SettleAssertions.ts │ │ │ ├── common.ts │ │ │ └── index.ts │ │ ├── health-check-runner │ │ │ └── index.ts │ │ ├── monitor-dvm │ │ │ ├── MonitorDeletion.ts │ │ │ ├── MonitorEmergency.ts │ │ │ ├── MonitorGovernance.ts │ │ │ ├── MonitorGovernorTransfers.ts │ │ │ ├── MonitorLogger.ts │ │ │ ├── MonitorMints.ts │ │ │ ├── MonitorRolled.ts │ │ │ ├── MonitorStakes.ts │ │ │ ├── MonitorUnstakes.ts │ │ │ ├── README.md │ │ │ ├── common.ts │ │ │ └── index.ts │ │ ├── monitor-og │ │ │ ├── MonitorEvents.ts │ │ │ ├── MonitorLogger.ts │ │ │ ├── MonitorSnapshotProposals.ts │ │ │ ├── README.md │ │ │ ├── SnapshotVerification.ts │ │ │ ├── common.ts │ │ │ ├── index.ts │ │ │ └── oSnapAutomation.ts │ │ ├── monitor-oo-v3 │ │ │ ├── MonitorAssertions.ts │ │ │ ├── MonitorDisputes.ts │ │ │ ├── MonitorLogger.ts │ │ │ ├── MonitorSettlements.ts │ │ │ ├── README.md │ │ │ ├── common.ts │ │ │ └── index.ts │ │ ├── monitor-polymarket │ │ │ ├── MonitorLogger.ts │ │ │ ├── MonitorProposalsOrderBook.ts │ │ │ ├── README.md │ │ │ ├── abi │ │ │ │ ├── binaryAdapter.json │ │ │ │ ├── ctfAdapter.json │ │ │ │ ├── ctfAdapterV2.json │ │ │ │ ├── ctfExchange.json │ │ │ │ └── umaSportsOracle.json │ │ │ ├── common.ts │ │ │ └── index.ts │ │ ├── price-publisher │ │ │ ├── BotLogger.ts │ │ │ ├── PublishPrices.ts │ │ │ ├── README.md │ │ │ ├── ResolvePrices.ts │ │ │ ├── common.ts │ │ │ └── index.ts │ │ ├── price-speed-up │ │ │ ├── BotLogger.ts │ │ │ ├── README.md │ │ │ ├── SpeedUpPriceRequests.ts │ │ │ ├── common.ts │ │ │ └── index.ts │ │ └── utils │ │ │ ├── constants.ts │ │ │ ├── contracts.ts │ │ │ └── logger.ts │ ├── test │ │ ├── DVM2Monitor.ts │ │ ├── DVM2PricePublisherBot.ts │ │ ├── DVM2ResolvePriceRequests.ts │ │ ├── DVM2SpeedUpPriceRequests.ts │ │ ├── OptimisticGovernorMonitor.ts │ │ ├── OptimisticOracleV3Bot.ts │ │ ├── OptimisticOracleV3Monitor.ts │ │ ├── PolymarketMonitor.ts │ │ ├── constants.ts │ │ ├── fixtures │ │ │ ├── DVM2.Fixture.ts │ │ │ ├── OptimisticGovernor.Fixture.ts │ │ │ ├── OptimisticOracleV2.Fixture.ts │ │ │ ├── OptimisticOracleV3.Fixture.ts │ │ │ └── UmaEcosystem.Fixture.ts │ │ └── utils.ts │ └── tsconfig.json ├── monitors │ ├── .mocharc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── hardhat.config.js │ ├── index.js │ ├── package.json │ ├── src │ │ ├── BalanceMonitor.js │ │ ├── CRMonitor.js │ │ ├── ContractMonitor.js │ │ ├── OptimisticOracleContractMonitor.js │ │ └── SyntheticPegMonitor.js │ └── test │ │ ├── BalanceMonitor.js │ │ ├── CRMonitor.js │ │ ├── ContractMonitor.js │ │ ├── OptimisticOracleContractMonitor.js │ │ ├── SyntheticPegMonitor.js │ │ └── index.js ├── optimistic-oracle │ ├── CHANGELOG.md │ ├── hardhat.config.js │ ├── index.js │ ├── package.json │ ├── src │ │ └── proposer.js │ └── test │ │ ├── index.js │ │ ├── proposer.js │ │ ├── proposerV2.js │ │ └── skinnyProposer.js ├── polymarket-notifier │ ├── CHANGELOG.md │ ├── README.md │ ├── index.js │ ├── package.json │ └── src │ │ ├── abi │ │ └── abi.js │ │ └── polymarketNotifier.js ├── scripts │ ├── .mocharc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── hardhat.config.js │ ├── package.json │ ├── setupFork.sh │ ├── src │ │ ├── DecodeTransactionData.js │ │ ├── EmergencyShutdown.js │ │ ├── ManualRelay.js │ │ ├── admin-proposals │ │ │ ├── README.md │ │ │ ├── add-address-whitelist │ │ │ │ ├── 0_Propose.ts │ │ │ │ ├── 1_Verify.ts │ │ │ │ └── readme.md │ │ │ ├── add-identifier │ │ │ │ ├── 0_Propose.ts │ │ │ │ ├── 1_Verify.ts │ │ │ │ ├── 2_VerifyRelays.ts │ │ │ │ ├── common.ts │ │ │ │ └── readme.md │ │ │ ├── addContractCreator.js │ │ │ ├── adminChildRegistration.ts │ │ │ ├── change-final-fee │ │ │ │ ├── 0_Propose.ts │ │ │ │ ├── 1_Verify.ts │ │ │ │ ├── 2_VerifyRelays.ts │ │ │ │ ├── README.md │ │ │ │ └── common.ts │ │ │ ├── changeFinderAddress.js │ │ │ ├── collateral.js │ │ │ ├── common │ │ │ │ ├── constants.ts │ │ │ │ ├── helpers.ts │ │ │ │ ├── index.ts │ │ │ │ ├── networks.ts │ │ │ │ ├── spoofedRelay.ts │ │ │ │ └── types.ts │ │ │ ├── executeProposal.js │ │ │ ├── executeProposalV2.ts │ │ │ ├── funding │ │ │ │ ├── 0_Propose.ts │ │ │ │ └── README.md │ │ │ ├── identifier.js │ │ │ ├── proposeAdminTransactions.js │ │ │ ├── proposeEmissionRate.ts │ │ │ ├── register-parent-messenger-and-gas-limit │ │ │ │ ├── 0_Propose.ts │ │ │ │ ├── 1_Verify.ts │ │ │ │ ├── common.ts │ │ │ │ └── readme.md │ │ │ ├── register-parent-messenger │ │ │ │ ├── 0_Propose.ts │ │ │ │ ├── 1_Verify.ts │ │ │ │ └── readme.md │ │ │ ├── registerContract.js │ │ │ ├── resolveProposal.js │ │ │ ├── revokeMinters.ts │ │ │ ├── set-gat-and-spat │ │ │ │ ├── 0_Propose.ts │ │ │ │ ├── 1_Verify.ts │ │ │ │ └── README.md │ │ │ ├── simulateEmergencyProposal.ts │ │ │ ├── simulateVote.js │ │ │ ├── simulateVoteV2.ts │ │ │ ├── transferTokensFromGovernor.js │ │ │ ├── upgrade-oo-request-bridging │ │ │ │ ├── 0_InitPolygonRootTunnels.ts │ │ │ │ ├── 1_InitPolygonChildTunnels.ts │ │ │ │ ├── 2_Propose.ts │ │ │ │ ├── 3_Execute.ts │ │ │ │ ├── 4_Verify.ts │ │ │ │ └── README.md │ │ │ └── utils.js │ │ ├── demo │ │ │ ├── DepositBox.js │ │ │ └── OptimisticDepositBox.js │ │ ├── designated-voting │ │ │ └── Deploy.ts │ │ ├── local │ │ │ ├── AdvanceToNextVotingPhase.js │ │ │ ├── CalculateContractBytecode.js │ │ │ ├── GasEthQuery.js │ │ │ ├── RequestOraclePrice.js │ │ │ ├── getGasEthHistoricalPrice.js │ │ │ └── getHistoricalPrice.js │ │ ├── mainnet │ │ │ └── ProposeAdmin.js │ │ ├── migration │ │ │ └── dvm2-designated-voting │ │ │ │ ├── 0_Deploy.ts │ │ │ │ ├── 1_ClaimRewards.ts │ │ │ │ ├── 2_Migrate.ts │ │ │ │ ├── 3_Delegate.ts │ │ │ │ └── common.ts │ │ ├── monitoring-dvm2.0 │ │ │ ├── gasMonitor.ts │ │ │ ├── rollTiming.ts │ │ │ ├── simulateVoting.ts │ │ │ ├── slashingEvents.ts │ │ │ ├── unstake.ts │ │ │ └── voterStakes.ts │ │ ├── testnet │ │ │ ├── OptimisticGovernorDeploy.ts │ │ │ ├── OptimisticGovernorExecute.ts │ │ │ ├── OptimisticGovernorRequest.ts │ │ │ └── OptimisticOracleRequestSender.ts │ │ ├── upgrade-tests │ │ │ ├── 162 │ │ │ │ ├── 1_Propose.ts │ │ │ │ ├── 2_Verify.ts │ │ │ │ └── readme.md │ │ │ ├── Proposer.js │ │ │ ├── register-new-contract │ │ │ │ ├── 1_Propose.ts │ │ │ │ ├── 2_Verify.ts │ │ │ │ ├── 3_VerifyRelays.ts │ │ │ │ ├── common.ts │ │ │ │ └── readme.md │ │ │ ├── sherlock-update │ │ │ │ ├── 0_Deploy.ts │ │ │ │ ├── 1_Propose.ts │ │ │ │ ├── 2_Verify.ts │ │ │ │ └── readme.md │ │ │ └── voting2 │ │ │ │ ├── 0_Deploy.ts │ │ │ │ ├── 1_Propose.ts │ │ │ │ ├── 2_Verify.ts │ │ │ │ ├── 3_SimulateVoting.ts │ │ │ │ ├── migrationUtils.ts │ │ │ │ └── readme.md │ │ └── utils │ │ │ ├── Deploy.js │ │ │ ├── constants.js │ │ │ ├── contracts.ts │ │ │ ├── gnosisPayload.ts │ │ │ ├── gnosisSafeDeployment.ts │ │ │ ├── impersonateAccounts.js │ │ │ ├── index.js │ │ │ ├── optimisticGovernorPayload.ts │ │ │ ├── relay.ts │ │ │ ├── seedProposerWithUma.js │ │ │ ├── utils.ts │ │ │ └── votingv2-utils.ts │ ├── test │ │ ├── DecodeTransactionData.js │ │ └── EmergencyShutdown.js │ └── tsconfig.json ├── sdk │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── build.js │ ├── jest-e2e-config.json │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── README.md │ │ ├── across │ │ │ ├── README.md │ │ │ ├── clients │ │ │ │ ├── README.md │ │ │ │ ├── bobaBridge.ts │ │ │ │ ├── bridgePool.e2e.ts │ │ │ │ ├── bridgePool.test.ts │ │ │ │ ├── bridgePool.ts │ │ │ │ ├── index.ts │ │ │ │ └── optimismBridge.ts │ │ │ ├── constants.ts │ │ │ ├── feeCalculator.test.ts │ │ │ ├── feeCalculator.ts │ │ │ ├── gasFeeCalculator.e2e.ts │ │ │ ├── gasFeeCalculator.ts │ │ │ ├── index.ts │ │ │ ├── lpFeeCalculator.ts │ │ │ ├── rateModel.ts │ │ │ ├── test │ │ │ │ ├── lpFeeCalculator.e2e.ts │ │ │ │ └── rateModel.e2e.ts │ │ │ ├── transactionManager.ts │ │ │ ├── utils.test.ts │ │ │ └── utils.ts │ │ ├── blockFinder.ts │ │ ├── clients │ │ │ ├── README.md │ │ │ ├── bridgeDepositBox │ │ │ │ ├── README.md │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── bridgePool │ │ │ │ ├── README.md │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── emp │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── erc20 │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── etherchain │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── lsp-creator │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── lsp │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── multicall │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── multicall2 │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── optimisticOracle │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── optimisticOracleV2 │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── rateModelStore │ │ │ │ ├── README.md │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ ├── registry │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ │ └── skinnyOptimisticOracle │ │ │ │ ├── README.md │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── client.ts │ │ │ │ └── index.ts │ │ ├── coingecko │ │ │ ├── README.md │ │ │ ├── coingecko.e2e.ts │ │ │ ├── coingecko.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── multicall.e2e.ts │ │ ├── multicall.ts │ │ ├── multicall2.e2e.ts │ │ ├── multicall2.ts │ │ ├── oracle │ │ │ ├── README.md │ │ │ ├── client.ts │ │ │ ├── errors.ts │ │ │ ├── factory.ts │ │ │ ├── index.ts │ │ │ ├── optimisticFactory.ts │ │ │ ├── optimisticV2Factory.ts │ │ │ ├── services │ │ │ │ ├── erc20.ts │ │ │ │ ├── index.ts │ │ │ │ ├── optimisticOracle.ts │ │ │ │ ├── optimisticOracleV2.ts │ │ │ │ ├── skinnyOptimisticOracle.ts │ │ │ │ ├── sortedRequests.ts │ │ │ │ ├── statemachines │ │ │ │ │ ├── approve.ts │ │ │ │ │ ├── clearUser.ts │ │ │ │ │ ├── disputePrice.ts │ │ │ │ │ ├── fetchEventBased.ts │ │ │ │ │ ├── fetchPastEvents.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── pollActiveRequest.ts │ │ │ │ │ ├── pollActiveUser.ts │ │ │ │ │ ├── pollNewEvents.ts │ │ │ │ │ ├── proposePrice.ts │ │ │ │ │ ├── setActiveRequest.ts │ │ │ │ │ ├── setActiveRequestByTransaction.ts │ │ │ │ │ ├── setUser.ts │ │ │ │ │ ├── settle.ts │ │ │ │ │ ├── statemachine.ts │ │ │ │ │ ├── switchOrAddChain.ts │ │ │ │ │ ├── updateActiveRequest.ts │ │ │ │ │ └── utils.ts │ │ │ │ ├── tests │ │ │ │ │ ├── erc20.e2e.ts │ │ │ │ │ ├── optimisticOracle.e2e.ts │ │ │ │ │ └── skinnyOracle.e2e.ts │ │ │ │ └── update.ts │ │ │ ├── skinnyFactory.ts │ │ │ ├── store │ │ │ │ ├── has.ts │ │ │ │ ├── index.ts │ │ │ │ ├── read.ts │ │ │ │ ├── store.ts │ │ │ │ ├── test │ │ │ │ │ └── store.test.ts │ │ │ │ └── write.ts │ │ │ ├── tests │ │ │ │ ├── client.e2e.ts │ │ │ │ ├── errors.test.ts │ │ │ │ ├── optimisticV2.e2e.ts │ │ │ │ └── utils.test.ts │ │ │ ├── types │ │ │ │ ├── ethers.ts │ │ │ │ ├── index.ts │ │ │ │ ├── interfaces.ts │ │ │ │ ├── misc.ts │ │ │ │ ├── state.ts │ │ │ │ └── statemachine.ts │ │ │ └── utils.ts │ │ ├── stores │ │ │ ├── README.md │ │ │ ├── google-datastore │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── store.e2e.ts │ │ │ │ └── store.ts │ │ │ ├── index.ts │ │ │ ├── js-map │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── store.test.ts │ │ │ │ └── store.ts │ │ │ └── sorted-js-map │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── store.test.ts │ │ │ │ └── store.ts │ │ ├── tables │ │ │ ├── README.md │ │ │ ├── base │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ └── table.ts │ │ │ ├── blocks │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── emps │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── erc20s │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ ├── historical-prices │ │ │ │ ├── README.md │ │ │ │ ├── index.ts │ │ │ │ ├── table.test.ts │ │ │ │ ├── table.ts │ │ │ │ └── utils.ts │ │ │ └── index.ts │ │ ├── types.d.ts │ │ ├── utils.test.ts │ │ └── utils.ts │ ├── templates │ │ └── index.d.ts │ ├── tsconfig.json │ └── tsdx.config.js └── serverless-orchestration │ ├── .mocharc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── hardhat.config.js │ ├── index.js │ ├── package.json │ ├── src │ ├── ServerlessHub.js │ └── ServerlessSpoke.js │ ├── test-helpers │ ├── TimeoutSpokeMock.js │ └── TimeoutSpokeProcess.js │ └── test │ ├── ServerlessHub.js │ └── ServerlessSpoke.js ├── scripts ├── DeployNode.sh ├── bot-deployment │ ├── DeployBotGCP.sh │ ├── DeployBotMonitorConfig.sh │ ├── DeployJsonScheduler.sh │ ├── DeployReporterCR.sh │ ├── PushBotConfigs.sh │ ├── PushBotHotFix.sh │ ├── RetrieveBotConfigs.sh │ └── UpdateBotGCP.sh ├── deploy_dapp.sh ├── gen-nav.js ├── generate_private_key.sh ├── runCommand.sh └── run_release.sh └── yarn.lock /.dockerignore: -------------------------------------------------------------------------------- 1 | circleci 2 | .github 3 | ci 4 | documentation 5 | voter-dapp 6 | node_modules 7 | build 8 | bridge.log 9 | package-lock.json 10 | .coverage_contracts 11 | .coverage 12 | coverage 13 | coverage.json 14 | out.log 15 | .GckmsOverride.js 16 | modules 17 | public 18 | ui 19 | .DS_Store 20 | antora.yml 21 | .eslintcache 22 | app.yaml 23 | .gae_deploy 24 | *-env.txt 25 | .env 26 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | docs 4 | modules 5 | public 6 | ui 7 | sponsor-dapp-v2 8 | voter-dapp 9 | build 10 | dist 11 | .github 12 | cache 13 | types 14 | contract-types 15 | generated 16 | typechain 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Description** 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | **Reproduction** 15 | 16 | Steps to reproduce the behavior: 17 | 1. Go to '...' 18 | 2. Click on '....' 19 | 3. Scroll down to '....' 20 | 4. See error 21 | 22 | **Expected Behavior** 23 | 24 | A clear and concise description of what you expected to happen. 25 | 26 | **Screenshots** 27 | 28 | If applicable, add screenshots to help explain your problem. 29 | 30 | **Version and OS Info** 31 | 32 | - OS: [e.g. Ubuntu] 33 | - Browser [e.g. chrome, safari] 34 | - Version [either git hash of the repository or release] 35 | 36 | **Additional Context** 37 | 38 | Add any other context about the problem here. 39 | 40 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/task.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Task 3 | about: Used to plan tasks for the UMA team 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Why** 11 | 12 | What is the motivation for this feature or task? 13 | 14 | **How** 15 | 16 | How do you think this should be implemented? You don't need to have all the details figured out, but this section should include your thoughts on how this should be implemented. 17 | 18 | **Resolution** 19 | 20 | What is the deliverable to consider this task done? 21 | 22 | **Difficulty Score [1-10]** 23 | 24 | This is a measure of the amount of developer time this task will require to be completed. Note: this should include design and planning time in addition to implementation time. The scale is not linear: 25 | 26 | - 1: <=5 minutes 27 | - 2: ~30 minutes 28 | - 3: ~1 hour 29 | - 4: ~2 hours 30 | - 5: ~4 hours 31 | - 6: ~1 day 32 | - 7: ~3 days 33 | - 8: ~1 week 34 | - 9: ~2 weeks 35 | - 10: ~4 weeks 36 | -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | require: 2 | members: false 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | dist 4 | bridge.log 5 | package-lock.json 6 | .coverage_contracts 7 | .coverage 8 | coverage 9 | coverage.json 10 | out.log 11 | .GckmsOverride.js 12 | .GckmsOverride.ts 13 | docs 14 | modules 15 | ui 16 | .DS_Store 17 | antora.yml 18 | .eslintcache 19 | .idea 20 | optimism 21 | generated 22 | typechain 23 | 24 | # GAE deployment files and directories for GAE deployments. 25 | app.yaml 26 | .gae_deploy 27 | *.env 28 | *env.txt 29 | 30 | # environment-specific values pulled by dotenv package 31 | .env 32 | 33 | # daily reporter temp files. 34 | response.json 35 | *daily-report.txt 36 | 37 | # Gas rebate temp files 38 | debug 39 | 2KEY_ADDRESS_OVERRIDE.json 40 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "packages/core/temp/lib/forge-std"] 2 | path = packages/core/temp/lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | docs 4 | modules 5 | public 6 | ui 7 | build 8 | dist 9 | artifacts 10 | cache 11 | .github 12 | types 13 | contract-types 14 | generated 15 | typechain 16 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "bracketSpacing": true, 4 | "explicitTypes": "preserve", 5 | "tabWidth": 2, 6 | "overrides": [ 7 | { 8 | "files": "*.sol", 9 | "options": { 10 | "tabWidth": 4, 11 | "useTabs": false, 12 | "singleQuote": false, 13 | "explicitTypes": "always" 14 | } 15 | }, 16 | { 17 | "files": "*.md", 18 | "options": { 19 | "semi": false 20 | } 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | network-timeout 300000 -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This is a comment. 2 | # Each line is a file pattern followed by one or more owners. 3 | # Note: CODEOWNERS are automatically requested for review on relevant PRs. 4 | # Order is important; the last matching pattern takes the most 5 | # precedence. 6 | 7 | # These owners will be the default owners for everything in 8 | # the repo unless a later match takes precedence. 9 | * @mrice32 @chrismaree @md0x @Reinis-FRP @daywiss 10 | -------------------------------------------------------------------------------- /ci/check_lerna_packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | if [[ $(git branch | awk '/^\* / { print $2 }') = master ]]; then 7 | HASH=$(git merge-base HEAD~1 master) 8 | echo "You are using master, comparing changes with commit $HASH" 9 | else 10 | HASH=$(git merge-base HEAD master) 11 | echo "You are not using master, comparing changes with commit $HASH" 12 | fi 13 | 14 | yarn lerna ls --since ${HASH} --include-dependents > lerna_output 15 | if [[ $(cat lerna_output | grep @) ]]; then 16 | cat lerna_output | grep @ > lerna_packages 17 | echo "Packages to test:" 18 | cat lerna_packages 19 | else 20 | echo "No packages for testing." 21 | touch lerna_packages 22 | exit 0; 23 | fi 24 | -------------------------------------------------------------------------------- /ci/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # The truffle directory is passed in as the first argument. 5 | TRUFFLE_DIR=$1 6 | 7 | PROTOCOL_DIR=$(pwd) 8 | 9 | # $1 is the truffle directory over which we want to run the coverage tool. 10 | cd $TRUFFLE_DIR 11 | # Truffle compile can take a lot of memory, which I've experienced with the solc-0.6 compatible versions, 12 | # so I explicitly increase the javascript heap size. 13 | # More details here: https://github.com/trufflesuite/truffle/issues/957 14 | # Truffle compile for DecodeTransactionData 15 | node --max-old-space-size=4096 $(npm bin)/truffle compile 16 | node --max-old-space-size=4096 $(npm bin)/truffle run coverage && cat coverage/lcov.info | $(npm bin)/coveralls --verbose 17 | 18 | -------------------------------------------------------------------------------- /ci/dockerhub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << 'EOF' 4 | docker-publish-latest: 5 | machine: 6 | image: ubuntu-2204:2023.10.1 7 | resource_class: large 8 | steps: 9 | - restore_cache: 10 | key: protocol-completed-build-{{ .Environment.CIRCLE_SHA1 }} 11 | - run: 12 | name: Build Docker image 13 | command: | 14 | cd /home/circleci/protocol 15 | docker build -t umaprotocol/protocol:latest . 16 | - run: 17 | name: Publish Docker Image to Docker Hub 18 | command: | 19 | echo $DOCKERHUB_PASS | docker login -u $DOCKERHUB_USERNAME --password-stdin 20 | docker push umaprotocol/protocol:latest 21 | EOF 22 | -------------------------------------------------------------------------------- /ci/dockerhub_workflow.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << EOF 4 | - docker-publish-latest: 5 | context: dockerhub-publish 6 | requires: 7 | - tests-required 8 | filters: 9 | branches: 10 | only: master 11 | EOF 12 | -------------------------------------------------------------------------------- /ci/false_positive.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Exit with no error 4 | exit 0 5 | -------------------------------------------------------------------------------- /ci/install_node_npm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | curl -sSL "https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x64.tar.xz" | sudo tar --strip-components=2 -xJ -C /usr/local/bin/ node-v12.16.2-linux-x64/bin/node 4 | curl https://www.npmjs.com/install.sh | sudo bash 5 | -------------------------------------------------------------------------------- /ci/lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | PROTOCOL_DIR=$(pwd) 5 | 6 | # Lint JS 7 | echo "Linting Solidity and js" 8 | yarn run lint 9 | -------------------------------------------------------------------------------- /ci/run_slither.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | PROTOCOL_DIR=$(pwd) 5 | sudo chmod -R a+rwx /usr/local/lib/node_modules 6 | 7 | 8 | run_slither() { 9 | cd $1 10 | mkdir -p node_modules/ 11 | cp -r ../../node_modules/@openzeppelin ./node_modules/@openzeppelin 12 | 13 | cd $PROTOCOL_DIR 14 | 15 | # print out slither version for debugging 16 | slither --version 17 | slither --exclude=divide-before-multiply,unused-return,timestamp,naming-convention,pragma,solc-version,external-function,reentrancy-benign,reentrancy-no-eth,arbitrary-send,incorrect-equality,reentrancy-events,assembly,uninitialized-local --filter-paths="@openzeppelin|WETH9.sol|test" $1 18 | } 19 | 20 | run_slither $PROTOCOL_DIR/packages/core 21 | -------------------------------------------------------------------------------- /ci/tests/test-financial-templates-lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << EOF 4 | test-financial-templates-lib-hardhat: 5 | docker: 6 | - image: cimg/node:lts 7 | - image: trufflesuite/ganache-cli 8 | command: ganache-cli -i 1234 -l 9000000 -p 9545 9 | working_directory: ~/protocol 10 | resource_class: medium+ 11 | parallelism: 10 12 | steps: 13 | - restore_cache: 14 | key: protocol-completed-build-{{ .Environment.CIRCLE_SHA1 }} 15 | - run: 16 | name: Run tests 17 | command: | 18 | pwd 19 | cd packages/financial-templates-lib 20 | circleci tests glob "test/**/*.js" | circleci tests split > /tmp/test-files 21 | yarn mocha ./$(echo '$(cat /tmp/test-files)') 22 | EOF 23 | -------------------------------------------------------------------------------- /ci/tests/test-integration.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << EOF 4 | test-integration: 5 | machine: 6 | image: ubuntu-2004:202010-01 7 | working_directory: ~/protocol 8 | resource_class: xlarge 9 | steps: 10 | - restore_cache: 11 | key: protocol-completed-build-{{ .Environment.CIRCLE_SHA1 }} 12 | - run: 13 | name: Install dependencies 14 | command: | 15 | sudo apt update 16 | sudo apt install nodejs npm 17 | sudo npm install --global yarn 18 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash 19 | nvm install 15.10.0 20 | - run: 21 | name: Run integration tests 22 | command: | 23 | nvm use 15.10.0 24 | yarn optimism-up 25 | sleep 120 26 | yarn --cwd packages/core test-e2e 27 | EOF 28 | -------------------------------------------------------------------------------- /ci/tests/test-liquidator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << EOF 4 | test-liquidator-package: 5 | docker: 6 | - image: cimg/node:lts 7 | - image: trufflesuite/ganache-cli 8 | command: ganache-cli -i 1234 -l 9000000 -p 9545 9 | working_directory: ~/protocol 10 | resource_class: medium+ 11 | parallelism: 10 12 | steps: 13 | - restore_cache: 14 | key: protocol-completed-build-{{ .Environment.CIRCLE_SHA1 }} 15 | - run: 16 | name: Run tests 17 | command: | 18 | pwd 19 | cd packages/liquidator 20 | circleci tests glob "test/**/*.js" | circleci tests split > /tmp/test-files 21 | yarn hardhat test ./$(echo '$(cat /tmp/test-files)') 22 | EOF 23 | -------------------------------------------------------------------------------- /ci/tests/test-not-required.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << EOF 4 | version: 2.1 5 | jobs: 6 | tests-required: 7 | docker: 8 | - image: cimg/node:lts 9 | steps: 10 | - run: 11 | name: Test dependencies 12 | command: | 13 | echo "No packages for testing." 14 | circleci-agent step halt; 15 | 16 | workflows: 17 | version: 2.1 18 | build_and_test: 19 | jobs: 20 | - tests-required 21 | EOF 22 | -------------------------------------------------------------------------------- /ci/tests/test-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PACKAGE=$1 4 | 5 | cat << EOF 6 | test-${PACKAGE:5}: 7 | docker: 8 | - image: cimg/node:lts 9 | - image: trufflesuite/ganache-cli 10 | command: ganache-cli -i 1234 -l 9000000 -p 9545 11 | working_directory: ~/protocol 12 | resource_class: large 13 | steps: 14 | - restore_cache: 15 | key: protocol-completed-build-{{ .Environment.CIRCLE_SHA1 }} 16 | - run: 17 | name: Run tests 18 | command: | 19 | export PATH="$PATH:/home/circleci/.foundry/bin" 20 | yarn test --scope ${PACKAGE}; 21 | EOF 22 | -------------------------------------------------------------------------------- /ci/tests/test-required.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat << EOF 4 | tests-required: 5 | docker: 6 | - image: cimg/node:lts 7 | steps: 8 | - run: 9 | name: Test dependencies 10 | command: | 11 | echo "All packages tested successfully!" 12 | circleci-agent step halt; 13 | EOF 14 | -------------------------------------------------------------------------------- /hardhat.config.js: -------------------------------------------------------------------------------- 1 | // Note: this config is only here as a matter of convenience to allow all hardhat commands that can be run from core 2 | // work at root as well. 3 | const { getHardhatConfig } = require("@uma/common"); 4 | 5 | const path = require("path"); 6 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | }, 14 | }; 15 | 16 | module.exports = getHardhatConfig(configOverride, coreWkdir); 17 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": ["packages/**"], 3 | "npmClient": "yarn", 4 | "useWorkspaces": true, 5 | "version": "independent" 6 | } 7 | -------------------------------------------------------------------------------- /packages/affiliates/.gitignore: -------------------------------------------------------------------------------- 1 | artifacts 2 | -------------------------------------------------------------------------------- /packages/affiliates/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | timeout: 100000, 3 | exit: true, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/affiliates/README.md: -------------------------------------------------------------------------------- 1 | # Affiliates 2 | 3 | This package is mostly deprecated. It only contains logic for running UMA DVM vote gas rebates. 4 | -------------------------------------------------------------------------------- /packages/affiliates/hardhat.config.js: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("@uma/common"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const packageWkdir = path.dirname(require.resolve("@uma/affiliates/package.json")); 6 | 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | tests: `${packageWkdir}/test`, 14 | }, 15 | }; 16 | 17 | module.exports = getHardhatConfig(configOverride, coreWkdir); 18 | -------------------------------------------------------------------------------- /packages/affiliates/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@uma/affiliates", 3 | "version": "1.27.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@uma/common": "^2.37.3", 8 | "@uma/contracts-node": "^0.4.25", 9 | "cli-progress": "^3.8.2", 10 | "minimist": "^1.2.7", 11 | "mkdirp": "^1.0.4", 12 | "moment": "^2.29.1" 13 | }, 14 | "devDependencies": { 15 | "chai": "^4.3.4", 16 | "mocha": "^9.1.1", 17 | "tape": "^5.0.1" 18 | }, 19 | "publishConfig": { 20 | "registry": "https://registry.npmjs.com/", 21 | "access": "public" 22 | }, 23 | "scripts": { 24 | "test": "yarn test-local", 25 | "test-local": "mocha 'test/mocha-local/**/*.js'" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/affiliates/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "include": ["**/*.ts"], 4 | "compilerOptions": { 5 | "outDir": "build", 6 | "esModuleInterop": true, 7 | "resolveJsonModule": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/api/README.md: -------------------------------------------------------------------------------- 1 | # UMA Api 2 | 3 | This package is meant as a collection of API style services and applications to serve data about the UMA ecosystem. 4 | 5 | ## Developer Quickstart 6 | 7 | ### Install everything 8 | 9 | `yarn` 10 | 11 | ### Build 12 | 13 | `yarn build` 14 | 15 | ### Build watching for changes 16 | 17 | `yarn build:watch` 18 | 19 | ### Test 20 | 21 | `yarn test` 22 | 23 | ### Test watching for changes 24 | 25 | `yarn test:watch` 26 | 27 | ### Lint 28 | 29 | `yarn lint` 30 | 31 | ## Docs 32 | 33 | Go to [source docs](./src/README.md) 34 | -------------------------------------------------------------------------------- /packages/api/src/apps/README.md: -------------------------------------------------------------------------------- 1 | # Uma Api 2 | 3 | This package is meant to ingest and expose data about the UMA ecosystem through a restful API. 4 | 5 | ## Apps 6 | 7 | - [api](./apps/api): entry point to run all the api logic 8 | - [lsp_api](./apps/lsp_api): entry point to run all the api logic 9 | - [datastore_api](./apps/datastore_api): entry point to run all the api logic 10 | 11 | ## Libraries 12 | 13 | - [libs](./libs) - various supporting libraries 14 | - [services](./services) - microservice style components 15 | - [tables](./tables) - data tables for storing api related data 16 | - [examples](./examples) - various frontend tools 17 | 18 | ### ENV 19 | 20 | You will need a .env for each application. See the specific application readme. 21 | 22 | ## Quickstart 23 | 24 | There maybe 1 or more available apps in the `src/apps` folder. To start the `api` app: 25 | 26 | Install dependencies: `yarn` 27 | 28 | To run `api`: 29 | 30 | 1. `yarn build` 31 | 2. `yarn api` 32 | -------------------------------------------------------------------------------- /packages/api/src/apps/api/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./app"; 2 | -------------------------------------------------------------------------------- /packages/api/src/apps/datastore_api/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./app"; 2 | -------------------------------------------------------------------------------- /packages/api/src/apps/index.ts: -------------------------------------------------------------------------------- 1 | export { default as api } from "./api"; 2 | export { default as lsp_api } from "./lsp_api"; 3 | export { default as datastore_api } from "./datastore_api"; 4 | export { default as serverless_write } from "./serverless_write"; 5 | export { default as serverless_read } from "./serverless_read"; 6 | -------------------------------------------------------------------------------- /packages/api/src/apps/lsp_api/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./app"; 2 | -------------------------------------------------------------------------------- /packages/api/src/apps/serverless_read/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./app"; 2 | -------------------------------------------------------------------------------- /packages/api/src/apps/serverless_write/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./app"; 2 | -------------------------------------------------------------------------------- /packages/api/src/examples/README.md: -------------------------------------------------------------------------------- 1 | # API Examples 2 | 3 | Examples of how to use api, or other useful reference code. 4 | -------------------------------------------------------------------------------- /packages/api/src/examples/action-client.e2e.ts: -------------------------------------------------------------------------------- 1 | import Client from "./action-client"; 2 | import type { Client as ClientType } from "./action-client"; 3 | import assert from "assert"; 4 | describe("action client", function () { 5 | let client: ClientType; 6 | it("init", function () { 7 | client = Client("http://localhost:8282", "emp"); 8 | assert.ok(client); 9 | }); 10 | // these test requires integration testing setup with API running. disable for ci 11 | it("echo", async function () { 12 | const result = await client("echo", "test"); 13 | assert.deepEqual(result, ["test"]); 14 | }); 15 | it("error", async function () { 16 | let plan = 1; 17 | try { 18 | await client("dne", "test"); 19 | } catch (err) { 20 | plan--; 21 | assert.ok(err); 22 | } 23 | assert.equal(plan, 0); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /packages/api/src/examples/index.ts: -------------------------------------------------------------------------------- 1 | export * as actionClient from "./action-client"; 2 | -------------------------------------------------------------------------------- /packages/api/src/index.ts: -------------------------------------------------------------------------------- 1 | export * as apps from "./apps"; 2 | export * as services from "./services"; 3 | export * as libs from "./libs"; 4 | export * as tables from "./tables"; 5 | export * as examples from "./examples"; 6 | export * as types from "./types"; 7 | -------------------------------------------------------------------------------- /packages/api/src/libs/index.ts: -------------------------------------------------------------------------------- 1 | export * as zrx from "./zrx"; 2 | export * as utils from "./utils"; 3 | export * as queries from "./queries"; 4 | export * as osnap from "./osnap"; 5 | -------------------------------------------------------------------------------- /packages/api/src/libs/osnap/index.ts: -------------------------------------------------------------------------------- 1 | export * as utils from "./utils"; 2 | export * as interfaces from "./interfaces"; 3 | -------------------------------------------------------------------------------- /packages/api/src/libs/queries/global.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UMAprotocol/protocol/39808d73d8b02227e65d0ea4c04a88d1db87b51e/packages/api/src/libs/queries/global.ts -------------------------------------------------------------------------------- /packages/api/src/libs/queries/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Emp } from "./emp"; 2 | export { default as Lsp } from "./lsp"; 3 | -------------------------------------------------------------------------------- /packages/api/src/services/README.md: -------------------------------------------------------------------------------- 1 | # Api Services 2 | 3 | These are classes which do a specific task. Services all maintain the same creation signature so they can be 4 | instantiated predictably. 5 | 6 | ## Function signature 7 | 8 | `type Service = (config:Json, libs:Libs, emit?:(...args:any[]):void):Promise{}` 9 | 10 | ## Return types 11 | 12 | Services can return anything really, but typically you want them to be class-like, ie returning an object or collection 13 | of functions that can call into the service. 14 | -------------------------------------------------------------------------------- /packages/api/src/services/actions/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Emp } from "./emp"; 2 | export { default as Lsp } from "./lsp"; 3 | export { default as Global } from "./global"; 4 | export { default as Scheduler } from "./scheduler"; 5 | export { default as Osnap } from "./osnap"; 6 | -------------------------------------------------------------------------------- /packages/api/src/services/actions/osnap.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Actions, Json, ActionCall } from "../../types"; 3 | import { simulateOsnapProposal } from "../../libs/osnap/utils"; 4 | 5 | export function Handlers(): Actions { 6 | const actions: Actions = { 7 | async ping() { 8 | return "pong"; 9 | }, 10 | simulate: simulateOsnapProposal, 11 | }; 12 | 13 | // list all available actions 14 | const keys = Object.keys(actions); 15 | actions.actions = () => keys; 16 | 17 | return actions; 18 | } 19 | 20 | export default (): ActionCall => { 21 | const actions = Handlers(); 22 | return async (action: string, ...args: Json[]): Promise => { 23 | assert(actions[action], `Invalid action: ${action}`); 24 | return actions[action](...args); 25 | }; 26 | }; 27 | -------------------------------------------------------------------------------- /packages/api/src/services/index.ts: -------------------------------------------------------------------------------- 1 | export { EmpState } from "./emp-state"; 2 | export { Registry } from "./emp-registry"; 3 | export { Erc20s } from "./erc20-state"; 4 | export { LspCreator } from "./lsp-creator"; 5 | export { LspState } from "./lsp-state"; 6 | export { default as MultiLspCreator } from "./multi-lsp-creator"; 7 | export { default as Express } from "./express"; 8 | export { default as ExpressChannels } from "./express-channels"; 9 | export { Contracts } from "./contracts"; 10 | // this exports a folder with several services inside 11 | -------------------------------------------------------------------------------- /packages/api/src/start.ts: -------------------------------------------------------------------------------- 1 | // start apps in the app folder: npx ts-node src/start ${appname} 2 | // to see a list of apps, look in src/apps, the folders match the app name 3 | require("dotenv").config(); 4 | import minimist from "minimist"; 5 | import assert from "assert"; 6 | import * as Apps from "./apps"; 7 | const args: string[] = minimist(process.argv.slice(2))._; 8 | const [appType] = args; 9 | assert(appType, `requires app name, for example: ts-node src/start api`); 10 | 11 | type AppType = keyof typeof Apps; 12 | 13 | const app = Apps[appType.toLowerCase() as AppType]; 14 | 15 | assert(app, `No such app: ${appType}`); 16 | 17 | app(process.env) 18 | .then(() => console.log(`${appType} started`)) 19 | .catch(console.error); 20 | -------------------------------------------------------------------------------- /packages/api/src/tables/addresses/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/api/src/tables/addresses/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("addresses table", function () { 5 | let table: Table; 6 | it("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | it("create", async function () { 11 | const result = await table.create({ 12 | address: "0x", 13 | }); 14 | assert.ok(result.id); 15 | }); 16 | it("values", async function () { 17 | const result = await table.values(); 18 | assert.equal(result.length, 1); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/api/src/tables/addresses/table.ts: -------------------------------------------------------------------------------- 1 | import * as uma from "@uma/sdk"; 2 | import { Data, makeId } from "./utils"; 3 | 4 | const BaseTable = uma.tables.base; 5 | const { JsMap } = uma.stores; 6 | 7 | export const Table = (type = "Addresses", store = JsMap()) => { 8 | const table = BaseTable>({ type, makeId }, store); 9 | 10 | async function set(address: string) { 11 | await store.set(address, { id: address, address }); 12 | } 13 | 14 | return { 15 | ...table, 16 | set, 17 | }; 18 | }; 19 | 20 | export type Table = ReturnType; 21 | -------------------------------------------------------------------------------- /packages/api/src/tables/addresses/utils.ts: -------------------------------------------------------------------------------- 1 | export type Data = { 2 | id?: string; 3 | address: string; 4 | }; 5 | export function makeId(data: Pick) { 6 | return data.address; 7 | } 8 | -------------------------------------------------------------------------------- /packages/api/src/tables/app-stats/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/api/src/tables/app-stats/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("app stats js-map", function () { 5 | let table: Table; 6 | it("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | it("create", async function () { 11 | const result = await table.create({ 12 | id: 1, 13 | }); 14 | assert.ok(result.id); 15 | }); 16 | it("values", async function () { 17 | const result = await table.values(); 18 | assert.equal(result.length, 1); 19 | }); 20 | it("setLastBlockUpdate", async function () { 21 | const result = await table.setLastBlockUpdate(10); 22 | assert.strictEqual(result.lastBlockUpdate, 10); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /packages/api/src/tables/app-stats/table.ts: -------------------------------------------------------------------------------- 1 | import * as uma from "@uma/sdk"; 2 | import { Data, makeId } from "./utils"; 3 | 4 | const BaseTable = uma.tables.base; 5 | const { JsMap } = uma.stores; 6 | 7 | export const Table = (type = "App Stats", store = JsMap()) => { 8 | const table = BaseTable>({ type, makeId }, store); 9 | 10 | async function setLastBlockUpdate(lastBlockUpdate: number) { 11 | return table.set({ 12 | id: 1, 13 | lastBlockUpdate, 14 | }); 15 | } 16 | 17 | async function getLastBlockUpdate() { 18 | try { 19 | return (await table.get(1)).lastBlockUpdate; 20 | } catch { 21 | return undefined; 22 | } 23 | } 24 | 25 | return { 26 | ...table, 27 | setLastBlockUpdate, 28 | getLastBlockUpdate, 29 | }; 30 | }; 31 | 32 | export type Table = ReturnType; 33 | -------------------------------------------------------------------------------- /packages/api/src/tables/app-stats/utils.ts: -------------------------------------------------------------------------------- 1 | export type Data = { 2 | id: number; 3 | lastBlockUpdate?: number; 4 | }; 5 | export function makeId(data: Pick) { 6 | return data.id; 7 | } 8 | -------------------------------------------------------------------------------- /packages/api/src/tables/emp-stats-history/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UMAprotocol/protocol/39808d73d8b02227e65d0ea4c04a88d1db87b51e/packages/api/src/tables/emp-stats-history/README.md -------------------------------------------------------------------------------- /packages/api/src/tables/emp-stats-history/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/api/src/tables/emp-stats-history/utils.ts: -------------------------------------------------------------------------------- 1 | export type Data = { 2 | id?: number; 3 | address: string; 4 | timestamp: number; 5 | value: string; 6 | }; 7 | // this is a funny id, but allows us to maintain time series data for multiple addresses in the same table 8 | export function makeId(data: Pick) { 9 | return [data.address, data.timestamp.toString().padStart(16, "0")].join("!"); 10 | } 11 | // this creates an id which would represents above the maximum value an address + timestamp can represent 12 | // useful for calculating the end id for a between(start,end) query 13 | export function makeEndId(data: Pick) { 14 | return [data.address, "~"].join("!"); 15 | } 16 | -------------------------------------------------------------------------------- /packages/api/src/tables/emp-stats/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UMAprotocol/protocol/39808d73d8b02227e65d0ea4c04a88d1db87b51e/packages/api/src/tables/emp-stats/README.md -------------------------------------------------------------------------------- /packages/api/src/tables/emp-stats/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/api/src/tables/emp-stats/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("emp stat table", function () { 5 | let table: any; 6 | it("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | it("create", async function () { 11 | const data = { 12 | address: "a", 13 | }; 14 | const result = await table.getOrCreate(data.address); 15 | assert.equal(result.id, data.address); 16 | }); 17 | it("upsert", async function () { 18 | const address = "b"; 19 | const update = { 20 | tvl: "100", 21 | }; 22 | const result = await table.upsert(address, update); 23 | assert.equal(result.id, address); 24 | assert.equal(result.tvl, update.tvl); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /packages/api/src/tables/emp-stats/utils.ts: -------------------------------------------------------------------------------- 1 | export type Data = { 2 | id?: string; 3 | address: string; 4 | timestamp?: number; 5 | value?: string; 6 | }; 7 | export function makeId(data: Pick) { 8 | return data.address; 9 | } 10 | -------------------------------------------------------------------------------- /packages/api/src/tables/index.ts: -------------------------------------------------------------------------------- 1 | export * as empStats from "./emp-stats"; 2 | export * as empStatsHistory from "./emp-stats-history"; 3 | export * as lsps from "./lsps"; 4 | export * as appStats from "./app-stats"; 5 | export * as registeredContracts from "./registered-contracts"; 6 | export * as addresses from "./addresses"; 7 | export * as priceSamples from "./price-samples"; 8 | export * as tvl from "./tvl"; 9 | export { default as StoresFactory } from "./stores-factory"; 10 | -------------------------------------------------------------------------------- /packages/api/src/tables/lsps/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/api/src/tables/lsps/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("emp js-map", function () { 5 | let table: Table; 6 | it("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | it("create", async function () { 11 | const result = await table.create({ 12 | address: "a", 13 | }); 14 | assert.ok(result.id); 15 | await table.create({ 16 | address: "b", 17 | }); 18 | assert.ok(result.id); 19 | }); 20 | it("values", async function () { 21 | const result = await table.values(); 22 | assert.equal(result.length, 2); 23 | }); 24 | it("addSponsors", async function () { 25 | const result = await table.addSponsors("a", ["a", "b", "c", "a"]); 26 | assert.ok(result.sponsors); 27 | // one dupe, so 3 total 28 | assert.equal(result.sponsors.length, 3); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/api/src/tables/price-samples/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/api/src/tables/price-samples/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("price samples table", function () { 5 | let table: Table; 6 | it("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | it("create", async function () { 11 | const result = await table.create({ 12 | address: "0x", 13 | timestamp: 16300011, 14 | price: "21331", 15 | }); 16 | assert.ok(result.id); 17 | }); 18 | it("values", async function () { 19 | const result = await table.values(); 20 | assert.equal(result.length, 1); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/api/src/tables/price-samples/table.ts: -------------------------------------------------------------------------------- 1 | import * as uma from "@uma/sdk"; 2 | import { Data, makeId } from "./utils"; 3 | 4 | const BaseTable = uma.tables.base; 5 | const { JsMap } = uma.stores; 6 | 7 | export const Table = (type = "Price Samples", store = JsMap()) => { 8 | const table = BaseTable>({ type, makeId }, store); 9 | 10 | return { 11 | ...table, 12 | }; 13 | }; 14 | 15 | export type Table = ReturnType; 16 | -------------------------------------------------------------------------------- /packages/api/src/tables/price-samples/utils.ts: -------------------------------------------------------------------------------- 1 | export type Data = { 2 | id?: string; 3 | address: string; 4 | timestamp: number; 5 | price: string; 6 | }; 7 | export function makeId(data: Pick) { 8 | return data.address; 9 | } 10 | -------------------------------------------------------------------------------- /packages/api/src/tables/registered-contracts/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/api/src/tables/registered-contracts/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("registered emps table", function () { 5 | let table: Table; 6 | it("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | it("create", async function () { 11 | const result = await table.create({ 12 | id: "0x", 13 | address: "0x", 14 | }); 15 | assert.ok(result.id); 16 | }); 17 | it("values", async function () { 18 | const result = await table.values(); 19 | assert.equal(result.length, 1); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /packages/api/src/tables/registered-contracts/table.ts: -------------------------------------------------------------------------------- 1 | import * as uma from "@uma/sdk"; 2 | import { Data, makeId } from "./utils"; 3 | 4 | const BaseTable = uma.tables.base; 5 | const { JsMap } = uma.stores; 6 | 7 | export const Table = (type = "Registered Emps", store = JsMap()) => { 8 | const table = BaseTable>({ type, makeId }, store); 9 | 10 | return { 11 | ...table, 12 | }; 13 | }; 14 | 15 | export type Table = ReturnType; 16 | -------------------------------------------------------------------------------- /packages/api/src/tables/registered-contracts/utils.ts: -------------------------------------------------------------------------------- 1 | export type Data = { 2 | id: string; 3 | address: string; 4 | blockNumber?: number; 5 | }; 6 | export function makeId(data: Pick) { 7 | return data.address; 8 | } 9 | -------------------------------------------------------------------------------- /packages/api/src/tables/tvl/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/api/src/tables/tvl/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("tvl table", function () { 5 | let table: Table; 6 | it("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | it("create", async function () { 11 | const result = await table.create({ 12 | id: 1, 13 | timestamp: 16300011, 14 | value: "21331", 15 | }); 16 | assert.ok(result.id); 17 | }); 18 | it("values", async function () { 19 | const result = await table.values(); 20 | assert.equal(result.length, 1); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/api/src/tables/tvl/table.ts: -------------------------------------------------------------------------------- 1 | import * as uma from "@uma/sdk"; 2 | import { Data, makeId } from "./utils"; 3 | 4 | const BaseTable = uma.tables.base; 5 | const { JsMap } = uma.stores; 6 | 7 | export const Table = (type = "Total Value", store = JsMap()) => { 8 | const table = BaseTable>({ type, makeId }, store); 9 | 10 | async function set(value: string, timestamp: number) { 11 | await store.set(1, { 12 | id: 1, 13 | value, 14 | timestamp, 15 | }); 16 | } 17 | 18 | async function get() { 19 | return store.get(1); 20 | } 21 | 22 | return { 23 | ...table, 24 | set, 25 | get, 26 | }; 27 | }; 28 | 29 | export type Table = ReturnType; 30 | -------------------------------------------------------------------------------- /packages/api/src/tables/tvl/utils.ts: -------------------------------------------------------------------------------- 1 | export type Data = { 2 | id: number; 3 | value: string; 4 | timestamp: number; 5 | }; 6 | export function makeId(data: Pick) { 7 | return data.id; 8 | } 9 | -------------------------------------------------------------------------------- /packages/api/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "include": ["src", "types"], 4 | "compilerOptions": { 5 | "resolveJsonModule": true, 6 | "outDir": "build", 7 | "esModuleInterop": true, 8 | "downlevelIteration": true, 9 | "declaration":true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/common/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | timeout: 100000, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/common/README.md: -------------------------------------------------------------------------------- 1 | # @uma/common 2 | 3 | This package contains common javascript utilities and files used by other `@uma` packages. It is rarely used outside of 4 | that context. 5 | 6 | ## Installing the package 7 | 8 | ```bash 9 | yarn add @uma/common 10 | ``` 11 | 12 | ## Importing the package 13 | 14 | ```js 15 | // One of many possible possible functions to import. 16 | const { getHardhatConfig } = require("@uma/common") 17 | ``` 18 | -------------------------------------------------------------------------------- /packages/common/hardhat.config.js: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("./dist/HardhatConfig"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const packageWkdir = path.dirname(require.resolve("./package.json")); 6 | 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | tests: `${packageWkdir}/test`, 14 | }, 15 | }; 16 | 17 | module.exports = getHardhatConfig(configOverride, coreWkdir); 18 | -------------------------------------------------------------------------------- /packages/common/src/AxiosRetry.ts: -------------------------------------------------------------------------------- 1 | import axios, { AxiosRequestConfig, AxiosResponse } from "axios"; 2 | import retry, { Options as RetryOptions } from "async-retry"; 3 | 4 | // Axios wrapper that retries on network errors and non-2xx HTTP responses. 5 | export const axiosWithRetry = async ( 6 | requestConfig: AxiosRequestConfig, 7 | retryOptions: RetryOptions 8 | ): Promise => { 9 | return await retry(async () => { 10 | return await axios(requestConfig); 11 | }, retryOptions); 12 | }; 13 | -------------------------------------------------------------------------------- /packages/common/src/MultiDecimalTestHelper.ts: -------------------------------------------------------------------------------- 1 | // Run the tests against 2 different kinds of token/synth decimal combinations: 2 | // 1) matching 18 collateral & 18 synthetic decimals with 18 decimals for price feed. 3 | // 3) matching 8 collateral & 8 synthetic decimals with 18 decimals for price feed. 4 | export const TEST_DECIMAL_COMBOS = [ 5 | { 6 | tokenSymbol: "WETH", 7 | tokenName: "Wrapped Ether", 8 | collateralDecimals: 18, 9 | syntheticDecimals: 18, 10 | priceFeedDecimals: 18, 11 | }, 12 | { 13 | tokenSymbol: "WBTC", 14 | tokenName: "Wrapped Bitcoin", 15 | collateralDecimals: 8, 16 | syntheticDecimals: 8, 17 | priceFeedDecimals: 18, 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /packages/common/src/Random.ts: -------------------------------------------------------------------------------- 1 | import Web3 from "web3"; 2 | import { BN } from "./types"; 3 | 4 | export function getRandomSignedInt(): BN { 5 | const unsignedValue = getRandomUnsignedInt(); 6 | 7 | // The signed range is just the unsigned range decreased by 2^255. 8 | const signedOffset = Web3.utils.toBN(2).pow(Web3.utils.toBN(255)); 9 | return unsignedValue.sub(signedOffset); 10 | } 11 | 12 | // Generate a random unsigned 256 bit int. 13 | export function getRandomUnsignedInt(): BN { 14 | return Web3.utils.toBN(Web3.utils.randomHex(32)); 15 | } 16 | -------------------------------------------------------------------------------- /packages/common/src/browser.ts: -------------------------------------------------------------------------------- 1 | // Only the browser-safe modules. 2 | export * from "./AncillaryDataParser"; 3 | export * from "./AdminUtils"; 4 | export * from "./Constants"; 5 | export * from "./Constants"; 6 | export * from "./AdminUtils"; 7 | export * from "./ContractUtils"; 8 | export * from "./TransactionUtils"; 9 | export * from "./Crypto"; 10 | export * from "./EmpUtils"; 11 | export * from "./EncryptionHelper"; 12 | export * from "./Enums"; 13 | export * from "./FormattingUtils"; 14 | export * from "./ObjectUtils"; 15 | export * from "./PublicNetworks"; 16 | export * from "./Random"; 17 | export * from "./SolidityTestUtils"; 18 | export * from "./TimeUtils"; 19 | export * from "./PriceIdentifierUtils"; 20 | export * from "./MultiDecimalTestHelper"; 21 | export * from "./MultiVersionTestHelpers"; 22 | export * from "./hardhat/fixtures"; 23 | -------------------------------------------------------------------------------- /packages/common/src/hardhat/fixtures/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./default"; 2 | export * from "./VotingV2"; 3 | -------------------------------------------------------------------------------- /packages/common/src/hardhat/index.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import path from "path"; 3 | 4 | ["tasks"].forEach((folder) => 5 | fs 6 | .readdirSync(path.join(__dirname, folder)) 7 | .filter((path) => path.endsWith(".js")) 8 | .forEach((mod) => require(path.join(__dirname, folder, mod))) 9 | ); 10 | -------------------------------------------------------------------------------- /packages/common/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./browser"; 2 | export * from "./gckms/ManagedSecretProvider"; 3 | export * from "./gckms/utils"; 4 | export * from "./FileHelpers"; 5 | export * from "./MerkleTree"; 6 | export * from "./ProviderUtils"; 7 | export * from "./HardhatConfig"; 8 | export * from "./RetryProvider"; 9 | export * from "./UniswapV3Helpers"; 10 | export * from "./types"; 11 | export * from "./EthersSignerUtils"; 12 | export * from "./EthersProviderUtils"; 13 | export * from "./EventUtils"; 14 | export * from "./TenderlyFork"; 15 | export * from "./TenderlySimulation"; 16 | export * from "./AxiosRetry"; 17 | -------------------------------------------------------------------------------- /packages/common/src/types.ts: -------------------------------------------------------------------------------- 1 | import type _Web3 from "web3"; 2 | 3 | import { runTransaction } from "./TransactionUtils"; 4 | 5 | export type BN = ReturnType<_Web3["utils"]["toBN"]>; 6 | 7 | export type TransactionType = Parameters[0]["transaction"]; 8 | -------------------------------------------------------------------------------- /packages/common/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "include": ["src/**/*", "index.ts"], 4 | "exclude": ["dist/**/*"], 5 | "compilerOptions": { 6 | "typeRoots": ["./types", "./node_modules/@types"], 7 | "outDir": "dist", 8 | "declaration": true, 9 | "resolveJsonModule": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/common/types/umaprotocol__truffle-ledger-provider/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module "@umaprotocol/truffle-ledger-provider" { 2 | interface JsonRpcPayload { 3 | jsonrpc: string; 4 | method: string; 5 | params: any[]; 6 | id?: string | number; 7 | } 8 | 9 | interface JsonRpcResponse { 10 | jsonrpc: string; 11 | id: number; 12 | result?: any; 13 | error?: string; 14 | } 15 | 16 | export default class TruffleLedgerProvider { 17 | constructor(options: any, urlOrProvider: any); 18 | sendAsync(payload: JsonRpcPayload, callback: (error: Error | null, result?: JsonRpcResponse) => void): void; 19 | send(payload: JsonRpcPayload, callback: (error: Error | null, result?: JsonRpcResponse) => void): void; 20 | } 21 | } -------------------------------------------------------------------------------- /packages/common/types/umaprotocol__ynatm/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module "@umaprotocol/ynatm" { 2 | export const EXPONENTIAL: (base?: number, inGwei?: boolean) => (arg: { x?: number }) => number; 3 | export const LINEAR: (slope?: number, inGwei?: boolean) => (arg: { x?: number, c?: number }) => number; 4 | export const DOUBLES: (arg: { y?: number }) => number; 5 | export const toGwei: (x: number) => number; 6 | 7 | export interface SendArgs { 8 | sendTransactionFunction: (gasPrice: number) => T; 9 | minGasPrice: string | number; 10 | maxGasPrice: string | number; 11 | gasPriceScalingFunction?: (args: { x?: number, y?: number, c?: number }) => number; 12 | delay?: number; 13 | rejectImmediatelyOnCondition?: (e: Error) => boolean; 14 | } 15 | 16 | export const send: (args: SendArgs) => T; 17 | } -------------------------------------------------------------------------------- /packages/contract-notifier/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@uma/contract-notifier", 3 | "version": "1.3.38", 4 | "description": "UMA Contract Notification Bot", 5 | "homepage": "https://umaproject.org", 6 | "license": "AGPL-3.0-or-later", 7 | "main": "index.js", 8 | "dependencies": { 9 | "@google-cloud/datastore": "^7.0.0", 10 | "@uma/common": "^2.37.3", 11 | "@uma/financial-templates-lib": "^2.36.3", 12 | "async-retry": "^1.3.1", 13 | "dotenv": "^6.2.0" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/UMAprotocol/protocol.git" 18 | }, 19 | "files": [ 20 | "/src/**/*.js" 21 | ], 22 | "bin": "index.js", 23 | "bugs": { 24 | "url": "https://github.com/UMAprotocol/protocol/issues" 25 | }, 26 | "publishConfig": { 27 | "registry": "https://registry.npmjs.com/", 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/contracts-frontend/hardhat.config.cjs: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("@uma/common"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const configOverride = { 6 | paths: { 7 | sources: `${coreWkdir}/contracts`, 8 | artifacts: `${coreWkdir}/artifacts`, 9 | cache: `${coreWkdir}/cache`, 10 | }, 11 | }; 12 | 13 | module.exports = getHardhatConfig(configOverride, __dirname); 14 | -------------------------------------------------------------------------------- /packages/contracts-frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["generated/index.ts", "typechain/**/*"], 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "declaration": true, 6 | "resolveJsonModule": true, 7 | "target": "ES2020", 8 | "module": "ES2020", 9 | "moduleResolution": "node", 10 | "esModuleInterop": true, 11 | "strict": true, 12 | "skipLibCheck": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/contracts-node/hardhat.config.js: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("@uma/common"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const configOverride = { 6 | paths: { sources: `${coreWkdir}/contracts`, artifacts: `${coreWkdir}/artifacts`, cache: `${coreWkdir}/cache` }, 7 | }; 8 | 9 | module.exports = getHardhatConfig(configOverride, __dirname); 10 | -------------------------------------------------------------------------------- /packages/contracts-node/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "esModuleInterop": true, 4 | "include": [ 5 | "generated/index.ts", 6 | "typechain/**/*", 7 | "../core/artifacts/**/*.json", 8 | "../../node_modules/@across-protocol/contracts/artifacts/**/*.json", 9 | "../../node_modules/@across-protocol/contracts/artifacts/**/*.json" 10 | ], 11 | "exclude": [ 12 | "../core/artifacts/build-info/**/*.json", 13 | "../core/artifacts/**/*.dbg.json", 14 | "../../node_modules/@across-protocol/artifacts/**/*.dbg.json" 15 | ], 16 | "compilerOptions": { 17 | "outDir": "./dist", 18 | "declaration": true, 19 | "resolveJsonModule": true, 20 | "target": "ES2020", 21 | "module": "CommonJS" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/core/.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | cache-ovm/ 3 | artifacts/ 4 | artifacts-ovm/ 5 | flattened/ 6 | types/ 7 | contract-types/ 8 | deployments/ 9 | lib/ 10 | forge-cache/ 11 | out/ 12 | -------------------------------------------------------------------------------- /packages/core/config/identifiers.json: -------------------------------------------------------------------------------- 1 | { 2 | "BTC/USD": {}, 3 | "USD/BTC": {}, 4 | "ETH/USD": {}, 5 | "CMC Total Market Cap": {}, 6 | "S&P 500": {}, 7 | "TSLA": {}, 8 | "Gold (Rolling Future)": {}, 9 | "Crude Oil (Rolling Future)": {}, 10 | "CNY/USD": {}, 11 | "EUR/USD": {}, 12 | "Telegram SAFT": {}, 13 | "USD/ETH": {}, 14 | "Custom Index (1)": {}, 15 | "Custom Index (100)": {}, 16 | "ETH/BTC": {}, 17 | "COMPUSD": {}, 18 | "USDETH": {}, 19 | "USDBTC": {}, 20 | "PERL/USDT": {}, 21 | "USDT/PERL": {}, 22 | "CHF/USD": {}, 23 | "GBP/USD": {}, 24 | "XAU/USD": {}, 25 | "SPX/USD": {}, 26 | "XTI/USD": {}, 27 | "XAG/USD": {}, 28 | "STABLESPREAD": {}, 29 | "STABLESPREAD/USDC": {}, 30 | "STABLESPREAD/BTC": {}, 31 | "ELASTIC_STABLESPREAD/USDC": {}, 32 | "EURUSD": {}, 33 | "CHFUSD": {}, 34 | "GBPUSD": {}, 35 | "BCHNBTC": {}, 36 | "preTORN": {}, 37 | "preICP": {}, 38 | "preCLX": {}, 39 | "DAIPHP": {} 40 | } 41 | -------------------------------------------------------------------------------- /packages/core/config/identifiersTest.json: -------------------------------------------------------------------------------- 1 | { 2 | "BTCETH": {} 3 | } 4 | -------------------------------------------------------------------------------- /packages/core/contracts/common/implementation/HasFinder.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.9; 2 | 3 | // SPDX-License-Identifier: UNLICENSED 4 | import "../../data-verification-mechanism/interfaces/FinderInterface.sol"; 5 | 6 | // Contract stores a reference to the DVM Finder contract which can be used to locate other important DVM contracts. 7 | contract HasFinder { 8 | FinderInterface public finder; 9 | 10 | constructor(address _finder) { 11 | finder = FinderInterface(_finder); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/core/contracts/common/implementation/Timer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | /** 5 | * @title Universal store of current contract time for testing environments. 6 | */ 7 | contract Timer { 8 | uint256 private currentTime; 9 | 10 | constructor() { 11 | currentTime = block.timestamp; // solhint-disable-line not-rely-on-time 12 | } 13 | 14 | /** 15 | * @notice Sets the current time. 16 | * @dev Will revert if not running in test mode. 17 | * @param time timestamp to set `currentTime` to. 18 | */ 19 | function setCurrentTime(uint256 time) external { 20 | currentTime = time; 21 | } 22 | 23 | /** 24 | * @notice Gets the currentTime variable set in the Timer. 25 | * @return uint256 for the current Testable timestamp. 26 | */ 27 | function getCurrentTime() public view returns (uint256) { 28 | return currentTime; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/core/contracts/common/interfaces/AddressWhitelistInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | interface AddressWhitelistInterface { 5 | function addToWhitelist(address newElement) external; 6 | 7 | function removeFromWhitelist(address newElement) external; 8 | 9 | function isOnWhitelist(address newElement) external view returns (bool); 10 | 11 | function getWhitelist() external view returns (address[] memory); 12 | } 13 | -------------------------------------------------------------------------------- /packages/core/contracts/common/interfaces/Balancer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | /** 5 | * @title Interface for Balancer. 6 | * @dev This only contains the methods/events that we use in our contracts or offchain infrastructure. 7 | */ 8 | abstract contract Balancer { 9 | function getSpotPriceSansFee(address tokenIn, address tokenOut) external view virtual returns (uint256 spotPrice); 10 | } 11 | -------------------------------------------------------------------------------- /packages/core/contracts/common/interfaces/HarvestVaultInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | /** 7 | * @title Interface for Harvest-style vaults. 8 | * @dev This only contains the methods/events that we use in our contracts or offchain infrastructure. 9 | */ 10 | abstract contract HarvestVaultInterface { 11 | // Return the underlying token. 12 | function underlying() external view virtual returns (IERC20); 13 | 14 | // Gets the number of return tokens that a "share" of this vault is worth. 15 | function getPricePerFullShare() external view virtual returns (uint256); 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/contracts/common/interfaces/Multicall.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity >=0.5.0; 3 | 4 | /** 5 | * @title interface for MakerDao's Multicall contract. 6 | * @dev This only contains the methods/events that we use in our contracts or offchain infrastructure. 7 | */ 8 | contract Multicall { 9 | struct Call { 10 | address target; 11 | bytes callData; 12 | } 13 | 14 | function aggregate(Call[] memory calls) public virtual returns (uint256 blockNumber, bytes[] memory returnData) {} 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/contracts/common/interfaces/TransactionBatcher.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | // This is an interface to interact with a deployed implementation by https://github.com/kleros/action-callback-bots for 5 | // batching on-chain transactions. 6 | // See deployed implementation here: https://etherscan.io/address/0x82458d1c812d7c930bb3229c9e159cbabd9aa8cb. 7 | abstract contract TransactionBatcher { 8 | function batchSend( 9 | address[] memory targets, 10 | uint256[] memory values, 11 | bytes[] memory datas 12 | ) public payable virtual; 13 | } 14 | -------------------------------------------------------------------------------- /packages/core/contracts/common/interfaces/UniswapV2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | /** 5 | * @title Interface for Uniswap v2. 6 | * @dev This only contains the methods/events that we use in our contracts or offchain infrastructure. 7 | */ 8 | abstract contract UniswapV2 { 9 | // Called after every swap showing the new uniswap "price" for this token pair. 10 | event Sync(uint112 reserve0, uint112 reserve1); 11 | // Base currency. 12 | address public token0; 13 | // Quote currency. 14 | address public token1; 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/contracts/common/interfaces/UniswapV3.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | /** 5 | * @title Interface for Uniswap v3. 6 | * @dev This only contains the methods/events that we use in our contracts or offchain infrastructure. 7 | */ 8 | abstract contract UniswapV3 { 9 | // Called after every swap showing the new uniswap price for this token pair. 10 | event Swap( 11 | address indexed sender, 12 | address indexed recipient, 13 | int256 amount0, 14 | int256 amount1, 15 | uint160 sqrtPriceX96, 16 | uint128 liquidity, 17 | int24 tick 18 | ); 19 | // Base currency. 20 | address public token0; 21 | // Quote currency. 22 | address public token1; 23 | } 24 | -------------------------------------------------------------------------------- /packages/core/contracts/common/interfaces/VaultInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | /** 7 | * @title Interface for Yearn-style vaults. 8 | * @dev This only contains the methods/events that we use in our contracts or offchain infrastructure. 9 | */ 10 | abstract contract VaultInterface { 11 | // Return the underlying token. 12 | function token() external view virtual returns (IERC20); 13 | 14 | // Gets the number of return tokens that a "share" of this vault is worth. 15 | function getPricePerFullShare() external view virtual returns (uint256); 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/BalancerMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../interfaces/Balancer.sol"; 5 | 6 | /** 7 | * @title Balancer Mock 8 | */ 9 | contract BalancerMock is Balancer { 10 | uint256 price = 0; 11 | 12 | // these params arent used in the mock, but this is to maintain compatibility with balancer API 13 | function getSpotPriceSansFee(address, address) external view virtual override returns (uint256 spotPrice) { 14 | return price; 15 | } 16 | 17 | // this is not a balancer call, but for testing for changing price. 18 | function setPrice(uint256 newPrice) external { 19 | price = newPrice; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/HarvestVaultMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../interfaces/HarvestVaultInterface.sol"; 5 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 6 | 7 | /** 8 | * @title Mock for Harvest-style vaults for use in tests. 9 | */ 10 | contract HarvestVaultMock is HarvestVaultInterface { 11 | IERC20 public override underlying; 12 | uint256 private pricePerFullShare = 0; 13 | 14 | constructor(IERC20 _underlying) { 15 | underlying = _underlying; 16 | } 17 | 18 | function getPricePerFullShare() external view override returns (uint256) { 19 | return pricePerFullShare; 20 | } 21 | 22 | function setPricePerFullShare(uint256 _pricePerFullShare) external { 23 | pricePerFullShare = _pricePerFullShare; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/MintableERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 5 | 6 | // Test ERC721 contract that allows free minting 7 | contract MintableERC721 is ERC721 { 8 | constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {} 9 | 10 | function mint(address to, uint256 tokenId) public { 11 | _safeMint(to, tokenId); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/MultiCallerTest.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | import "../implementation/MultiCaller.sol"; 4 | 5 | contract MultiCallerTest is MultiCaller { 6 | uint256 public value; 7 | 8 | function call(bool shouldFail) public pure { 9 | require(shouldFail, "shouldFail set to true"); 10 | } 11 | 12 | function add(uint256 amount) public { 13 | value += amount; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/MulticallMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.0; 2 | 3 | /// @title Multicall - Aggregate results from multiple read-only function calls 4 | /// @author Michael Elliot 5 | /// @author Joshua Levine 6 | /// @author Nick Johnson 7 | 8 | contract MulticallMock { 9 | struct Call { 10 | address target; 11 | bytes callData; 12 | } 13 | 14 | function aggregate(Call[] memory calls) public returns (uint256 blockNumber, bytes[] memory returnData) { 15 | blockNumber = block.number; 16 | returnData = new bytes[](calls.length); 17 | for (uint256 i = 0; i < calls.length; i++) { 18 | (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData); 19 | require(success); 20 | returnData[i] = ret; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/ReentrancyAttack.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | // Tests reentrancy guards defined in Lockable.sol. 5 | // Copied from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.0.1/contracts/mocks/ReentrancyAttack.sol. 6 | contract ReentrancyAttack { 7 | function callSender(bytes4 data) public { 8 | // solhint-disable-next-line avoid-low-level-calls 9 | (bool success, ) = msg.sender.call(abi.encodeWithSelector(data)); 10 | require(success, "ReentrancyAttack: failed call"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/TestableTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../implementation/Testable.sol"; 5 | 6 | // TestableTest is derived from the abstract contract Testable for testing purposes. 7 | contract TestableTest is Testable { 8 | // solhint-disable-next-line no-empty-blocks 9 | constructor(address _timerAddress) Testable(_timerAddress) {} 10 | 11 | function getTestableTimeAndBlockTime() external view returns (uint256 testableTime, uint256 blockTime) { 12 | // solhint-disable-next-line not-rely-on-time 13 | return (getCurrentTime(), block.timestamp); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/UniswapV2Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../interfaces/UniswapV2.sol"; 5 | 6 | /** 7 | * @title Uniswap v2 Mock that allows manual price injection. 8 | */ 9 | contract UniswapV2Mock is UniswapV2 { 10 | function setTokens(address _token0, address _token1) external { 11 | token0 = _token0; 12 | token1 = _token1; 13 | } 14 | 15 | function setPrice(uint112 reserve0, uint112 reserve1) external { 16 | emit Sync(reserve0, reserve1); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/UniswapV3Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../interfaces/UniswapV3.sol"; 5 | 6 | /** 7 | * @title Uniswap v3 Mock that allows manual price injection. 8 | */ 9 | contract UniswapV3Mock is UniswapV3 { 10 | function setTokens(address _token0, address _token1) external { 11 | token0 = _token0; 12 | token1 = _token1; 13 | } 14 | 15 | function setPrice( 16 | address sender, 17 | address recipient, 18 | int256 amount0, 19 | int256 amount1, 20 | uint160 sqrtPriceX96, 21 | uint128 liquidity, 22 | int24 tick 23 | ) external { 24 | emit Swap(sender, recipient, amount0, amount1, sqrtPriceX96, liquidity, tick); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/VaultMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../interfaces/VaultInterface.sol"; 5 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 6 | 7 | /** 8 | * @title Mock for yearn-style vaults for use in tests. 9 | */ 10 | contract VaultMock is VaultInterface { 11 | IERC20 public override token; 12 | uint256 private pricePerFullShare = 0; 13 | 14 | constructor(IERC20 _token) { 15 | token = _token; 16 | } 17 | 18 | function getPricePerFullShare() external view override returns (uint256) { 19 | return pricePerFullShare; 20 | } 21 | 22 | function setPricePerFullShare(uint256 _pricePerFullShare) external { 23 | pricePerFullShare = _pricePerFullShare; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/core/contracts/common/test/WithdrawableTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../implementation/Withdrawable.sol"; 5 | 6 | // WithdrawableTest is derived from the abstract contract Withdrawable for testing purposes. 7 | contract WithdrawableTest is Withdrawable { 8 | enum Roles { Governance, Withdraw } 9 | 10 | // solhint-disable-next-line no-empty-blocks 11 | constructor() { 12 | _createExclusiveRole(uint256(Roles.Governance), uint256(Roles.Governance), msg.sender); 13 | _createWithdrawRole(uint256(Roles.Withdraw), uint256(Roles.Governance), msg.sender); 14 | } 15 | 16 | function pay() external payable { 17 | require(msg.value > 0); 18 | } 19 | 20 | function setInternalWithdrawRole(uint256 setRoleId) public { 21 | _setWithdrawRole(setRoleId); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/core/contracts/cross-chain-oracle/chain-adapters/test/OVM_L1CrossDomainMessengerMock.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | import "@eth-optimism/contracts/libraries/bridge/ICrossDomainMessenger.sol"; 3 | 4 | contract OVM_L1CrossDomainMessengerMock is ICrossDomainMessenger { 5 | function xDomainMessageSender() external view override returns (address) { 6 | // Trivial return this contract's address. 7 | return address(this); 8 | } 9 | 10 | function sendMessage( 11 | address _target, 12 | bytes calldata _message, 13 | uint32 _gasLimit 14 | ) external override {} 15 | // Do nothing. 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/contracts/cross-chain-oracle/chain-adapters/test/ParentMessengerBaseMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../ParentMessengerBase.sol"; 5 | 6 | contract ParentMessengerBaseMock is ParentMessengerBase { 7 | constructor(uint256 _childChainId) ParentMessengerBase(_childChainId) {} 8 | 9 | function sendMessageToChild(bytes memory) public view override { 10 | require(false, "unused function"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/core/contracts/cross-chain-oracle/chain-adapters/test/Polygon_ChildMessengerMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../Polygon_ChildMessenger.sol"; 5 | 6 | contract Polygon_ChildMessengerMock is Polygon_ChildMessenger { 7 | constructor(address _fxChild, address _finder) Polygon_ChildMessenger(_fxChild, _finder) {} 8 | 9 | function processMessageFromRoot(address sender, bytes memory data) external { 10 | _processMessageFromRoot( 11 | 1, // Unused param set to arbitrary value. 12 | sender, 13 | data 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/contracts/cross-chain-oracle/chain-adapters/test/Polygon_ParentMessengerMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../Polygon_ParentMessenger.sol"; 5 | 6 | contract Polygon_ParentMessengerMock is Polygon_ParentMessenger { 7 | constructor( 8 | address _checkpointManager, 9 | address _fxRoot, 10 | uint256 _childChainId 11 | ) Polygon_ParentMessenger(_checkpointManager, _fxRoot, _childChainId) {} 12 | 13 | function processMessageFromChild(bytes memory data) external { 14 | _processMessageFromChild(data); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/contracts/cross-chain-oracle/interfaces/ChildMessengerConsumerInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | interface ChildMessengerConsumerInterface { 5 | // Called on L2 by child messenger. 6 | function processMessageFromParent(bytes memory data) external; 7 | } 8 | -------------------------------------------------------------------------------- /packages/core/contracts/cross-chain-oracle/interfaces/ChildMessengerInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | interface ChildMessengerInterface { 5 | // Should send cross-chain message to Parent messenger contract or revert. 6 | function sendMessageToParent(bytes memory data) external; 7 | } 8 | -------------------------------------------------------------------------------- /packages/core/contracts/cross-chain-oracle/interfaces/ParentMessengerConsumerInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | interface ParentMessengerConsumerInterface { 5 | // Function called on Oracle hub to pass in data send from L2, with chain ID. 6 | function processMessageFromChild(uint256 chainId, bytes memory data) external; 7 | } 8 | -------------------------------------------------------------------------------- /packages/core/contracts/cross-chain-oracle/interfaces/ParentMessengerInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | interface ParentMessengerInterface { 5 | // Should send cross-chain message to Child messenger contract or revert. 6 | function sendMessageToChild(bytes memory data) external; 7 | 8 | // Informs Hub how much msg.value they need to include to call `sendMessageToChild`. 9 | function getL1CallValue() external view returns (uint256); 10 | } 11 | -------------------------------------------------------------------------------- /packages/core/contracts/data-verification-mechanism/implementation/test/EmergencyProposerTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity 0.8.16; 3 | 4 | import "../EmergencyProposer.sol"; 5 | import "../../../common/implementation/Testable.sol"; 6 | 7 | contract EmergencyProposerTest is EmergencyProposer, Testable { 8 | constructor( 9 | IERC20 _token, 10 | uint256 _quorum, 11 | GovernorV2 _governor, 12 | address _executor, 13 | address _timerAddress, 14 | uint64 _minimumWaitTime 15 | ) EmergencyProposer(_token, _quorum, _governor, _executor, _minimumWaitTime) Testable(_timerAddress) {} 16 | 17 | function getCurrentTime() public view override(EmergencyProposer, Testable) returns (uint256) { 18 | return Testable.getCurrentTime(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/core/contracts/data-verification-mechanism/implementation/test/GovernorV2Test.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../GovernorV2.sol"; 5 | import "../../../common/implementation/Testable.sol"; 6 | 7 | contract GovernorV2Test is GovernorV2, Testable { 8 | constructor( 9 | address _finderAddress, 10 | uint256 _startingId, 11 | address _timerAddress 12 | ) GovernorV2(_finderAddress, _startingId) Testable(_timerAddress) {} 13 | 14 | function getCurrentTime() public view override(GovernorV2, Testable) returns (uint256) { 15 | return Testable.getCurrentTime(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/core/contracts/data-verification-mechanism/implementation/test/MockAdministratee.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../../interfaces/AdministrateeInterface.sol"; 5 | 6 | // A mock implementation of AdministrateeInterface, taking the place of a financial contract. 7 | contract MockAdministratee is AdministrateeInterface { 8 | uint256 public timesRemargined; 9 | uint256 public timesEmergencyShutdown; 10 | 11 | function remargin() external override { 12 | timesRemargined++; 13 | } 14 | 15 | function emergencyShutdown() external override { 16 | timesEmergencyShutdown++; 17 | } 18 | 19 | function pfc() external pure override returns (FixedPoint.Unsigned memory) { 20 | return FixedPoint.fromUnscaledUint(0); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/core/contracts/data-verification-mechanism/implementation/test/ProposerV2Test.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../ProposerV2.sol"; 5 | import "../AdminIdentifierLib.sol"; 6 | import "../../../common/implementation/Testable.sol"; 7 | 8 | contract ProposerV2Test is ProposerV2, Testable { 9 | constructor( 10 | IERC20 _token, 11 | uint256 _bond, 12 | GovernorV2 _governor, 13 | Finder _finder, 14 | address _timerAddress 15 | ) ProposerV2(_token, _bond, _governor, _finder) Testable(_timerAddress) {} 16 | 17 | function getCurrentTime() public view override(ProposerV2, Testable) returns (uint256) { 18 | return Testable.getCurrentTime(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/core/contracts/data-verification-mechanism/interfaces/MinimumVotingAncillaryInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity 0.8.16; 3 | 4 | interface MinimumVotingAncillaryInterface { 5 | struct Unsigned { 6 | uint256 rawValue; 7 | } 8 | 9 | struct PendingRequestAncillary { 10 | bytes32 identifier; 11 | uint256 time; 12 | bytes ancillaryData; 13 | } 14 | 15 | function retrieveRewards( 16 | address voterAddress, 17 | uint256 roundId, 18 | PendingRequestAncillary[] memory toRetrieve 19 | ) external returns (Unsigned memory); 20 | } 21 | -------------------------------------------------------------------------------- /packages/core/contracts/external/README.md: -------------------------------------------------------------------------------- 1 | # External contracts 2 | 3 | All contracts in this folder were originally copied from an external source and any changes are documented in the `CHANGELOG.md` for each respective sub folder. 4 | -------------------------------------------------------------------------------- /packages/core/contracts/external/boba/BobaAddressManager.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.9; 3 | 4 | abstract contract BobaAddressManager { 5 | /** 6 | * Retrieves the address associated with a given name. 7 | * @param _name Name to retrieve an address for. 8 | * @return Address associated with the given name. 9 | */ 10 | function getAddress(string memory _name) external view virtual returns (address); 11 | } 12 | -------------------------------------------------------------------------------- /packages/core/contracts/external/chainbridge/interfaces/IBridge.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | /** 5 | @title Interface for Bridge contract. 6 | @author ChainSafe Systems. 7 | */ 8 | interface IBridge { 9 | /** 10 | @notice Exposing getter for {_chainID} instead of forcing the use of call. 11 | @return uint8 The {_chainID} that is currently set for the Bridge contract. 12 | */ 13 | function _chainID() external returns (uint8); 14 | 15 | function deposit( 16 | uint8 destinationChainID, 17 | bytes32 resourceID, 18 | bytes calldata data 19 | ) external; 20 | } 21 | -------------------------------------------------------------------------------- /packages/core/contracts/external/optimism-bridge/interfaces/OptimismL2StandardBridge.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | /** 5 | * @title L2StandardBridge 6 | * @dev The L2 Standard bridge is a contract which works together with the L1 Standard bridge to 7 | * enable ETH and ERC20 transitions between L1 and L2. 8 | * This contract acts as a minter for new tokens when it hears about deposits into the L1 Standard 9 | * bridge. 10 | * This contract also acts as a burner of the tokens intended for withdrawal, informing the L1 11 | * bridge to release L1 funds. 12 | */ 13 | contract OptimismL2StandardBridge { 14 | /******************************** 15 | * External Contract References * 16 | ********************************/ 17 | 18 | address public l1TokenBridge; 19 | } 20 | -------------------------------------------------------------------------------- /packages/core/contracts/external/optimism-bridge/interfaces/OptimismL2StandardERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | 6 | abstract contract OptimismL2StandardERC20 is ERC20 { 7 | address public l1Token; 8 | address public l2Bridge; 9 | } 10 | -------------------------------------------------------------------------------- /packages/core/contracts/financial-templates/common/financial-product-libraries/long-short-pair-libraries/LongShortPairFinancialProductLibrary.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | import "../../../../common/implementation/FixedPoint.sol"; 4 | import "@openzeppelin/contracts/utils/math/SafeMath.sol"; 5 | 6 | interface ExpiringContractInterface { 7 | function expirationTimestamp() external view returns (uint256); 8 | } 9 | 10 | abstract contract LongShortPairFinancialProductLibrary { 11 | function percentageLongCollateralAtExpiry(int256 expiryPrice) public view virtual returns (uint256); 12 | } 13 | -------------------------------------------------------------------------------- /packages/core/contracts/financial-templates/expiring-multiparty/ExpiringMultiParty.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "./Liquidatable.sol"; 5 | 6 | /** 7 | * @title Expiring Multi Party. 8 | * @notice Convenient wrapper for Liquidatable. 9 | */ 10 | contract ExpiringMultiParty is Liquidatable { 11 | /** 12 | * @notice Constructs the ExpiringMultiParty contract. 13 | * @param params struct to define input parameters for construction of Liquidatable. Some params 14 | * are fed directly into the PricelessPositionManager's constructor within the inheritance tree. 15 | */ 16 | constructor(ConstructorParams memory params) 17 | Liquidatable(params) 18 | // Note: since there is no logic here, there is no need to add a re-entrancy guard. 19 | { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/core/contracts/financial-templates/perpetual-multiparty/Perpetual.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "./PerpetualLiquidatable.sol"; 5 | 6 | /** 7 | * @title Perpetual Multiparty Contract. 8 | * @notice Convenient wrapper for Liquidatable. 9 | */ 10 | contract Perpetual is PerpetualLiquidatable { 11 | /** 12 | * @notice Constructs the Perpetual contract. 13 | * @param params struct to define input parameters for construction of Liquidatable. Some params 14 | * are fed directly into the PositionManager's constructor within the inheritance tree. 15 | */ 16 | constructor(ConstructorParams memory params) 17 | PerpetualLiquidatable(params) 18 | // Note: since there is no logic here, there is no need to add a re-entrancy guard. 19 | { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/core/contracts/financial-templates/test/LongShortPairFinancialProjectLibraryTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | import "../common/financial-product-libraries/long-short-pair-libraries/LongShortPairFinancialProductLibrary.sol"; 4 | 5 | // Implements a simple FinancialProductLibrary to test price and collateral requirement transoformations. 6 | contract LongShortPairFinancialProjectLibraryTest is LongShortPairFinancialProductLibrary { 7 | using FixedPoint for FixedPoint.Unsigned; 8 | 9 | uint256 public valueToReturn; 10 | 11 | function setValueToReturn(uint256 value) public { 12 | valueToReturn = value; 13 | } 14 | 15 | function percentageLongCollateralAtExpiry( 16 | int256 /*expiryPrice*/ 17 | ) public view override returns (uint256) { 18 | return valueToReturn; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/core/contracts/financial-templates/test/LongShortPairMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | contract LongShortPairMock { 5 | uint256 public expirationTimestamp; 6 | uint256 public collateralPerPair; 7 | 8 | constructor(uint256 _expirationTimestamp, uint256 _collateralPerPair) { 9 | expirationTimestamp = _expirationTimestamp; 10 | collateralPerPair = _collateralPerPair; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/core/contracts/optimistic-governor/test/TestModuleProxyFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.6; 3 | 4 | import "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol"; 5 | 6 | contract TestModuleProxyFactory is ModuleProxyFactory {} 7 | -------------------------------------------------------------------------------- /packages/core/contracts/optimistic-oracle-v3/implementation/ClaimData.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity 0.8.16; 3 | 4 | import { AncillaryData as ClaimData } from "../../common/implementation/AncillaryData.sol"; 5 | -------------------------------------------------------------------------------- /packages/core/contracts/optimistic-oracle-v3/implementation/test/OptimisticOracleV3Test.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity 0.8.16; 3 | 4 | import "../OptimisticOracleV3.sol"; 5 | import "../../../common/implementation/Testable.sol"; 6 | 7 | // Test contract used to manage the time for the contract in tests. 8 | contract OptimisticOracleV3Test is OptimisticOracleV3, Testable { 9 | constructor( 10 | FinderInterface _finder, 11 | IERC20 _defaultCurrency, 12 | uint64 _defaultLiveness, 13 | address _timerAddress 14 | ) OptimisticOracleV3(_finder, _defaultCurrency, _defaultLiveness) Testable(_timerAddress) {} 15 | 16 | function getCurrentTime() public view override(OptimisticOracleV3, Testable) returns (uint256) { 17 | return uint256(Testable.getCurrentTime()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/core/contracts/proxy-scripts/bot-action-wrappers/LiquidationWithdrawer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../../common/implementation/FixedPoint.sol"; 5 | 6 | // Simple contract used to withdraw liquidations using a DSProxy from legacy contracts (1.2.2 and below). 7 | contract LiquidationWithdrawer { 8 | function withdrawLiquidation( 9 | address financialContractAddress, 10 | uint256 liquidationId, 11 | address sponsor 12 | ) public returns (FixedPoint.Unsigned memory) { 13 | return IFinancialContract(financialContractAddress).withdrawLiquidation(liquidationId, sponsor); 14 | } 15 | } 16 | 17 | interface IFinancialContract { 18 | function withdrawLiquidation(uint256 liquidationId, address sponsor) 19 | external 20 | returns (FixedPoint.Unsigned memory amountWithdrawn); 21 | } 22 | -------------------------------------------------------------------------------- /packages/core/contracts/proxy-scripts/bot-action-wrappers/PositionSettler.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../../common/implementation/FixedPoint.sol"; 5 | 6 | // Simple contract used to Settle expired positions using a DSProxy. 7 | contract PositionSettler { 8 | function settleExpired(address financialContractAddress) public returns (FixedPoint.Unsigned memory) { 9 | return IFinancialContract(financialContractAddress).settleExpired(); 10 | } 11 | } 12 | 13 | interface IFinancialContract { 14 | function settleExpired() external returns (FixedPoint.Unsigned memory amountWithdrawn); 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/contracts/proxy-scripts/bot-action-wrappers/TokenSender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "../../common/implementation/ExpandedERC20.sol"; 5 | 6 | contract TokenSender { 7 | function transferERC20( 8 | address tokenAddress, 9 | address recipientAddress, 10 | uint256 amount 11 | ) public returns (bool) { 12 | IERC20 token = IERC20(tokenAddress); 13 | token.transfer(recipientAddress, amount); 14 | return true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/contracts/umip-helpers/OriginValidator.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity 0.8.16; 3 | 4 | /** 5 | * @title An auxiliary contract that checks if the tx origin is the upgrader. 6 | * @dev Note: the validate function can be used as the first transaction in a governance proposals to block any other 7 | * transactions from being executed if the proposal is not initiated by the upgrader. 8 | */ 9 | contract OriginValidator { 10 | /** 11 | * @notice Checks if the caller is the upgrader. 12 | * @dev This is used as the first transaction in the upgrade process to block any other transactions from being 13 | * executed if the upgrade is not initiated by the upgrader. 14 | */ 15 | function validate(address upgrader) public view { 16 | require(tx.origin == upgrader); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/core/deploy/001_deploy_finder.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("Finder", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 8 | }; 9 | module.exports = func; 10 | func.tags = ["Finder", "dvm"]; 11 | -------------------------------------------------------------------------------- /packages/core/deploy/002_deploy_timer.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts, network } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | const { live } = network; 7 | 8 | if (live === undefined) throw new Error("Network has no live parameter"); 9 | 10 | // If live === false, don't deploy a timer. 11 | if (live === false) { 12 | await deploy("Timer", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 13 | } 14 | }; 15 | module.exports = func; 16 | func.tags = ["Timer"]; 17 | -------------------------------------------------------------------------------- /packages/core/deploy/003_deploy_registry.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("Registry", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 8 | }; 9 | module.exports = func; 10 | func.tags = ["Registry", "dvm", "dvmv2"]; 11 | -------------------------------------------------------------------------------- /packages/core/deploy/004_deploy_voting_token.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("VotingToken", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 8 | }; 9 | module.exports = func; 10 | func.tags = ["dvm", "VotingToken"]; 11 | -------------------------------------------------------------------------------- /packages/core/deploy/005_deploy_identifier_whitelist.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("IdentifierWhitelist", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 8 | }; 9 | module.exports = func; 10 | func.tags = ["IdentifierWhitelist", "dvm", "dvmv2"]; 11 | -------------------------------------------------------------------------------- /packages/core/deploy/007_deploy_financial_contracts_admin.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("FinancialContractsAdmin", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 8 | }; 9 | module.exports = func; 10 | func.tags = ["FinancialContractsAdmin", "dvm"]; 11 | -------------------------------------------------------------------------------- /packages/core/deploy/008_deploy_store.js: -------------------------------------------------------------------------------- 1 | const { ZERO_ADDRESS } = require("@uma/common"); 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | const Timer = (await deployments.getOrNull("Timer")) || { address: ZERO_ADDRESS }; 8 | 9 | // Initialize both fees to 0. 10 | const initialFixedOracleFeePerSecondPerPfc = { rawValue: "0" }; 11 | const initialWeeklyDelayFeePerSecondPerPfc = { rawValue: "0" }; 12 | 13 | await deploy("Store", { 14 | from: deployer, 15 | args: [initialFixedOracleFeePerSecondPerPfc, initialWeeklyDelayFeePerSecondPerPfc, Timer.address], 16 | log: true, 17 | skipIfAlreadyDeployed: true, 18 | }); 19 | }; 20 | module.exports = func; 21 | func.tags = ["Store", "dvm", "dvmv2"]; 22 | func.dependencies = ["Timer"]; 23 | -------------------------------------------------------------------------------- /packages/core/deploy/009_deploy_governor.js: -------------------------------------------------------------------------------- 1 | const { ZERO_ADDRESS } = require("@uma/common"); 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | const Timer = (await deployments.getOrNull("Timer")) || { address: ZERO_ADDRESS }; 8 | const Finder = await deployments.get("Finder"); 9 | 10 | const startingProposalId = 0; 11 | 12 | await deploy("Governor", { 13 | from: deployer, 14 | args: [Finder.address, startingProposalId, Timer.address], 15 | log: true, 16 | skipIfAlreadyDeployed: true, 17 | }); 18 | }; 19 | module.exports = func; 20 | func.tags = ["Governor", "dvm"]; 21 | func.dependencies = ["Finder", "Timer"]; 22 | -------------------------------------------------------------------------------- /packages/core/deploy/010_deploy_designated_voting_factory.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | const Finder = await deployments.get("Finder"); 7 | 8 | await deploy("DesignatedVotingFactory", { 9 | from: deployer, 10 | args: [Finder.address], 11 | log: true, 12 | skipIfAlreadyDeployed: true, 13 | }); 14 | }; 15 | module.exports = func; 16 | func.tags = ["DesignatedVotingFactory", "dvm"]; 17 | func.dependencies = ["Finder"]; 18 | -------------------------------------------------------------------------------- /packages/core/deploy/011_deploy_address_whitelist.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("AddressWhitelist", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 8 | }; 9 | module.exports = func; 10 | func.tags = ["AddressWhitelist", "dvm", "dvmv2"]; 11 | -------------------------------------------------------------------------------- /packages/core/deploy/012_deploy_optimistic_oracle.js: -------------------------------------------------------------------------------- 1 | const { ZERO_ADDRESS } = require("@uma/common"); 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | 8 | // 2 hours. 9 | const defaultLiveness = 7200; 10 | const Finder = await deployments.get("Finder"); 11 | const Timer = (await deployments.getOrNull("Timer")) || { address: ZERO_ADDRESS }; 12 | 13 | await deploy("OptimisticOracle", { 14 | from: deployer, 15 | args: [defaultLiveness, Finder.address, Timer.address], 16 | log: true, 17 | skipIfAlreadyDeployed: true, 18 | }); 19 | }; 20 | module.exports = func; 21 | func.tags = ["OptimisticOracle", "dvm", "dvmv2"]; 22 | func.dependencies = ["Finder"]; 23 | -------------------------------------------------------------------------------- /packages/core/deploy/013_deploy_mock_oracle.js: -------------------------------------------------------------------------------- 1 | const { ZERO_ADDRESS } = require("@uma/common"); 2 | 3 | const func = async function (hre) { 4 | const { deployments, getNamedAccounts } = hre; 5 | const { deploy } = deployments; 6 | 7 | const { deployer } = await getNamedAccounts(); 8 | 9 | const Finder = await deployments.get("Finder"); 10 | const Timer = (await deployments.getOrNull("Timer")) || { address: ZERO_ADDRESS }; 11 | 12 | const args = [Finder.address, Timer.address]; 13 | await deploy("MockOracleAncillary", { from: deployer, args, log: true, skipIfAlreadyDeployed: true }); 14 | }; 15 | module.exports = func; 16 | func.tags = ["MockOracle", "test"]; 17 | module.exports.dependencies = ["Finder", "Timer"]; 18 | -------------------------------------------------------------------------------- /packages/core/deploy/014_deploy_token_factory.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("TokenFactory", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 8 | }; 9 | module.exports = func; 10 | func.tags = ["TokenFactory", "emp"]; 11 | -------------------------------------------------------------------------------- /packages/core/deploy/017_deploy_bridge.js: -------------------------------------------------------------------------------- 1 | const { getBridgeChainId } = require("@uma/common"); 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts, getChainId } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | 8 | const chainId = await getChainId(); 9 | const bridgeId = getBridgeChainId(chainId); 10 | 11 | const args = [ 12 | bridgeId, // Current chain ID. 13 | [deployer], // Initial relayers defaults to deployer as 1 of 1 14 | 1, // Relayer threshold set to 1 15 | 0, // Deposit fee 16 | 100, // # of blocks after which a proposal expires 17 | ]; 18 | await deploy("Bridge", { from: deployer, args, log: true, skipIfAlreadyDeployed: true }); 19 | }; 20 | module.exports = func; 21 | func.tags = ["Bridge", "bridge-l2", "bridge-l1"]; 22 | -------------------------------------------------------------------------------- /packages/core/deploy/018_deploy_generic_handler.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | const Bridge = await deployments.get("Bridge"); 8 | 9 | const args = [Bridge.address, [], [], [], []]; 10 | await deploy("GenericHandler", { from: deployer, args, log: true, skipIfAlreadyDeployed: true }); 11 | }; 12 | module.exports = func; 13 | func.tags = ["GenericHandler", "bridge-l2", "bridge-l1"]; 14 | func.dependencies = ["Bridge"]; 15 | -------------------------------------------------------------------------------- /packages/core/deploy/020_deploy_source_oracle.js: -------------------------------------------------------------------------------- 1 | const { getBridgeChainId } = require("@uma/common"); 2 | 3 | const func = async function (hre) { 4 | const { deployments, getNamedAccounts, getChainId } = hre; 5 | const { deploy } = deployments; 6 | 7 | const { deployer } = await getNamedAccounts(); 8 | 9 | const chainId = await getChainId(); 10 | const bridgeId = getBridgeChainId(chainId); 11 | const Finder = await deployments.get("Finder"); 12 | 13 | const args = [ 14 | Finder.address, 15 | bridgeId, // Current chain ID. 16 | ]; 17 | await deploy("SourceOracle", { from: deployer, args, log: true, skipIfAlreadyDeployed: true }); 18 | }; 19 | module.exports = func; 20 | func.tags = ["SourceOracle", "l1-chainbridge"]; 21 | func.dependencies = ["Finder"]; 22 | -------------------------------------------------------------------------------- /packages/core/deploy/021_deploy_sink_governor.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | const Finder = await deployments.get("Finder"); 8 | 9 | await deploy("SinkGovernor", { from: deployer, args: [Finder.address], log: true, skipIfAlreadyDeployed: true }); 10 | }; 11 | module.exports = func; 12 | func.tags = ["SinkGovernor", "l2-chainbridge"]; 13 | func.dependencies = ["Finder", "Registry"]; 14 | -------------------------------------------------------------------------------- /packages/core/deploy/022_deploy_source_governor.js: -------------------------------------------------------------------------------- 1 | const { getBridgeChainId } = require("@uma/common"); 2 | 3 | const func = async function (hre) { 4 | const { deployments, getNamedAccounts, getChainId } = hre; 5 | const { deploy } = deployments; 6 | 7 | const { deployer } = await getNamedAccounts(); 8 | 9 | const chainId = await getChainId(); 10 | const bridgeId = getBridgeChainId(chainId); 11 | 12 | const Finder = await deployments.get("Finder"); 13 | 14 | await deploy("SourceGovernor", { 15 | from: deployer, 16 | args: [Finder.address, bridgeId], 17 | log: true, 18 | skipIfAlreadyDeployed: true, 19 | }); 20 | }; 21 | module.exports = func; 22 | func.tags = ["SourceGovernor", "l1-chainbridge"]; 23 | func.dependencies = ["Finder"]; 24 | -------------------------------------------------------------------------------- /packages/core/deploy/023_deploy_state_sync_mock.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { getNamedAccounts, deployments } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | await deploy("StateSyncMock", { from: deployer, args: [], log: true, skipIfAlreadyDeployed: true }); 7 | }; 8 | module.exports = func; 9 | func.tags = ["StateSyncMock", "test"]; 10 | module.exports.dependencies = []; 11 | -------------------------------------------------------------------------------- /packages/core/deploy/024_deploy_fx_root_mock.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { getNamedAccounts, deployments } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | const StateSyncMock = await deployments.get("StateSyncMock"); 8 | 9 | await deploy("FxRootMock", { from: deployer, args: [StateSyncMock.address], log: true, skipIfAlreadyDeployed: true }); 10 | }; 11 | module.exports = func; 12 | func.tags = ["FxRootMock", "test"]; 13 | module.exports.dependencies = ["StateSyncMock"]; 14 | -------------------------------------------------------------------------------- /packages/core/deploy/025_deploy_fx_child_mock.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { getNamedAccounts, deployments } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("FxChildMock", { 8 | from: deployer, 9 | args: [deployer], // Set deployer as the systemSuperUser. 10 | log: true, 11 | skipIfAlreadyDeployed: true, 12 | }); 13 | }; 14 | module.exports = func; 15 | func.tags = ["FxChildMock", "test"]; 16 | module.exports.dependencies = []; 17 | -------------------------------------------------------------------------------- /packages/core/deploy/030_deploy_long_short_pair_creator.js: -------------------------------------------------------------------------------- 1 | const { ZERO_ADDRESS } = require("@uma/common"); 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | 8 | const Finder = await deployments.get("Finder"); 9 | const TokenFactory = await deployments.get("TokenFactory"); 10 | const Timer = (await deployments.getOrNull("Timer")) || { address: ZERO_ADDRESS }; 11 | 12 | await deploy("LongShortPairCreator", { 13 | from: deployer, 14 | args: [Finder.address, TokenFactory.address, Timer.address], 15 | log: true, 16 | skipIfAlreadyDeployed: true, 17 | }); 18 | }; 19 | module.exports = func; 20 | func.tags = ["LongShortPairCreator", "lsp"]; 21 | func.dependencies = ["Finder", "TokenFactory", "Timer"]; 22 | -------------------------------------------------------------------------------- /packages/core/deploy/031_deploy_long_short_pair_libraries_covered_call.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("CoveredCallLongShortPairFinancialProductLibrary", { 8 | from: deployer, 9 | log: true, 10 | skipIfAlreadyDeployed: true, 11 | }); 12 | }; 13 | module.exports = func; 14 | func.tags = ["LongShortPairLibraries", "lsplib", "CoveredCallLongShortPairLibrary"]; 15 | -------------------------------------------------------------------------------- /packages/core/deploy/032_deploy_long_short_pair_libraries_range_bond.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("RangeBondLongShortPairFinancialProductLibrary", { 8 | from: deployer, 9 | log: true, 10 | skipIfAlreadyDeployed: true, 11 | }); 12 | }; 13 | module.exports = func; 14 | func.tags = ["LongShortPairLibraries", "lsplib", "RangeBondLongShortPairLibrary"]; 15 | -------------------------------------------------------------------------------- /packages/core/deploy/033_deploy_long_short_pair_library_binary.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("BinaryOptionLongShortPairFinancialProductLibrary", { 8 | from: deployer, 9 | log: true, 10 | skipIfAlreadyDeployed: true, 11 | }); 12 | }; 13 | module.exports = func; 14 | func.tags = ["LongShortPairLibraries", "lsplib", "BinaryLongShortPairLibrary"]; 15 | -------------------------------------------------------------------------------- /packages/core/deploy/034_deploy_long_short_pair_library_linear.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("LinearLongShortPairFinancialProductLibrary", { 8 | from: deployer, 9 | log: true, 10 | skipIfAlreadyDeployed: true, 11 | }); 12 | }; 13 | module.exports = func; 14 | func.tags = ["LongShortPairLibraries", "lsplib", "LinearLongShortPairLibrary"]; 15 | -------------------------------------------------------------------------------- /packages/core/deploy/035_deploy_skinny_optimistic_oracle.js: -------------------------------------------------------------------------------- 1 | const { ZERO_ADDRESS } = require("@uma/common"); 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | 8 | // 2 hours. 9 | const defaultLiveness = 7200; 10 | const Finder = await deployments.get("Finder"); 11 | const Timer = (await deployments.getOrNull("Timer")) || { address: ZERO_ADDRESS }; 12 | 13 | await deploy("SkinnyOptimisticOracle", { 14 | from: deployer, 15 | args: [defaultLiveness, Finder.address, Timer.address], 16 | log: true, 17 | skipIfAlreadyDeployed: true, 18 | }); 19 | }; 20 | module.exports = func; 21 | func.tags = ["SkinnyOptimisticOracle", "dvm", "dvmv2"]; 22 | func.dependencies = ["Finder", "Timer"]; 23 | -------------------------------------------------------------------------------- /packages/core/deploy/036_deploy_arbitrum_parent_messenger.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("Arbitrum_ParentMessenger", { 8 | from: deployer, 9 | args: [ 10 | "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f", // Arbitrum system "inbox" contract 11 | 42161, // Child network ID 12 | ], 13 | log: true, 14 | skipIfAlreadyDeployed: true, 15 | }); 16 | }; 17 | module.exports = func; 18 | func.tags = ["ArbitrumParentMessenger", "l1-arbitrum-xchain"]; 19 | -------------------------------------------------------------------------------- /packages/core/deploy/038_deploy_oracle_spoke.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy, get } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | const finder = await get("Finder"); 8 | console.log(`Using finder @ ${finder.address}`); 9 | 10 | await deploy("OracleSpoke", { from: deployer, args: [finder.address], log: true, skipIfAlreadyDeployed: true }); 11 | }; 12 | module.exports = func; 13 | func.tags = [ 14 | "OracleSpoke", 15 | "l2-arbitrum-xchain", 16 | "l2-boba-xchain", 17 | "l2-optimism-xchain", 18 | "l2-admin-xchain", 19 | "l2-base-xchain", 20 | "l2-blast-xchain", 21 | ]; 22 | func.dependencies = ["Finder"]; 23 | -------------------------------------------------------------------------------- /packages/core/deploy/040_deploy_governor_spoke.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | const finder = await deployments.get("Finder"); 8 | console.log(`Using finder @ ${finder.address}`); 9 | 10 | await deploy("GovernorSpoke", { from: deployer, args: [finder.address], log: true, skipIfAlreadyDeployed: true }); 11 | }; 12 | module.exports = func; 13 | func.tags = [ 14 | "GovernorSpoke", 15 | "l2-arbitrum-xchain", 16 | "l2-boba-xchain", 17 | "l2-optimism-xchain", 18 | "l2-admin-xchain", 19 | "l2-base-xchain", 20 | "l2-blast-xchain", 21 | ]; 22 | func.dependencies = ["Finder"]; 23 | -------------------------------------------------------------------------------- /packages/core/deploy/041_deploy_governor_hub.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("GovernorHub", { from: deployer, args: [], log: true, skipIfAlreadyDeployed: true }); 8 | }; 9 | module.exports = func; 10 | func.tags = [ 11 | "GovernorHub", 12 | "l1-arbitrum-xchain", 13 | "l1-boba-xchain", 14 | "l1-optimism-xchain", 15 | "l1-base-xchain", 16 | "l1-blast-xchain", 17 | ]; 18 | -------------------------------------------------------------------------------- /packages/core/deploy/042_deploy_boba_parent_messenger.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | // Note: Boba is a fork of Optimism, so we can deploy the same messenger contracts on Boba as we would on Optimism. 8 | await deploy("Boba_ParentMessenger", { 9 | contract: "Optimism_ParentMessenger", 10 | from: deployer, 11 | args: [ 12 | "0x6d4528d192db72e282265d6092f4b872f9dff69e", // Boba's OVM L1 Cross Domain Messenger 13 | 288, // Child network ID 14 | ], 15 | log: true, 16 | skipIfAlreadyDeployed: true, 17 | }); 18 | }; 19 | module.exports = func; 20 | func.tags = ["BobaParentMessenger", "l1-boba-xchain"]; 21 | -------------------------------------------------------------------------------- /packages/core/deploy/044_deploy_optimism_parent_messenger.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("Optimism_ParentMessenger", { 8 | contract: "Optimism_ParentMessenger", 9 | from: deployer, 10 | args: [ 11 | "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1", // Optimism's OVM L1 Cross Domain Messenger 12 | 10, // Child network ID 13 | ], 14 | log: true, 15 | skipIfAlreadyDeployed: true, 16 | }); 17 | }; 18 | module.exports = func; 19 | func.tags = ["OptimismParentMessenger", "l1-optimism-xchain"]; 20 | -------------------------------------------------------------------------------- /packages/core/deploy/046_deploy_admin_child_messenger.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | const { deployer } = await getNamedAccounts(); 5 | 6 | // Admin Child Messenger does not require a parent messenger. 7 | await deploy("Admin_ChildMessenger", { 8 | contract: "Admin_ChildMessenger", 9 | from: deployer, 10 | args: [], 11 | log: true, 12 | skipIfAlreadyDeployed: true, 13 | }); 14 | }; 15 | module.exports = func; 16 | func.tags = ["AdminChildMessenger", "l2-admin-xchain"]; 17 | -------------------------------------------------------------------------------- /packages/core/deploy/048_deploy_long_short_pair_libraries_simple_success_token.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("SimpleSuccessTokenLongShortPairFinancialProductLibrary", { 8 | from: deployer, 9 | log: true, 10 | skipIfAlreadyDeployed: true, 11 | }); 12 | }; 13 | module.exports = func; 14 | func.tags = ["LongShortPairLibraries", "lsplib", "SimpleSuccessTokenLongShortPairLibrary"]; 15 | -------------------------------------------------------------------------------- /packages/core/deploy/049_deploy_long_short_pair_libraries_success_token.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("SuccessTokenLongShortPairFinancialProductLibrary", { 8 | from: deployer, 9 | log: true, 10 | skipIfAlreadyDeployed: true, 11 | }); 12 | }; 13 | module.exports = func; 14 | func.tags = ["LongShortPairLibraries", "lsplib", "SuccessTokenLongShortPairLibrary"]; 15 | -------------------------------------------------------------------------------- /packages/core/deploy/050_deploy_long_short_pair_libraries_capped_yield_dollar.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("CappedYieldDollarLongShortPairFinancialProductLibrary", { 8 | from: deployer, 9 | log: true, 10 | skipIfAlreadyDeployed: true, 11 | }); 12 | }; 13 | module.exports = func; 14 | func.tags = ["LongShortPairLibraries", "lsplib", "CappedYieldDollarLongShortPairLibrary"]; 15 | -------------------------------------------------------------------------------- /packages/core/deploy/051_deploy_optimistic_oracle_V2.js: -------------------------------------------------------------------------------- 1 | const { ZERO_ADDRESS } = require("@uma/common"); 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | 8 | // 2 hours. 9 | const defaultLiveness = 7200; 10 | const Finder = await deployments.get("Finder"); 11 | const Timer = (await deployments.getOrNull("Timer")) || { address: ZERO_ADDRESS }; 12 | 13 | await deploy("OptimisticOracleV2", { 14 | from: deployer, 15 | args: [defaultLiveness, Finder.address, Timer.address], 16 | log: true, 17 | skipIfAlreadyDeployed: true, 18 | }); 19 | }; 20 | module.exports = func; 21 | func.tags = ["OptimisticOracleV2", "dvm", "dvmv2"]; 22 | func.dependencies = ["Finder"]; 23 | -------------------------------------------------------------------------------- /packages/core/deploy/054_deploy_designated_votingV2_factory.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | const Finder = await deployments.get("Finder"); 7 | 8 | await deploy("DesignatedVotingV2Factory", { 9 | from: deployer, 10 | args: [Finder.address], 11 | log: true, 12 | skipIfAlreadyDeployed: true, 13 | }); 14 | }; 15 | module.exports = func; 16 | func.tags = ["DesignatedVotingV2Factory", "dvm", "dvmv2"]; 17 | func.dependencies = ["Finder"]; 18 | -------------------------------------------------------------------------------- /packages/core/deploy/056_deploy_skinny_optimistic_oracle_V2.js: -------------------------------------------------------------------------------- 1 | const { ZERO_ADDRESS } = require("@uma/common"); 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | 8 | // 2 hours. 9 | const defaultLiveness = 7200; 10 | const Finder = await deployments.get("Finder"); 11 | const Timer = (await deployments.getOrNull("Timer")) || { address: ZERO_ADDRESS }; 12 | 13 | await deploy("SkinnyOptimisticOracleV2", { 14 | from: deployer, 15 | args: [defaultLiveness, Finder.address, Timer.address], 16 | log: true, 17 | skipIfAlreadyDeployed: true, 18 | }); 19 | }; 20 | module.exports = func; 21 | func.tags = ["SkinnyOptimisticOracleV2", "dvm", "dvmv2"]; 22 | func.dependencies = ["Finder", "Timer"]; 23 | -------------------------------------------------------------------------------- /packages/core/deploy/059_deploy_snapshot_helper.js: -------------------------------------------------------------------------------- 1 | // Deploys helper contract to calculate snapshot voting power. 2 | const func = async function (hre) { 3 | const { deployments, getNamedAccounts } = hre; 4 | const { deploy } = deployments; 5 | 6 | const { deployer } = await getNamedAccounts(); 7 | 8 | await deploy("SnapshotVotingPower", { from: deployer, log: true, skipIfAlreadyDeployed: true }); 9 | }; 10 | module.exports = func; 11 | func.tags = ["SnapshotVotingPower"]; 12 | -------------------------------------------------------------------------------- /packages/core/deploy/060_deploy_proposer_v2.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts, web3 } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | const Finder = await deployments.get("Finder"); 8 | const GovernorV2 = await deployments.get("GovernorV2"); 9 | const VotingToken = await deployments.get("VotingToken"); 10 | 11 | const defaultBond = web3.utils.toWei("5000"); 12 | 13 | await deploy("ProposerV2", { 14 | from: deployer, 15 | args: [VotingToken.address, defaultBond, GovernorV2.address, Finder.address], 16 | log: true, 17 | skipIfAlreadyDeployed: true, 18 | }); 19 | }; 20 | module.exports = func; 21 | func.tags = ["ProposerV2", "dvmv2"]; 22 | func.dependencies = ["Finder", "VotingToken", "GovernorV2"]; 23 | -------------------------------------------------------------------------------- /packages/core/deploy/062_deploy_base_parent_messenger.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("Base_ParentMessenger", { 8 | contract: "Optimism_ParentMessenger", 9 | from: deployer, 10 | args: [ 11 | "0x866E82a600A1414e583f7F13623F1aC5d58b0Afa", // Base's OVM L1 Cross Domain Messenger 12 | 8453, // Child network ID 13 | ], 14 | log: true, 15 | skipIfAlreadyDeployed: true, 16 | }); 17 | }; 18 | module.exports = func; 19 | func.tags = ["Base_ParentMessenger", "l1-base-xchain"]; 20 | -------------------------------------------------------------------------------- /packages/core/deploy/064_deploy_blast_parent_messenger.js: -------------------------------------------------------------------------------- 1 | const func = async function (hre) { 2 | const { deployments, getNamedAccounts } = hre; 3 | const { deploy } = deployments; 4 | 5 | const { deployer } = await getNamedAccounts(); 6 | 7 | await deploy("Blast_ParentMessenger", { 8 | contract: "Optimism_ParentMessenger", 9 | from: deployer, 10 | args: [ 11 | "0x5D4472f31Bd9385709ec61305AFc749F0fA8e9d0", // Blast's OVM L1 Cross Domain Messenger 12 | 81457, // Child network ID 13 | ], 14 | log: true, 15 | skipIfAlreadyDeployed: true, 16 | }); 17 | }; 18 | module.exports = func; 19 | func.tags = ["Blast_ParentMessenger", "l1-blast-xchain"]; 20 | -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/CommandlineUtil.js: -------------------------------------------------------------------------------- 1 | function validateAddress(address) { 2 | return address.substring(0, 2) == "0x" || address.length == 42; 3 | } 4 | 5 | module.exports = { validateAddress }; 6 | -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/local/AddMemberToRole.js: -------------------------------------------------------------------------------- 1 | const argv = require("minimist")(process.argv.slice(), { string: ["contract", "role_id", "address"] }); 2 | 3 | const MultiRole = artifacts.require("MultiRole"); 4 | 5 | const addMemberToRole = async function (callback) { 6 | try { 7 | const roleManager = (await web3.eth.getAccounts())[0]; 8 | 9 | // Initialize the MultiRole interface from the provided address. 10 | const multiRole = await MultiRole.at(argv.contract); 11 | 12 | // Add the new member. 13 | await multiRole.addMember(argv.role_id, argv.address, { from: roleManager }); 14 | 15 | console.log(`Added ${argv.address} to role id ${argv.role_id} to MultiRole contract at ${argv.contract}`); 16 | } catch (e) { 17 | console.log(`ERROR: ${e}`); 18 | } 19 | 20 | callback(); 21 | }; 22 | 23 | module.exports = addMemberToRole; 24 | -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/local/AdvanceToCommitPhase.js: -------------------------------------------------------------------------------- 1 | const Voting = artifacts.require("Voting"); 2 | const { moveToNextPhase } = require("../../utils/Voting.js"); 3 | 4 | // to advance to next commit phase 5 | // call dvm (voting) getVotePhase 6 | // commit phase is 0, revealphase is 1 7 | const run = async function (callback) { 8 | const voting = await Voting.deployed(); 9 | 10 | const startingPhase = await voting.getVotePhase(); 11 | // we are in a commit phase. move to reveal, then move to next commit. 12 | if (startingPhase == 0) { 13 | // move to reveal 14 | await moveToNextPhase(voting); 15 | } 16 | // move to commit 17 | await moveToNextPhase(voting); 18 | const endingPhase = await voting.getVotePhase(); 19 | 20 | console.log("Moved from phase", startingPhase.toString(), "to", endingPhase.toString()); 21 | callback(); 22 | }; 23 | 24 | module.exports = run; 25 | -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/local/DeployBalancerMock.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @notice Deploy a new Balancer market. 3 | * 4 | * 5 | * Example: $(npm bin)/truffle exec ./scripts/local/DeployBalancerMock.js --network kovan_mnemonic 6 | */ 7 | 8 | // Deployed contract ABI's and addresses we need to fetch. 9 | const BalancerMock = artifacts.require("BalancerMock"); 10 | 11 | // Contracts we need to interact with. 12 | let balancer; 13 | 14 | /** *************************************************** 15 | * Main Script 16 | /*****************************************************/ 17 | const deployBalancerMock = async (callback) => { 18 | try { 19 | balancer = await BalancerMock.new(); 20 | console.log(`Deployed new BalancerMock @ ${balancer.address}`); 21 | } catch (err) { 22 | console.error(err); 23 | callback(err); 24 | return; 25 | } 26 | callback(); 27 | }; 28 | 29 | module.exports = deployBalancerMock; 30 | -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/local/DeployUniswapMock.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @notice Deploy a new UniswapMock market. 3 | * 4 | * 5 | * Example: $(npm bin)/truffle exec ./scripts/local/DeployUniswapMock.js --network kovan_mnemonic 6 | */ 7 | 8 | // Deployed contract ABI's and addresses we need to fetch. 9 | const UniswapMock = artifacts.require("UniswapMock"); 10 | 11 | // Contracts we need to interact with. 12 | let uniswap; 13 | 14 | /** *************************************************** 15 | * Main Script 16 | /*****************************************************/ 17 | const deployUniswapMock = async (callback) => { 18 | try { 19 | uniswap = await UniswapMock.new(); 20 | console.log(`Deployed new UniswapMock @ ${uniswap.address}`); 21 | } catch (err) { 22 | console.error(err); 23 | callback(err); 24 | return; 25 | } 26 | callback(); 27 | }; 28 | 29 | module.exports = deployUniswapMock; 30 | -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/local/GetUniswapAddress.js: -------------------------------------------------------------------------------- 1 | const argv = require("minimist")(process.argv.slice(), { string: ["token1", "token2"] }); 2 | 3 | const { getUniswapPairDetails } = require("@uma/financial-templates-lib"); 4 | 5 | const getUniswapPairAddress = async function (callback) { 6 | try { 7 | const { pairAddress } = await getUniswapPairDetails(web3, argv.token1, argv.token2); 8 | 9 | console.log(`Uniswap V2 pair address for tokens ${argv.token1} and ${argv.token2} is ${pairAddress}`); 10 | } catch (e) { 11 | console.log(`ERROR: ${e}`); 12 | } 13 | 14 | callback(); 15 | }; 16 | 17 | module.exports = getUniswapPairAddress; 18 | -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/local/SnapshotCurrentRound.js: -------------------------------------------------------------------------------- 1 | const Voting = artifacts.require("Voting"); 2 | const { signMessage } = require("@uma/common"); 3 | 4 | const snapshotRound = async (callback) => { 5 | try { 6 | const voting = await Voting.deployed(); 7 | const accounts = await web3.eth.getAccounts(); 8 | const snapshotMessage = "Sign For Snapshot"; 9 | const signature = await signMessage(web3, snapshotMessage, accounts[0]); 10 | 11 | const transaction = await voting.snapshotCurrentRound(signature, { from: accounts[0] }); 12 | console.log("Snapshotted current round:", transaction.receipt.rawLogs); 13 | } catch (err) { 14 | callback(err); 15 | return; 16 | } 17 | callback(); 18 | }; 19 | 20 | module.exports = snapshotRound; 21 | -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/optimistic-oracle-umip/2_VoteSimulate.js: -------------------------------------------------------------------------------- 1 | ../umip-3/2_VoteSimulate.js -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/remove-collateral-upp/2_VoteSimulate.js: -------------------------------------------------------------------------------- 1 | ../umip-3/2_VoteSimulate.js -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/umip-8/2_VoteSimulate.js: -------------------------------------------------------------------------------- 1 | ../umip-3/2_VoteSimulate.js -------------------------------------------------------------------------------- /packages/core/deprecated_truffle_scripts/voting-upgrade-umip/2_VoteSimulate.js: -------------------------------------------------------------------------------- 1 | ../umip-3/2_VoteSimulate.js -------------------------------------------------------------------------------- /packages/core/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | allow_paths = ["../../node_modules"] 3 | cache_path = 'forge-cache' 4 | libs = ['node_modules', 'lib'] 5 | out = 'out' 6 | src = 'contracts' 7 | test = 'test/foundry' 8 | -------------------------------------------------------------------------------- /packages/core/index.ts: -------------------------------------------------------------------------------- 1 | export { findContractVersion } from "./src/FindContractVersion"; 2 | -------------------------------------------------------------------------------- /packages/core/networks/1516.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "contractName": "Finder", 4 | "address": "0x28077B47Cd03326De7838926A63699849DD4fa87" 5 | }, 6 | { 7 | "contractName": "AddressWhitelist", 8 | "address": "0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64" 9 | }, 10 | { 11 | "contractName": "IdentifierWhitelist", 12 | "address": "0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75" 13 | }, 14 | { 15 | "contractName": "MockOracleAncillary", 16 | "address": "0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96" 17 | }, 18 | { 19 | "contractName": "Store", 20 | "address": "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4" 21 | }, 22 | { 23 | "contractName": "TestnetERC20", 24 | "address": "0x38fAc33bD20D4c4Cce085C0f347153C06CbA2968" 25 | }, 26 | { 27 | "contractName": "OptimisticOracleV3", 28 | "address": "0x3CA11702f7c0F28e0b4e03C31F7492969862C569" 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /packages/core/networks/421611.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "contractName": "Arbitrum_ChildMessenger", 4 | "address": "0x62530b7D3DcbCb0699480094E29Cec181eC3ea6a" 5 | }, 6 | { 7 | "contractName": "Finder", 8 | "address": "0x0d6b8752e5AdBafb3F75299aD15863a1fd02D565" 9 | }, 10 | { 11 | "contractName": "Registry", 12 | "address": "0xD8c6dD978a3768F7DDfE3A9aAD2c3Fd75Fa9B6Fd" 13 | }, 14 | { 15 | "contractName": "OracleSpoke", 16 | "address": "0xA011B82880D0235f845c9d1EA5610b965e0CD759" 17 | }, 18 | { 19 | "contractName": "GovernorSpoke", 20 | "address": "0xe59E84570052D3A7aA84Fdc0dA78389206fba9fD" 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /packages/core/networks/84531.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "contractName": "Finder", 4 | "address": "0x2BC84A3777469f67e040DAb9d00512a5D5258f39" 5 | }, 6 | { 7 | "contractName": "AddressWhitelist", 8 | "address": "0xa4199d73ae206d49c966cF16c58436851f87d47F" 9 | }, 10 | { 11 | "contractName": "IdentifierWhitelist", 12 | "address": "0x278d6b1aA37d09769E519f05FcC5923161A8536D" 13 | }, 14 | { 15 | "contractName": "MockOracleAncillary", 16 | "address": "0x55743451B0921B555B4AeAf878c2f3E37aA41755" 17 | }, 18 | { 19 | "contractName": "Store", 20 | "address": "0xCD43CEa89DF8fE39031C03c24BC24480e942470B" 21 | }, 22 | { 23 | "contractName": "TestnetERC20", 24 | "address": "0xEF8b46765ae805537053C59f826C3aD61924Db45" 25 | }, 26 | { 27 | "contractName": "OptimisticOracleV3", 28 | "address": "0x1F4dC6D69E3b4dAC139E149E213a7e863a813466" 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /packages/core/remappings.txt: -------------------------------------------------------------------------------- 1 | @openzeppelin/=../../node_modules/@openzeppelin/ 2 | @uniswap/=../../node_modules/@uniswap/ 3 | @gnosis.pm/=../../node_modules/@gnosis.pm/ 4 | @maticnetwork/=../../node_modules/@maticnetwork/ 5 | @eth-optimism/=../../node_modules/@eth-optimism/ 6 | ds-test/=lib/forge-std/lib/ds-test/src/ 7 | forge-std/=lib/forge-std/src/ 8 | -------------------------------------------------------------------------------- /packages/core/test/foundry/fixtures/common/CommonTestBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "forge-std/Test.sol"; 5 | import "./TestAddress.sol"; 6 | 7 | contract CommonTestBase is Test {} 8 | -------------------------------------------------------------------------------- /packages/core/test/foundry/fixtures/common/TestAddress.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | library TestAddress { 5 | address public constant owner = address(0x1); 6 | address public constant account1 = address(0x2); 7 | address public constant account2 = address(0x3); 8 | address public constant account3 = address(0x4); 9 | address public constant random = address(0x5); 10 | } 11 | -------------------------------------------------------------------------------- /packages/core/test/foundry/fixtures/common/TimerFixture.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.16; 2 | 3 | import "../../../../contracts/common/implementation/Timer.sol"; 4 | 5 | contract TimerFixture { 6 | function setUp() public returns (Timer timer) { 7 | return new Timer(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/core/test/foundry/optimistic-oracle-v3/integration-tests/FullPolicyEscalationManager.Common.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | import "./BaseEscalationManager.t.sol"; 5 | import "../../../../contracts/optimistic-oracle-v3/implementation/escalation-manager/FullPolicyEscalationManager.sol"; 6 | 7 | contract FullPolicyEscalationManagerCommon is BaseEscalationManagerTest { 8 | function setUp() public override { 9 | _commonSetup(); 10 | 11 | // Fund Account1 for making assertion through wrapper. 12 | vm.startPrank(TestAddress.account1); 13 | defaultCurrency.allocateTo(TestAddress.account1, defaultBond); 14 | defaultCurrency.approve(address(assertingCaller), defaultBond); 15 | vm.stopPrank(); 16 | 17 | escalationManager = address(new FullPolicyEscalationManager(address(optimisticOracleV3))); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/core/test/hardhat/helpers/ArbitrumHelper.js: -------------------------------------------------------------------------------- 1 | const { web3 } = require("hardhat"); 2 | const { toHex, toBN } = web3.utils; 3 | 4 | function applyL1ToL2Alias(l1Address) { 5 | const offset = toBN("0x1111000000000000000000000000000000001111"); 6 | const l1AddressAsNumber = toBN(l1Address); 7 | 8 | const l2AddressAsNumber = l1AddressAsNumber.add(offset); 9 | 10 | const mask = toBN("2").pow(toBN("160")); 11 | return toHex(l2AddressAsNumber.mod(mask)); 12 | } 13 | 14 | module.exports = { applyL1ToL2Alias }; 15 | -------------------------------------------------------------------------------- /packages/core/test/hardhat/merkle-distributor/SamplePayout.json: -------------------------------------------------------------------------------- 1 | { 2 | "totalRewardsDistributed": "45000000000000000000", 3 | "exampleRecipients": { 4 | "0x00b591bc2b682a0b30dd72bac9406bfa13e5d3cd": "1000000000000000000", 5 | "0x00e4846e2971bb2b29cec7c9efc8fa686ae21342": "2000000000000000000", 6 | "0x00e4f5a158ec094da8cf55f8d994b84b6f5f33d9": "3000000000000000000", 7 | "0x0156ff30a13abbe641cb17f33967eb67feafeb4e": "4000000000000000000", 8 | "0x01b01c6fb158e55c83883219a533f1efd2abfdf4": "5000000000000000000", 9 | "0x1c8a109a8818dc343781e783b8b30d233f3d379f": "6000000000000000000", 10 | "0x1ce2304369d957fc1f0dd32c983f445e449f4c7a": "7000000000000000000", 11 | "0x1dc5eefe2d20d1ab0db794a4236df147c0f60921": "8000000000000000000", 12 | "0x1c11ecbba07f6f122fef22caec28daee5ed1c908": "9000000000000000000", 13 | "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266": "0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "esModuleInterop": true, 4 | "include": ["contract-types/**/*.ts", "index.ts", "browser.ts", "src/**/*.ts"], 5 | "compilerOptions": { 6 | "outDir": "./dist", 7 | "declaration": true, 8 | "declarationDir": "./types" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/financial-templates-lib/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | timeout: 100000, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/financial-templates-lib/hardhat.config.js: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("@uma/common"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const packageWkdir = path.dirname(require.resolve("@uma/financial-templates-lib/package.json")); 6 | 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | tests: `${packageWkdir}/test`, 14 | }, 15 | }; 16 | 17 | module.exports = getHardhatConfig(configOverride, coreWkdir); 18 | -------------------------------------------------------------------------------- /packages/financial-templates-lib/src/price-feed/NetworkerMock.ts: -------------------------------------------------------------------------------- 1 | import { NetworkerInterface } from "./Networker"; 2 | 3 | // A mock of the Networker to allow the user to check the inputs and set the outputs of network requests. 4 | export class NetworkerMock extends NetworkerInterface { 5 | // Value that will hold the most recent input to getJson. 6 | public getJsonInputs: string[] = []; 7 | 8 | // Value that will be returned on the next call to getJson. 9 | // Users of this mock should set this value to force getJson to return the value. 10 | public getJsonReturns: any[] = []; 11 | 12 | // Mocked getJson function. 13 | public async getJson(url: string): Promise { 14 | // Note: shift and unshift add and remove from the front of the array, so the elements are ordered such that the 15 | // first elements in the arrays are the first in/out. 16 | this.getJsonInputs.unshift(url); 17 | return this.getJsonReturns.shift(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/financial-templates-lib/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { AbiItem, toBN } from "web3-utils"; 2 | 3 | export type Abi = AbiItem | AbiItem[]; 4 | 5 | export type BN = ReturnType; 6 | 7 | export type Awaited = T extends PromiseLike ? Awaited : T; 8 | 9 | export type FinancialContractType = "ExpiringMultiParty" | "Perpetual"; 10 | export type FinancialContractFactoryType = "PerpetualCreator" | "ExpiringMultiPartyCreator"; 11 | 12 | export function isDefined(val: T | undefined | null): val is T { 13 | return val !== undefined && val !== null; 14 | } 15 | -------------------------------------------------------------------------------- /packages/financial-templates-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "include": ["src/**/*"], 4 | "compilerOptions": { 5 | "typeRoots": ["./types", "./node_modules/@types"], 6 | "outDir": "dist", 7 | "esModuleInterop": true, 8 | "declaration": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/financial-templates-lib/types/abi-decoder/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module "abi-decoder" { 2 | export function addABI(abi: any | any[]): void; 3 | export function decodeMethod(data: string): { name: string; params: any }; 4 | export function getMethodIDs(): { [signature: string]: any }; 5 | export function getABIs(): any[]; 6 | export function decodeLogs(logs: any[]): { name: string; events: any[]; address: string }[]; 7 | export function removeABI(abi: any | any[]): void; 8 | } -------------------------------------------------------------------------------- /packages/financial-templates-lib/types/node-pagerduty/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module "node-pagerduty" { 2 | interface Incidents { 3 | createIncident: (from: string, payload: { [key: string]: any }) => void; 4 | } 5 | export default class Client { 6 | constructor(apiToken: string, tokenType?: string, options?: any); 7 | public incidents: Incidents; 8 | } 9 | } -------------------------------------------------------------------------------- /packages/fx-tunnel-relayer/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { getHardhatConfig } from "@uma/common"; 2 | import path from "path"; 3 | 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const packageWkdir = path.dirname(require.resolve("@uma/fx-tunnel-relayer/package.json")); 6 | 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | tests: `${packageWkdir}/test`, 14 | }, 15 | }; 16 | 17 | export default getHardhatConfig(configOverride, coreWkdir); 18 | -------------------------------------------------------------------------------- /packages/fx-tunnel-relayer/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const SECONDS_PER_HOUR = 3600; 2 | export const HOURS_PER_DAY = 24; 3 | export const SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY; 4 | export const SKIP_THRESHOLD_SECONDS = 4 * SECONDS_PER_HOUR; 5 | export const PHASE_LENGTH_SECONDS = 2 * SECONDS_PER_DAY; 6 | -------------------------------------------------------------------------------- /packages/fx-tunnel-relayer/src/timeUtils.ts: -------------------------------------------------------------------------------- 1 | import { PHASE_LENGTH_SECONDS, SKIP_THRESHOLD_SECONDS } from "./constants"; 2 | 3 | /** 4 | * Given a phase length and a Unix-timestamp, returns how many seconds remain 5 | * until the end of the current phase. 6 | */ 7 | export function secondsUntilRoundEnd(): number { 8 | const currentTimestampSec: number = Math.floor(Date.now() / 1000); 9 | const roundIndex = Math.floor(currentTimestampSec / PHASE_LENGTH_SECONDS); 10 | const nextRoundStart = (roundIndex + 1) * PHASE_LENGTH_SECONDS; 11 | return nextRoundStart - currentTimestampSec; 12 | } 13 | 14 | /** 15 | * Decide whether we should skip relaying because we’re too close to the 16 | * round’s end. 17 | */ 18 | export function isTooCloseToRoundEnd(timeRemainingSec: number, thresholdSec: number = SKIP_THRESHOLD_SECONDS): boolean { 19 | return timeRemainingSec < thresholdSec; 20 | } 21 | -------------------------------------------------------------------------------- /packages/fx-tunnel-relayer/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "include": ["./**/*.ts"], 4 | "compilerOptions": { 5 | "outDir": "../dist", 6 | "rootDir": "../", 7 | "composite": true, 8 | "resolveJsonModule": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/fx-tunnel-relayer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "include": ["test/**/*.ts", "hardhat.config.ts"], 4 | "compilerOptions": { 5 | "outDir": "build", 6 | "esModuleInterop": true, 7 | "resolveJsonModule": true 8 | }, 9 | "references": [{ "path": "./src/" }] 10 | } 11 | -------------------------------------------------------------------------------- /packages/llm-bot/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { getHardhatConfig } from "@uma/common"; 2 | import path from "path"; 3 | 4 | // Hardhat plugins used in monitor-v2 package tests. 5 | import "@nomiclabs/hardhat-ethers"; 6 | import "@nomiclabs/hardhat-waffle"; 7 | import "hardhat-deploy"; 8 | 9 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 10 | const packageWkdir = path.dirname(require.resolve("./package.json")); 11 | 12 | const configOverride = { 13 | paths: { 14 | root: coreWkdir, 15 | sources: `${coreWkdir}/contracts`, 16 | artifacts: `${coreWkdir}/artifacts`, 17 | cache: `${coreWkdir}/cache`, 18 | tests: `${packageWkdir}/test`, 19 | }, 20 | }; 21 | 22 | export default getHardhatConfig(configOverride, coreWkdir); 23 | -------------------------------------------------------------------------------- /packages/llm-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@uma/llm-bot", 3 | "version": "1.1.8", 4 | "description": "LLM bots for UMA", 5 | "author": "UMA Team", 6 | "license": "AGPL-3.0-only", 7 | "scripts": { 8 | "build": "tsc --build", 9 | "test": "hardhat test" 10 | }, 11 | "dependencies": { 12 | "@ethersproject/abstract-provider": "^5.4.0", 13 | "@uma/common": "^2.37.3", 14 | "@uma/contracts-node": "^0.4.25", 15 | "@uma/financial-templates-lib": "^2.36.3", 16 | "async-retry": "^1.3.3", 17 | "ethers": "^5.4.2" 18 | }, 19 | "devDependencies": { 20 | "@nomicfoundation/hardhat-network-helpers": "^1.0.8", 21 | "@nomiclabs/hardhat-waffle": "^2.0.5", 22 | "chai": "^4.3.7", 23 | "ethereum-waffle": "^4.0.10", 24 | "sinon": "^15.0.1" 25 | }, 26 | "publishConfig": { 27 | "registry": "https://registry.npmjs.com/", 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/llm-bot/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "resolveJsonModule": true, 6 | "declaration": true, 7 | "outDir": "./dist", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true 12 | }, 13 | "include": ["./src"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/logger/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | timeout: 100000, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/logger/README.md: -------------------------------------------------------------------------------- 1 | # @uma/logger 2 | 3 | @uma/logger is a specialized logger package optimized for minimal dependencies, ensuring compatibility and ease of integration. 4 | 5 | ## Installing the package 6 | 7 | ```bash 8 | yarn add @uma/logger 9 | ``` 10 | 11 | ## Importing the package 12 | 13 | The [Logger](./src/logger) directory contains helpers and factories for logging with Winston. To get the default 14 | logger: 15 | 16 | ```js 17 | const { Logger } = require("@uma/logger") 18 | 19 | // You can also log directly using the winston logger. 20 | Logger.debug({ 21 | at: "createPriceFeed", 22 | message: "Creating CryptoWatchPriceFeed", 23 | otherParam: 5, 24 | }) 25 | ``` 26 | 27 | ## Helpers 28 | 29 | There are two helper files that are available in logger: 30 | 31 | - [delay.js](./src/helpers/delay.js): simple file containing a function to "sleep". 32 | -------------------------------------------------------------------------------- /packages/logger/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const noBotId = "NO_BOT_ID"; 2 | 3 | export const redisDefaultUrl = "redis://localhost:6379"; 4 | -------------------------------------------------------------------------------- /packages/logger/src/helpers/delay.ts: -------------------------------------------------------------------------------- 1 | export function delay(s: number): Promise { 2 | return new Promise((r) => setTimeout(r, s * 1000)); 3 | } 4 | -------------------------------------------------------------------------------- /packages/logger/src/helpers/typeGuards.ts: -------------------------------------------------------------------------------- 1 | // Helper type guard for dictionary objects. Useful when dealing with any info type passed to log method. 2 | export const isDictionary = (arg: unknown): arg is Record => { 3 | return typeof arg === "object" && arg !== null && !Array.isArray(arg); 4 | }; 5 | -------------------------------------------------------------------------------- /packages/logger/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./constants"; 2 | export * from "./helpers/delay"; 3 | export * from "./helpers/typeGuards"; 4 | export * from "./logger/Logger"; 5 | export * from "./logger/SpyTransport"; 6 | export * from "./logger/ConsoleTransport"; 7 | export * from "./logger/Formatters"; 8 | -------------------------------------------------------------------------------- /packages/logger/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { AbiItem, toBN } from "web3-utils"; 2 | 3 | export type Abi = AbiItem | AbiItem[]; 4 | 5 | export type BN = ReturnType; 6 | 7 | export type Awaited = T extends PromiseLike ? Awaited : T; 8 | 9 | export type FinancialContractType = "ExpiringMultiParty" | "Perpetual"; 10 | export type FinancialContractFactoryType = "PerpetualCreator" | "ExpiringMultiPartyCreator"; 11 | 12 | export function isDefined(val: T | undefined | null): val is T { 13 | return val !== undefined && val !== null; 14 | } 15 | -------------------------------------------------------------------------------- /packages/logger/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "include": ["src/**/*"], 4 | "compilerOptions": { 5 | "typeRoots": ["./types", "./node_modules/@types"], 6 | "outDir": "dist", 7 | "esModuleInterop": true, 8 | "declaration": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/logger/types/node-pagerduty/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module "node-pagerduty" { 2 | interface Incidents { 3 | createIncident: (from: string, payload: { [key: string]: any }) => void; 4 | } 5 | export default class Client { 6 | constructor(apiToken: string, tokenType?: string, options?: any); 7 | public incidents: Incidents; 8 | } 9 | } -------------------------------------------------------------------------------- /packages/monitor-v2/.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | -------------------------------------------------------------------------------- /packages/monitor-v2/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { getHardhatConfig } from "@uma/common"; 2 | import path from "path"; 3 | 4 | // Hardhat plugins used in monitor-v2 package tests. 5 | import "@nomiclabs/hardhat-ethers"; 6 | import "@nomiclabs/hardhat-waffle"; 7 | import "hardhat-deploy"; 8 | 9 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 10 | const packageWkdir = path.dirname(require.resolve("./package.json")); 11 | 12 | const configOverride = { 13 | paths: { 14 | root: coreWkdir, 15 | sources: `${coreWkdir}/contracts`, 16 | artifacts: `${coreWkdir}/artifacts`, 17 | cache: `${coreWkdir}/cache`, 18 | tests: `${packageWkdir}/test`, 19 | }, 20 | }; 21 | 22 | export default getHardhatConfig(configOverride, coreWkdir); 23 | -------------------------------------------------------------------------------- /packages/monitor-v2/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "resolveJsonModule": true, 6 | "declaration": true, 7 | "outDir": "./dist", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true 12 | }, 13 | "include": ["./src"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/monitors/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | timeout: 10000, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/monitors/hardhat.config.js: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("@uma/common"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const packageWkdir = path.dirname(require.resolve("@uma/monitors/package.json")); 6 | 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | tests: `${packageWkdir}/test`, 14 | }, 15 | }; 16 | 17 | module.exports = getHardhatConfig(configOverride, coreWkdir); 18 | -------------------------------------------------------------------------------- /packages/optimistic-oracle/hardhat.config.js: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("@uma/common"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const packageWkdir = path.dirname(require.resolve("@uma/optimistic-oracle/package.json")); 6 | 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | tests: `${packageWkdir}/test`, 14 | }, 15 | }; 16 | 17 | module.exports = getHardhatConfig(configOverride, coreWkdir); 18 | -------------------------------------------------------------------------------- /packages/polymarket-notifier/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@uma/polymarket-notifier", 3 | "version": "1.4.10", 4 | "description": "Polymarket Notification Bot", 5 | "homepage": "https://umaproject.org", 6 | "license": "AGPL-3.0-or-later", 7 | "main": "index.js", 8 | "dependencies": { 9 | "@google-cloud/datastore": "^7.0.0", 10 | "@uma/common": "^2.37.3", 11 | "@uma/financial-templates-lib": "^2.36.3", 12 | "async-retry": "^1.3.1", 13 | "dotenv": "^6.2.0", 14 | "graphql": "^16.6.0", 15 | "graphql-request": "^5.2.0" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/UMAprotocol/protocol.git" 20 | }, 21 | "files": [ 22 | "/src/**/*.js" 23 | ], 24 | "bin": "index.js", 25 | "bugs": { 26 | "url": "https://github.com/UMAprotocol/protocol/issues" 27 | }, 28 | "publishConfig": { 29 | "registry": "https://registry.npmjs.com/", 30 | "access": "public" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/scripts/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | timeout: 100000, 3 | exit: true, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/scripts/hardhat.config.js: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("@uma/common"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const packageWkdir = path.dirname(require.resolve("./package.json")); 6 | 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | tests: `${packageWkdir}/test`, 14 | }, 15 | }; 16 | 17 | module.exports = getHardhatConfig(configOverride, coreWkdir); 18 | -------------------------------------------------------------------------------- /packages/scripts/setupFork.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CURRENT_DIR=$(pwd) 4 | 5 | # This script assumes that you've started a hardhat node fork of Ethereum mainnet, and makes requests to the fork that 6 | # modify it in preparation for running test scripts connected to it. For example, running `impersonateAccounts` unlocks 7 | # accounts that we'll use to submit and vote on Admin proposals. 8 | HARDHAT_NETWORK=localhost yarn hardhat run $CURRENT_DIR/packages/scripts/src/utils/impersonateAccounts.js --no-compile 9 | 10 | # Run this after impersonating the foundation wallet. This sends UMA to the deployer so it 11 | # can submit new proposals. 12 | HARDHAT_NETWORK=localhost yarn hardhat run $CURRENT_DIR/packages/scripts/src/utils/seedProposerWithUma.js --no-compile 13 | -------------------------------------------------------------------------------- /packages/scripts/src/admin-proposals/add-address-whitelist/readme.md: -------------------------------------------------------------------------------- 1 | Adds a new address to AddressWhitelist and sets a final fee in the Store for the corresponding address through a proposal in ProposerV2 and vote in VotingV2. 2 | 3 | Console 1 4 | 5 | ``` 6 | HARDHAT_CHAIN_ID=1 yarn hardhat node --fork https://mainnet.infura.io/v3/ --port 9545 --no-deploy 7 | ``` 8 | 9 | Console 2 10 | 11 | ``` 12 | ./packages/scripts/setupFork.sh 13 | 14 | ADDRESS=
FINAL_FEE= UMIP_NUMBER= NODE_URL_1= yarn hardhat run ./packages/scripts/src/admin-proposals/add-address-whitelist/0_Propose.ts --network localhost 15 | 16 | yarn hardhat run ./packages/scripts/src/admin-proposals/simulateVoteV2.ts --network localhost 17 | 18 | ADDRESS=
FINAL_FEE= NODE_URL_1= yarn hardhat run ./packages/scripts/src/admin-proposals/add-address-whitelist/1_Verify.ts --network localhost 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/scripts/src/admin-proposals/common/constants.ts: -------------------------------------------------------------------------------- 1 | // Address of deployer key in GCKMS used to propose governance actions. 2 | export const PROPOSER_ADDRESS = "0x2bAaA41d155ad8a4126184950B31F50A1513cE25"; 3 | -------------------------------------------------------------------------------- /packages/scripts/src/admin-proposals/common/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./constants"; 2 | export * from "./helpers"; 3 | export * from "./networks"; 4 | export * from "./spoofedRelay"; 5 | export * from "./types"; 6 | -------------------------------------------------------------------------------- /packages/scripts/src/admin-proposals/common/networks.ts: -------------------------------------------------------------------------------- 1 | const supportedNetworks = ["mainnet", "polygon", "arbitrum", "optimism", "base", "blast"] as const; 2 | export type SupportedNetwork = typeof supportedNetworks[number]; 3 | 4 | export const networksNumber: Record = { 5 | mainnet: 1, 6 | polygon: 137, 7 | optimism: 10, 8 | arbitrum: 42161, 9 | base: 8453, 10 | blast: 81457, 11 | }; 12 | 13 | export const l2Networks = supportedNetworks.filter((network) => network !== "mainnet"); 14 | export type L2Network = typeof l2Networks[number]; 15 | 16 | export const rollupNetworks = supportedNetworks.filter((network) => network !== "mainnet" && network !== "polygon"); 17 | export type RollupNetwork = typeof rollupNetworks[number]; 18 | 19 | export const ovmNetworks = ["optimism", "base", "blast"] as const; 20 | export type OVMNetwork = typeof ovmNetworks[number]; 21 | -------------------------------------------------------------------------------- /packages/scripts/src/admin-proposals/register-parent-messenger-and-gas-limit/common.ts: -------------------------------------------------------------------------------- 1 | export const BASE_CHAIN_ID = 8453; 2 | export const PARENT_MESSENGER_DEFAULT_GAS_LIMIT = 500_000; 3 | -------------------------------------------------------------------------------- /packages/scripts/src/admin-proposals/register-parent-messenger-and-gas-limit/readme.md: -------------------------------------------------------------------------------- 1 | Register a new Parent Messenger in the OracleHub and GovernorHub contracts in mainnet. 2 | 3 | Console 1 4 | 5 | ``` 6 | HARDHAT_CHAIN_ID=1 yarn hardhat node --fork https://mainnet.infura.io/v3/ --port 9545 --no-deploy 7 | ``` 8 | 9 | Console 2 10 | 11 | ``` 12 | ./packages/scripts/setupFork.sh 13 | 14 | yarn hardhat run packages/scripts/src/admin-proposals/register-parent-messenger-and-gas-limit/0_Propose.ts --network localhost 15 | 16 | yarn hardhat run ./packages/scripts/src/admin-proposals/simulateVoteV2.ts --network localhost 17 | 18 | yarn hardhat run packages/scripts/src/admin-proposals/register-parent-messenger-and-gas-limit/1_Verify.ts --network localhost 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/scripts/src/admin-proposals/register-parent-messenger/readme.md: -------------------------------------------------------------------------------- 1 | Register a new Parent Messenger in the OracleHub and GovernorHub contracts in mainnet. 2 | 3 | Console 1 4 | 5 | ``` 6 | HARDHAT_CHAIN_ID=1 yarn hardhat node --fork https://mainnet.infura.io/v3/ --port 9545 --no-deploy 7 | ``` 8 | 9 | Console 2 10 | 11 | ``` 12 | ./packages/scripts/setupFork.sh 13 | 14 | yarn hardhat run packages/scripts/src/admin-proposals/register-parent-messenger/0_Propose.ts --network localhost 15 | 16 | yarn hardhat run ./packages/scripts/src/admin-proposals/simulateVoteV2.ts --network localhost 17 | 18 | yarn hardhat run packages/scripts/src/admin-proposals/register-parent-messenger/1_Verify.ts --network localhost 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/scripts/src/local/AdvanceToNextVotingPhase.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { getContract, web3 } = require("hardhat"); 4 | const Voting = getContract("Voting"); 5 | 6 | const secondsPerDay = web3.utils.toBN(86400); 7 | 8 | async function main() { 9 | const [account] = await web3.eth.getAccounts(); 10 | const voting = await Voting.deployed(); 11 | const startingPhase = await voting.methods.getVotePhase().call(); 12 | const currentTime = web3.utils.toBN(await voting.methods.getCurrentTime().call()); 13 | await voting.methods.setCurrentTime(currentTime.add(secondsPerDay)).send({ from: account }); 14 | const endingPhase = await voting.methods.getVotePhase().call(); 15 | console.log("Moved from phase", startingPhase.toString(), "to", endingPhase.toString()); 16 | } 17 | 18 | main().then( 19 | () => { 20 | process.exit(0); 21 | }, 22 | (error) => { 23 | console.error(error); 24 | process.exit(1); 25 | } 26 | ); 27 | -------------------------------------------------------------------------------- /packages/scripts/src/upgrade-tests/sherlock-update/readme.md: -------------------------------------------------------------------------------- 1 | How to test this scripts: 2 | 3 | Console 1 4 | 5 | ``` 6 | HARDHAT_CHAIN_ID=1 yarn hardhat node --fork https://mainnet.infura.io/v3/ --port 9545 --no-deploy 7 | ``` 8 | 9 | Console 2 10 | 11 | ``` 12 | ./packages/scripts/setupFork.sh 13 | 14 | yarn hardhat run ./packages/scripts/src/upgrade-tests/sherlock-update/0_Deploy.ts --network localhost 15 | 16 | ORIGIN_VALIDATOR_ADDRESS= yarn hardhat run ./packages/scripts/src/upgrade-tests/sherlock-update/1_Propose.ts --network localhost 17 | 18 | SKIP_EXECUTE=1 yarn hardhat run ./packages/scripts/src/admin-proposals/simulateVoteV2.ts --network localhost 19 | 20 | MNEMONIC= MULTICALL=1 yarn hardhat run ./packages/scripts/src/admin-proposals/executeProposalV2.ts --network localhost 21 | 22 | yarn hardhat run ./packages/scripts/src/upgrade-tests/sherlock-update/2_Verify.ts --network localhost 23 | ``` 24 | -------------------------------------------------------------------------------- /packages/scripts/src/utils/Deploy.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const hre = require("hardhat"); 4 | const { runDefaultFixture } = require("@uma/common"); 5 | 6 | // Main script. 7 | const main = async () => { 8 | await runDefaultFixture(hre, false); 9 | console.log("Done!"); 10 | }; 11 | 12 | main().then( 13 | () => { 14 | process.exit(0); 15 | }, 16 | (error) => { 17 | console.error(error.stack); 18 | process.exit(1); 19 | } 20 | ); 21 | -------------------------------------------------------------------------------- /packages/scripts/src/utils/constants.js: -------------------------------------------------------------------------------- 1 | // Accounts we will request to impersonate on hardhat node. 2 | const REQUIRED_SIGNER_ADDRESSES = { 3 | deployer: "0x2bAaA41d155ad8a4126184950B31F50A1513cE25", 4 | foundation: "0x8180d59b7175d4064bdfa8138a58e9babffda44a", 5 | }; 6 | 7 | // Net ID that this script should simulate with. 8 | const PROD_NET_ID = 1; 9 | 10 | // Wallets we need to use to sign transactions. 11 | const SECONDS_PER_DAY = 86400; 12 | const YES_VOTE = "1"; 13 | // Need to sign this message to take an UMA voting token snapshot before any votes can be revealed. 14 | const SNAPSHOT_MESSAGE = "Sign For Snapshot"; 15 | 16 | module.exports = { REQUIRED_SIGNER_ADDRESSES, PROD_NET_ID, SECONDS_PER_DAY, YES_VOTE, SNAPSHOT_MESSAGE }; 17 | -------------------------------------------------------------------------------- /packages/scripts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "esModuleInterop": true, 6 | "forceConsistentCasingInFileNames": true, 7 | "strict": true, 8 | "outDir": "./dist", 9 | "declaration": true, 10 | "skipLibCheck": true, 11 | "resolveJsonModule": true, 12 | "allowJs": true 13 | }, 14 | "include": ["./src"] 15 | } 16 | -------------------------------------------------------------------------------- /packages/sdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | dist 5 | -------------------------------------------------------------------------------- /packages/sdk/jest-e2e-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "testMatch": ["**/*.e2e.ts"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/sdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testMatch: ["**/*.test.ts"], 3 | preset: "ts-jest", 4 | testEnvironment: "node", 5 | verbose: true, 6 | maxWorkers: 1, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/sdk/src/README.md: -------------------------------------------------------------------------------- 1 | ## UMA SDK SRC 2 | 3 | This contains all non application code, meant to be composed in your app or other libraries. The code is generally 4 | classified into a few major types: 5 | 6 | - [stores](./stores/README.md): technology specific adapters which persist data, databases, caches, etc. These inherit a very similar interface to a JS Map 7 | - [tables](./tables/README.md): data specific classes which rely on stores for persistence. These model data by a schema, and fit them into tables with unique identifiers. 8 | - [clients](./clients/README.md): contract specific classes with helper functions for finding addresses, connecting and query state. 9 | - [utils](./utils.ts): catch all place for code that is shared across the sdk. 10 | -------------------------------------------------------------------------------- /packages/sdk/src/across/clients/bridgePool.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import * as bridgePool from "./bridgePool"; 3 | import { BigNumber } from "ethers"; 4 | 5 | test("previewRemoval", function () { 6 | const user = { 7 | address: "0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D", 8 | lpTokens: "900000000000000000", 9 | positionValue: "900000541941830509", 10 | totalDeposited: "900000000000000000", 11 | feesEarned: "541941830509", 12 | }; 13 | const result = bridgePool.previewRemoval(user, 0.75); 14 | assert.equal(BigNumber.from(result.position.recieve).add(result.position.remain).toString(), user.totalDeposited); 15 | assert.equal(BigNumber.from(result.fees.recieve).add(result.fees.remain).toString(), user.feesEarned); 16 | assert.equal(BigNumber.from(result.total.recieve).add(result.total.remain).toString(), user.positionValue); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/sdk/src/across/clients/index.ts: -------------------------------------------------------------------------------- 1 | export * as bridgePool from "./bridgePool"; 2 | export * as optimismBridge from "./optimismBridge"; 3 | export * as bobaBridge from "./bobaBridge"; 4 | -------------------------------------------------------------------------------- /packages/sdk/src/across/index.ts: -------------------------------------------------------------------------------- 1 | export * as feeCalculator from "./feeCalculator"; 2 | export * as rateModel from "./rateModel"; 3 | export { default as LpFeeCalculator } from "./lpFeeCalculator"; 4 | export * as gasFeeCalculator from "./gasFeeCalculator"; 5 | export * as utils from "./utils"; 6 | export * as constants from "./constants"; 7 | export * as clients from "./clients"; 8 | export { default as TransactionManager } from "./transactionManager"; 9 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/bridgeDepositBox/README.md: -------------------------------------------------------------------------------- 1 | # UMA SDK Bridge Deposit Box Client 2 | 3 | ## Usage 4 | 5 | Connect to a typechain contract instance and recreate state from events. 6 | 7 | ```js 8 | import {ethers} from 'ethers' 9 | import * as uma from '@uma/sdk' 10 | 11 | // assume you have a url injected from env 12 | const provider = new ethers.providers.WebSocketProvider(env.CUSTOM_NODE_URL) 13 | 14 | // get the contract instance 15 | const contractAddress:string = 0x... 16 | const client:uma.clients.bridgeDepositBox.Instance = uma.clients.bridgeDepositBox.connect(contractAddress,provider) 17 | // gets all events using etheres query filter api 18 | const events = await client.queryFilter({}) 19 | 20 | // returns EventState, defined in the lsp client 21 | const state:uma.clients.bridgeDepositBox.EventState = uma.clients.bridgeDepositBox.getEventState(events) 22 | 23 | ``` 24 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/bridgeDepositBox/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/bridgePool/README.md: -------------------------------------------------------------------------------- 1 | # UMA SDK Bridge Pool Client 2 | 3 | ## Usage 4 | 5 | Connect to a typechain contract instance and recreate state from events. 6 | 7 | ```js 8 | import {ethers} from 'ethers' 9 | import * as uma from '@uma/sdk' 10 | 11 | // assume you have a url injected from env 12 | const provider = new ethers.providers.WebSocketProvider(env.CUSTOM_NODE_URL) 13 | 14 | // get the contract instance 15 | const contractAddress:string = 0x... 16 | const client:uma.clients.bridgePool.Instance = uma.clients.bridgePool.connect(contractAddress,provider) 17 | // gets all events using etheres query filter api 18 | const events = await client.queryFilter({}) 19 | 20 | // returns EventState, defined in the lsp client 21 | const state:uma.clients.bridgePool.EventState = uma.clients.bridgePool.getEventState(events) 22 | 23 | ``` 24 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/bridgePool/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/emp/README.md: -------------------------------------------------------------------------------- 1 | # UMA SDK EMP Client 2 | 3 | This is emp contract client using ethers and typechain generated types. 4 | 5 | ## Usage 6 | 7 | This can calculate user balances for both tokens and collateral within the emp contract using events. 8 | 9 | ```js 10 | import {ethers} from 'ethers' 11 | import uma from '@uma/sdk' 12 | 13 | // assume you have a url injected from env 14 | const provider = new ethers.providers.WebSocketProvider(env.CUSTOM_NODE_URL) 15 | 16 | // get the contract instance 17 | const empAddress:string = // assume you have an emp address you want to connect to 18 | const empInstance:uma.clients.emp.Instance = uma.clients.emp.connect(empAddress,provider) 19 | // gets all emp events 20 | const empEvents = await empInstance.queryFilter({}) 21 | 22 | // returns EventState, defined in the emp client 23 | const state:uma.clients.emp.EventState = uma.clients.emp.getEventState(empEvents) 24 | 25 | ``` 26 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/emp/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/erc20/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/etherchain/client.e2e.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Etherchain } from "."; 3 | 4 | describe("etherchain", () => { 5 | let etherchain: Etherchain; 6 | 7 | test("init", () => { 8 | etherchain = new Etherchain(); 9 | assert.ok(etherchain); 10 | }); 11 | 12 | test("oracle gas price", async () => { 13 | const gasPrice = await etherchain.getGasPrice(); 14 | assert.strictEqual(typeof gasPrice.currentBaseFee === "number", true); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/etherchain/client.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import get from "lodash/get"; 3 | 4 | type GasPrice = { 5 | safeLow: number; 6 | standard: number; 7 | fast: number; 8 | fastest: number; 9 | currentBaseFee: number; 10 | recommendedBaseFee: number; 11 | }; 12 | 13 | export class Etherchain { 14 | constructor(private url = "https://www.etherchain.org/api") {} 15 | 16 | public async getGasPrice(): Promise { 17 | try { 18 | const endpoint = this.url + "/gasPriceOracle"; 19 | const result = await axios.get(endpoint); 20 | return result.data; 21 | } catch (err) { 22 | const msg = get(err, "response.data.error", get(err, "response.statusText", "Unknown Coingecko Error")); 23 | throw new Error(msg); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/etherchain/index.ts: -------------------------------------------------------------------------------- 1 | export { Etherchain } from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/index.ts: -------------------------------------------------------------------------------- 1 | export * as registry from "./registry"; 2 | export * as emp from "./emp"; 3 | export * as erc20 from "./erc20"; 4 | export * as multicall from "./multicall"; 5 | export * as multicall2 from "./multicall2"; 6 | export * as lspCreator from "./lsp-creator"; 7 | export * as lsp from "./lsp"; 8 | export * as bridgeDepositBox from "./bridgeDepositBox"; 9 | export * as bridgePool from "./bridgePool"; 10 | export * as etherchain from "./etherchain"; 11 | export * as rateModelStore from "./rateModelStore"; 12 | export * as optimisticOracle from "./optimisticOracle"; 13 | export * as skinnyOptimisticOracle from "./skinnyOptimisticOracle"; 14 | export * as optimisticOracleV2 from "./optimisticOracleV2"; 15 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/lsp-creator/client.e2e.ts: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | import assert from "assert"; 3 | import * as Client from "./client"; 4 | import { ethers } from "ethers"; 5 | 6 | // these require integration testing, skip for ci 7 | describe("lsp creator", function () { 8 | let client: Client.Instance; 9 | test("inits", async function () { 10 | const provider = ethers.providers.getDefaultProvider(process.env.CUSTOM_NODE_URL); 11 | const address = await Client.getAddress(1); 12 | client = Client.connect(address, provider); 13 | assert.ok(client); 14 | }); 15 | test("getEventState", async function () { 16 | const events = await client.queryFilter({}); 17 | const state = await Client.getEventState(events); 18 | assert.ok(state.contracts); 19 | assert.ok(Object.keys(state.contracts).length > 0); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/lsp-creator/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/lsp/README.md: -------------------------------------------------------------------------------- 1 | # UMA SDK LSP Client 2 | 3 | This is an LSP (Long Short Pair) contract client using ethers and typechain generated types. 4 | 5 | ## Usage 6 | 7 | Connect to a typechain contract instance and recreate state from events. 8 | 9 | ```js 10 | import {ethers} from 'ethers' 11 | import uma from '@uma/sdk' 12 | 13 | // assume you have a url injected from env 14 | const provider = new ethers.providers.WebSocketProvider(env.CUSTOM_NODE_URL) 15 | 16 | // get the contract instance 17 | const contractAddress:string = // assume you have an lsp address you want to connect to 18 | const client:uma.clients.lsp.Instance = uma.clients.lsp.connect(contractAddress,provider) 19 | // gets all events using etheres query filter api 20 | const events = await client.queryFilter({}) 21 | 22 | // returns EventState, defined in the lsp client 23 | const state:uma.clients.lsp.EventState = uma.clients.lsp.getEventState(events) 24 | 25 | ``` 26 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/lsp/client.e2e.ts: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | import assert from "assert"; 3 | import * as Client from "./client"; 4 | import { ethers } from "ethers"; 5 | 6 | const address = "0x651EcbFc3d03109Bb9B2183A068F61dF6935a15A"; 7 | // these require integration testing, skip for ci 8 | describe("lsp", function () { 9 | let client: Client.Instance; 10 | test("inits", function () { 11 | const provider = ethers.providers.getDefaultProvider(process.env.CUSTOM_NODE_URL); 12 | client = Client.connect(address, provider); 13 | assert.ok(client); 14 | }); 15 | test("getEventState", async function () { 16 | const events = await client.queryFilter({}); 17 | const state = await Client.getEventState(events); 18 | assert.ok(state.collateral); 19 | assert.ok(state.shorts); 20 | assert.ok(state.longs); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/lsp/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/multicall/README.md: -------------------------------------------------------------------------------- 1 | # UMA Multicall Client 2 | 3 | This client helps you batch multiple calls together in a single transaction. Useful also for 4 | reducing api calls to infura when reading many properties from contracts. 5 | 6 | ## Usage 7 | 8 | ```js 9 | import { ethers } from "ethers" 10 | import * as uma from "@uma/sdk" 11 | 12 | // assume you have a url injected from env 13 | const provider = new ethers.providers.WebSocketProvider(env.CUSTOM_NODE_URL) 14 | 15 | // get the contract instance 16 | const client = uma.clients.multicall.connect(address, provider) 17 | ``` 18 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/multicall/client.ts: -------------------------------------------------------------------------------- 1 | import { MulticallEthers, MulticallEthers__factory } from "@uma/contracts-node"; 2 | import type { SignerOrProvider } from "../.."; 3 | 4 | export type Instance = MulticallEthers; 5 | const Factory = MulticallEthers__factory; 6 | 7 | export function connect(address: string, provider: SignerOrProvider): Instance { 8 | return Factory.connect(address, provider); 9 | } 10 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/multicall/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/multicall2/README.md: -------------------------------------------------------------------------------- 1 | # UMA Multicall2 Client 2 | 3 | This client helps you batch multiple calls together in a single transaction. Useful also for 4 | reducing api calls to infura when reading many properties from contracts. 5 | 6 | ## Usage 7 | 8 | ```ts 9 | import { ethers } from "ethers" 10 | import * as uma from "@uma/sdk" 11 | 12 | // assume you have a url injected from env 13 | const provider = new ethers.providers.WebSocketProvider(env.CUSTOM_NODE_URL) 14 | 15 | // get the contract instance 16 | const client = uma.clients.multicall2.connect(address, provider) 17 | ``` 18 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/multicall2/client.ts: -------------------------------------------------------------------------------- 1 | import { Multicall2Ethers, Multicall2Ethers__factory } from "@uma/contracts-node"; 2 | import type { SignerOrProvider } from "../.."; 3 | 4 | export type Instance = Multicall2Ethers; 5 | const Factory = Multicall2Ethers__factory; 6 | 7 | export function connect(address: string, provider: SignerOrProvider): Instance { 8 | return Factory.connect(address, provider); 9 | } 10 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/multicall2/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/optimisticOracle/client.e2e.ts: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | import assert from "assert"; 3 | import * as Client from "./client"; 4 | import { ethers } from "ethers"; 5 | 6 | const address = "0xc43767f4592df265b4a9f1a398b97ff24f38c6a6"; 7 | // these require integration testing, skip for ci 8 | describe("OptimisticOracle", function () { 9 | let client: Client.Instance; 10 | test("inits", function () { 11 | const provider = ethers.providers.getDefaultProvider(process.env.CUSTOM_NODE_URL); 12 | client = Client.connect(address, provider); 13 | assert.ok(client); 14 | }); 15 | test("getEventState", async function () { 16 | const events = await client.queryFilter({}); 17 | const state = await Client.getEventState(events); 18 | assert.ok(Object.values(state.requests || {}).length > 0); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/optimisticOracle/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/optimisticOracleV2/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/rateModelStore/README.md: -------------------------------------------------------------------------------- 1 | # UMA SDK Rate Model Store Client 2 | 3 | ## Usage 4 | 5 | Connect to a typechain contract instance and recreate state from events. 6 | 7 | ```js 8 | import {ethers} from 'ethers' 9 | import * as uma from '@uma/sdk' 10 | 11 | // assume you have a url injected from env 12 | const provider = new ethers.providers.WebSocketProvider(env.CUSTOM_NODE_URL) 13 | 14 | // get the contract instance 15 | const contractAddress:string = 0x... 16 | const client:uma.clients.rateModelStore.Instance = uma.clients.rateModelStore.connect(contractAddress,provider) 17 | // gets all events using etheres query filter api 18 | const events = await client.queryFilter({}) 19 | 20 | ``` 21 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/rateModelStore/client.ts: -------------------------------------------------------------------------------- 1 | import { 2 | RateModelStoreEthers, 3 | RateModelStoreEthers__factory, 4 | getRateModelStoreAddress as getAddress, 5 | } from "@uma/contracts-node"; 6 | import type { SignerOrProvider } from "../.."; 7 | 8 | export type Instance = RateModelStoreEthers; 9 | export const Factory = RateModelStoreEthers__factory; 10 | 11 | export { getAddress }; 12 | 13 | export function connect(address: string, provider: SignerOrProvider): Instance { 14 | return Factory.connect(address, provider); 15 | } 16 | export function attach(address: string): Instance { 17 | return new Factory().attach(address); 18 | } 19 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/rateModelStore/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/registry/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/skinnyOptimisticOracle/client.e2e.ts: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | import assert from "assert"; 3 | import * as Client from "./client"; 4 | import { ethers } from "ethers"; 5 | 6 | const address = "0xeE3Afe347D5C74317041E2618C49534dAf887c24"; 7 | // these require integration testing, skip for ci 8 | describe("SkinnyOptimisticOracle", function () { 9 | let client: Client.Instance; 10 | test("inits", function () { 11 | const provider = ethers.providers.getDefaultProvider(process.env.CUSTOM_NODE_URL); 12 | client = Client.connect(address, provider); 13 | assert.ok(client); 14 | }); 15 | test("getEventState", async function () { 16 | const events = await client.queryFilter({}); 17 | const state = await Client.getEventState(events); 18 | assert.ok(Object.values(state.requests || {}).length > 0); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/sdk/src/clients/skinnyOptimisticOracle/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/coingecko/README.md: -------------------------------------------------------------------------------- 1 | # UMA SDK - Coingecko 2 | 3 | Small class to interface with various coingecko calls. Add more calls if needed. Coingecko docs [here](https://www.coingecko.com/en/api#explore-api). 4 | 5 | ## Usage 6 | 7 | ```js 8 | import * as uma from "@sdk/uma" 9 | 10 | const coingecko = new uma.Coingecko() 11 | 12 | // erc20 token address for UMA 13 | const address = "0x04fa0d235c4abf4bcf4787af4cf447de572ef828" 14 | 15 | // returns a tuple of latest timestamp/price 16 | const [timestamp, price] = await coingecko.getCurrentPriceByContract(address) 17 | 18 | // returns detailed info from coingecko about this contract 19 | const details = await coingecko.getContractDetails(address) 20 | 21 | // get historical price information on contract from 10 minutes ago 22 | const historicalPrices = await coingecko.getHistoricContractPrices(address, Date.now() - 1000 * 60 * 10, Date.now()) 23 | ``` 24 | -------------------------------------------------------------------------------- /packages/sdk/src/coingecko/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./coingecko"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/index.ts: -------------------------------------------------------------------------------- 1 | export * as client from "./client"; 2 | export * as services from "./services"; 3 | export * as types from "./types"; 4 | export * as store from "./store"; 5 | export * as utils from "./utils"; 6 | export * as errors from "./errors"; 7 | export { default as skinnyFactory } from "./skinnyFactory"; 8 | export { default as optimisticFactory } from "./optimisticFactory"; 9 | export { default as factory } from "./factory"; 10 | export { default as optimisticV2Factory } from "./optimisticV2Factory"; 11 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/optimisticFactory.ts: -------------------------------------------------------------------------------- 1 | import { Client, factory } from "./client"; 2 | import { OptimisticOracle } from "./services/optimisticOracle"; 3 | import { SortedRequests } from "./services/sortedRequests"; 4 | import { DefaultConfig, getMulticall2Address } from "./utils"; 5 | import { state } from "./types"; 6 | import { Emit } from "./store"; 7 | 8 | export default ( 9 | config: state.PartialConfig, 10 | emit: Emit, 11 | sortedRequests: SortedRequests = new SortedRequests() 12 | ): Client => { 13 | const fullConfig = DefaultConfig({ 14 | getMulticall2Address, 15 | })({ ...config }, state.OracleType.Optimistic); 16 | return factory(fullConfig, emit, OptimisticOracle, sortedRequests); 17 | }; 18 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/optimisticV2Factory.ts: -------------------------------------------------------------------------------- 1 | import { Client, factory } from "./client"; 2 | import { OptimisticOracleV2 } from "./services/optimisticOracleV2"; 3 | import { SortedRequests } from "./services/sortedRequests"; 4 | import { DefaultConfig, getMulticall2Address } from "./utils"; 5 | import { state } from "./types"; 6 | import { Emit } from "./store"; 7 | 8 | export default ( 9 | config: state.PartialConfig, 10 | emit: Emit, 11 | sortedRequests: SortedRequests = new SortedRequests() 12 | ): Client => { 13 | const fullConfig = DefaultConfig({ 14 | getMulticall2Address, 15 | })({ ...config }, state.OracleType.OptimisticV2); 16 | return factory(fullConfig, emit, OptimisticOracleV2, sortedRequests); 17 | }; 18 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/services/index.ts: -------------------------------------------------------------------------------- 1 | export * as erc20 from "./erc20"; 2 | export * as optimisticOracle from "./optimisticOracle"; 3 | export * as statemachines from "./statemachines"; 4 | export * as sortedRequests from "./sortedRequests"; 5 | export * as skinnyOptimisticOracle from "./skinnyOptimisticOracle"; 6 | export * as optimisticOracleV2 from "./optimisticOracleV2"; 7 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/services/statemachines/clearUser.ts: -------------------------------------------------------------------------------- 1 | import Store from "../../store"; 2 | import { Handlers as GenericHandlers } from "../../types/statemachine"; 3 | 4 | // require exports for a new context handler 5 | export type Params = undefined; 6 | export type Memory = undefined; 7 | 8 | export function initMemory(): Memory { 9 | return undefined; 10 | } 11 | 12 | export function Handlers(store: Store): GenericHandlers { 13 | return { 14 | async start() { 15 | store.write((write) => { 16 | write.inputs().user().clear(); 17 | }); 18 | return "done"; 19 | }, 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/services/statemachines/index.ts: -------------------------------------------------------------------------------- 1 | export * as setUser from "./setUser"; 2 | export * as clearUser from "./clearUser"; 3 | export * as setActiveRequest from "./setActiveRequest"; 4 | export * as approve from "./approve"; 5 | export * as disputePrice from "./disputePrice"; 6 | export * as proposePrice from "./proposePrice"; 7 | export * as switchOrAddChain from "./switchOrAddChain"; 8 | export * as pollActiveRequest from "./pollActiveRequest"; 9 | export * as fetchPastEvents from "./fetchPastEvents"; 10 | export * as pollNewEvents from "./pollNewEvents"; 11 | export * as setActiveRequestByTransaction from "./setActiveRequestByTransaction"; 12 | export * as settle from "./settle"; 13 | export * as fetchEventBased from "./fetchEventBased"; 14 | 15 | export * from "./statemachine"; 16 | export * from "./utils"; 17 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/services/statemachines/setActiveRequest.ts: -------------------------------------------------------------------------------- 1 | import Store from "../../store"; 2 | import { Inputs } from "../../types/state"; 3 | import { Handlers as GenericHandlers } from "../../types/statemachine"; 4 | 5 | // required exports for state machine 6 | export type Params = Inputs["request"]; 7 | export type Memory = undefined; 8 | export function initMemory(): Memory { 9 | return undefined; 10 | } 11 | export function Handlers(store: Store): GenericHandlers { 12 | return { 13 | async start(params: Params) { 14 | store.write((write) => write.inputs().request(params)); 15 | return "done"; 16 | }, 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/skinnyFactory.ts: -------------------------------------------------------------------------------- 1 | import { Client, factory } from "./client"; 2 | import { SkinnyOptimisticOracle } from "./services/skinnyOptimisticOracle"; 3 | import { SortedRequests } from "./services/sortedRequests"; 4 | import { DefaultConfig, getMulticall2Address } from "./utils"; 5 | import { state } from "./types"; 6 | import { Emit } from "./store"; 7 | 8 | export default ( 9 | config: state.PartialConfig, 10 | emit: Emit, 11 | sortedRequests: SortedRequests = new SortedRequests() 12 | ): Client => { 13 | const fullConfig = DefaultConfig({ 14 | getMulticall2Address, 15 | })({ ...config }, state.OracleType.Skinny); 16 | return factory(fullConfig, emit, SkinnyOptimisticOracle, sortedRequests); 17 | }; 18 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/types/ethers.ts: -------------------------------------------------------------------------------- 1 | import type { Event } from "ethers"; 2 | import type { Interface } from "@ethersproject/abi"; 3 | 4 | export type { Signer, BigNumber, BigNumberish, Contract } from "ethers"; 5 | export type { Overrides } from "@ethersproject/contracts"; 6 | export { Provider, JsonRpcSigner, JsonRpcProvider, Web3Provider, FallbackProvider } from "@ethersproject/providers"; 7 | export { TransactionRequest, TransactionReceipt, TransactionResponse } from "@ethersproject/abstract-provider"; 8 | export type { Log } from "@ethersproject/abstract-provider"; 9 | export type { Event, Interface }; 10 | 11 | export type SerializableEvent = Omit< 12 | Event, 13 | "decode" | "removeListener" | "getBlock" | "getTransaction" | "getTransactionReceipt" 14 | >; 15 | 16 | // taken from ethers code https://github.com/ethers-io/ethers.js/blob/master/packages/abi/src.ts/interface.ts#L654 17 | export type ParsedLog = ReturnType; 18 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/types/index.ts: -------------------------------------------------------------------------------- 1 | export * as state from "./state"; 2 | export * as ethers from "./ethers"; 3 | export * as misc from "./misc"; 4 | export * as statemachine from "./statemachine"; 5 | export * as interfaces from "./interfaces"; 6 | -------------------------------------------------------------------------------- /packages/sdk/src/oracle/types/misc.ts: -------------------------------------------------------------------------------- 1 | import { BatchReadWithErrors } from "../../utils"; 2 | export type BatchReadWithErrorsType = ReturnType>; 3 | -------------------------------------------------------------------------------- /packages/sdk/src/stores/google-datastore/README.md: -------------------------------------------------------------------------------- 1 | # Google Datastore Store 2 | 3 | This store wraps the google-cloud/datastore client to match the store interface. 4 | 5 | ## Usage 6 | 7 | See [tests](./store.test.ts) for more example usage. 8 | 9 | ```js 10 | import uma from "@uma/sdk" 11 | const Store = uma.stores.GoogleDatastore 12 | type Data = { 13 | name: string, 14 | age: number, 15 | } 16 | const datastore = new Datastore() 17 | 18 | // create a store that accepts a Data value 19 | const store = Store < Data > ("users", datastore) 20 | 21 | await store.set("john", { name: "john", age: 23 }) 22 | 23 | console.log(await store.has("john")) // true 24 | console.log(await store.has("larry")) // false 25 | console.log(await store.get("john")) // {name:'john',age:23} 26 | console.log(await store.delete("john")) 27 | console.log(await store.has("john")) // false 28 | ``` 29 | -------------------------------------------------------------------------------- /packages/sdk/src/stores/google-datastore/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./store"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/stores/js-map/README.md: -------------------------------------------------------------------------------- 1 | # JS Map Store 2 | 3 | This store is a simple cache which wraps an underlying Map. All stores functions are async, unlike a map. 4 | 5 | ## Usage 6 | 7 | See [tests](./store.test.ts) for more example usage. 8 | 9 | ```js 10 | import uma from '@uma/sdk' 11 | const Store = uma.stores.JsMap 12 | // create a store that accepts a string key and string value 13 | const store = Store() 14 | await store.set('a','b') 15 | console.log(await store.has('a')) // true 16 | console.log(await store.has('b')) // false 17 | console.log(await store.get('a')) // 'b' 18 | console.log(await store.delete('b')) 19 | console.log(await store.has('a')) // false 20 | 21 | // initialize store with a pre warmed map 22 | const map = new Map(['a','b']) 23 | const store = Store(map) 24 | console.log(await store.has('a')) // true 25 | ``` 26 | -------------------------------------------------------------------------------- /packages/sdk/src/stores/js-map/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./store"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/stores/js-map/store.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import Store from "."; 3 | import type { Store as StoreType } from ".."; 4 | 5 | describe("map store", function () { 6 | let store: StoreType; 7 | test("init", function () { 8 | store = Store(); 9 | assert.ok(store); 10 | }); 11 | test("set", async function () { 12 | await store.set("a", "a"); 13 | }); 14 | test("get", async function () { 15 | const result = await store.get("a"); 16 | assert.equal(result, "a"); 17 | }); 18 | test("has", async function () { 19 | const result = await store.has("a"); 20 | assert.equal(result, true); 21 | }); 22 | test("delete", async function () { 23 | await store.delete("a"); 24 | const result = await store.has("a"); 25 | assert.equal(result, false); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /packages/sdk/src/stores/sorted-js-map/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./store"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/base/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from "./table"; 2 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/base/table.test.ts: -------------------------------------------------------------------------------- 1 | import Table from "."; 2 | import { default as JsMapStore } from "../../stores/js-map"; 3 | import assert from "assert"; 4 | import type { Store } from "../../stores"; 5 | 6 | type D = { 7 | id: string; 8 | [key: string]: string; 9 | }; 10 | describe("basic table", function () { 11 | let table: any; 12 | let store: any; 13 | test("init", function () { 14 | store = JsMapStore(); 15 | table = Table>({ makeId: (x: D) => x.id, type: "test" }, store); 16 | assert.ok(table); 17 | }); 18 | test("create", async function () { 19 | const data: D = { id: "s", optional: "yes" }; 20 | const result = await table.create(data); 21 | assert.deepEqual(result, data); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/blocks/README.md: -------------------------------------------------------------------------------- 1 | # Blocks Table 2 | 3 | Defines an ethereum block type and returns a base table typed to that. Currently exposes a js-map compatible table. 4 | 5 | ## Usage 6 | 7 | See [tests](./js-map.test.ts) for more example usage. 8 | 9 | ```js 10 | import { stores, tables } from "@uma/sdk" 11 | const Table = tables.blocks.Table 12 | 13 | const table = tables.blocks.Table() 14 | type Data = tables.blocks.Data 15 | 16 | const entry: Data = { number: "100" } 17 | const result: Data = await tables.create(entry) 18 | ``` 19 | 20 | ## Types 21 | 22 | Found in [utils.ts](./utils.ts) 23 | 24 | ```js 25 | import type * as uma from "@uma/sdk"; 26 | type Block = uma.tables.blocks.Data; 27 | ``` 28 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/blocks/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/blocks/utils.ts: -------------------------------------------------------------------------------- 1 | export function makeId(data: Pick) { 2 | return data.number; 3 | } 4 | 5 | export type Data = { 6 | id?: number; 7 | number: number; 8 | hash: string; 9 | // block time is in seconds 10 | timestamp: number; 11 | }; 12 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/emps/README.md: -------------------------------------------------------------------------------- 1 | # UMA Sdk EMP Table 2 | 3 | This table is meant to store emp state data. It will use typescript to ensure you supply valid data. 4 | 5 | ## Usage 6 | 7 | ```js 8 | import { stores, tables } from '@uma/sdk' 9 | const empTable:table.emps.Table = tables.emps.Table() 10 | 11 | const data:table.emps.Data = await empTable.create({ 12 | address:// ...emp address 13 | }) 14 | // returns data = { id:address, address } 15 | ``` 16 | 17 | ## Types 18 | 19 | Found in [utils.ts](./utils.ts) 20 | 21 | ```js 22 | import type * as uma from "@uma/sdk"; 23 | type Emp = uma.tables.emps.Data; 24 | ``` 25 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/emps/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/emps/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("emp js-map", function () { 5 | let table: Table; 6 | test("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | test("create", async function () { 11 | const result = await table.create({ 12 | address: "a", 13 | }); 14 | assert.ok(result.id); 15 | await table.create({ 16 | address: "b", 17 | }); 18 | assert.ok(result.id); 19 | }); 20 | test("values", async function () { 21 | const result = await table.values(); 22 | assert.equal(result.length, 2); 23 | }); 24 | test("addSponsors", async function () { 25 | const result = await table.addSponsors("a", ["a", "b", "c", "a"]); 26 | assert.ok(result.sponsors); 27 | // one dupe, so 3 total 28 | assert.equal(result.sponsors.length, 3); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/erc20s/README.md: -------------------------------------------------------------------------------- 1 | # Erc20 Table 2 | 3 | Stores basic information for erc20 tokens, keyed by token address. 4 | 5 | ## Usage 6 | 7 | See [tests](./js-map.test.ts) for more example usage. 8 | 9 | ```js 10 | import { stores, tables } from "@uma/sdk" 11 | 12 | const table = tables.erc20s.Table() 13 | type Data = tables.erc20s.Data 14 | 15 | const entry: Data = { address: "0xeca82185adCE47f39c684352B0439f030f860318" } 16 | const result: Data = await tables.create(entry) 17 | ``` 18 | 19 | ## Types 20 | 21 | Found in [utils.ts](./utils.ts) 22 | 23 | ```js 24 | import type * as uma from "@uma/sdk"; 25 | type Erc20Type = uma.tables.erc20s.Data; 26 | ``` 27 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/erc20s/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/erc20s/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table } from "."; 3 | 4 | describe("block map table", function () { 5 | let table: any; 6 | test("init", function () { 7 | table = Table(); 8 | assert.ok(table); 9 | }); 10 | test("create", async function () { 11 | const token = { 12 | address: "a", 13 | }; 14 | const result = await table.getOrCreate(token.address); 15 | assert.equal(result.id, token.address); 16 | }); 17 | test("upsert", async function () { 18 | const address = "b"; 19 | const update = { 20 | name: "tokenb", 21 | }; 22 | const result = await table.upsert(address, update); 23 | assert.equal(result.id, address); 24 | assert.equal(result.name, update.name); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/erc20s/table.ts: -------------------------------------------------------------------------------- 1 | import { Data, makeId } from "./utils"; 2 | import BaseTable from "../base"; 3 | import { JsMap } from "../../stores"; 4 | import type { Store } from "../../stores"; 5 | 6 | export const Table = (type = "Token", store: Store = JsMap()) => { 7 | const table = BaseTable>({ type, makeId }, store); 8 | async function getOrCreate(address: string) { 9 | if (!(await table.has(makeId({ address })))) return table.create({ address }); 10 | return table.get(makeId({ address })); 11 | } 12 | async function upsert(address: string, data: Partial) { 13 | await getOrCreate(address); 14 | return table.update(address, data); 15 | } 16 | return { 17 | ...table, 18 | getOrCreate, 19 | upsert, 20 | }; 21 | }; 22 | export type Table = ReturnType; 23 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/erc20s/utils.ts: -------------------------------------------------------------------------------- 1 | export function makeId(data: Pick) { 2 | return data.address; 3 | } 4 | 5 | export type Data = { 6 | id?: string; 7 | address: string; 8 | decimals?: number; 9 | name?: string; 10 | totalSupply?: string; 11 | symbol?: string; 12 | }; 13 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/historical-prices/index.ts: -------------------------------------------------------------------------------- 1 | export { Table } from "./table"; 2 | export * from "./utils"; 3 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/historical-prices/table.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { Table, makeId } from "."; 3 | 4 | const data = { 5 | timestamp: 10, 6 | price: "100", 7 | }; 8 | describe("block map table", function () { 9 | let table: any; 10 | test("init", function () { 11 | table = Table(); 12 | assert.ok(table); 13 | }); 14 | test("create", async function () { 15 | const result = await table.create(data); 16 | assert.equal(result.id, makeId(data)); 17 | }); 18 | test("has", async function () { 19 | let has = await table.has(makeId(data)); 20 | assert.ok(has); 21 | has = await table.has(1); 22 | assert.ok(!has); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/historical-prices/utils.ts: -------------------------------------------------------------------------------- 1 | export function makeId(data: Pick) { 2 | return data.timestamp.toString().padStart(24, "0"); 3 | } 4 | 5 | export type Data = { 6 | id?: string; 7 | timestamp: number; 8 | price: string; 9 | }; 10 | -------------------------------------------------------------------------------- /packages/sdk/src/tables/index.ts: -------------------------------------------------------------------------------- 1 | export { default as base } from "./base"; 2 | export * as blocks from "./blocks"; 3 | export * as emps from "./emps"; 4 | export * as historicalPrices from "./historical-prices"; 5 | export * as erc20s from "./erc20s"; 6 | -------------------------------------------------------------------------------- /packages/sdk/src/types.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace NodeJS { 2 | export interface Process { 3 | envType: string; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/sdk/templates/index.d.ts: -------------------------------------------------------------------------------- 1 | // file copied into dis folders 2 | export * from "../types"; 3 | -------------------------------------------------------------------------------- /packages/sdk/tsdx.config.js: -------------------------------------------------------------------------------- 1 | const replace = require("@rollup/plugin-replace"); 2 | const envType = process.env.ENV_TYPE; 3 | 4 | module.exports = { 5 | rollup(config) { 6 | // removes the esm prefix -> that just makes importing the module more difficult 7 | config.output.file = config.output.file.replace(".esm", ""); 8 | 9 | if (envType == "web") 10 | // unshift so that this plugin gets run first 11 | config.plugins.unshift( 12 | replace({ 13 | "@uma/contracts-node": "@uma/contracts-frontend", 14 | // its important to have this, otherwise string wont be replaced 15 | delimiters: ["", ""], 16 | }) 17 | ); 18 | return config; 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /packages/serverless-orchestration/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | timeout: 100000, 3 | exit: true, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/serverless-orchestration/README.md: -------------------------------------------------------------------------------- 1 | # @uma/serverless-orchestration 2 | 3 | This package contains scripts that enable bots to be run in a serverless fashion. 4 | 5 | ## Orchestration scripts 6 | 7 | The two serverless orchestration scripts are: 8 | 9 | 1. The `ServerlessHub` script which reads in a global configuration file stored and executes parallel serverless instances for each configured bot. This enables one global config file to define all bot instances. This drastically simplifying the devops and management overhead for spinning up new instances as this can be done by simply updating a single config file. 10 | 11 | 1. The `ServerlessSpoke` script which enables serverless functions to execute any arbitrary command from the UMA Docker container. This can be run on a local machine, within GCP cloud run or GCP cloud function environments. 12 | -------------------------------------------------------------------------------- /packages/serverless-orchestration/hardhat.config.js: -------------------------------------------------------------------------------- 1 | const { getHardhatConfig } = require("@uma/common"); 2 | 3 | const path = require("path"); 4 | const coreWkdir = path.dirname(require.resolve("@uma/core/package.json")); 5 | const packageWkdir = path.dirname(require.resolve("@uma/financial-templates-lib/package.json")); 6 | 7 | const configOverride = { 8 | paths: { 9 | root: coreWkdir, 10 | sources: `${coreWkdir}/contracts`, 11 | artifacts: `${coreWkdir}/artifacts`, 12 | cache: `${coreWkdir}/cache`, 13 | tests: `${packageWkdir}/test`, 14 | }, 15 | }; 16 | 17 | module.exports = getHardhatConfig(configOverride, coreWkdir); 18 | -------------------------------------------------------------------------------- /packages/serverless-orchestration/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { ...require("./src/ServerlessHub"), ...require("./src/ServerlessSpoke") }; 2 | -------------------------------------------------------------------------------- /packages/serverless-orchestration/test-helpers/TimeoutSpokeMock.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const timeoutSpoke = express(); 3 | timeoutSpoke.use(express.json()); // Enables json to be parsed by the express process. 4 | 5 | const { delay } = require("@uma/financial-templates-lib"); 6 | 7 | let responseDelay; 8 | 9 | timeoutSpoke.post("/", async (req, res) => { 10 | console.log("inbound delay call...waiting"); 11 | await delay(responseDelay); 12 | res.status(200).send({ message: `returned after ${responseDelay}` }); 13 | }); 14 | async function Poll(port = 8080, _responseDelay = 5) { 15 | responseDelay = _responseDelay; 16 | return timeoutSpoke.listen(port, () => { 17 | console.log(`timeout timeoutSpoke mock with ${responseDelay} responseDelay listening...`); 18 | }); 19 | } 20 | timeoutSpoke.Poll = Poll; 21 | module.exports = timeoutSpoke; 22 | -------------------------------------------------------------------------------- /packages/serverless-orchestration/test-helpers/TimeoutSpokeProcess.js: -------------------------------------------------------------------------------- 1 | // script the sleeps for a defined duration then closes. Can be used to debug hub/spoke interactions. 2 | const { delay } = require("@uma/financial-templates-lib"); 3 | 4 | async function Run() { 5 | console.log("Running timeoutsimulatedSpoke"); 6 | await delay(70); 7 | console.log("Done & closing"); 8 | } 9 | 10 | Run().then(() => {}); 11 | -------------------------------------------------------------------------------- /scripts/bot-deployment/PushBotConfigs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ $# -ne 1 ]; then 5 | echo "Incorrect number of arguments supplied! Expect directory containing configs to push" 6 | echo "example: ./PushBotConfigs.sh ./configs/" 7 | exit 1 8 | fi 9 | 10 | gsutil cp $1/*.env gs://bot-configs/ -------------------------------------------------------------------------------- /scripts/bot-deployment/RetrieveBotConfigs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ $# -ne 1 ]; then 5 | echo "Incorrect number of arguments supplied! Expect destination directory for bot config files" 6 | echo "example: ./RetrieveBotConfigs.sh ./" 7 | exit 1 8 | fi 9 | 10 | gsutil cp gs://bot-configs/* $1/ -------------------------------------------------------------------------------- /scripts/runCommand.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Simple script that simply runs a command input as an environment variable. This is used to allow the docker image to 4 | # run arbitrary commands by specifying them in the environment rather than the docker run command. Optionally, specify 5 | # UMA_PACKAGE as an ENV which lets you navigate to additional base packages installed within the container. 6 | if [ -z ${UMA_PACKAGE+x} ]; then $COMMAND; else cd ../${UMA_PACKAGE} && $COMMAND; fi 7 | --------------------------------------------------------------------------------