├── .solhintignore ├── .eslintignore ├── .gitattributes ├── requirements-dev.txt ├── packages ├── contracts-watr │ ├── .env.deploy.example │ ├── test │ │ ├── utils │ │ │ ├── index.ts │ │ │ ├── parseTrueUSD.ts │ │ │ └── timeTravel.ts │ │ └── fixtures │ │ │ └── beforeEachWithFixture.ts │ ├── .env.test.example │ ├── .gitignore │ ├── scripts │ │ └── deployment │ │ │ ├── deploy.ts │ │ │ └── deployRegistry.ts │ ├── .compiler.json │ ├── contracts │ │ ├── interface │ │ │ ├── IRegistry.sol │ │ │ ├── IClaimableOwnable.sol │ │ │ ├── IOwnedUpgradeabilityProxy.sol │ │ │ ├── IMintableXC20.sol │ │ │ ├── ITrueCurrency.sol │ │ │ └── IProofOfReserveToken.sol │ │ ├── test │ │ │ └── IRegistryClone.sol │ │ ├── mocks │ │ │ ├── RegistryMock.sol │ │ │ ├── ForceEther.sol │ │ │ └── MockTrueCurrency.sol │ │ └── tokens │ │ │ └── TrueUSD.sol │ ├── .mocharc.json │ ├── .waffle.json │ ├── hardhat.config.ts │ └── tsconfig.json ├── contracts-bsc │ ├── .gitignore │ ├── .compiler.json │ ├── contracts │ │ ├── interface │ │ │ ├── IRegistry.sol │ │ │ ├── IClaimableOwnable.sol │ │ │ ├── IOwnedUpgradeabilityProxy.sol │ │ │ ├── ITrueCurrency.sol │ │ │ └── IProofOfReserveToken.sol │ │ ├── test │ │ │ └── IRegistryClone.sol │ │ └── mocks │ │ │ ├── ForceEther.sol │ │ │ ├── RegistryMock.sol │ │ │ └── MockTrueCurrency.sol │ ├── .mocharc.json │ ├── test │ │ ├── utils │ │ │ └── timeTravel.ts │ │ └── fixtures │ │ │ └── beforeEachWithFixture.ts │ ├── .waffle.json │ ├── hardhat.config.ts │ ├── deployments.json │ └── tsconfig.json └── contracts-por │ ├── .gitignore │ ├── .compiler.json │ ├── contracts │ ├── interface │ │ ├── IRegistry.sol │ │ ├── IOwnedUpgradeabilityProxy.sol │ │ ├── ITrueCurrency.sol │ │ └── IProofOfReserveToken.sol │ ├── test │ │ └── IRegistryClone.sol │ ├── mocks │ │ ├── ForceEther.sol │ │ ├── RegistryMock.sol │ │ └── MockTrueCurrency.sol │ └── tokens │ │ └── TrueUSD.sol │ ├── .mocharc.json │ ├── test │ ├── utils │ │ └── timeTravel.ts │ └── fixtures │ │ └── beforeEachWithFixture.ts │ ├── .waffle.json │ ├── hardhat.config.ts │ ├── deployments.json │ └── tsconfig.json ├── docs ├── true-gold │ ├── mocks │ │ ├── OwnableMock.md │ │ └── ERC20Mock.md │ ├── common │ │ ├── ProxyStorage.md │ │ ├── ERC20Burnable.md │ │ └── Initializable.md │ ├── interface │ │ └── IOwnable.md │ ├── Reclaimable.md │ ├── TrueGold.md │ ├── PausedTrueGold.md │ └── TrueMintableBurnable.md ├── governance │ ├── interface │ │ ├── IVoteTokenWithERC20.md │ │ ├── IVoteToken.md │ │ └── IStkTruToken.md │ ├── common │ │ └── ProxyStorage.md │ └── mocks │ │ ├── MockPauseableContract.md │ │ └── MockTimeLock.md ├── registry │ ├── mocks │ │ ├── ProvisionalRegistryMock.md │ │ ├── RegistryMock.md │ │ ├── MockRegistrySubscriber.md │ │ └── ProvisionalRegistry.md │ └── interface │ │ ├── IRegistryClone.md │ │ └── IHasOwner.md ├── true-currencies │ ├── interface │ │ ├── IHook.md │ │ ├── IHasOwner.md │ │ ├── IReclaimerToken.md │ │ └── ITrueCurrency.md │ ├── mocks │ │ ├── MockHook.md │ │ ├── MockTrueUSD.md │ │ ├── TokenFaucet.md │ │ ├── ForceEther.md │ │ ├── MockGasRefundToken.md │ │ ├── TokenControllerPauseMock.md │ │ ├── TokenControllerMock.md │ │ ├── MockTrueCurrency.md │ │ ├── MockTrueCurrencyWithAutosweep.md │ │ ├── MockTrueCurrencyWithGasRefund.md │ │ └── IDelegateERC20.md │ ├── TrueCurrencyWithGasRefund.md │ ├── common │ │ ├── ProxyStorage.md │ │ ├── ReclaimerToken.md │ │ ├── GasRefund.md │ │ └── ClaimableOwnable.md │ └── tokens │ │ ├── TrueCAD.md │ │ ├── TrueGBP.md │ │ ├── TrueHKD.md │ │ ├── TrueUSD.md │ │ └── TrueAUD.md ├── truefi │ ├── mocks │ │ ├── MockLog.md │ │ ├── MockCurveGauge.md │ │ ├── MockYToken.md │ │ ├── MockLoanFactory.md │ │ ├── MockTrueLender.md │ │ ├── PoolArbitrageTest.md │ │ ├── MockCrvPriceOracle.md │ │ ├── MockTruPriceOracle.md │ │ ├── MockCurve.md │ │ ├── MockStakingPool.md │ │ ├── TestTrueFiPool.md │ │ └── MockCurvePool.md │ ├── IChainLink.md │ ├── interface │ │ ├── IYToken.md │ │ ├── IMockTruPriceOracle.md │ │ ├── IUniswapPair.md │ │ ├── ICurveMinter.md │ │ ├── ICrvPriceOracle.md │ │ ├── ITruPriceOracle.md │ │ ├── ICurve.md │ │ ├── ITrueLender.md │ │ ├── IUniswapRouter.md │ │ ├── ILoanFactory.md │ │ ├── IStakingPool.md │ │ ├── ICurveGauge.md │ │ ├── ISushiswapRewarder.md │ │ ├── ITrueDistributor.md │ │ ├── IArbitraryDistributor.md │ │ ├── ITrueRatingAgencyV2.md │ │ ├── ITrueRatingAgency.md │ │ ├── ICurvePool.md │ │ ├── ITrueFarm.md │ │ └── ITrueFiPool.md │ ├── TruPriceChainLinkOracle.md │ ├── common │ │ └── Initializable.md │ ├── TruSushiswapRewarder.md │ ├── LoanFactory.md │ ├── ABDKMath64x64.md │ └── CrvPriceOracle.md ├── proxy │ ├── mocks │ │ └── StringReturn.md │ ├── interface │ │ ├── IImplementationReference.md │ │ └── IOwnedUpgradeabilityProxy.md │ ├── ImplementationReference.md │ └── TimeOwnedUpgradeabilityProxy.md ├── truefi2 │ ├── mocks │ │ ├── MockUsdc.md │ │ ├── MintableErc20.md │ │ ├── TestTimeAveragedBaseRateOracle.md │ │ ├── MockUsdStableCoinOracle.md │ │ ├── PowTest.md │ │ ├── TestDeficiencyToken.md │ │ ├── TestTrueLender.md │ │ ├── Mock1InchV3.md │ │ ├── MockStrategy.md │ │ ├── TestCurveStrategy.md │ │ ├── MockTrueFiPoolOracle.md │ │ └── BadStrategy.md │ ├── interface │ │ ├── ILoanFactory2.md │ │ ├── IPoolFactory.md │ │ ├── IERC20WithDecimals.md │ │ ├── ILiquidator2.md │ │ ├── ITrueCreditAgency.md │ │ ├── ILoanFactory3.md │ │ ├── IDeficiencyToken.md │ │ ├── ISAFU.md │ │ ├── ITrueFiCreditOracle.md │ │ ├── I1Inch3.md │ │ ├── ITrueLender2.md │ │ ├── ITimeAveragedBaseRateOracle.md │ │ ├── IAaveLendingPool.md │ │ ├── ITrueMultiFarm.md │ │ ├── ITrueFiPoolOracle.md │ │ └── ITrueStrategy.md │ ├── ITrueFiPool2WithDecimals.md │ ├── libraries │ │ ├── IUniRouter.md │ │ └── OneInchExchange.md │ ├── oracles │ │ └── ChainlinkTruUsdcOracle.md │ ├── PoolExtensions.md │ ├── DeficiencyToken.md │ └── SpotBaseRateOracle.md ├── trusttoken │ ├── interface │ │ └── IBurnableERC20.md │ ├── common │ │ ├── ProxyStorage.md │ │ └── TruProxyStorage.md │ ├── mocks │ │ ├── TestUSDCToken.md │ │ ├── TestUSDTToken.md │ │ ├── MockERC20Token.md │ │ └── TestTrustToken.md │ └── TrustToken.md ├── common │ ├── interface │ │ └── IPauseableContract.md │ └── Initializable.md └── avalanche │ └── AvalancheTrueUSD.md ├── test ├── utils │ ├── toHex.ts │ ├── parseTRU.ts │ ├── parseUSDC.ts │ ├── parseEth.ts │ ├── chai.d.ts │ ├── toAddress.ts │ ├── constants.ts │ ├── index.ts │ ├── updateRateOracle.ts │ └── writeAttributeFor.ts ├── integration │ ├── poolExchanges.test.ts │ └── SpotBaseRateOracle.test.ts ├── fixtures │ ├── beforeEachWithFixture.ts │ ├── trueGold.ts │ └── trueCurrency.ts ├── truefi2 │ └── Pow.test.ts ├── truefi │ └── Log.test.ts └── scripts │ └── deployPausedTrueGold.test.ts ├── .prettierignore ├── spec ├── truefi2 │ ├── scripts │ │ ├── BorrowingMutex.sh │ │ ├── RateModel.sh │ │ └── FixedTermLoan.sh │ ├── RateModel.spec │ └── FixedTermLoan.spec └── true-currencies │ └── scripts │ └── TrueUSDWithPoR.sh ├── .mocharc.integration-ci.js ├── contracts ├── true-currencies │ ├── interface │ │ ├── IHook.sol │ │ ├── IHasOwner.sol │ │ ├── IReclaimerToken.sol │ │ └── ITrueCurrency.sol │ ├── mocks │ │ ├── MockHook.sol │ │ ├── MockTrueUSD.sol │ │ ├── TokenFaucet.sol │ │ ├── ForceEther.sol │ │ ├── MockTrueCurrency.sol │ │ ├── MockTrueCurrencyWithGasRefund.sol │ │ └── MockTrueCurrencyWithAutosweep.sol │ ├── TrueCurrencyWithGasRefund.sol │ └── tokens │ │ ├── TrueUSDWithPoR.sol │ │ ├── TrueAUD.sol │ │ ├── TrueCAD.sol │ │ ├── TrueGBP.sol │ │ ├── TrueHKD.sol │ │ └── TrueUSD.sol ├── true-gold │ ├── interface │ │ └── IOwnable.sol │ ├── mocks │ │ ├── OwnableMock.sol │ │ └── ERC20Mock.sol │ └── Reclaimable.sol ├── truefi │ ├── interface │ │ ├── IMockTruPriceOracle.sol │ │ ├── IYToken.sol │ │ ├── ICrvPriceOracle.sol │ │ ├── ITruPriceOracle.sol │ │ ├── ILoanFactory.sol │ │ ├── ITrueLender.sol │ │ ├── IUniswapPair.sol │ │ ├── IUniswapRouter.sol │ │ ├── ITrueRatingAgencyV2.sol │ │ ├── IStakingPool.sol │ │ ├── IArbitraryDistributor.sol │ │ ├── ITrueDistributor.sol │ │ ├── ITrueRatingAgency.sol │ │ ├── ISushiswapRewarder.sol │ │ └── ITrueFarm.sol │ └── mocks │ │ ├── MockCurveGauge.sol │ │ ├── MockLoanFactory.sol │ │ ├── MockTrueLender.sol │ │ ├── MockLog.sol │ │ ├── MockCrvPriceOracle.sol │ │ ├── MockTruPriceOracle.sol │ │ └── MockStakingPool.sol ├── registry │ ├── interface │ │ ├── IHasOwner.sol │ │ └── IRegistryClone.sol │ └── mocks │ │ ├── MockRegistrySubscriber.sol │ │ └── RegistryMock.sol ├── truefi2 │ ├── deprecated │ │ ├── ITrueFiCreditOracleDeprecated.sol │ │ └── ITrueLender2Deprecated.sol │ ├── interface │ │ ├── IERC20WithDecimals.sol │ │ ├── ITruPriceOracle.sol │ │ ├── IFixedTermLoanAgency.sol │ │ ├── ILiquidator2.sol │ │ ├── IPoolFactory.sol │ │ ├── IStakingVault.sol │ │ ├── ITimeAveragedBaseRateOracle.sol │ │ ├── ILineOfCreditAgency.sol │ │ ├── IDeficiencyToken.sol │ │ ├── IBorrowingMutex.sol │ │ ├── ITrueFiCreditOracle.sol │ │ ├── ITrueMultiFarm.sol │ │ ├── IFixedTermLoan.sol │ │ ├── ISAFU.sol │ │ ├── IAaveLendingPool.sol │ │ ├── ITrueFiPoolOracle.sol │ │ ├── ITrueStrategy.sol │ │ ├── IDebtToken.sol │ │ ├── I1Inch3.sol │ │ └── ILoanFactory2.sol │ ├── mocks │ │ ├── TestTrueFiPool2.sol │ │ ├── TestLoanToken.sol │ │ ├── TestTimeAveragedBaseRateOracle.sol │ │ ├── TestTimeAveragedTruPriceOracle.sol │ │ ├── MockUsdc.sol │ │ ├── PowTest.sol │ │ ├── TestDeficiencyToken.sol │ │ ├── TestTrueRatingAgencyV2.sol │ │ ├── MockUsdStableCoinOracle.sol │ │ ├── MockStrategy.sol │ │ ├── MockTrueFiPoolOracle.sol │ │ └── TestCurveStrategy.sol │ ├── oracles │ │ ├── ChainlinkTruBusdOracle.sol │ │ ├── ChainlinkTruTusdOracle.sol │ │ ├── ChainlinkTruUsdcOracle.sol │ │ └── ChainlinkTruUsdtOracle.sol │ └── PoolExtensions.sol ├── proxy │ ├── interface │ │ ├── IImplementationReference.sol │ │ └── IOwnedUpgradeabilityProxy.sol │ └── mocks │ │ └── StringReturn.sol ├── trusttoken │ ├── interface │ │ └── IBurnableERC20.sol │ └── mocks │ │ ├── TestUSDCToken.sol │ │ ├── TestUSDTToken.sol │ │ └── TestBUSDToken.sol ├── common │ └── interface │ │ ├── IPauseableContract.sol │ │ └── IPoRToken.sol ├── governance │ ├── mocks │ │ ├── MockPauseableContract.sol │ │ └── MockTimeLock.sol │ └── interface │ │ ├── IVoteToken.sol │ │ └── IStkTruToken.sol └── avalanche │ └── AvalancheTrueUSD.sol ├── deploy ├── trueUSDNoDelegate.ts ├── avalanche.ts └── config.json ├── scripts ├── utils │ ├── toTrustToken.ts │ ├── waitForTx.ts │ ├── asProxy.ts │ ├── ask.ts │ └── deployContract.ts ├── deployedAddresses │ ├── kovan.json │ ├── mainnet.json │ └── ropsten.json ├── deploy_paused_true_gold.ts └── model │ └── Address.ts ├── slither.config.json ├── .mocharc.json ├── .mocharc.integration.json ├── .waffle.json ├── .prettierrc ├── .gitignore ├── flattenBuild.sh ├── .solhint.json ├── .githooks └── pre-commit ├── runCoverage.sh ├── SECURITY.md ├── .solcover.js ├── .github └── workflows │ └── coverage.yml ├── deployments-unknown.json ├── tsconfig.json ├── hardhat.config.ts ├── LICENSE.md └── indexBuildHardhat.sh /.solhintignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | packages/ 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | slither-analyzer 2 | solc-select 3 | -------------------------------------------------------------------------------- /packages/contracts-watr/.env.deploy.example: -------------------------------------------------------------------------------- 1 | TRUE_USD_ASSET_ID=1983 2 | -------------------------------------------------------------------------------- /docs/true-gold/mocks/OwnableMock.md: -------------------------------------------------------------------------------- 1 | ## `OwnableMock` 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/true-gold/common/ProxyStorage.md: -------------------------------------------------------------------------------- 1 | ## `ProxyStorage` 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/contracts-bsc/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /build 3 | /cache 4 | /flattened_contracts 5 | -------------------------------------------------------------------------------- /packages/contracts-por/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /build 3 | /cache 4 | /flattened_contracts 5 | -------------------------------------------------------------------------------- /test/utils/toHex.ts: -------------------------------------------------------------------------------- 1 | export function toHex (value: string): string { 2 | return '0x' + value 3 | } 4 | -------------------------------------------------------------------------------- /docs/governance/interface/IVoteTokenWithERC20.md: -------------------------------------------------------------------------------- 1 | ## `IVoteTokenWithERC20` 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/contracts-watr/test/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './timeTravel' 2 | export * from './parseTrueUSD' 3 | -------------------------------------------------------------------------------- /docs/registry/mocks/ProvisionalRegistryMock.md: -------------------------------------------------------------------------------- 1 | ## `ProvisionalRegistryMock` 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/contracts-watr/.env.test.example: -------------------------------------------------------------------------------- 1 | # required to run `yarn verify:deployments` 2 | PRIVATE_KEY_DEPLOYER=private_key 3 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | contracts/governance/GovernorAlpha.sol 2 | contracts/governance/Timelock.sol 3 | contracts/governance/VoteToken.sol 4 | -------------------------------------------------------------------------------- /docs/true-currencies/interface/IHook.md: -------------------------------------------------------------------------------- 1 | ## `IHook` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `hook()` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spec/truefi2/scripts/BorrowingMutex.sh: -------------------------------------------------------------------------------- 1 | certoraRun contracts/truefi2/BorrowingMutex.sol \ 2 | --verify BorrowingMutex:spec/truefi2/BorrowingMutex.spec 3 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/MockHook.md: -------------------------------------------------------------------------------- 1 | ## `MockHook` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `hook()` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockLog.md: -------------------------------------------------------------------------------- 1 | ## `MockLog` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `ln(uint256 x) → int128` (public) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/contracts-watr/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /build 3 | /cache 4 | /flattened_contracts 5 | deployments-watr_local.json 6 | .env.test 7 | .env.deploy 8 | -------------------------------------------------------------------------------- /docs/truefi/IChainLink.md: -------------------------------------------------------------------------------- 1 | ## `IChainLink` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `latestAnswer() → int256` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.mocharc.integration-ci.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | ...require('./.mocharc.integration.json'), 5 | grep: /\[Skip CI]/i, 6 | invert: true 7 | } 8 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/MockTrueUSD.md: -------------------------------------------------------------------------------- 1 | ## `MockTrueUSD` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `initialize()` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /contracts/true-currencies/interface/IHook.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IHook { 5 | function hook() external; 6 | } 7 | -------------------------------------------------------------------------------- /docs/truefi/interface/IYToken.md: -------------------------------------------------------------------------------- 1 | ## `IYToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `getPricePerFullShare() → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockCurveGauge.md: -------------------------------------------------------------------------------- 1 | ## `MockCurveGauge` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `minter() → address` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/proxy/mocks/StringReturn.md: -------------------------------------------------------------------------------- 1 | ## `StringReturn` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `reflect(string text) → string` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/TokenFaucet.md: -------------------------------------------------------------------------------- 1 | ## `TokenFaucet` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `faucet(uint256 _amount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockYToken.md: -------------------------------------------------------------------------------- 1 | ## `MockYToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `getPricePerFullShare() → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/MockUsdc.md: -------------------------------------------------------------------------------- 1 | ## `MockUsdc` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `mint(address receiver, uint256 amount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/true-gold/interface/IOwnable.md: -------------------------------------------------------------------------------- 1 | ## `IOwnable` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `transferOwnership(address newOwner)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockLoanFactory.md: -------------------------------------------------------------------------------- 1 | ## `MockLoanFactory` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `setLender(address newLender)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ILoanFactory2.md: -------------------------------------------------------------------------------- 1 | ## `ILoanFactory2` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `isLoanToken(address) → bool` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/interface/IPoolFactory.md: -------------------------------------------------------------------------------- 1 | ## `IPoolFactory` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `isPool(address pool) → bool` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/MintableErc20.md: -------------------------------------------------------------------------------- 1 | ## `MintableErc20` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `mint(address _to, uint256 _value)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/trusttoken/interface/IBurnableERC20.md: -------------------------------------------------------------------------------- 1 | ## `IBurnableERC20` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `burn(uint256 amount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spec/true-currencies/scripts/TrueUSDWithPoR.sh: -------------------------------------------------------------------------------- 1 | certoraRun contracts/true-currencies/tokens/TrueUSDWithPoR.sol \ 2 | --verify TrueUSDWithPoR:spec/true-currencies/TrueUSDWithPoR.spec 3 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/ForceEther.md: -------------------------------------------------------------------------------- 1 | ## `ForceEther` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `destroyAndSend(address _recipient)` (public) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockTrueLender.md: -------------------------------------------------------------------------------- 1 | ## `MockTrueLender` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `setPool(contract ITrueFiPool newPool)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/ITrueFiPool2WithDecimals.md: -------------------------------------------------------------------------------- 1 | ## `ITrueFiPool2WithDecimals` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `decimals() → uint8` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/interface/IERC20WithDecimals.md: -------------------------------------------------------------------------------- 1 | ## `IERC20WithDecimals` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `decimals() → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ILiquidator2.md: -------------------------------------------------------------------------------- 1 | ## `ILiquidator2` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `liquidate(contract ILoanToken2 loan)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi/mocks/PoolArbitrageTest.md: -------------------------------------------------------------------------------- 1 | ## `PoolArbitrageTest` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `joinExit(contract ITrueFiPool pool)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/utils/parseTRU.ts: -------------------------------------------------------------------------------- 1 | import { BigNumberish } from 'ethers' 2 | import { parseEth } from './parseEth' 3 | 4 | export const parseTRU = (amount: BigNumberish) => parseEth(amount).div(10 ** 10) 5 | -------------------------------------------------------------------------------- /test/utils/parseUSDC.ts: -------------------------------------------------------------------------------- 1 | import { BigNumberish } from 'ethers' 2 | import { parseEth } from './parseEth' 3 | 4 | export const parseUSDC = (amount: BigNumberish) => parseEth(amount).div(10 ** 12) 5 | -------------------------------------------------------------------------------- /docs/truefi/interface/IMockTruPriceOracle.md: -------------------------------------------------------------------------------- 1 | ## `IMockTruPriceOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `toTru(uint256 amount) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/contracts-watr/scripts/deployment/deploy.ts: -------------------------------------------------------------------------------- 1 | import { deploy } from 'ethereum-mars' 2 | import { baseDeployment } from './baseDeployment' 3 | 4 | deploy({ verify: false }, baseDeployment) 5 | -------------------------------------------------------------------------------- /test/utils/parseEth.ts: -------------------------------------------------------------------------------- 1 | import { BigNumberish } from 'ethers' 2 | import { parseEther } from 'ethers/lib/utils' 3 | 4 | export const parseEth = (amount: BigNumberish) => parseEther(amount.toString()) 5 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/TestTimeAveragedBaseRateOracle.md: -------------------------------------------------------------------------------- 1 | ## `TestTimeAveragedBaseRateOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `bufferSize() → uint16` (public) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /contracts/true-gold/interface/IOwnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity 0.6.10; 3 | 4 | interface IOwnable { 5 | function transferOwnership(address newOwner) external; 6 | } 7 | -------------------------------------------------------------------------------- /deploy/trueUSDNoDelegate.ts: -------------------------------------------------------------------------------- 1 | import { contract, createProxy, deploy } from 'ethereum-mars' 2 | import { 3 | TrueUSD 4 | } from '../build/artifacts' 5 | 6 | deploy({}, () => { 7 | contract(TrueUSD) 8 | }) 9 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/MockUsdStableCoinOracle.md: -------------------------------------------------------------------------------- 1 | ## `MockUsdStableCoinOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `tokenToUsd(uint256 tokenAmount) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/governance/common/ProxyStorage.md: -------------------------------------------------------------------------------- 1 | ## `ProxyStorage` 2 | 3 | All storage must be declared here 4 | New storage must be appended to the end 5 | Never remove items from this list 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ITrueCreditAgency.md: -------------------------------------------------------------------------------- 1 | ## `ILineOfCreditAgency` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `poolCreditValue(contract ITrueFiPool2 pool) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/trusttoken/common/ProxyStorage.md: -------------------------------------------------------------------------------- 1 | ## `ProxyStorage` 2 | 3 | All storage must be declared here 4 | New storage must be appended to the end 5 | Never remove items from this list 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/contracts-bsc/.compiler.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.6.10", 3 | "settings": { 4 | "optimizer": { 5 | "enabled": true, 6 | "runs": 200 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/contracts-por/.compiler.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.6.10", 3 | "settings": { 4 | "optimizer": { 5 | "enabled": true, 6 | "runs": 200 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/contracts-watr/.compiler.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.6.10", 3 | "settings": { 4 | "optimizer": { 5 | "enabled": true, 6 | "runs": 200 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /scripts/utils/toTrustToken.ts: -------------------------------------------------------------------------------- 1 | import { BigNumberish } from 'ethers' 2 | import { parseUnits } from '@ethersproject/units' 3 | 4 | export const toTrustToken = (amount: BigNumberish) => parseUnits(amount.toString(), 8) 5 | -------------------------------------------------------------------------------- /contracts/truefi/interface/IMockTruPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IMockTruPriceOracle { 5 | function toTru(uint256 amount) external returns (uint256); 6 | } 7 | -------------------------------------------------------------------------------- /docs/proxy/interface/IImplementationReference.md: -------------------------------------------------------------------------------- 1 | ## `IImplementationReference` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `implementation() → address currentImplementation` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/trusttoken/common/TruProxyStorage.md: -------------------------------------------------------------------------------- 1 | ## `TruProxyStorage` 2 | 3 | All storage must be declared here 4 | New storage must be appended to the end 5 | Never remove items from this list 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/registry/interface/IRegistryClone.md: -------------------------------------------------------------------------------- 1 | ## `IRegistryClone` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `syncAttributeValue(address _who, bytes32 _attribute, uint256 _value)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi/interface/IUniswapPair.md: -------------------------------------------------------------------------------- 1 | ## `IUniswapPair` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `getReserves() → uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/PowTest.md: -------------------------------------------------------------------------------- 1 | ## `PowTest` 2 | 3 | 4 | 5 | Wrapper over TrueFiFixed64x64 library for testing purposes 6 | 7 | 8 | ### `pow(uint256 x, uint256 y) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/utils/chai.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | declare namespace Chai { 4 | interface CloseTo { 5 | (expected: any, delta: number, message?: string): Assertion, 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /docs/common/interface/IPauseableContract.md: -------------------------------------------------------------------------------- 1 | ## `IPauseableContract` 2 | 3 | 4 | 5 | interface to allow standard pause function 6 | 7 | 8 | ### `setPauseStatus(bool pauseStatus)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi2/libraries/IUniRouter.md: -------------------------------------------------------------------------------- 1 | ## `IUniRouter` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `token0() → address` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `token1() → address` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /slither.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude_optimization": true, 3 | "exclude_informational": true, 4 | "exclude_low": true, 5 | "exclude_medium": true, 6 | "solc_disable_warnings": true, 7 | "detectors_to_exclude": "" 8 | } 9 | -------------------------------------------------------------------------------- /contracts/truefi/mocks/MockCurveGauge.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | contract MockCurveGauge { 5 | function minter() external pure returns (address) { 6 | return address(0); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/truefi/interface/ICurveMinter.md: -------------------------------------------------------------------------------- 1 | ## `ICurveMinter` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `mint(address gauge)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `token() → contract IERC20` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/interface/IRegistry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IRegistry { 5 | function hasAttribute(address _who, bytes32 _attribute) external view returns (bool); 6 | } 7 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/interface/IRegistry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IRegistry { 5 | function hasAttribute(address _who, bytes32 _attribute) external view returns (bool); 6 | } 7 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/interface/IRegistry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IRegistry { 5 | function hasAttribute(address _who, bytes32 _attribute) external view returns (bool); 6 | } 7 | -------------------------------------------------------------------------------- /packages/contracts-watr/test/utils/parseTrueUSD.ts: -------------------------------------------------------------------------------- 1 | import { parseUnits } from 'ethers/lib/utils' 2 | 3 | export const trueUSDDecimals = 18 4 | export function parseTrueUSD(amount: string) { 5 | return parseUnits(amount, trueUSDDecimals) 6 | } 7 | -------------------------------------------------------------------------------- /contracts/registry/interface/IHasOwner.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IHasOwner { 5 | function claimOwnership() external; 6 | 7 | function transferOwnership(address newOwner) external; 8 | } 9 | -------------------------------------------------------------------------------- /contracts/truefi2/deprecated/ITrueFiCreditOracleDeprecated.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ITrueFiCreditOracleDeprecated { 5 | function getScore(address account) external view returns (uint8); 6 | } 7 | -------------------------------------------------------------------------------- /docs/registry/interface/IHasOwner.md: -------------------------------------------------------------------------------- 1 | ## `IHasOwner` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `claimOwnership()` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `transferOwnership(address newOwner)` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/contracts-bsc/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": ["ts-node/register/transpile-only", "tsconfig-paths/register"], 3 | "extension": ["ts"], 4 | "target": "esnext", 5 | "timeout": 40000, 6 | "watch-files": ["test"], 7 | "exit": true 8 | } 9 | -------------------------------------------------------------------------------- /packages/contracts-por/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": ["ts-node/register/transpile-only", "tsconfig-paths/register"], 3 | "extension": ["ts"], 4 | "target": "esnext", 5 | "timeout": 40000, 6 | "watch-files": ["test"], 7 | "exit": true 8 | } 9 | -------------------------------------------------------------------------------- /packages/contracts-watr/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": ["ts-node/register/transpile-only", "tsconfig-paths/register"], 3 | "extension": ["ts"], 4 | "target": "esnext", 5 | "timeout": 40000, 6 | "watch-files": ["test"], 7 | "exit": true 8 | } 9 | -------------------------------------------------------------------------------- /contracts/proxy/interface/IImplementationReference.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IImplementationReference { 5 | function implementation() external view returns (address currentImplementation); 6 | } 7 | -------------------------------------------------------------------------------- /contracts/proxy/mocks/StringReturn.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | contract StringReturn { 5 | function reflect(string memory text) external pure returns (string memory) { 6 | return text; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /contracts/true-currencies/interface/IHasOwner.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IHasOwner { 5 | function claimOwnership() external; 6 | 7 | function transferOwnership(address newOwner) external; 8 | } 9 | -------------------------------------------------------------------------------- /docs/true-currencies/interface/IHasOwner.md: -------------------------------------------------------------------------------- 1 | ## `IHasOwner` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `claimOwnership()` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `transferOwnership(address newOwner)` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /contracts/true-gold/mocks/OwnableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "@openzeppelin/contracts/access/Ownable.sol"; 5 | 6 | // solhint-disable-next-line no-empty-blocks 7 | contract OwnableMock is Ownable { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /docs/governance/mocks/MockPauseableContract.md: -------------------------------------------------------------------------------- 1 | ## `MockPauseableContract` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `setPauseStatus(bool status)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | ### `PauseStatusChanged(bool pauseStatus)` 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/MockGasRefundToken.md: -------------------------------------------------------------------------------- 1 | ## `MockGasRefundToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `sponsorGas(uint256 amount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `sponsorGas2(uint256 amount)` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/truefi/interface/ICrvPriceOracle.md: -------------------------------------------------------------------------------- 1 | ## `ICrvPriceOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `usdToCrv(uint256 amount) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `crvToUsd(uint256 amount) → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/truefi/interface/ITruPriceOracle.md: -------------------------------------------------------------------------------- 1 | ## `ITruPriceOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `usdToTru(uint256 amount) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `truToUsd(uint256 amount) → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /scripts/utils/waitForTx.ts: -------------------------------------------------------------------------------- 1 | import { ContractReceipt, ContractTransaction } from 'ethers' 2 | 3 | export async function waitForTx (transaction: Promise): Promise { 4 | const response = await transaction 5 | return response.wait() 6 | } 7 | -------------------------------------------------------------------------------- /.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": ["ts-node/register/transpile-only", "tsconfig-paths/register"], 3 | "extension": ["ts"], 4 | "target": "esnext", 5 | "timeout": 40000, 6 | "exclude": "test/integration/**/*.ts", 7 | "watch-files": ["test"], 8 | "exit": true 9 | } 10 | -------------------------------------------------------------------------------- /docs/truefi/interface/ICurve.md: -------------------------------------------------------------------------------- 1 | ## `ICurve` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `calc_token_amount(uint256[4] amounts, bool deposit) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `get_virtual_price() → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockCrvPriceOracle.md: -------------------------------------------------------------------------------- 1 | ## `MockCrvPriceOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `usdToCrv(uint256 amount) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `crvToUsd(uint256 amount) → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockTruPriceOracle.md: -------------------------------------------------------------------------------- 1 | ## `MockTruPriceOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `usdToTru(uint256 amount) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `truToUsd(uint256 amount) → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/interface/IClaimableOwnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IClaimableOwnable { 5 | function claimOwnership() external; 6 | 7 | function transferOwnership(address newOwner) external; 8 | } 9 | -------------------------------------------------------------------------------- /packages/contracts-bsc/test/utils/timeTravel.ts: -------------------------------------------------------------------------------- 1 | import { providers } from 'ethers' 2 | 3 | export const timeTravel = async (provider: providers.JsonRpcProvider, time: number) => { 4 | await provider.send('evm_increaseTime', [time]) 5 | await provider.send('evm_mine', []) 6 | } 7 | -------------------------------------------------------------------------------- /packages/contracts-por/test/utils/timeTravel.ts: -------------------------------------------------------------------------------- 1 | import { providers } from 'ethers' 2 | 3 | export const timeTravel = async (provider: providers.JsonRpcProvider, time: number) => { 4 | await provider.send('evm_increaseTime', [time]) 5 | await provider.send('evm_mine', []) 6 | } 7 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/interface/IClaimableOwnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IClaimableOwnable { 5 | function claimOwnership() external; 6 | 7 | function transferOwnership(address newOwner) external; 8 | } 9 | -------------------------------------------------------------------------------- /packages/contracts-watr/test/utils/timeTravel.ts: -------------------------------------------------------------------------------- 1 | import { providers } from 'ethers' 2 | 3 | export const timeTravel = async (provider: providers.JsonRpcProvider, time: number) => { 4 | await provider.send('evm_increaseTime', [time]) 5 | await provider.send('evm_mine', []) 6 | } 7 | -------------------------------------------------------------------------------- /test/utils/toAddress.ts: -------------------------------------------------------------------------------- 1 | import { Wallet } from 'ethers' 2 | 3 | export type WalletOrAddress = Wallet | string 4 | 5 | export function toAddress (walletOrAddress: WalletOrAddress) { 6 | return typeof walletOrAddress === 'string' ? walletOrAddress : walletOrAddress.address 7 | } 8 | -------------------------------------------------------------------------------- /contracts/trusttoken/interface/IBurnableERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface IBurnableERC20 is IERC20 { 7 | function burn(uint256 amount) external; 8 | } 9 | -------------------------------------------------------------------------------- /docs/truefi/interface/ITrueLender.md: -------------------------------------------------------------------------------- 1 | ## `ITrueLender` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `value() → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `distribute(address recipient, uint256 numerator, uint256 denominator)` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/truefi/interface/IUniswapRouter.md: -------------------------------------------------------------------------------- 1 | ## `IUniswapRouter` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) → uint256[] amounts` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/truefi/interface/ILoanFactory.md: -------------------------------------------------------------------------------- 1 | ## `ILoanFactory` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `createLoanToken(uint256 _amount, uint256 _term, uint256 _apy)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `isLoanToken(address) → bool` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /spec/truefi2/scripts/RateModel.sh: -------------------------------------------------------------------------------- 1 | certoraRun contracts/truefi2/RateModel.sol \ 2 | contracts/truefi2/TrueFiPool2.sol \ 3 | contracts/truefi2/oracles/TimeAveragedTruPriceOracle.sol \ 4 | contracts/common/UpgradeableERC20.sol:ERC20 \ 5 | --verify RateModel:spec/truefi2/RateModel.spec 6 | -------------------------------------------------------------------------------- /contracts/truefi/interface/IYToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface IYToken is IERC20 { 7 | function getPricePerFullShare() external view returns (uint256); 8 | } 9 | -------------------------------------------------------------------------------- /docs/truefi2/oracles/ChainlinkTruUsdcOracle.md: -------------------------------------------------------------------------------- 1 | ## `ChainlinkTruUsdcOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `token() → contract IERC20WithDecimals` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `tokenToUsd(uint256 tokenAmount) → uint256` (public) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.mocharc.integration.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": ["ts-node/register/transpile-only", "tsconfig-paths/register"], 3 | "extension": ["ts"], 4 | "target": "esnext", 5 | "recursive": true, 6 | "timeout": 200000, 7 | "spec": "test/integration/*.test.ts", 8 | "watch-files": ["test"] 9 | } 10 | -------------------------------------------------------------------------------- /contracts/common/interface/IPauseableContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity 0.6.10; 4 | 5 | /** 6 | * @dev interface to allow standard pause function 7 | */ 8 | interface IPauseableContract { 9 | function setPauseStatus(bool pauseStatus) external; 10 | } 11 | -------------------------------------------------------------------------------- /contracts/registry/interface/IRegistryClone.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IRegistryClone { 5 | function syncAttributeValue( 6 | address _who, 7 | bytes32 _attribute, 8 | uint256 _value 9 | ) external; 10 | } 11 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ICrvPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ICrvPriceOracle { 5 | function usdToCrv(uint256 amount) external view returns (uint256); 6 | 7 | function crvToUsd(uint256 amount) external view returns (uint256); 8 | } 9 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ITruPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ITruPriceOracle { 5 | function usdToTru(uint256 amount) external view returns (uint256); 6 | 7 | function truToUsd(uint256 amount) external view returns (uint256); 8 | } 9 | -------------------------------------------------------------------------------- /docs/true-currencies/interface/IReclaimerToken.md: -------------------------------------------------------------------------------- 1 | ## `IReclaimerToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `reclaimToken(contract IERC20 token, address _to)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `reclaimEther(address payable _to)` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.waffle.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerVersion": "v0.6.10+commit.00c0fcaf", 3 | "compilerOptions": { 4 | "optimizer": { 5 | "enabled": true, 6 | "runs": 20000 7 | } 8 | }, 9 | "sourceDirectory": "./contracts", 10 | "outputDirectory": "./build" 11 | } 12 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/IERC20WithDecimals.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface IERC20WithDecimals is IERC20 { 7 | function decimals() external view returns (uint256); 8 | } 9 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ITruPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | /** 5 | * @dev Oracle that converts TRU token to USD 6 | */ 7 | interface ITruPriceOracle { 8 | function truToUsd(uint256 tokenAmount) external view returns (uint256); 9 | } 10 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ILoanFactory3.md: -------------------------------------------------------------------------------- 1 | ## `ILoanFactory2` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `createLoanToken(contract ITrueFiPool2 _pool, uint256 _amount, uint256 _term)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `isLoanToken(address) → bool` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/test/IRegistryClone.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IRegistryClone { 5 | function syncAttributeValue( 6 | address _who, 7 | bytes32 _attribute, 8 | uint256 _value 9 | ) external; 10 | } 11 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/test/IRegistryClone.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IRegistryClone { 5 | function syncAttributeValue( 6 | address _who, 7 | bytes32 _attribute, 8 | uint256 _value 9 | ) external; 10 | } 11 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/test/IRegistryClone.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IRegistryClone { 5 | function syncAttributeValue( 6 | address _who, 7 | bytes32 _attribute, 8 | uint256 _value 9 | ) external; 10 | } 11 | -------------------------------------------------------------------------------- /contracts/true-currencies/mocks/MockHook.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | contract MockHook { 5 | uint256[] t; 6 | 7 | function hook() external { 8 | for (uint256 i = 0; i < 100; i++) { 9 | t.push(i + 1); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /docs/truefi2/PoolExtensions.md: -------------------------------------------------------------------------------- 1 | ## `PoolExtensions` 2 | 3 | 4 | 5 | Library that has shared functions between legacy TrueFi Pool and Pool2 6 | 7 | 8 | ### `_liquidate(contract ISAFU safu, contract ILoanToken2 loan, contract ITrueLender2Deprecated lender)` (internal) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /contracts/truefi/mocks/MockLoanFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {LoanFactory} from "../LoanFactory.sol"; 5 | 6 | contract MockLoanFactory is LoanFactory { 7 | function setLender(address newLender) external { 8 | lender = newLender; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/TestTrueFiPool2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "../TrueFiPool2.sol"; 5 | 6 | contract TestTrueFiPool2 is TrueFiPool2 { 7 | function setLender(ITrueLender2Deprecated _lender) external onlyOwner { 8 | lender = _lender; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /docs/registry/mocks/RegistryMock.md: -------------------------------------------------------------------------------- 1 | ## `RegistryMock` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor()` (public) 9 | 10 | 11 | 12 | sets the original `owner` of the contract to the sender 13 | at construction. Must then be reinitialized 14 | 15 | ### `initialize()` (public) 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /scripts/utils/asProxy.ts: -------------------------------------------------------------------------------- 1 | import { Contract } from 'ethers' 2 | import { OwnedUpgradeabilityProxy__factory, OwnedUpgradeabilityProxy } from 'contracts' 3 | 4 | export function asProxy (contract: Contract): OwnedUpgradeabilityProxy { 5 | return OwnedUpgradeabilityProxy__factory.connect(contract.address, contract.signer) 6 | } 7 | -------------------------------------------------------------------------------- /spec/truefi2/scripts/FixedTermLoan.sh: -------------------------------------------------------------------------------- 1 | certoraRun contracts/truefi2/FixedTermLoan.sol \ 2 | contracts/truefi2/BorrowingMutex.sol \ 3 | contracts/common/UpgradeableERC20.sol:ERC20 \ 4 | --verify FixedTermLoan:spec/truefi2/FixedTermLoan.spec \ 5 | --link FixedTermLoan:token=ERC20 \ 6 | --short_output \ 7 | --optimistic_loop 8 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "overrides": [ 3 | { 4 | "files": "*.sol", 5 | "options": { 6 | "printWidth": 135, 7 | "tabWidth": 4, 8 | "useTabs": false, 9 | "singleQuote": false, 10 | "bracketSpacing": false, 11 | "explicitTypes": "always" 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /docs/truefi/interface/IStakingPool.md: -------------------------------------------------------------------------------- 1 | ## `IStakingPool` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `stakeSupply() → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `withdraw(uint256 amount)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `payFee(uint256 amount, uint256 endTime)` (external) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/registry/mocks/MockRegistrySubscriber.md: -------------------------------------------------------------------------------- 1 | ## `MockRegistrySubscriber` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `syncAttributeValue(address _who, bytes32 _attribute, uint256 _value)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `getAttributeValue(address _who, bytes32 _attribute) → uint256` (public) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/truefi2/interface/IDeficiencyToken.md: -------------------------------------------------------------------------------- 1 | ## `IDeficiencyToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `loan() → contract ILoanToken2` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `burnFrom(address account, uint256 amount)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `version() → uint8` (external) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/contracts-bsc/.waffle.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerVersion": "v0.6.10+commit.00c0fcaf", 3 | "compilerOptions": { 4 | "optimizer": { 5 | "enabled": true, 6 | "runs": 20000 7 | } 8 | }, 9 | "sourceDirectory": "./contracts", 10 | "flattenOutputDirectory": "./flattened_contracts" 11 | } 12 | -------------------------------------------------------------------------------- /packages/contracts-por/.waffle.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerVersion": "v0.6.10+commit.00c0fcaf", 3 | "compilerOptions": { 4 | "optimizer": { 5 | "enabled": true, 6 | "runs": 20000 7 | } 8 | }, 9 | "sourceDirectory": "./contracts", 10 | "flattenOutputDirectory": "./flattened_contracts" 11 | } 12 | -------------------------------------------------------------------------------- /packages/contracts-watr/.waffle.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerVersion": "v0.6.10+commit.00c0fcaf", 3 | "compilerOptions": { 4 | "optimizer": { 5 | "enabled": true, 6 | "runs": 20000 7 | } 8 | }, 9 | "sourceDirectory": "./contracts", 10 | "flattenOutputDirectory": "./flattened_contracts" 11 | } 12 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/IFixedTermLoanAgency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ITrueFiPool2} from "./ITrueFiPool2.sol"; 5 | 6 | interface IFixedTermLoanAgency { 7 | // @dev calculate overall value of the pools 8 | function value(ITrueFiPool2 pool) external view returns (uint256); 9 | } 10 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/TokenControllerPauseMock.md: -------------------------------------------------------------------------------- 1 | ## `TokenControllerPauseMock` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `setPausedImplementation(address _pausedToken)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `pauseToken()` (external) 15 | 16 | 17 | 18 | pause all pausable actions on TrueUSD, mints/burn/transfer/approve 19 | 20 | 21 | -------------------------------------------------------------------------------- /contracts/true-currencies/mocks/MockTrueUSD.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "../tokens/TrueUSD.sol"; 5 | 6 | contract MockTrueUSD is TrueUSD { 7 | function initialize() external { 8 | require(!initialized); 9 | owner = msg.sender; 10 | initialized = true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ILoanFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ILoanFactory { 5 | function createLoanToken( 6 | uint256 _amount, 7 | uint256 _term, 8 | uint256 _apy 9 | ) external; 10 | 11 | function isLoanToken(address) external view returns (bool); 12 | } 13 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ITrueLender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ITrueLender { 5 | function value() external view returns (uint256); 6 | 7 | function distribute( 8 | address recipient, 9 | uint256 numerator, 10 | uint256 denominator 11 | ) external; 12 | } 13 | -------------------------------------------------------------------------------- /docs/true-gold/Reclaimable.md: -------------------------------------------------------------------------------- 1 | ## `Reclaimable` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `reclaimEther(address payable to)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `reclaimToken(contract IERC20 token, address to)` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `reclaimContract(contract IOwnable ownable)` (public) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/TestDeficiencyToken.md: -------------------------------------------------------------------------------- 1 | ## `TestDeficiencyToken` 2 | 3 | 4 | 5 | Helper contract to test the burning feature of DeficiencyToken 6 | 7 | 8 | ### `constructor(contract ILoanToken2 _loan, uint256 _amount)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `mint(address account, uint256 amount)` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /contracts/truefi/interface/IUniswapPair.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IUniswapPair { 5 | function getReserves() 6 | external 7 | view 8 | returns ( 9 | uint112 reserve0, 10 | uint112 reserve1, 11 | uint32 blockTimestampLast 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/TestLoanToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ERC20} from "../../common/UpgradeableERC20.sol"; 5 | 6 | // This contract mimics loan token with different initialize signature 7 | contract TestLoanToken is ERC20 { 8 | function initialize(address _borrower) external initializer {} 9 | } 10 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/TokenControllerMock.md: -------------------------------------------------------------------------------- 1 | ## `TokenControllerMock` 2 | 3 | Token Controller with custom init function for testing 4 | 5 | 6 | 7 | 8 | ### `initialize()` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `initializeWithParams(contract ITrueCurrency _token, contract IRegistry _registry)` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /scripts/deployedAddresses/kovan.json: -------------------------------------------------------------------------------- 1 | { 2 | "trueUsd": "0x0000000000075EfBeE23fe2de1bd0b7690883cc9", 3 | "registry": "0x0000000000013949F288172bD7E36837bDdC7211", 4 | "aaveLendingPool": "0x580D4Fdc4BF8f9b5ae2fb9225D584fED4AD5375c", 5 | "aTUSD": "0xA79383e0d2925527ba5Ec1c1bcaA13c28EE00314", 6 | "uniswapFactory": "0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30" 7 | } 8 | -------------------------------------------------------------------------------- /contracts/true-currencies/interface/IReclaimerToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface IReclaimerToken { 7 | function reclaimToken(IERC20 token, address _to) external; 8 | 9 | function reclaimEther(address payable _to) external; 10 | } 11 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/interface/IOwnedUpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IOwnedUpgradeabilityProxy { 5 | function transferProxyOwnership(address newOwner) external; 6 | 7 | function claimProxyOwnership() external; 8 | 9 | function upgradeTo(address implementation) external; 10 | } 11 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/interface/IOwnedUpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IOwnedUpgradeabilityProxy { 5 | function transferProxyOwnership(address newOwner) external; 6 | 7 | function claimProxyOwnership() external; 8 | 9 | function upgradeTo(address implementation) external; 10 | } 11 | -------------------------------------------------------------------------------- /contracts/truefi/mocks/MockTrueLender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ITrueFiPool} from "../interface/ITrueFiPool.sol"; 5 | 6 | import {TrueLender} from "../TrueLender.sol"; 7 | 8 | contract MockTrueLender is TrueLender { 9 | function setPool(ITrueFiPool newPool) external { 10 | pool = newPool; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /docs/governance/mocks/MockTimeLock.md: -------------------------------------------------------------------------------- 1 | ## `MockTimeLock` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `mockInitialize(address admin_, uint256 delay_)` (external) 9 | 10 | 11 | 12 | Initialize sets the addresses of admin and the delay timestamp 13 | 14 | 15 | ### `mockSetDelay(uint256 _delay)` (external) 16 | 17 | 18 | 19 | Function to set delay for testing 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/true-currencies/TrueCurrencyWithGasRefund.md: -------------------------------------------------------------------------------- 1 | ## `TrueCurrencyWithGasRefund` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `refundGas(uint256 amount)` (external) 9 | 10 | 11 | 12 | reclaim gas from legacy gas refund #1 13 | will refund 15,000 * amount gas to sender (minus exection cost) 14 | If gas pool is empty, refund 39,000 * amount gas by calling selfdestruct 15 | 16 | 17 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/interface/IOwnedUpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IOwnedUpgradeabilityProxy { 5 | function transferProxyOwnership(address newOwner) external; 6 | 7 | function claimProxyOwnership() external; 8 | 9 | function upgradeTo(address implementation) external; 10 | } 11 | -------------------------------------------------------------------------------- /contracts/truefi/mocks/MockLog.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.10; 3 | 4 | import {ABDKMath64x64} from "../Log.sol"; 5 | 6 | contract MockLog { 7 | using ABDKMath64x64 for uint256; 8 | using ABDKMath64x64 for int128; 9 | 10 | function ln(uint256 x) public pure returns (int128) { 11 | return x.fromUInt().ln(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docs/truefi2/DeficiencyToken.md: -------------------------------------------------------------------------------- 1 | ## `DeficiencyToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor(contract ILoanToken2 _loan, uint256 _amount)` (public) 9 | 10 | 11 | 12 | Create Deficiency 13 | 14 | 15 | ### `burnFrom(address account, uint256 amount)` (external) 16 | 17 | 18 | 19 | 20 | 21 | ### `version() → uint8` (external) 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /build 3 | /flatten 4 | /cache 5 | 6 | # python virtual environment 7 | /venv 8 | 9 | # Generated by solidity-coverage? 10 | scTopics 11 | allFiredEvents 12 | coverage 13 | coverage.json 14 | coverageEnv 15 | /.coverage_artifacts 16 | .idea 17 | .DS_Store 18 | /scripts/.ropsten-test.env 19 | 20 | # Generated by Certora 21 | .certora_* 22 | .last_confs 23 | -------------------------------------------------------------------------------- /docs/true-currencies/common/ProxyStorage.md: -------------------------------------------------------------------------------- 1 | ## `ProxyStorage` 2 | 3 | Defines the storage layout of the token implementation contract. Any 4 | newly declared state variables in future upgrades should be appended 5 | to the bottom. Never remove state variables from this list, however variables 6 | can be renamed. Please add _Deprecated to deprecated variables. 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ISAFU.md: -------------------------------------------------------------------------------- 1 | ## `ISAFU` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `poolDeficit(address pool) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `deficiencyToken(contract ILoanToken2 loan) → contract IDeficiencyToken` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `reclaim(contract ILoanToken2 loan, uint256 amount)` (external) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ITrueFiCreditOracle.md: -------------------------------------------------------------------------------- 1 | ## `ITrueFiCreditOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `status(address account) → enum ITrueFiCreditOracle.Status` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `score(address account) → uint8` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `maxBorrowerLimit(address account) → uint256` (external) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/TestTimeAveragedBaseRateOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TimeAveragedBaseRateOracle} from "../TimeAveragedBaseRateOracle.sol"; 5 | 6 | contract TestTimeAveragedBaseRateOracle is TimeAveragedBaseRateOracle { 7 | function bufferSize() public pure override returns (uint16) { 8 | return 7 + 1; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /scripts/utils/ask.ts: -------------------------------------------------------------------------------- 1 | import readline from 'readline' 2 | 3 | export async function ask (message: string) { 4 | const rl = readline.createInterface({ 5 | input: process.stdin, 6 | output: process.stdout, 7 | }) 8 | 9 | return new Promise(resolve => { 10 | rl.question(message, (answer) => { 11 | rl.close() 12 | resolve(answer) 13 | }) 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /contracts/truefi/interface/IUniswapRouter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IUniswapRouter { 5 | function swapExactTokensForTokens( 6 | uint256 amountIn, 7 | uint256 amountOutMin, 8 | address[] calldata path, 9 | address to, 10 | uint256 deadline 11 | ) external returns (uint256[] memory amounts); 12 | } 13 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/TestTimeAveragedTruPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TimeAveragedTruPriceOracle} from "../oracles/TimeAveragedTruPriceOracle.sol"; 5 | 6 | contract TestTimeAveragedTruPriceOracle is TimeAveragedTruPriceOracle { 7 | function bufferSize() public pure override returns (uint16) { 8 | return 7 + 1; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /docs/truefi2/interface/I1Inch3.md: -------------------------------------------------------------------------------- 1 | ## `I1Inch3` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `swap(address caller, struct I1Inch3.SwapDescription desc, bytes data) → uint256 returnAmount, uint256 gasLeft, uint256 chiSpent` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `unoswap(address srcToken, uint256 amount, uint256 minReturn, bytes32[]) → uint256 returnAmount` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/utils/constants.ts: -------------------------------------------------------------------------------- 1 | import { constants } from 'ethers' 2 | 3 | export const AddressOne = '0x0000000000000000000000000000000000000001' 4 | export const BURN_AMOUNT_MULTIPLIER = 12_441_000 5 | export const MAX_BURN_BOUND = constants.MaxUint256.sub(constants.MaxUint256.mod(BURN_AMOUNT_MULTIPLIER)) 6 | 7 | export const MAX_APY = 100_000 8 | export const DAY = 60 * 60 * 24 9 | export const YEAR = 365 * DAY 10 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ITrueRatingAgencyV2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ITrueRatingAgencyV2 { 5 | function getResults(address id) 6 | external 7 | view 8 | returns ( 9 | uint256, 10 | uint256, 11 | uint256 12 | ); 13 | 14 | function claim(address id, address voter) external; 15 | } 16 | -------------------------------------------------------------------------------- /docs/truefi/interface/ICurveGauge.md: -------------------------------------------------------------------------------- 1 | ## `ICurveGauge` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `balanceOf(address depositor) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `minter() → contract ICurveMinter` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `deposit(uint256 amount)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `withdraw(uint256 amount)` (external) 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockCurve.md: -------------------------------------------------------------------------------- 1 | ## `MockCurve` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `calc_token_amount(uint256[4] amounts, bool) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `set_withdraw_price(uint256 price)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `get_virtual_price() → uint256` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `burn300kGas()` (public) 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /flattenBuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ODline=$(grep 'artifacts' hardhat.config.ts) 5 | regex=': \"(.+)\"' 6 | [[ $ODline =~ $regex ]] 7 | outputDir=${BASH_REMATCH[1]} 8 | 9 | touch $outputDir/index.ts 10 | > $outputDir/index.ts 11 | 12 | for file in $(find $outputDir -name '[a-zA-Z_]*.json' -not -name '*.dbg.json') 13 | do 14 | mv $file $outputDir 15 | done 16 | 17 | echo "Build files moved succesfully!" -------------------------------------------------------------------------------- /docs/truefi2/libraries/OneInchExchange.md: -------------------------------------------------------------------------------- 1 | ## `OneInchExchange` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `exchange(contract I1Inch3 _1inchExchange, bytes data) → struct I1Inch3.SwapDescription description, uint256 returnedAmount` (internal) 9 | 10 | 11 | 12 | Forward data to 1Inch contract 13 | 14 | 15 | 16 | ### `Swapped(struct I1Inch3.SwapDescription description, uint256 returnedAmount)` 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /contracts/truefi/interface/IStakingPool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface IStakingPool is IERC20 { 7 | function stakeSupply() external view returns (uint256); 8 | 9 | function withdraw(uint256 amount) external; 10 | 11 | function payFee(uint256 amount, uint256 endTime) external; 12 | } 13 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ILiquidator2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ILoanToken2Deprecated} from "../deprecated/ILoanToken2Deprecated.sol"; 5 | import {IDebtToken} from "./IDebtToken.sol"; 6 | 7 | interface ILiquidator2 { 8 | function legacyLiquidate(ILoanToken2Deprecated loan) external; 9 | 10 | function liquidate(IDebtToken[] calldata debts) external; 11 | } 12 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/TestTrueLender.md: -------------------------------------------------------------------------------- 1 | ## `TestTrueLender` 2 | 3 | 4 | 5 | Helper contract to test distribute feature of the TrueLender2Deprecated 6 | 7 | 8 | ### `testDistribute(address recipient, uint256 numerator, uint256 denominator, address pool)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `testTransferAllLoanTokens(contract ILoanToken2 loan, address recipient)` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/truefi/interface/ISushiswapRewarder.md: -------------------------------------------------------------------------------- 1 | ## `ISushiswapRewarder` 2 | 3 | 4 | 5 | Interface for sushiswap rewards 6 | 7 | 8 | ### `onSushiReward(uint256 pid, address user, address recipient, uint256 sushiAmount, uint256 newLpAmount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `pendingTokens(uint256 pid, address user, uint256 sushiAmount) → contract IERC20[], uint256[]` (external) 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/MockUsdc.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | 6 | contract MockUsdc is ERC20 { 7 | constructor() public ERC20("usdc", "usdc") { 8 | _setupDecimals(6); 9 | } 10 | 11 | function mint(address receiver, uint256 amount) external { 12 | _mint(receiver, amount); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/MockTrueCurrency.md: -------------------------------------------------------------------------------- 1 | ## `MockTrueCurrency` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `initialize()` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `decimals() → uint8` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `rounding() → uint8` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `name() → string` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `symbol() → string` (public) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ITrueLender2.md: -------------------------------------------------------------------------------- 1 | ## `ITrueLender2Deprecated` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `value(contract ITrueFiPool2 pool) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `distribute(address recipient, uint256 numerator, uint256 denominator)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `transferAllLoanTokens(contract ILoanToken2 loan, address recipient)` (external) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /scripts/deployedAddresses/mainnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "trueUsd": "0x0000000000085d4780B73119b644AE5ecd22b376", 3 | "tokenController": "0x0000000000075EfBeE23fe2de1bd0b7690883cc9", 4 | "registry": "0x0000000000013949F288172bD7E36837bDdC7211", 5 | "aaveLendingPool": "0x398eC7346DcD622eDc5ae82352F02bE94C62d119", 6 | "aTUSD": "0x4DA9b813057D04BAef4e5800E36083717b4a0341", 7 | "uniswapFactory": "0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95" 8 | } 9 | -------------------------------------------------------------------------------- /scripts/deployedAddresses/ropsten.json: -------------------------------------------------------------------------------- 1 | { 2 | "trueUsd": "0xa2EA00Df6d8594DBc76b79beFe22db9043b8896F", 3 | "tokenController": "0x47106c72DE9144d43Bb026d848806Ab29e2A0227", 4 | "registry": "0xe24c8f14295da7f308B73B94C72197e8Ee73A484", 5 | "aaveLendingPool": "0x9E5C7835E4b13368fd628196C4f1c6cEc89673Fa", 6 | "aTUSD": "0x9265d51f5abf1e23be64418827859bc83ae70a57", 7 | "uniswapFactory": "0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351" 8 | } 9 | -------------------------------------------------------------------------------- /contracts/truefi/interface/IArbitraryDistributor.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IArbitraryDistributor { 5 | function amount() external returns (uint256); 6 | 7 | function remaining() external returns (uint256); 8 | 9 | function beneficiary() external returns (address); 10 | 11 | function distribute(uint256 _amount) external; 12 | 13 | function empty() external; 14 | } 15 | -------------------------------------------------------------------------------- /docs/trusttoken/mocks/TestUSDCToken.md: -------------------------------------------------------------------------------- 1 | ## `TestUSDCToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `mint(address _to, uint256 _value)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `burn(uint256 _value)` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `decimals() → uint8` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `name() → string` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `symbol() → string` (public) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/trusttoken/mocks/TestUSDTToken.md: -------------------------------------------------------------------------------- 1 | ## `TestUSDTToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `mint(address _to, uint256 _value)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `burn(uint256 _value)` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `decimals() → uint8` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `name() → string` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `symbol() → string` (public) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/IPoolFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ITrueFiPool2} from "./ITrueFiPool2.sol"; 5 | 6 | interface IPoolFactory { 7 | function isSupportedPool(ITrueFiPool2 pool) external view returns (bool); 8 | 9 | function getSupportedPools() external view returns (ITrueFiPool2[] memory); 10 | 11 | function supportedPoolsTVL() external view returns (uint256); 12 | } 13 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/IStakingVault.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20WithDecimals} from "./IERC20WithDecimals.sol"; 5 | 6 | interface IStakingVault { 7 | function slash(address borrower) external returns (uint256); 8 | 9 | function stakedAmount(address borrower) external view returns (uint256); 10 | 11 | function stakedToken() external view returns (IERC20WithDecimals); 12 | } 13 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/Mock1InchV3.md: -------------------------------------------------------------------------------- 1 | ## `Mock1InchV3` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `setOutputAmount(uint256 amount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `swap(address, struct I1Inch3.SwapDescription description, bytes) → uint256 returnAmount, uint256 gasLeft, uint256 chiSpent` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `unoswap(address, uint256, uint256, bytes32[]) → uint256` (external) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/truefi/interface/ITrueDistributor.md: -------------------------------------------------------------------------------- 1 | ## `ITrueDistributor` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `trustToken() → contract IERC20` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `farm() → address` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `distribute()` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `nextDistribution() → uint256` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `empty()` (external) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ITimeAveragedBaseRateOracle.md: -------------------------------------------------------------------------------- 1 | ## `ITimeAveragedBaseRateOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `calculateAverageAPY(uint16 numberOfValues) → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `getWeeklyAPY() → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `getMonthlyAPY() → uint256` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `getYearlyAPY() → uint256` (external) 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /contracts/true-currencies/mocks/TokenFaucet.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TokenControllerMock} from "./TokenControllerMock.sol"; 5 | 6 | contract TokenFaucet is TokenControllerMock { 7 | function faucet(uint256 _amount) external { 8 | require(_amount <= instantMintThreshold); 9 | token.mint(msg.sender, _amount); 10 | emit InstantMint(msg.sender, _amount, msg.sender); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/MockTrueCurrencyWithAutosweep.md: -------------------------------------------------------------------------------- 1 | ## `MockTrueCurrencyWithAutosweep` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `initialize()` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `decimals() → uint8` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `rounding() → uint8` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `name() → string` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `symbol() → string` (public) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/MockTrueCurrencyWithGasRefund.md: -------------------------------------------------------------------------------- 1 | ## `MockTrueCurrencyWithGasRefund` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `initialize()` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `decimals() → uint8` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `rounding() → uint8` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `name() → string` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `symbol() → string` (public) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/truefi/interface/IArbitraryDistributor.md: -------------------------------------------------------------------------------- 1 | ## `IArbitraryDistributor` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `amount() → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `remaining() → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `beneficiary() → address` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `distribute(uint256 _amount)` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `empty()` (external) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /test/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './constants' 2 | export * from './eventHelpers' 3 | export * from './expectCloseTo' 4 | export * from './parseEth' 5 | export * from './parseTRU' 6 | export * from './parseUSDC' 7 | export * from './timeTravel' 8 | export * from './toAddress' 9 | export * from './toHex' 10 | export * from './writeAttributeFor' 11 | export * from './updateRateOracle' 12 | export * from './setUtilization' 13 | export * from './connectMockContract' 14 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockStakingPool.md: -------------------------------------------------------------------------------- 1 | ## `MockStakingPool` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor(contract ITrueFiPool _pool)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `stakeSupply() → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `withdraw(uint256)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `unstake()` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `payFee(uint256 amount, uint256)` (external) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/MockStrategy.md: -------------------------------------------------------------------------------- 1 | ## `MockStrategy` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor(contract IERC20 _token, address _pool)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `deposit(uint256 amount)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `withdraw(uint256 minAmount)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `withdrawAll()` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `value() → uint256` (external) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/TestCurveStrategy.md: -------------------------------------------------------------------------------- 1 | ## `TestCurveStrategy` 2 | 3 | 4 | 5 | Test helper that allows using any wallet as a pool 6 | 7 | 8 | ### `testInitialize(contract IERC20WithDecimals _token, address _pool, contract ICurvePool _curvePool, contract ICurveGauge _curveGauge, contract ICurveMinter _minter, contract I1Inch3 _1inchExchange, contract ICrvPriceOracle _crvOracle, uint256 _maxPriceSlippage, uint8 _tokenIndex)` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /contracts/truefi/mocks/MockCrvPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "../interface/ICrvPriceOracle.sol"; 5 | 6 | contract MockCrvPriceOracle is ICrvPriceOracle { 7 | function usdToCrv(uint256 amount) external view override returns (uint256) { 8 | return amount * 2; 9 | } 10 | 11 | function crvToUsd(uint256 amount) external view override returns (uint256) { 12 | return amount / 2; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ITimeAveragedBaseRateOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ITimeAveragedBaseRateOracle { 5 | function calculateAverageAPY(uint16 numberOfValues) external view returns (uint256); 6 | 7 | function getWeeklyAPY() external view returns (uint256); 8 | 9 | function getMonthlyAPY() external view returns (uint256); 10 | 11 | function getYearlyAPY() external view returns (uint256); 12 | } 13 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ILineOfCreditAgency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ITrueFiPool2} from "./ITrueFiPool2.sol"; 5 | 6 | interface ILineOfCreditAgency { 7 | function poolCreditValue(ITrueFiPool2 pool) external view returns (uint256); 8 | 9 | function isOverProFormaLimit(address borrower, uint256 stakedAmount) external view returns (bool); 10 | 11 | function updateAllCreditScores(address borrower) external; 12 | } 13 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/IDeficiencyToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | import {IDebtToken} from "./IDebtToken.sol"; 6 | 7 | interface IDeficiencyToken is IERC20 { 8 | function debt() external view returns (IDebtToken); 9 | 10 | function burnFrom(address account, uint256 amount) external; 11 | 12 | function version() external pure returns (uint8); 13 | } 14 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/interface/IMintableXC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20Plus} from "./IERC20Plus.sol"; 5 | 6 | interface IMintableXC20 is IERC20Plus { 7 | function freeze(address account) external returns (bool); 8 | 9 | function thaw(address account) external returns (bool); 10 | 11 | function freezeAsset() external returns (bool); 12 | 13 | function thawAsset() external returns (bool); 14 | } 15 | -------------------------------------------------------------------------------- /contracts/truefi/mocks/MockTruPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "../interface/ITruPriceOracle.sol"; 5 | 6 | contract MockTruPriceOracle is ITruPriceOracle { 7 | function usdToTru(uint256 amount) external view override returns (uint256) { 8 | return (amount * 4) / 1e10; 9 | } 10 | 11 | function truToUsd(uint256 amount) external view override returns (uint256) { 12 | return (amount * 1e10) / 4; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/true-currencies/tokens/TrueCAD.md: -------------------------------------------------------------------------------- 1 | ## `TrueCAD` 2 | 3 | 4 | 5 | This is the top-level ERC20 contract, but most of the interesting functionality is 6 | inherited - see the documentation on the corresponding contracts. 7 | 8 | 9 | ### `decimals() → uint8` (public) 10 | 11 | 12 | 13 | 14 | 15 | ### `rounding() → uint8` (public) 16 | 17 | 18 | 19 | 20 | 21 | ### `name() → string` (public) 22 | 23 | 24 | 25 | 26 | 27 | ### `symbol() → string` (public) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/true-currencies/tokens/TrueGBP.md: -------------------------------------------------------------------------------- 1 | ## `TrueGBP` 2 | 3 | 4 | 5 | This is the top-level ERC20 contract, but most of the interesting functionality is 6 | inherited - see the documentation on the corresponding contracts. 7 | 8 | 9 | ### `decimals() → uint8` (public) 10 | 11 | 12 | 13 | 14 | 15 | ### `rounding() → uint8` (public) 16 | 17 | 18 | 19 | 20 | 21 | ### `name() → string` (public) 22 | 23 | 24 | 25 | 26 | 27 | ### `symbol() → string` (public) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/true-currencies/tokens/TrueHKD.md: -------------------------------------------------------------------------------- 1 | ## `TrueHKD` 2 | 3 | 4 | 5 | This is the top-level ERC20 contract, but most of the interesting functionality is 6 | inherited - see the documentation on the corresponding contracts. 7 | 8 | 9 | ### `decimals() → uint8` (public) 10 | 11 | 12 | 13 | 14 | 15 | ### `rounding() → uint8` (public) 16 | 17 | 18 | 19 | 20 | 21 | ### `name() → string` (public) 22 | 23 | 24 | 25 | 26 | 27 | ### `symbol() → string` (public) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/true-currencies/tokens/TrueUSD.md: -------------------------------------------------------------------------------- 1 | ## `TrueUSD` 2 | 3 | 4 | 5 | This is the top-level ERC20 contract, but most of the interesting functionality is 6 | inherited - see the documentation on the corresponding contracts. 7 | 8 | 9 | ### `decimals() → uint8` (public) 10 | 11 | 12 | 13 | 14 | 15 | ### `rounding() → uint8` (public) 16 | 17 | 18 | 19 | 20 | 21 | ### `name() → string` (public) 22 | 23 | 24 | 25 | 26 | 27 | ### `symbol() → string` (public) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/truefi/mocks/TestTrueFiPool.md: -------------------------------------------------------------------------------- 1 | ## `TestTrueFiPool` 2 | 3 | 4 | 5 | TrueFi pool with initializer used for tests. 6 | initializer was removed from TrueFiPool to reduce the contract size 7 | 8 | 9 | ### `initialize(contract ICurvePool __curvePool, contract ICurveGauge __curveGauge, contract IERC20 __currencyToken, contract ITrueLender __lender, contract IUniswapRouter __uniRouter, contract ITrueFiPoolOracle __truOracle, contract ICrvPriceOracle __crvOracle)` (public) 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/mocks/RegistryMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {Registry} from "../test/Registry.sol"; 5 | 6 | contract RegistryMock is Registry { 7 | /** 8 | * @dev sets the original `owner` of the contract to the sender 9 | * at construction. Must then be reinitialized 10 | */ 11 | constructor() public { 12 | owner = msg.sender; 13 | emit OwnershipTransferred(address(0), owner); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ITrueDistributor.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface ITrueDistributor { 7 | function asset() external view returns (IERC20); 8 | 9 | function farm() external view returns (address); 10 | 11 | function distribute() external; 12 | 13 | function nextDistribution() external view returns (uint256); 14 | 15 | function empty() external; 16 | } 17 | -------------------------------------------------------------------------------- /docs/truefi2/interface/IAaveLendingPool.md: -------------------------------------------------------------------------------- 1 | ## `IAaveLendingPool` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `getReserveData(address asset) → uint256 configuration, uint128 liquidityIndex, uint128 variableBorrowIndex, uint128 currentLiquidityRate, uint128 currentVariableBorrowRate, uint128 currentStableBorrowRate, uint40 lastUpdateTimestamp, address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress, address interestRateStrategyAddress, uint8 id` (external) 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/governance/interface/IVoteToken.md: -------------------------------------------------------------------------------- 1 | ## `IVoteToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `delegate(address delegatee)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `getCurrentVotes(address account) → uint96` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `getPriorVotes(address account, uint256 blockNumber) → uint96` (external) 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/registry/mocks/ProvisionalRegistry.md: -------------------------------------------------------------------------------- 1 | ## `ProvisionalRegistry` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `requireCanTransfer(address _from, address _to) → address, bool` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `requireCanTransferFrom(address _sender, address _from, address _to) → address, bool` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `requireCanMint(address _to) → address, bool` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `requireCanBurn(address _from)` (public) 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/true-currencies/tokens/TrueAUD.md: -------------------------------------------------------------------------------- 1 | ## `TrueAUD` 2 | 3 | title TrueAUD 4 | 5 | 6 | This is the top-level ERC20 contract, but most of the interesting functionality is 7 | inherited - see the documentation on the corresponding contracts. 8 | 9 | 10 | ### `decimals() → uint8` (public) 11 | 12 | 13 | 14 | 15 | 16 | ### `rounding() → uint8` (public) 17 | 18 | 19 | 20 | 21 | 22 | ### `name() → string` (public) 23 | 24 | 25 | 26 | 27 | 28 | ### `symbol() → string` (public) 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.solhint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "solhint:recommended", 3 | "rules": { 4 | "avoid-suicide": "error", 5 | "compiler-version": ["error","0.6.10"], 6 | "state-visibility": "off", 7 | "func-name-mixedcase": "off", 8 | "var-name-mixedcase": "off", 9 | "no-empty-blocks": "off", 10 | "no-inline-assembly": "off", 11 | "not-rely-on-time": "off", 12 | "max-states-count": "off", 13 | "reason-string": "off", 14 | "const-name-snakecase": "off", 15 | "avoid-tx-origin": "off" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /contracts/governance/mocks/MockPauseableContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity 0.6.10; 4 | 5 | import {IPauseableContract} from "../../common/interface/IPauseableContract.sol"; 6 | 7 | contract MockPauseableContract is IPauseableContract { 8 | bool public pauseStatus; 9 | 10 | event PauseStatusChanged(bool pauseStatus); 11 | 12 | function setPauseStatus(bool status) external override { 13 | pauseStatus = status; 14 | emit PauseStatusChanged(status); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/true-currencies/common/ReclaimerToken.md: -------------------------------------------------------------------------------- 1 | ## `ReclaimerToken` 2 | 3 | 4 | 5 | ERC20 token which allows owner to reclaim ERC20 tokens 6 | or ether sent to this contract 7 | 8 | 9 | ### `reclaimEther(address payable _to)` (external) 10 | 11 | 12 | 13 | send all eth balance in the contract to another address 14 | 15 | 16 | ### `reclaimToken(contract IERC20 token, address _to)` (external) 17 | 18 | 19 | 20 | send all token balance of an arbitrary erc20 token 21 | in the contract to another address 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /packages/contracts-bsc/test/fixtures/beforeEachWithFixture.ts: -------------------------------------------------------------------------------- 1 | import { waffle } from 'hardhat' 2 | import type { MockProvider } from 'ethereum-waffle' 3 | import type { Wallet } from 'ethers' 4 | 5 | export type Fixture = (wallets: Wallet[], provider: MockProvider) => Promise; 6 | 7 | export const loadFixture = waffle.createFixtureLoader( 8 | waffle.provider.getWallets(), 9 | waffle.provider, 10 | ) 11 | 12 | export function beforeEachWithFixture(fixture: Fixture) { 13 | beforeEach(() => loadFixture(fixture)) 14 | } 15 | -------------------------------------------------------------------------------- /packages/contracts-por/test/fixtures/beforeEachWithFixture.ts: -------------------------------------------------------------------------------- 1 | import { waffle } from 'hardhat' 2 | import type { MockProvider } from 'ethereum-waffle' 3 | import type { Wallet } from 'ethers' 4 | 5 | export type Fixture = (wallets: Wallet[], provider: MockProvider) => Promise; 6 | 7 | export const loadFixture = waffle.createFixtureLoader( 8 | waffle.provider.getWallets(), 9 | waffle.provider, 10 | ) 11 | 12 | export function beforeEachWithFixture(fixture: Fixture) { 13 | beforeEach(() => loadFixture(fixture)) 14 | } 15 | -------------------------------------------------------------------------------- /packages/contracts-watr/test/fixtures/beforeEachWithFixture.ts: -------------------------------------------------------------------------------- 1 | import { waffle } from 'hardhat' 2 | import type { MockProvider } from 'ethereum-waffle' 3 | import type { Wallet } from 'ethers' 4 | 5 | export type Fixture = (wallets: Wallet[], provider: MockProvider) => Promise; 6 | 7 | export const loadFixture = waffle.createFixtureLoader( 8 | waffle.provider.getWallets(), 9 | waffle.provider, 10 | ) 11 | 12 | export function beforeEachWithFixture(fixture: Fixture) { 13 | beforeEach(() => loadFixture(fixture)) 14 | } 15 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ITrueMultiFarm.md: -------------------------------------------------------------------------------- 1 | ## `ITrueMultiFarm` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `trueDistributor() → contract ITrueDistributor` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `stake(contract IERC20 token, uint256 amount)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `unstake(contract IERC20 token, uint256 amount)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `claim(contract IERC20[] tokens)` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `exit(contract IERC20[] tokens)` (external) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /scripts/deploy_paused_true_gold.ts: -------------------------------------------------------------------------------- 1 | import { Wallet } from 'ethers' 2 | 3 | import { deployContract } from 'scripts/utils/deployContract' 4 | import { waitForTx } from 'scripts/utils/waitForTx' 5 | 6 | import { 7 | PausedTrueGold__factory, 8 | PausedTrueGold, 9 | } from 'contracts' 10 | 11 | export async function deployPausedTrueGold (deployer: Wallet): Promise { 12 | const pausedToken = await deployContract(deployer, PausedTrueGold__factory) 13 | await waitForTx(pausedToken.initialize(0, 0)) 14 | return pausedToken 15 | } 16 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/PowTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "../libraries/TrueFiFixed64x64.sol"; 5 | 6 | /** 7 | * @dev Wrapper over TrueFiFixed64x64 library for testing purposes 8 | */ 9 | contract PowTest { 10 | function pow(uint256 x, uint256 y) external pure returns (uint256) { 11 | return 12 | TrueFiFixed64x64.toUInt( 13 | TrueFiFixed64x64.fixed64x64Pow(TrueFiFixed64x64.fromUInt(x), TrueFiFixed64x64.fromUInt(y) / 10000) 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/true-currencies/interface/ITrueCurrency.md: -------------------------------------------------------------------------------- 1 | ## `ITrueCurrency` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `refundGas(uint256 amount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `setBlacklisted(address account, bool _isBlacklisted)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `setCanBurn(address account, bool _canBurn)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `setBurnBounds(uint256 _min, uint256 _max)` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `mint(address account, uint256 amount)` (external) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/contracts-watr/scripts/deployment/deployRegistry.ts: -------------------------------------------------------------------------------- 1 | import { contract, createProxy } from 'ethereum-mars' 2 | import { OwnedUpgradeabilityProxy, Registry } from '../../build/artifacts' 3 | 4 | export function deployRegistry() { 5 | const ownedUpgradabilityProxy = createProxy(OwnedUpgradeabilityProxy) 6 | 7 | const implementation = contract(Registry) 8 | const proxy = ownedUpgradabilityProxy(implementation, (registry) => { 9 | registry.initialize() 10 | }) 11 | 12 | return { 13 | implementation, 14 | proxy, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /scripts/model/Address.ts: -------------------------------------------------------------------------------- 1 | type Opaque = T & { __TYPE__: K } 2 | const HEX_REGEX = /^0x[\da-fA-F]*$/ 3 | 4 | /** 5 | * An hexadecimal string representing an ethereum address. 6 | * Always prefixed with 0x, always lowercase and of length 42. 7 | */ 8 | export type Address = Opaque<'Address', string> 9 | 10 | export function makeAddress (value: string): Address { 11 | if (!HEX_REGEX.test(value) || value.length !== 42) { 12 | throw new TypeError(`Value "${value}" is not a valid address`) 13 | } 14 | return value.toLowerCase() as Address 15 | } 16 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/MockTrueFiPoolOracle.md: -------------------------------------------------------------------------------- 1 | ## `MockTrueFiPoolOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor(contract IERC20WithDecimals __token)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `token() → contract IERC20WithDecimals` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `tokenToTru(uint256 tokenAmount) → uint256` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `truToToken(uint256 truAmount) → uint256` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `tokenToUsd(uint256 tokenAmount) → uint256` (external) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | skipcheckprivatekey=$(git config --bool hooks.skipcheckprivatekey) 4 | 5 | if [ "$skipcheckprivatekey" != "true" ] && git --no-pager diff --cached | grep -i -q -E '[a-f0-9]{64}' 6 | then 7 | cat < { 9 | const proxy = createProxy(OwnedUpgradeabilityProxy) 10 | const tusd = proxy(contract(AvalancheTrueUSD), 'initialize', []) 11 | const controller = proxy(contract(AvalancheTokenController), 'initialize', []) 12 | tusd.transferOwnership(controller) 13 | controller.issueClaimOwnership(tusd) 14 | controller.setToken(tusd) 15 | }) 16 | -------------------------------------------------------------------------------- /docs/true-gold/mocks/ERC20Mock.md: -------------------------------------------------------------------------------- 1 | ## `ERC20Mock` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor(address initialAccount, uint256 initialBalance)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `mint(address account, uint256 amount)` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `burn(address account, uint256 amount)` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `transferInternal(address from, address to, uint256 value)` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `approveInternal(address owner, address spender, uint256 value)` (public) 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ITrueFiPoolOracle.md: -------------------------------------------------------------------------------- 1 | ## `ITrueFiPoolOracle` 2 | 3 | 4 | 5 | Oracle that converts any token to and from TRU 6 | Used for liquidations and valuing of liquidated TRU in the pool 7 | 8 | 9 | ### `token() → contract IERC20WithDecimals` (external) 10 | 11 | 12 | 13 | 14 | 15 | ### `truToToken(uint256 truAmount) → uint256` (external) 16 | 17 | 18 | 19 | 20 | 21 | ### `tokenToTru(uint256 tokenAmount) → uint256` (external) 22 | 23 | 24 | 25 | 26 | 27 | ### `tokenToUsd(uint256 tokenAmount) → uint256` (external) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/truefi2/SpotBaseRateOracle.md: -------------------------------------------------------------------------------- 1 | ## `SpotBaseRateOracle` 2 | 3 | 4 | 5 | Oracle to get spot rates from different lending protocols 6 | 7 | 8 | ### `constructor(contract IAaveLendingPool _aaveLendingPool)` (public) 9 | 10 | 11 | 12 | constructor which sets aave pool to `_aaveLendingPool` 13 | 14 | ### `getRate(address asset) → uint256` (external) 15 | 16 | 17 | 18 | Get rate for an `asset` 19 | 20 | 21 | ### `_getAaveVariableBorrowAPY(address asset) → uint256` (internal) 22 | 23 | 24 | 25 | Internal function to get Aave variable borrow apy for `asset` 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Our smart contracts are under active development. As such, we only support contracts in `main` or deployed in the most recent release. 6 | 7 | | Version | Supported | 8 | | ------- | ------------------ | 9 | | main | :white_check_mark: | 10 | | [deployed](deployments-mainnet.json) | :white_check_mark: | 11 | 12 | ## Reporting a Vulnerability 13 | 14 | Please disclose any vulnerabilities to security@trusttoken.com. 15 | Guidelines for our bug bounty program are located at https://github.com/trusttoken/bug-bounty. 16 | -------------------------------------------------------------------------------- /contracts/proxy/interface/IOwnedUpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IOwnedUpgradeabilityProxy { 5 | function proxyOwner() external view returns (address owner); 6 | 7 | function pendingProxyOwner() external view returns (address pendingOwner); 8 | 9 | function transferProxyOwnership(address newOwner) external; 10 | 11 | function claimProxyOwnership() external; 12 | 13 | function upgradeTo(address implementation) external; 14 | 15 | function implementation() external view returns (address impl); 16 | } 17 | -------------------------------------------------------------------------------- /test/integration/poolExchanges.test.ts: -------------------------------------------------------------------------------- 1 | import { upgradeSuite } from './suite' 2 | import { TrueFiPool__factory } from 'contracts' 3 | import { expect, use } from 'chai' 4 | import { solidity } from 'ethereum-waffle' 5 | import { parseUnits } from '@ethersproject/units' 6 | 7 | use(solidity) 8 | 9 | describe('Pool Curve integration', () => { 10 | it('deposit TUSD to Curve', async () => { 11 | const pool = await upgradeSuite(TrueFiPool__factory, '0xa1e72267084192Db7387c8CC1328fadE470e4149', []) 12 | await expect(pool.flush(parseUnits('1000', 18))).to.be.not.reverted 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /contracts/registry/mocks/MockRegistrySubscriber.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | contract MockRegistrySubscriber { 5 | mapping(address => mapping(bytes32 => uint256)) attributes; 6 | 7 | function syncAttributeValue( 8 | address _who, 9 | bytes32 _attribute, 10 | uint256 _value 11 | ) public { 12 | attributes[_who][_attribute] = _value; 13 | } 14 | 15 | function getAttributeValue(address _who, bytes32 _attribute) public view returns (uint256) { 16 | return attributes[_who][_attribute]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/TestDeficiencyToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {DeficiencyToken} from "../DeficiencyToken.sol"; 5 | import {IDebtToken} from "../interface/IDebtToken.sol"; 6 | 7 | /** 8 | * @dev Helper contract to test the burning feature of DeficiencyToken 9 | */ 10 | contract TestDeficiencyToken is DeficiencyToken { 11 | constructor(IDebtToken _debt, uint256 _amount) public DeficiencyToken(_debt, _amount) {} 12 | 13 | function mint(address account, uint256 amount) external { 14 | _mint(account, amount); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/true-currencies/common/GasRefund.md: -------------------------------------------------------------------------------- 1 | ## `GasRefund` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `gasRefund15(uint256 amount)` (internal) 9 | 10 | 11 | 12 | Refund 15,000 gas per slot. 13 | 14 | 15 | ### `gasRefund39(uint256 amount)` (internal) 16 | 17 | 18 | 19 | use smart contract self-destruct to refund gas 20 | will refund 39,000 * amount gas 21 | 22 | ### `remainingGasRefundPool() → uint256 length` (public) 23 | 24 | 25 | 26 | Return the remaining sponsored gas slots 27 | 28 | ### `remainingSheepRefundPool() → uint256 length` (public) 29 | 30 | 31 | 32 | Return the remaining sheep slots 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/proxy/interface/IOwnedUpgradeabilityProxy.md: -------------------------------------------------------------------------------- 1 | ## `IOwnedUpgradeabilityProxy` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `proxyOwner() → address owner` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `pendingProxyOwner() → address pendingOwner` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `transferProxyOwnership(address newOwner)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `claimProxyOwnership()` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `upgradeTo(address implementation)` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `implementation() → address impl` (external) 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /test/fixtures/beforeEachWithFixture.ts: -------------------------------------------------------------------------------- 1 | import { waffle } from 'hardhat' 2 | import { proxyProvider } from 'utils/hardhatCallHistoryProvider' 3 | import type { MockProvider } from 'ethereum-waffle' 4 | import type { Wallet } from 'ethers' 5 | 6 | export type Fixture = (wallets: Wallet[], provider: MockProvider) => Promise; 7 | 8 | export const loadFixture = waffle.createFixtureLoader( 9 | proxyProvider.getWallets(), 10 | proxyProvider, 11 | ) 12 | 13 | export function beforeEachWithFixture (fixture: Fixture) { 14 | proxyProvider.clearCallHistory() 15 | beforeEach(() => loadFixture(fixture)) 16 | } 17 | -------------------------------------------------------------------------------- /spec/truefi2/RateModel.spec: -------------------------------------------------------------------------------- 1 | methods { 2 | poolBasicRate(address, uint256) returns uint256 envfree 3 | 4 | liquidRatio(uint256) returns uint256 => DISPATCHER(true) 5 | getWeeklyAPY() returns uint256 => DISPATCHER(true) 6 | balanceOf() returns uint256 => DISPATCHER(true) 7 | } 8 | 9 | rule poolBasicRateIsMonotoneWrtAmount { 10 | uint256 amount1; 11 | uint256 amount2; 12 | address pool; 13 | 14 | require amount1 <= amount2; 15 | 16 | uint256 rate1 = poolBasicRate(pool, amount1); 17 | uint256 rate2 = poolBasicRate(pool, amount2); 18 | 19 | assert rate1 <= rate2, "poolBasicRate() is not monotone"; 20 | } 21 | -------------------------------------------------------------------------------- /docs/truefi2/mocks/BadStrategy.md: -------------------------------------------------------------------------------- 1 | ## `BadStrategy` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor(contract IERC20 _token, address _pool)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `deposit(uint256 amount)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `withdraw(uint256 minAmount)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `withdrawAll()` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `value() → uint256` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `setErrorPercents(uint256 _error)` (external) 39 | 40 | 41 | 42 | 43 | 44 | ### `withError(uint256 amount) → uint256` (public) 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /docs/truefi/interface/ITrueRatingAgencyV2.md: -------------------------------------------------------------------------------- 1 | ## `ITrueRatingAgencyV2` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `getResults(address id) → uint256, uint256, uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `submit(address id)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `retract(address id)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `resetCastRatings(address id)` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `yes(address id)` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `no(address id)` (external) 39 | 40 | 41 | 42 | 43 | 44 | ### `claim(address id, address voter)` (external) 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /.solcover.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | skipFiles: [ 3 | './avalanche', 4 | './common/interface', 5 | './governance/interface', 6 | './governance/mocks', 7 | './proxy/interface', 8 | './proxy/mocks', 9 | './registry/interface', 10 | './registry/mocks', 11 | './true-currencies/interface', 12 | './true-currencies/mocks', 13 | './true-gold/interface', 14 | './true-gold/mocks', 15 | './truefi/interface', 16 | './truefi/mocks', 17 | './truefi2/interface', 18 | './truefi2/mocks', 19 | './truefi2/deprecated', 20 | './trusttoken/interface', 21 | './trusttoken/mocks', 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/utils/updateRateOracle.ts: -------------------------------------------------------------------------------- 1 | import { MockProvider } from 'ethereum-waffle' 2 | import { timeTravelTo } from '.' 3 | import { BigNumber } from 'ethers' 4 | 5 | interface AveragedOracle { 6 | update(): Promise, 7 | getTotalsBuffer(): Promise<[BigNumber[], BigNumber[], number]>, 8 | } 9 | 10 | export const updateRateOracle = async (oracle: AveragedOracle, cooldown: number, provider: MockProvider) => { 11 | const [, timestamps, currIndex] = await oracle.getTotalsBuffer() 12 | const newestTimestamp = timestamps[currIndex].toNumber() 13 | await timeTravelTo(provider, newestTimestamp + cooldown - 1) 14 | await oracle.update() 15 | } 16 | -------------------------------------------------------------------------------- /contracts/true-currencies/mocks/ForceEther.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | // Source: @openzeppelin/contracts/mocks/ForceEther.sol 5 | // @title Force Ether into a contract. 6 | // @notice even 7 | // if the contract is not payable. 8 | // @notice To use, construct the contract with the target as argument. 9 | // @author Remco Bloemen 10 | contract ForceEther { 11 | // solhint-disable-next-line no-empty-blocks 12 | constructor() public payable {} 13 | 14 | function destroyAndSend(address _recipient) public { 15 | selfdestruct(address(uint160(_recipient))); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ITrueMultiFarm.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | import {ITrueDistributor} from "../../truefi/interface/ITrueDistributor.sol"; 7 | 8 | interface ITrueMultiFarm { 9 | function trueDistributor() external view returns (ITrueDistributor); 10 | 11 | function stake(IERC20 token, uint256 amount) external; 12 | 13 | function unstake(IERC20 token, uint256 amount) external; 14 | 15 | function claim(IERC20[] calldata tokens) external; 16 | 17 | function exit(IERC20[] calldata tokens) external; 18 | } 19 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/TestTrueRatingAgencyV2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "../../truefi/TrueRatingAgencyV2.sol"; 5 | 6 | contract TestTrueRatingAgencyV2 is TrueRatingAgencyV2 { 7 | function yes(address id, uint256 stake) external { 8 | loans[id].prediction[true] = loans[id].prediction[true].add(stake); 9 | loans[id].ratings[msg.sender][true] = loans[id].ratings[msg.sender][true].add(stake); 10 | } 11 | 12 | function submit(address id) external { 13 | loans[id] = Loan({creator: msg.sender, timestamp: block.timestamp, blockNumber: block.number, reward: 0}); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/mocks/ForceEther.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | // Source: @openzeppelin/contracts/mocks/ForceEther.sol 5 | // @title Force Ether into a contract. 6 | // @notice even 7 | // if the contract is not payable. 8 | // @notice To use, construct the contract with the target as argument. 9 | // @author Remco Bloemen 10 | contract ForceEther { 11 | // solhint-disable-next-line no-empty-blocks 12 | constructor() public payable {} 13 | 14 | function destroyAndSend(address _recipient) public { 15 | selfdestruct(address(uint160(_recipient))); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/mocks/ForceEther.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | // Source: @openzeppelin/contracts/mocks/ForceEther.sol 5 | // @title Force Ether into a contract. 6 | // @notice even 7 | // if the contract is not payable. 8 | // @notice To use, construct the contract with the target as argument. 9 | // @author Remco Bloemen 10 | contract ForceEther { 11 | // solhint-disable-next-line no-empty-blocks 12 | constructor() public payable {} 13 | 14 | function destroyAndSend(address _recipient) public { 15 | selfdestruct(address(uint160(_recipient))); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/mocks/ForceEther.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | // Source: @openzeppelin/contracts/mocks/ForceEther.sol 5 | // @title Force Ether into a contract. 6 | // @notice even 7 | // if the contract is not payable. 8 | // @notice To use, construct the contract with the target as argument. 9 | // @author Remco Bloemen 10 | contract ForceEther { 11 | // solhint-disable-next-line no-empty-blocks 12 | constructor() public payable {} 13 | 14 | function destroyAndSend(address _recipient) public { 15 | selfdestruct(address(uint160(_recipient))); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/mocks/MockTrueCurrency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithProofOfReserve} from "../TrueCurrencyWithProofOfReserve.sol"; 5 | 6 | contract MockTrueCurrency is TrueCurrencyWithProofOfReserve { 7 | uint8 constant ROUNDING = 2; 8 | 9 | function rounding() public pure returns (uint8) { 10 | return ROUNDING; 11 | } 12 | 13 | function name() public pure override returns (string memory) { 14 | return "TrueCurrency"; 15 | } 16 | 17 | function symbol() public pure override returns (string memory) { 18 | return "TCUR"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.github/workflows/coverage.yml: -------------------------------------------------------------------------------- 1 | name: Test Coveralls 2 | on: 3 | schedule: 4 | - cron: "0 4 * * *" 5 | jobs: 6 | build: 7 | name: Build 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v1 11 | - name: Use Node.js 14.x 12 | uses: actions/setup-node@v1 13 | with: 14 | node-version: 14.x 15 | - name: yarn 16 | run: yarn 17 | - name: build 18 | run: yarn build 19 | - name: coverage 20 | run: yarn coverage 21 | - name: Coveralls 22 | uses: coverallsapp/github-action@master 23 | with: 24 | github-token: ${{ secrets.GITHUB_TOKEN }} 25 | -------------------------------------------------------------------------------- /docs/truefi/interface/ITrueRatingAgency.md: -------------------------------------------------------------------------------- 1 | ## `ITrueRatingAgency` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `getResults(address id) → uint256, uint256, uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `submit(address id)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `retract(address id)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `yes(address id, uint256 stake)` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `no(address id, uint256 stake)` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `withdraw(address id, uint256 stake)` (external) 39 | 40 | 41 | 42 | 43 | 44 | ### `claim(address id, address voter)` (external) 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /contracts/truefi2/oracles/ChainlinkTruBusdOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ChainlinkTruOracle, IERC20WithDecimals} from "./ChainlinkTruOracle.sol"; 5 | 6 | contract ChainlinkTruBusdOracle is ChainlinkTruOracle { 7 | function token() public view override returns (IERC20WithDecimals) { 8 | return IERC20WithDecimals(0x4Fabb145d64652a948d72533023f6E7A623C7C53); 9 | } 10 | 11 | /* 12 | * @dev assume price is always 1USD, convert 18 decimal places to 18 13 | */ 14 | function tokenToUsd(uint256 tokenAmount) public view override returns (uint256) { 15 | return tokenAmount; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /contracts/truefi2/oracles/ChainlinkTruTusdOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ChainlinkTruOracle, IERC20WithDecimals} from "./ChainlinkTruOracle.sol"; 5 | 6 | contract ChainlinkTruTusdOracle is ChainlinkTruOracle { 7 | function token() public view override returns (IERC20WithDecimals) { 8 | return IERC20WithDecimals(0x0000000000085d4780B73119b644AE5ecd22b376); 9 | } 10 | 11 | /* 12 | * @dev assume price is always 1USD, convert 18 decimal places to 18 13 | */ 14 | function tokenToUsd(uint256 tokenAmount) public view override returns (uint256) { 15 | return tokenAmount; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/mocks/RegistryMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {Registry} from "../test/Registry.sol"; 5 | 6 | contract RegistryMock is Registry { 7 | /** 8 | * @dev sets the original `owner` of the contract to the sender 9 | * at construction. Must then be reinitialized 10 | */ 11 | constructor() public { 12 | owner = msg.sender; 13 | emit OwnershipTransferred(address(0), owner); 14 | } 15 | 16 | function initialize() public { 17 | require(!initialized, "already initialized"); 18 | owner = msg.sender; 19 | initialized = true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/contracts-bsc/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import '@typechain/hardhat' 2 | import '@nomiclabs/hardhat-waffle' 3 | import './abi-exporter' 4 | 5 | import compiler from './.compiler.json' 6 | 7 | module.exports = { 8 | paths: { 9 | sources: './contracts', 10 | artifacts: './build', 11 | cache: './cache', 12 | }, 13 | abiExporter: { 14 | path: './build', 15 | flat: true, 16 | spacing: 2, 17 | }, 18 | networks: { 19 | hardhat: { 20 | allowUnlimitedContractSize: true, 21 | }, 22 | }, 23 | typechain: { 24 | outDir: 'build/types', 25 | target: 'ethers-v5', 26 | }, 27 | solidity: { 28 | compilers: [compiler], 29 | }, 30 | } 31 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/mocks/RegistryMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {Registry} from "../test/Registry.sol"; 5 | 6 | contract RegistryMock is Registry { 7 | /** 8 | * @dev sets the original `owner` of the contract to the sender 9 | * at construction. Must then be reinitialized 10 | */ 11 | constructor() public { 12 | owner = msg.sender; 13 | emit OwnershipTransferred(address(0), owner); 14 | } 15 | 16 | function initialize() public { 17 | require(!initialized, "already initialized"); 18 | owner = msg.sender; 19 | initialized = true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/contracts-por/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import '@typechain/hardhat' 2 | import '@nomiclabs/hardhat-waffle' 3 | import './abi-exporter' 4 | 5 | import compiler from './.compiler.json' 6 | 7 | module.exports = { 8 | paths: { 9 | sources: './contracts', 10 | artifacts: './build', 11 | cache: './cache', 12 | }, 13 | abiExporter: { 14 | path: './build', 15 | flat: true, 16 | spacing: 2, 17 | }, 18 | networks: { 19 | hardhat: { 20 | allowUnlimitedContractSize: true, 21 | }, 22 | }, 23 | typechain: { 24 | outDir: 'build/types', 25 | target: 'ethers-v5', 26 | }, 27 | solidity: { 28 | compilers: [compiler], 29 | }, 30 | } 31 | -------------------------------------------------------------------------------- /packages/contracts-watr/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import '@typechain/hardhat' 2 | import '@nomiclabs/hardhat-waffle' 3 | import './abi-exporter' 4 | 5 | import compiler from './.compiler.json' 6 | 7 | module.exports = { 8 | paths: { 9 | sources: './contracts', 10 | artifacts: './build', 11 | cache: './cache', 12 | }, 13 | abiExporter: { 14 | path: './build', 15 | flat: true, 16 | spacing: 2, 17 | }, 18 | networks: { 19 | hardhat: { 20 | allowUnlimitedContractSize: true, 21 | }, 22 | }, 23 | typechain: { 24 | outDir: 'build/types', 25 | target: 'ethers-v5', 26 | }, 27 | solidity: { 28 | compilers: [compiler], 29 | }, 30 | } 31 | -------------------------------------------------------------------------------- /contracts/truefi2/oracles/ChainlinkTruUsdcOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ChainlinkTruOracle, IERC20WithDecimals} from "./ChainlinkTruOracle.sol"; 5 | 6 | contract ChainlinkTruUsdcOracle is ChainlinkTruOracle { 7 | function token() public view override returns (IERC20WithDecimals) { 8 | return IERC20WithDecimals(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); 9 | } 10 | 11 | /* 12 | * @dev assume price is always 1USD, convert 6 decimal places to 18 13 | */ 14 | function tokenToUsd(uint256 tokenAmount) public view override returns (uint256) { 15 | return tokenAmount.mul(1e12); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /contracts/truefi2/oracles/ChainlinkTruUsdtOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ChainlinkTruOracle, IERC20WithDecimals} from "./ChainlinkTruOracle.sol"; 5 | 6 | contract ChainlinkTruUsdtOracle is ChainlinkTruOracle { 7 | function token() public view override returns (IERC20WithDecimals) { 8 | return IERC20WithDecimals(0xdAC17F958D2ee523a2206206994597C13D831ec7); 9 | } 10 | 11 | /* 12 | * @dev assume price is always 1USD, convert 6 decimal places to 18 13 | */ 14 | function tokenToUsd(uint256 tokenAmount) public view override returns (uint256) { 15 | return tokenAmount.mul(1e12); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docs/trusttoken/mocks/MockERC20Token.md: -------------------------------------------------------------------------------- 1 | ## `MockERC20Token` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `registry() → contract Registry` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `setRegistry(contract Registry _registry)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `mint(address _to, uint256 _value)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `burn(uint256 _value)` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `rounding() → uint8` (public) 33 | 34 | 35 | 36 | 37 | 38 | ### `decimals() → uint8` (public) 39 | 40 | 41 | 42 | 43 | 44 | ### `name() → string` (public) 45 | 46 | 47 | 48 | 49 | 50 | ### `symbol() → string` (public) 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/truefi/interface/ICurvePool.md: -------------------------------------------------------------------------------- 1 | ## `ICurvePool` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `add_liquidity(uint256[4] amounts, uint256 min_mint_amount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `remove_liquidity_one_coin(uint256 _token_amount, int128 i, uint256 min_amount, bool donate_dust)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `calc_withdraw_one_coin(uint256 _token_amount, int128 i) → uint256` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `token() → contract IERC20` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `curve() → contract ICurve` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `coins(int128 id) → contract IYToken` (external) 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ITrueRatingAgency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ITrueRatingAgency { 5 | function getResults(address id) 6 | external 7 | view 8 | returns ( 9 | uint256, 10 | uint256, 11 | uint256 12 | ); 13 | 14 | function submit(address id) external; 15 | 16 | function retract(address id) external; 17 | 18 | function yes(address id, uint256 stake) external; 19 | 20 | function no(address id, uint256 stake) external; 21 | 22 | function withdraw(address id, uint256 stake) external; 23 | 24 | function claim(address id, address voter) external; 25 | } 26 | -------------------------------------------------------------------------------- /contracts/common/interface/IPoRToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IPoRToken { 5 | /** 6 | * @notice Event emitted when the feed is updated 7 | */ 8 | event NewChainReserveFeed(address oldFeed, address newFeed); 9 | 10 | /** 11 | * @notice Event emitted when the heartbeat of chain reserve feed is updated 12 | */ 13 | event NewChainReserveHeartbeat(uint256 oldHeartbeat, uint256 newHeartbeat); 14 | 15 | /*** Admin Functions ***/ 16 | 17 | function setChainReserveFeed(address newFeed) external returns (uint256); 18 | 19 | function setChainReserveHeartbeat(uint256 newHeartbeat) external returns (uint256); 20 | } 21 | -------------------------------------------------------------------------------- /test/truefi2/Pow.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import { beforeEachWithFixture } from 'fixtures/beforeEachWithFixture' 3 | import { PowTest__factory, PowTest } from 'contracts' 4 | import { BigNumber } from 'ethers' 5 | 6 | describe('Power', () => { 7 | let pow: PowTest 8 | beforeEachWithFixture(async ([owner]) => { 9 | pow = await new PowTest__factory(owner).deploy() 10 | }) 11 | 12 | it('calculates x^y', async () => { 13 | expect(await pow.pow(10000, 5000)).to.be.closeTo(BigNumber.from(100), 1) 14 | expect(await pow.pow(1000, 3333)).to.be.closeTo(BigNumber.from(10), 1) 15 | expect(await pow.pow(4, 20000)).to.equal(16) 16 | expect(await pow.pow(4, 0)).to.equal(1) 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /scripts/utils/deployContract.ts: -------------------------------------------------------------------------------- 1 | import { Contract, Signer } from 'ethers' 2 | 3 | interface ContractFactory { 4 | deploy(...args: Parameters): Promise, 5 | attach(address: string): C, 6 | } 7 | 8 | export interface ContractFactoryConstructor { 9 | new(signer?: Signer): ContractFactory, 10 | } 11 | 12 | export async function deployContract ( 13 | deployer: Signer, 14 | Factory: ContractFactoryConstructor, 15 | args?: Parameters, 16 | ): Promise { 17 | const factory = new Factory(deployer) 18 | const contract = await factory.deploy(...(args || [] as any)) 19 | await contract.deployed() 20 | return contract 21 | } 22 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/interface/ITrueCurrency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface ITrueCurrency { 7 | function mint(address account, uint256 amount) external; 8 | 9 | function burn(uint256 amount) external; 10 | 11 | function setCanBurn(address account, bool _canBurn) external; 12 | 13 | function setBurnBounds(uint256 _min, uint256 _max) external; 14 | 15 | function reclaimEther(address payable _to) external; 16 | 17 | function reclaimToken(IERC20 token, address _to) external; 18 | 19 | function setBlacklisted(address account, bool isBlacklisted) external; 20 | } 21 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/interface/ITrueCurrency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface ITrueCurrency { 7 | function mint(address account, uint256 amount) external; 8 | 9 | function burn(uint256 amount) external; 10 | 11 | function setCanBurn(address account, bool _canBurn) external; 12 | 13 | function setBurnBounds(uint256 _min, uint256 _max) external; 14 | 15 | function reclaimEther(address payable _to) external; 16 | 17 | function reclaimToken(IERC20 token, address _to) external; 18 | 19 | function setBlacklisted(address account, bool isBlacklisted) external; 20 | } 21 | -------------------------------------------------------------------------------- /test/fixtures/trueGold.ts: -------------------------------------------------------------------------------- 1 | import { utils, Wallet } from 'ethers' 2 | 3 | import { MAX_BURN_BOUND } from 'utils' 4 | 5 | import { TrueGold__factory } from 'contracts' 6 | 7 | export const initialSupply = utils.parseUnits('12441', 6) 8 | 9 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 10 | export async function setupTrueGold ([deployer, initialHolder, secondAccount, thirdAccount]: Wallet[]) { 11 | const trueGoldFactory = new TrueGold__factory(deployer) 12 | const token = await trueGoldFactory.deploy() 13 | await token.initialize(0, MAX_BURN_BOUND) 14 | await token.mint(initialHolder.address, initialSupply) 15 | 16 | return { deployer, initialHolder, secondAccount, thirdAccount, token } 17 | } 18 | -------------------------------------------------------------------------------- /contracts/true-currencies/interface/ITrueCurrency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | import {IHasOwner} from "./IHasOwner.sol"; 7 | import {IReclaimerToken} from "./IReclaimerToken.sol"; 8 | 9 | interface ITrueCurrency is IERC20, IReclaimerToken, IHasOwner { 10 | function refundGas(uint256 amount) external; 11 | 12 | function setBlacklisted(address account, bool _isBlacklisted) external; 13 | 14 | function setCanBurn(address account, bool _canBurn) external; 15 | 16 | function setBurnBounds(uint256 _min, uint256 _max) external; 17 | 18 | function mint(address account, uint256 amount) external; 19 | } 20 | -------------------------------------------------------------------------------- /docs/true-gold/PausedTrueGold.md: -------------------------------------------------------------------------------- 1 | ## `PausedTrueGold` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `transfer(address, uint256) → bool` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `transferFrom(address, address, uint256) → bool` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `burn(uint256)` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `burnFrom(address, uint256)` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `mint(address, uint256)` (public) 33 | 34 | 35 | 36 | 37 | 38 | ### `approve(address, uint256) → bool` (public) 39 | 40 | 41 | 42 | 43 | 44 | ### `increaseAllowance(address, uint256) → bool` (public) 45 | 46 | 47 | 48 | 49 | 50 | ### `decreaseAllowance(address, uint256) → bool` (public) 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /contracts/governance/interface/IVoteToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface IVoteToken { 7 | function delegate(address delegatee) external; 8 | 9 | function delegateBySig( 10 | address delegatee, 11 | uint256 nonce, 12 | uint256 expiry, 13 | uint8 v, 14 | bytes32 r, 15 | bytes32 s 16 | ) external; 17 | 18 | function getCurrentVotes(address account) external view returns (uint96); 19 | 20 | function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96); 21 | } 22 | 23 | interface IVoteTokenWithERC20 is IVoteToken, IERC20 {} 24 | -------------------------------------------------------------------------------- /docs/true-gold/common/ERC20Burnable.md: -------------------------------------------------------------------------------- 1 | ## `ERC20Burnable` 2 | 3 | 4 | 5 | Extension of {ERC20} that allows token holders to destroy both their own 6 | tokens and those that they have an allowance for, in a way that can be 7 | recognized off-chain (via event analysis). 8 | 9 | 10 | ### `burn(uint256 amount)` (public) 11 | 12 | 13 | 14 | Destroys `amount` tokens from the caller. 15 | See {ERC20-_burn}. 16 | 17 | ### `burnFrom(address account, uint256 amount)` (public) 18 | 19 | 20 | 21 | Destroys `amount` tokens from `account`, deducting from the caller's 22 | allowance. 23 | See {ERC20-_burn} and {ERC20-allowance}. 24 | Requirements: 25 | - the caller must have allowance for ``accounts``'s tokens of at least 26 | `amount`. 27 | 28 | 29 | -------------------------------------------------------------------------------- /contracts/truefi2/deprecated/ITrueLender2Deprecated.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ITrueFiPool2} from "../interface/ITrueFiPool2.sol"; 5 | import {ILoanToken2Deprecated} from "../deprecated/ILoanToken2Deprecated.sol"; 6 | 7 | interface ITrueLender2Deprecated { 8 | // @dev calculate overall value of the pools 9 | function value(ITrueFiPool2 pool) external view returns (uint256); 10 | 11 | // @dev distribute a basket of tokens for exiting user 12 | function distribute( 13 | address recipient, 14 | uint256 numerator, 15 | uint256 denominator 16 | ) external; 17 | 18 | function transferAllLoanTokens(ILoanToken2Deprecated loan, address recipient) external; 19 | } 20 | -------------------------------------------------------------------------------- /docs/truefi/TruPriceChainLinkOracle.md: -------------------------------------------------------------------------------- 1 | ## `TruPriceChainLinkOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor(contract IChainLink _chainlinkOracle)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `usdToTru(uint256 amount) → uint256` (external) 15 | 16 | 17 | 18 | converts from USD with 18 decimals to TRU with 8 decimals 19 | Divide by 100 since Chainlink returns 10 decimals and TRU is 8 decimals 20 | 21 | 22 | ### `truToUsd(uint256 amount) → uint256` (external) 23 | 24 | 25 | 26 | converts from TRU with 8 decimals to USD with 18 decimals 27 | Multiply by 100 since Chainlink returns 10 decimals and TRU is 8 decimals 28 | 29 | 30 | ### `safeUint(int256 value) → uint256` (internal) 31 | 32 | 33 | 34 | convert int256 to uint256 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/truefi/interface/ITrueFarm.md: -------------------------------------------------------------------------------- 1 | ## `ITrueFarm` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `stakingToken() → contract IERC20` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `trustToken() → contract IERC20` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `trueDistributor() → contract ITrueDistributor` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `name() → string` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `totalStaked() → uint256` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `stake(uint256 amount)` (external) 39 | 40 | 41 | 42 | 43 | 44 | ### `unstake(uint256 amount)` (external) 45 | 46 | 47 | 48 | 49 | 50 | ### `claim()` (external) 51 | 52 | 53 | 54 | 55 | 56 | ### `exit(uint256 amount)` (external) 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/IFixedTermLoan.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | import {ITrueFiPool2} from "./ITrueFiPool2.sol"; 6 | 7 | interface IFixedTermLoan is IERC20 { 8 | enum Status { 9 | Withdrawn, 10 | Settled, 11 | Defaulted 12 | } 13 | 14 | function redeem() external; 15 | 16 | function status() external view returns (Status); 17 | 18 | function interest() external view returns (uint256); 19 | 20 | function debt() external view returns (uint256); 21 | 22 | function currentValue(address holder) external view returns (uint256); 23 | 24 | function pool() external view returns (ITrueFiPool2); 25 | } 26 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ISAFU.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IDeficiencyToken} from "./IDeficiencyToken.sol"; 5 | import {IDebtToken} from "./IDebtToken.sol"; 6 | import {ILoanToken2Deprecated} from "../deprecated/ILoanToken2Deprecated.sol"; 7 | 8 | interface ISAFU { 9 | function poolDeficit(address pool) external view returns (uint256); 10 | 11 | function legacyDeficiencyToken(ILoanToken2Deprecated loan) external view returns (IDeficiencyToken); 12 | 13 | function deficiencyToken(IDebtToken debt) external view returns (IDeficiencyToken); 14 | 15 | function legacyReclaim(ILoanToken2Deprecated loan, uint256 amount) external; 16 | 17 | function reclaim(IDebtToken debt, uint256 amount) external; 18 | } 19 | -------------------------------------------------------------------------------- /docs/truefi/common/Initializable.md: -------------------------------------------------------------------------------- 1 | ## `Initializable` 2 | 3 | 4 | 5 | Helper contract to support initializer functions. To use it, replace 6 | the constructor with a function that has the `initializer` modifier. 7 | WARNING: Unlike constructors, initializer functions must be manually 8 | invoked. This applies both to deploying an Initializable contract, as well 9 | as extending an Initializable contract via inheritance. 10 | WARNING: When used with inheritance, manual care must be taken to not invoke 11 | a parent initializer twice, or ensure that all initializers are idempotent, 12 | because this is not dealt with automatically as with constructors. 13 | 14 | ### `initializer()` 15 | 16 | 17 | 18 | Modifier to use in the initializer function of a contract. 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/truefi2/interface/ITrueStrategy.md: -------------------------------------------------------------------------------- 1 | ## `ITrueStrategy` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `deposit(uint256 amount)` (external) 9 | 10 | 11 | 12 | put `amount` of tokens into the strategy 13 | As a result of the deposit value of the strategy should increase by at least 98% of amount 14 | 15 | ### `withdraw(uint256 minAmount)` (external) 16 | 17 | 18 | 19 | pull at least `minAmount` of tokens from strategy and transfer to the pool 20 | 21 | ### `withdrawAll()` (external) 22 | 23 | 24 | 25 | withdraw everything from strategy 26 | As a result of calling withdrawAll(),at least 98% of strategy's value should be transferred to the pool 27 | Value must become 0 28 | 29 | ### `value() → uint256` (external) 30 | 31 | 32 | 33 | value evaluated to Pool's tokens 34 | 35 | 36 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/interface/ITrueCurrency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IBEP20} from "./IBEP20.sol"; 5 | import {IClaimableOwnable} from "./IClaimableOwnable.sol"; 6 | 7 | interface ITrueCurrency is IClaimableOwnable { 8 | function mint(address account, uint256 amount) external; 9 | 10 | function burn(uint256 amount) external; 11 | 12 | function setCanBurn(address account, bool _canBurn) external; 13 | 14 | function setBurnBounds(uint256 _min, uint256 _max) external; 15 | 16 | function reclaimEther(address payable _to) external; 17 | 18 | function reclaimToken(IBEP20 token, address _to) external; 19 | 20 | function setBlacklisted(address account, bool isBlacklisted) external; 21 | } 22 | -------------------------------------------------------------------------------- /docs/proxy/ImplementationReference.md: -------------------------------------------------------------------------------- 1 | ## `ImplementationReference` 2 | 3 | 4 | 5 | This contract is made to serve a simple purpose only. 6 | To hold the address of the implementation contract to be used by proxy. 7 | The implementation address, is changeable anytime by the owner of this contract. 8 | 9 | 10 | ### `constructor(address _implementation)` (public) 11 | 12 | 13 | 14 | Set initial ownership and implementation address 15 | 16 | 17 | ### `setImplementation(address newImplementation)` (external) 18 | 19 | 20 | 21 | Function to change the implementation address, which can be called only by the owner 22 | 23 | 24 | 25 | ### `ImplementationChanged(address newImplementation)` 26 | 27 | 28 | 29 | Event to show that implementation address has been changed 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/true-gold/common/Initializable.md: -------------------------------------------------------------------------------- 1 | ## `Initializable` 2 | 3 | 4 | 5 | Helper contract to support initializer functions. To use it, replace 6 | the constructor with a function that has the `initializer` modifier. 7 | WARNING: Unlike constructors, initializer functions must be manually 8 | invoked. This applies both to deploying an Initializable contract, as well 9 | as extending an Initializable contract via inheritance. 10 | WARNING: When used with inheritance, manual care must be taken to not invoke 11 | a parent initializer twice, or ensure that all initializers are idempotent, 12 | because this is not dealt with automatically as with constructors. 13 | 14 | ### `initializer()` 15 | 16 | 17 | 18 | Modifier to use in the initializer function of a contract. 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /contracts/true-gold/Reclaimable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity 0.6.10; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | import "./common/Ownable.sol"; 7 | import "./common/ProxyStorage.sol"; 8 | import "./interface/IOwnable.sol"; 9 | 10 | contract Reclaimable is Ownable { 11 | function reclaimEther(address payable to) public onlyOwner { 12 | to.transfer(address(this).balance); 13 | } 14 | 15 | function reclaimToken(IERC20 token, address to) public onlyOwner { 16 | uint256 balance = token.balanceOf(address(this)); 17 | token.transfer(to, balance); 18 | } 19 | 20 | function reclaimContract(IOwnable ownable) public onlyOwner { 21 | ownable.transferOwnership(_owner); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ISushiswapRewarder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // Copied from https://github.com/sushiswap/sushiswap/blob/master/contracts/interfaces/IRewarder.sol 3 | pragma solidity 0.6.10; 4 | 5 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 6 | 7 | /** 8 | * @dev Interface for sushiswap rewards 9 | */ 10 | interface ISushiswapRewarder { 11 | function onSushiReward( 12 | uint256 pid, 13 | address user, 14 | address recipient, 15 | uint256 sushiAmount, 16 | uint256 newLpAmount 17 | ) external; 18 | 19 | function pendingTokens( 20 | uint256 pid, 21 | address user, 22 | uint256 sushiAmount 23 | ) external view returns (IERC20[] memory, uint256[] memory); 24 | } 25 | -------------------------------------------------------------------------------- /contracts/true-currencies/TrueCurrencyWithGasRefund.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {GasRefund} from "./common/GasRefund.sol"; 5 | 6 | import {TrueCurrency} from "./TrueCurrency.sol"; 7 | 8 | abstract contract TrueCurrencyWithGasRefund is GasRefund, TrueCurrency { 9 | /** 10 | * @dev reclaim gas from legacy gas refund #1 11 | * will refund 15,000 * amount gas to sender (minus exection cost) 12 | * If gas pool is empty, refund 39,000 * amount gas by calling selfdestruct 13 | */ 14 | function refundGas(uint256 amount) external onlyOwner { 15 | if (remainingGasRefundPool() > 0) { 16 | gasRefund15(amount); 17 | } else { 18 | gasRefund39(amount.div(3)); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /deploy/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "BUSD": "0x4Fabb145d64652a948d72533023f6E7A623C7C53", 3 | "TUSD": "0x0000000000085d4780B73119b644AE5ecd22b376", 4 | "USDC": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", 5 | "USDT": "0xdAC17F958D2ee523a2206206994597C13D831ec7", 6 | "TRU": "0x4C19596f5aAfF459fA38B0f7eD92F11AE6543784", 7 | "CURVE_GAUGE": "0xFA712EE4788C042e2B7BB55E6cb8ec569C4530c1", 8 | "CURVE_POOL": "0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3", 9 | "CURVE_MINTER": "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0", 10 | "ONE_INCH_EXCHANGE": "0x11111112542D85B3EF69AE05771c2dCCff4fAa26", 11 | "SUSHI_MASTER_CHEF": "0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd", 12 | "TRU_DECIMALS": 8, 13 | "SUSHI_REWARD_MULTIPLIER": 100, 14 | "MAX_PRICE_SLIPPAGE": 75, 15 | "LOAN_INTEREST_FEE": 500 16 | } 17 | -------------------------------------------------------------------------------- /contracts/trusttoken/mocks/TestUSDCToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ERC20} from "../common/ERC20.sol"; 5 | 6 | contract TestUSDCToken is ERC20 { 7 | uint8 constant DECIMALS = 6; 8 | 9 | function mint(address _to, uint256 _value) public { 10 | _mint(_to, _value); 11 | } 12 | 13 | function burn(uint256 _value) public { 14 | _burn(msg.sender, _value); 15 | } 16 | 17 | function decimals() public pure override returns (uint8) { 18 | return DECIMALS; 19 | } 20 | 21 | function name() public pure override returns (string memory) { 22 | return "USD Coin"; 23 | } 24 | 25 | function symbol() public pure override returns (string memory) { 26 | return "USDC"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /contracts/trusttoken/mocks/TestUSDTToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ERC20} from "../common/ERC20.sol"; 5 | 6 | contract TestUSDTToken is ERC20 { 7 | uint8 constant DECIMALS = 6; 8 | 9 | function mint(address _to, uint256 _value) public { 10 | _mint(_to, _value); 11 | } 12 | 13 | function burn(uint256 _value) public { 14 | _burn(msg.sender, _value); 15 | } 16 | 17 | function decimals() public pure override returns (uint8) { 18 | return DECIMALS; 19 | } 20 | 21 | function name() public pure override returns (string memory) { 22 | return "USD Tether"; 23 | } 24 | 25 | function symbol() public pure override returns (string memory) { 26 | return "USDT"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/IAaveLendingPool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IAaveLendingPool { 5 | function getReserveData(address asset) 6 | external 7 | view 8 | returns ( 9 | uint256 configuration, 10 | uint128 liquidityIndex, 11 | uint128 variableBorrowIndex, 12 | uint128 currentLiquidityRate, 13 | uint128 currentVariableBorrowRate, 14 | uint128 currentStableBorrowRate, 15 | uint40 lastUpdateTimestamp, 16 | address aTokenAddress, 17 | address stableDebtTokenAddress, 18 | address variableDebtTokenAddress, 19 | address interestRateStrategyAddress, 20 | uint8 id 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /contracts/trusttoken/mocks/TestBUSDToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ERC20} from "../common/ERC20.sol"; 5 | 6 | contract TestBUSDToken is ERC20 { 7 | uint8 constant DECIMALS = 18; 8 | 9 | function mint(address _to, uint256 _value) public { 10 | _mint(_to, _value); 11 | } 12 | 13 | function burn(uint256 _value) public { 14 | _burn(msg.sender, _value); 15 | } 16 | 17 | function decimals() public pure override returns (uint8) { 18 | return DECIMALS; 19 | } 20 | 21 | function name() public pure override returns (string memory) { 22 | return "Binance USD"; 23 | } 24 | 25 | function symbol() public pure override returns (string memory) { 26 | return "BUSD"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/trusttoken/mocks/TestTrustToken.md: -------------------------------------------------------------------------------- 1 | ## `TestTrustToken` 2 | 3 | 4 | 5 | Adds faucet feature to the TRU, aimed to be used on testnets 6 | 7 | 8 | ### `faucet(address to, uint256 amount)` (public) 9 | 10 | 11 | 12 | faucet for testnet TRU 13 | Can never mint more than MAX_SUPPLY = 1.45 billion 14 | Set duration above 0 for block delays 15 | 16 | 17 | ### `ownerFaucet(address to, uint256 amount)` (public) 18 | 19 | 20 | 21 | faucet for testnet TRU owner 22 | Can never mint more than MAX_SUPPLY = 1.45 billion 23 | Set duration above 0 for block delays 24 | 25 | 26 | ### `getStamp() → uint256 stamp` (public) 27 | 28 | 29 | 30 | get last timestamp TRU was minted 31 | 32 | 33 | ### `setStamp(uint256 stamp)` (internal) 34 | 35 | 36 | 37 | store last timestamp TRU was minted 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/truefi/mocks/MockCurvePool.md: -------------------------------------------------------------------------------- 1 | ## `MockCurvePool` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `initialize(contract IERC20 _token)` (public) 9 | 10 | 11 | 12 | 13 | 14 | ### `add_liquidity(uint256[4] amounts, uint256)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `remove_liquidity_one_coin(uint256 _token_amount, int128, uint256, bool)` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `calc_withdraw_one_coin(uint256, int128) → uint256` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `set_withdraw_price(uint256 price)` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `token() → contract IERC20` (external) 39 | 40 | 41 | 42 | 43 | 44 | ### `curve() → contract ICurve` (external) 45 | 46 | 47 | 48 | 49 | 50 | ### `coins(int128) → contract IYToken` (external) 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /packages/contracts-bsc/deployments.json: -------------------------------------------------------------------------------- 1 | { 2 | "mainnet": { 3 | "TokenControllerV3_proxy": { 4 | "address": "0x0000000000075EfBeE23fe2de1bd0b7690883cc9" 5 | }, 6 | "TokenControllerV3": { 7 | "commitHash": "40991356a7572de7d519a52e0fe25a99d8cbc48a", 8 | "txHash": "0x5b51bd057bbdcb8dcf12a35d60ce19e26a75857f99efebc0fb922874731c108e", 9 | "address": "0x0cbA367Dacb539b5Fc00c31B4faa5EdD6Ab253F5" 10 | }, 11 | "TrueUSD_proxy": { 12 | "address": "0x0000000000085d4780B73119b644AE5ecd22b376" 13 | }, 14 | "TrueUSD": { 15 | "commitHash": "40991356a7572de7d519a52e0fe25a99d8cbc48a", 16 | "txHash": "0xbdab8e1de4f3dcf472ba9bb292dcf88f4f5594154ae1dc53c7312728688f3b70", 17 | "address": "0xB650eb28d35691dd1BD481325D40E65273844F9b" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/contracts-por/deployments.json: -------------------------------------------------------------------------------- 1 | { 2 | "mainnet": { 3 | "TokenControllerV3_proxy": { 4 | "address": "0x0000000000075EfBeE23fe2de1bd0b7690883cc9" 5 | }, 6 | "TokenControllerV3": { 7 | "commitHash": "40991356a7572de7d519a52e0fe25a99d8cbc48a", 8 | "txHash": "0x5b51bd057bbdcb8dcf12a35d60ce19e26a75857f99efebc0fb922874731c108e", 9 | "address": "0x0cbA367Dacb539b5Fc00c31B4faa5EdD6Ab253F5" 10 | }, 11 | "TrueUSD_proxy": { 12 | "address": "0x0000000000085d4780B73119b644AE5ecd22b376" 13 | }, 14 | "TrueUSD": { 15 | "commitHash": "40991356a7572de7d519a52e0fe25a99d8cbc48a", 16 | "txHash": "0xbdab8e1de4f3dcf472ba9bb292dcf88f4f5594154ae1dc53c7312728688f3b70", 17 | "address": "0xB650eb28d35691dd1BD481325D40E65273844F9b" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docs/truefi/TruSushiswapRewarder.md: -------------------------------------------------------------------------------- 1 | ## `TruSushiswapRewarder` 2 | 3 | 4 | 5 | 6 | 7 | ### `onlyMCV2()` 8 | 9 | 10 | 11 | 12 | 13 | 14 | ### `initialize(uint256 _rewardMultiplier, contract IERC20 _trustToken, address _MASTERCHEF_V2)` (external) 15 | 16 | 17 | 18 | Initialize this contract with provided parameters 19 | 20 | 21 | ### `onSushiReward(uint256, address, address recipient, uint256 sushiAmount, uint256)` (external) 22 | 23 | 24 | 25 | Hook called on sushi reward 26 | Calculate token reward amount based on sushi reward amount 27 | 28 | ### `pendingTokens(uint256, address, uint256 sushiAmount) → contract IERC20[] rewardTokens, uint256[] rewardAmounts` (external) 29 | 30 | 31 | 32 | Get pending token rewards 33 | Calculate token reward amount based on sushi reward amount 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/MockUsdStableCoinOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | contract MockUsdStableCoinOracle { 5 | uint256 decimalAdjustment; 6 | 7 | function tokenToUsd(uint256 tokenAmount) external view returns (uint256) { 8 | return tokenAmount * (10**decimalAdjustment); 9 | } 10 | 11 | function tokenToTru(uint256 tokenAmount) external view returns (uint256) { 12 | return (tokenAmount * 4 * 10**8) / 10**(18 - decimalAdjustment); 13 | } 14 | 15 | function truToToken(uint256 truAmount) external view returns (uint256) { 16 | return (truAmount * 1e10) / 4 / 10**decimalAdjustment; 17 | } 18 | 19 | function setDecimalAdjustment(uint256 adjustment) external { 20 | decimalAdjustment = adjustment; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/truefi/Log.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import { beforeEachWithFixture } from 'fixtures/beforeEachWithFixture' 3 | import { MockLog, MockLog__factory } from 'contracts' 4 | 5 | describe('Log', () => { 6 | let log: MockLog 7 | beforeEachWithFixture(async ([owner]) => { 8 | log = await new MockLog__factory(owner).deploy() 9 | }) 10 | 11 | const checkLog = async (x: number) => { 12 | const res = await log.ln(x) 13 | expect(res.mul(1000000).div(2 ** 32).div(2 ** 32).toNumber() / 1000000).to.be.closeTo(Math.log(x), 0.001) 14 | } 15 | 16 | it('calculates natural logarithm', async () => { 17 | for (let i = 1; i < 100; i++) { 18 | await checkLog(i) 19 | } 20 | }) 21 | 22 | it('calculates logarithm for larger numbers', async () => { 23 | await checkLog(1e8) 24 | }) 25 | }) 26 | -------------------------------------------------------------------------------- /contracts/truefi/mocks/MockStakingPool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ERC20} from "../../common/UpgradeableERC20.sol"; 5 | import {ITrueFiPool} from "./../interface/ITrueFiPool.sol"; 6 | 7 | contract MockStakingPool is ERC20 { 8 | ITrueFiPool pool; 9 | 10 | constructor(ITrueFiPool _pool) public { 11 | pool = _pool; 12 | } 13 | 14 | function stakeSupply() external pure returns (uint256) { 15 | return 0; 16 | } 17 | 18 | function withdraw(uint256) external pure {} 19 | 20 | function unstake() public { 21 | require(pool.transfer(msg.sender, pool.balanceOf(address(this)))); 22 | } 23 | 24 | function payFee(uint256 amount, uint256) external { 25 | pool.transferFrom(msg.sender, address(this), amount); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /contracts/truefi/interface/ITrueFarm.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | import {ITrueDistributor} from "./ITrueDistributor.sol"; 7 | 8 | interface ITrueFarm { 9 | function stakingToken() external view returns (IERC20); 10 | 11 | function trustToken() external view returns (IERC20); 12 | 13 | function trueDistributor() external view returns (ITrueDistributor); 14 | 15 | function name() external view returns (string memory); 16 | 17 | function totalStaked() external view returns (uint256); 18 | 19 | function stake(uint256 amount) external; 20 | 21 | function unstake(uint256 amount) external; 22 | 23 | function claim() external; 24 | 25 | function exit(uint256 amount) external; 26 | } 27 | -------------------------------------------------------------------------------- /docs/governance/interface/IStkTruToken.md: -------------------------------------------------------------------------------- 1 | ## `IStkTruToken` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `stake(uint256 amount)` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `unstake(uint256 amount)` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `cooldown()` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `withdraw(uint256 amount)` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `claim()` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `claimRewards(contract IERC20 token)` (external) 39 | 40 | 41 | 42 | 43 | 44 | ### `claimRestake(uint256 extraStakeAmount)` (external) 45 | 46 | 47 | 48 | 49 | 50 | ### `stakeSupply() → uint256` (external) 51 | 52 | 53 | 54 | 55 | 56 | ### `tfusd() → contract IERC20` (external) 57 | 58 | 59 | 60 | 61 | 62 | ### `feeToken() → contract IERC20` (external) 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /docs/truefi/LoanFactory.md: -------------------------------------------------------------------------------- 1 | ## `LoanFactory` 2 | 3 | Deploy LoanTokens with this Contract 4 | 5 | 6 | LoanTokens are deployed through a factory to ensure that all 7 | LoanTokens adhere to the same contract code, rather than using an interface. 8 | 9 | 10 | ### `initialize(contract IERC20 _currencyToken)` (external) 11 | 12 | 13 | 14 | Initialize this contract and set currency token 15 | 16 | 17 | ### `setLender()` (external) 18 | 19 | 20 | 21 | sets lender address * 22 | 23 | ### `setLiquidator()` (external) 24 | 25 | 26 | 27 | sets liquidator address * 28 | 29 | ### `createLoanToken(uint256 _amount, uint256 _term, uint256 _apy)` (external) 30 | 31 | 32 | 33 | Deploy LoanToken with parameters 34 | 35 | 36 | 37 | ### `LoanTokenCreated(address contractAddress)` 38 | 39 | 40 | 41 | Emitted when a LoanToken is created 42 | 43 | 44 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ITrueFiPoolOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20WithDecimals} from "./IERC20WithDecimals.sol"; 5 | 6 | /** 7 | * @dev Oracle that converts any token to and from TRU 8 | * Used for liquidations and valuing of liquidated TRU in the pool 9 | */ 10 | interface ITrueFiPoolOracle { 11 | // token address 12 | function token() external view returns (IERC20WithDecimals); 13 | 14 | // amount of tokens 1 TRU is worth 15 | function truToToken(uint256 truAmount) external view returns (uint256); 16 | 17 | // amount of TRU 1 token is worth 18 | function tokenToTru(uint256 tokenAmount) external view returns (uint256); 19 | 20 | // USD price of token with 18 decimals 21 | function tokenToUsd(uint256 tokenAmount) external view returns (uint256); 22 | } 23 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/tokens/TrueUSD.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithProofOfReserve} from "../TrueCurrencyWithProofOfReserve.sol"; 5 | 6 | /** 7 | * @title TrueUSD 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract TrueUSD is TrueCurrencyWithProofOfReserve { 12 | uint8 constant ROUNDING = 2; 13 | 14 | function rounding() public pure returns (uint8) { 15 | return ROUNDING; 16 | } 17 | 18 | function name() public pure override returns (string memory) { 19 | return "TrueUSD"; 20 | } 21 | 22 | function symbol() public pure override returns (string memory) { 23 | return "TUSD"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spec/truefi2/FixedTermLoan.spec: -------------------------------------------------------------------------------- 1 | using ERC20 as token 2 | 3 | methods { 4 | debt() returns uint256 envfree 5 | unpaidDebt() returns uint256 envfree 6 | 7 | token.balanceOf(address) returns uint256 envfree 8 | 9 | transfer(address, uint256) returns (bool) => DISPATCHER(true) 10 | transferFrom(address, address, uint256) returns (bool) => DISPATCHER(true) 11 | approve(address, uint256) returns (bool) => DISPATCHER(true) 12 | unlock(address) => DISPATCHER(true) 13 | } 14 | 15 | invariant debtNotGreaterThanSumOfBalanceAndUnpaidDebt() 16 | debt() <= token.balanceOf(currentContract) + unpaidDebt() 17 | filtered { f -> 18 | f.selector != redeem().selector && 19 | f.selector != initialize(address, address, address, address, address, address, address, uint256, uint256, uint256).selector 20 | } 21 | -------------------------------------------------------------------------------- /packages/contracts-bsc/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "resolveJsonModule": true, 4 | "esModuleInterop": true, 5 | "moduleResolution": "node", 6 | "skipLibCheck": true, 7 | "target": "esnext", 8 | "sourceMap": true, 9 | "baseUrl": ".", 10 | "paths": { 11 | "build/*": ["build/*"], 12 | "build": ["build"], 13 | "fixtures/*": ["test/fixtures/*"], 14 | "fixtures": ["test/fixtures"], 15 | "contracts/*": ["build/types/*"], 16 | "contracts": ["build/types", "build/types/factories"], 17 | "utils/*": ["test/utils/*"], 18 | "utils": ["test/utils"], 19 | "config/*": ["test/config/*"], 20 | "config": ["test/config"], 21 | } 22 | }, 23 | "include": [ 24 | "build", 25 | "contracts", 26 | "test" 27 | ], 28 | "files": ["./hardhat.config.ts"] 29 | } 30 | -------------------------------------------------------------------------------- /packages/contracts-por/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "resolveJsonModule": true, 4 | "esModuleInterop": true, 5 | "moduleResolution": "node", 6 | "skipLibCheck": true, 7 | "target": "esnext", 8 | "sourceMap": true, 9 | "baseUrl": ".", 10 | "paths": { 11 | "build/*": ["build/*"], 12 | "build": ["build"], 13 | "fixtures/*": ["test/fixtures/*"], 14 | "fixtures": ["test/fixtures"], 15 | "contracts/*": ["build/types/*"], 16 | "contracts": ["build/types", "build/types/factories"], 17 | "utils/*": ["test/utils/*"], 18 | "utils": ["test/utils"], 19 | "config/*": ["test/config/*"], 20 | "config": ["test/config"], 21 | } 22 | }, 23 | "include": [ 24 | "build", 25 | "contracts", 26 | "test" 27 | ], 28 | "files": ["./hardhat.config.ts"] 29 | } 30 | -------------------------------------------------------------------------------- /packages/contracts-watr/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "resolveJsonModule": true, 4 | "esModuleInterop": true, 5 | "moduleResolution": "node", 6 | "skipLibCheck": true, 7 | "target": "esnext", 8 | "sourceMap": true, 9 | "baseUrl": ".", 10 | "paths": { 11 | "build/*": ["build/*"], 12 | "build": ["build"], 13 | "fixtures/*": ["test/fixtures/*"], 14 | "fixtures": ["test/fixtures"], 15 | "contracts/*": ["build/types/*"], 16 | "contracts": ["build/types", "build/types/factories"], 17 | "utils/*": ["test/utils/*"], 18 | "utils": ["test/utils"], 19 | "config/*": ["test/config/*"], 20 | "config": ["test/config"], 21 | } 22 | }, 23 | "include": [ 24 | "build", 25 | "contracts", 26 | "test" 27 | ], 28 | "files": ["./hardhat.config.ts"] 29 | } 30 | -------------------------------------------------------------------------------- /contracts/governance/interface/IStkTruToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | import {IVoteToken} from "./IVoteToken.sol"; 6 | 7 | interface IStkTruToken is IERC20, IVoteToken { 8 | function stake(uint256 amount) external; 9 | 10 | function unstake(uint256 amount) external; 11 | 12 | function cooldown() external; 13 | 14 | function withdraw(uint256 amount) external; 15 | 16 | function claim() external; 17 | 18 | function claimRewards(IERC20 token) external; 19 | 20 | function claimRestake(uint256 extraStakeAmount) external; 21 | 22 | function stakeSupply() external view returns (uint256); 23 | 24 | function tfusd() external view returns (IERC20); 25 | 26 | function feeToken() external view returns (IERC20); 27 | } 28 | -------------------------------------------------------------------------------- /contracts/registry/mocks/RegistryMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {Registry} from "../Registry.sol"; 5 | import {ProvisionalRegistry} from "./ProvisionalRegistry.sol"; 6 | 7 | contract RegistryMock is Registry { 8 | /** 9 | * @dev sets the original `owner` of the contract to the sender 10 | * at construction. Must then be reinitialized 11 | */ 12 | constructor() public { 13 | owner = msg.sender; 14 | emit OwnershipTransferred(address(0), owner); 15 | } 16 | 17 | function initialize() public { 18 | require(!initialized, "already initialized"); 19 | owner = msg.sender; 20 | initialized = true; 21 | } 22 | } 23 | 24 | // solhint-disable-next-line no-empty-blocks 25 | contract ProvisionalRegistryMock is RegistryMock, ProvisionalRegistry { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /contracts/truefi2/PoolExtensions.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ILoanToken2Deprecated} from "./deprecated/ILoanToken2Deprecated.sol"; 5 | import {ITrueLender2Deprecated} from "./deprecated/ITrueLender2Deprecated.sol"; 6 | import {ISAFU} from "./interface/ISAFU.sol"; 7 | 8 | /** 9 | * Deprecated 10 | * @dev Library that has shared functions between legacy TrueFi Pool and Pool2 11 | * Was created to add common functions to Pool2 and now deprecated legacy pool 12 | */ 13 | library PoolExtensions { 14 | function _liquidate( 15 | ISAFU safu, 16 | ILoanToken2Deprecated loan, 17 | ITrueLender2Deprecated lender 18 | ) internal { 19 | require(msg.sender == address(safu), "TrueFiPool: Should be called by SAFU"); 20 | lender.transferAllLoanTokens(loan, address(safu)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /deployments-unknown.json: -------------------------------------------------------------------------------- 1 | { 2 | "unknown": { 3 | "avalancheTrueUSD": { 4 | "txHash": "0xe896845861efa50dadc75df87adeb286d11923cd284316c03e38a64ae415fc70", 5 | "address": "0xFc0912Fe09756bD5f51d609b13D0ee7D7C8d19a9" 6 | }, 7 | "avalancheTrueUSD_proxy": { 8 | "txHash": "0xb431b2f0a3729c7e2fdd98fb5cb07277590bce17d321971559d39ca4c11caa88", 9 | "address": "0xB36938c51c4f67e5E1112eb11916ed70A772bD75" 10 | }, 11 | "avalancheTokenController": { 12 | "txHash": "0x21be0a9ea61af0d457705b3760a8f7386069d35cab6a5194319937df0fe3ab33", 13 | "address": "0x1C20E891Bab6b1727d14Da358FAe2984Ed9B59EB" 14 | }, 15 | "avalancheTokenController_proxy": { 16 | "txHash": "0xb8a69fb68b07c1e72ac3adb9c6973b888f885eb6891488a6783227a9d7902f28", 17 | "address": "0x08031B53f15F7E5aADDCdF6da3382f8483dB4323" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docs/proxy/TimeOwnedUpgradeabilityProxy.md: -------------------------------------------------------------------------------- 1 | ## `TimeOwnedUpgradeabilityProxy` 2 | 3 | 4 | 5 | This contract combines an upgradeability proxy with 6 | basic authorization control functionalities 7 | This contract allows us to specify a time at which the proxy can no longer 8 | be upgraded 9 | 10 | 11 | ### `constructor()` (public) 12 | 13 | 14 | 15 | the constructor sets the original owner of the contract to the sender account. 16 | 17 | ### `setExpiration(uint256 newExpirationTime)` (external) 18 | 19 | 20 | 21 | sets new expiration time 22 | 23 | ### `_setExpiration(uint256 newExpirationTime)` (internal) 24 | 25 | 26 | 27 | 28 | 29 | ### `expiration() → uint256 _expiration` (public) 30 | 31 | 32 | 33 | 34 | 35 | ### `upgradeTo(address implementation)` (public) 36 | 37 | 38 | 39 | Allows the proxy owner to upgrade the current version of the proxy. 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "resolveJsonModule": true, 4 | "esModuleInterop": true, 5 | "moduleResolution": "node", 6 | "skipLibCheck": true, 7 | "target": "esnext", 8 | "sourceMap": true, 9 | "baseUrl": ".", 10 | "paths": { 11 | "build/*": ["build/*"], 12 | "build": ["build"], 13 | "contracts/*": ["build/types/*"], 14 | "contracts": ["build/types", "build/types/factories"], 15 | "scripts/*": ["scripts/*"], 16 | "scripts": ["scripts"], 17 | "utils/*": ["test/utils/*"], 18 | "utils": ["test/utils"], 19 | "fixtures/*": ["test/fixtures/*"], 20 | "fixtures": ["test/fixtures"] 21 | } 22 | }, 23 | "files": ["./hardhat.config.ts"], 24 | "exclude": [ 25 | "deploy" 26 | ], 27 | "include": [ 28 | "build", 29 | "scripts", 30 | "contracts", 31 | "test", 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /docs/common/Initializable.md: -------------------------------------------------------------------------------- 1 | ## `Initializable` 2 | 3 | 4 | 5 | Helper contract to support initializer functions. To use it, replace 6 | the constructor with a function that has the `initializer` modifier. 7 | WARNING: Unlike constructors, initializer functions must be manually 8 | invoked. This applies both to deploying an Initializable contract, as well 9 | as extending an Initializable contract via inheritance. 10 | WARNING: When used with inheritance, manual care must be taken to not invoke 11 | a parent initializer twice, or ensure that all initializers are idempotent, 12 | because this is not dealt with automatically as with constructors. 13 | 14 | ### `initializer()` 15 | 16 | 17 | 18 | Modifier to use in the initializer function of a contract. 19 | 20 | 21 | ### `isInitialized() → bool` (public) 22 | 23 | 24 | 25 | Return true if and only if the contract has been initialized 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /contracts/true-currencies/mocks/MockTrueCurrency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrency} from "../TrueCurrency.sol"; 5 | 6 | contract MockTrueCurrency is TrueCurrency { 7 | uint8 constant DECIMALS = 18; 8 | uint8 constant ROUNDING = 2; 9 | 10 | function initialize() external { 11 | require(!initialized); 12 | owner = msg.sender; 13 | initialized = true; 14 | } 15 | 16 | function decimals() public pure override returns (uint8) { 17 | return DECIMALS; 18 | } 19 | 20 | function rounding() public pure returns (uint8) { 21 | return ROUNDING; 22 | } 23 | 24 | function name() public pure override returns (string memory) { 25 | return "TrueCurrency"; 26 | } 27 | 28 | function symbol() public pure override returns (string memory) { 29 | return "TCUR"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/fixtures/trueCurrency.ts: -------------------------------------------------------------------------------- 1 | import { Wallet, utils } from 'ethers' 2 | import { MockProvider } from 'ethereum-waffle' 3 | 4 | import { setupDeploy } from 'scripts/utils' 5 | 6 | import { 7 | MockTrueCurrency__factory, 8 | OwnedUpgradeabilityProxy__factory, 9 | } from 'contracts' 10 | 11 | export const initialSupply = utils.parseEther('1000') 12 | 13 | export const trueCurrency = async (wallets: Wallet[], provider: MockProvider) => { 14 | const [owner] = wallets 15 | const deployContract = setupDeploy(owner) 16 | 17 | const implementation = await deployContract(MockTrueCurrency__factory) 18 | const proxy = await deployContract(OwnedUpgradeabilityProxy__factory) 19 | const token = implementation.attach(proxy.address) 20 | await proxy.upgradeTo(implementation.address) 21 | await token.initialize() 22 | await token.mint(owner.address, initialSupply) 23 | 24 | return { wallets, provider, token } 25 | } 26 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ITrueStrategy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface ITrueStrategy { 5 | /** 6 | * @dev put `amount` of tokens into the strategy 7 | * As a result of the deposit value of the strategy should increase by at least 98% of amount 8 | */ 9 | function deposit(uint256 amount) external; 10 | 11 | /** 12 | * @dev pull at least `minAmount` of tokens from strategy and transfer to the pool 13 | */ 14 | function withdraw(uint256 minAmount) external; 15 | 16 | /** 17 | * @dev withdraw everything from strategy 18 | * As a result of calling withdrawAll(),at least 98% of strategy's value should be transferred to the pool 19 | * Value must become 0 20 | */ 21 | function withdrawAll() external; 22 | 23 | /// @dev value evaluated to Pool's tokens 24 | function value() external view returns (uint256); 25 | } 26 | -------------------------------------------------------------------------------- /contracts/governance/mocks/MockTimeLock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {Timelock} from "../Timelock.sol"; 5 | import {UpgradeableClaimable} from "../../common/UpgradeableClaimable.sol"; 6 | 7 | contract MockTimeLock is Timelock { 8 | /** 9 | * @dev Initialize sets the addresses of admin and the delay timestamp 10 | * @param admin_ The address of admin 11 | * @param delay_ The timestamp of delay for timelock contract 12 | */ 13 | function mockInitialize(address admin_, uint256 delay_) external { 14 | UpgradeableClaimable.initialize(msg.sender); 15 | admin = admin_; 16 | pauser = admin_; 17 | delay = delay_; 18 | } 19 | 20 | /** 21 | * @dev Function to set delay for testing 22 | * @param _delay new delay 23 | */ 24 | function mockSetDelay(uint256 _delay) external { 25 | delay = _delay; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/integration/SpotBaseRateOracle.test.ts: -------------------------------------------------------------------------------- 1 | import { CONTRACTS_OWNER, forkChain } from './suite' 2 | import { SpotBaseRateOracle, SpotBaseRateOracle__factory } from 'contracts' 3 | import { expect, use } from 'chai' 4 | import { solidity } from 'ethereum-waffle' 5 | 6 | use(solidity) 7 | 8 | describe('SpotBaseRateOracle', () => { 9 | const AAVE_LENDING_POOL = '0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9' 10 | const USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' 11 | const provider = forkChain([CONTRACTS_OWNER]) 12 | const owner = provider.getSigner(CONTRACTS_OWNER) 13 | 14 | let oracle: SpotBaseRateOracle 15 | 16 | beforeEach(async () => { 17 | oracle = await new SpotBaseRateOracle__factory(owner).deploy(AAVE_LENDING_POOL) 18 | }) 19 | 20 | it('Borrow apy is within common range', async () => { 21 | const apy = await oracle.getRate(USDC_ADDRESS) 22 | expect(apy).to.be.within(1, 10000) 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/IDebtToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | import {ERC20} from "../../common/UpgradeableERC20.sol"; 6 | import {ITrueFiPool2} from "./ITrueFiPool2.sol"; 7 | 8 | interface IDebtToken is IERC20 { 9 | function borrower() external view returns (address); 10 | 11 | function debt() external view returns (uint256); 12 | 13 | function pool() external view returns (ITrueFiPool2); 14 | 15 | function isLiquidated() external view returns (bool); 16 | 17 | function redeem(uint256 _amount) external; 18 | 19 | function liquidate() external; 20 | 21 | function repaid() external view returns (uint256); 22 | 23 | function balance() external view returns (uint256); 24 | 25 | function token() external view returns (ERC20); 26 | 27 | function version() external pure returns (uint8); 28 | } 29 | -------------------------------------------------------------------------------- /hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import 'hardhat-typechain' 2 | import '@nomiclabs/hardhat-waffle' 3 | import 'solidity-coverage' 4 | import './abi-exporter' 5 | import 'tsconfig-paths/register' 6 | 7 | import mocharc from './.mocharc.json' 8 | 9 | module.exports = { 10 | paths: { 11 | sources: './contracts', 12 | artifacts: './build', 13 | cache: './cache', 14 | }, 15 | abiExporter: { 16 | path: './build', 17 | flat: true, 18 | spacing: 2, 19 | }, 20 | networks: { 21 | hardhat: { 22 | initialDate: '2020-01-01T00:00:00', 23 | allowUnlimitedContractSize: true, 24 | }, 25 | }, 26 | typechain: { 27 | outDir: 'build/types', 28 | target: 'ethers-v5', 29 | }, 30 | solidity: { 31 | version: '0.6.10', 32 | settings: { 33 | optimizer: { 34 | enabled: true, 35 | runs: 20000, 36 | }, 37 | }, 38 | }, 39 | mocha: { 40 | ...mocharc, 41 | timeout: 400000, 42 | }, 43 | } 44 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The software and documentation available in this repository (the "Software") is protected by copyright law and accessible pursuant to the license set forth below. Copyright (c) 2018 TrustLabs, Inc. All rights reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person or organization obtaining the Software (the “Licensee”) to privately study, review, and analyze the Software. Licensee shall not use the Software for any other purpose. Licensee shall not modify, transfer, assign, share, or sub-license the Software or any derivative works of the Software. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE. 6 | -------------------------------------------------------------------------------- /docs/truefi/interface/ITrueFiPool.md: -------------------------------------------------------------------------------- 1 | ## `ITrueFiPool` 2 | 3 | TruePool is an ERC20 which represents a share of a pool 4 | This contract can be used to wrap opportunities to be compatible 5 | with TrueFi and allow users to directly opt-in through the TUSD contract 6 | Each TruePool is also a staking opportunity for TRU 7 | 8 | 9 | 10 | 11 | ### `currencyToken() → contract IERC20` (external) 12 | 13 | 14 | 15 | pool token (TUSD) 16 | 17 | ### `join(uint256 amount)` (external) 18 | 19 | 20 | 21 | join pool 22 | 1. Transfer TUSD from sender 23 | 2. Mint pool tokens based on value to sender 24 | 25 | ### `borrow(uint256 amount, uint256 fee)` (external) 26 | 27 | 28 | 29 | borrow from pool 30 | 1. Transfer TUSD to sender 31 | 2. Only lending pool should be allowed to call this 32 | 33 | ### `repay(uint256 amount)` (external) 34 | 35 | 36 | 37 | join pool 38 | 1. Transfer TUSD from sender 39 | 2. Only lending pool should be allowed to call this 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/truefi/ABDKMath64x64.md: -------------------------------------------------------------------------------- 1 | ## `ABDKMath64x64` 2 | 3 | Smart contract library of mathematical functions operating with signed 4 | 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is 5 | basically a simple fraction whose numerator is signed 128-bit integer and 6 | denominator is 2^64. As long as denominator is always the same, there is no 7 | need to store it, thus in Solidity signed 64.64-bit fixed point numbers are 8 | represented by int128 type holding only the numerator. 9 | 10 | 11 | 12 | 13 | ### `fromUInt(uint256 x) → int128` (internal) 14 | 15 | Convert unsigned 256-bit integer number into signed 64.64-bit fixed point 16 | number. Revert on overflow. 17 | 18 | 19 | 20 | 21 | ### `log_2(int128 x) → int128` (internal) 22 | 23 | Calculate binary logarithm of x. Revert if x <= 0. 24 | 25 | 26 | 27 | 28 | ### `ln(int128 x) → int128` (internal) 29 | 30 | Calculate natural logarithm of x. Revert if x <= 0. 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /contracts/true-currencies/tokens/TrueUSDWithPoR.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithPoR} from "../TrueCurrencyWithPoR.sol"; 5 | 6 | /** 7 | * @title TrueUSD 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract TrueUSDWithPoR is TrueCurrencyWithPoR { 12 | uint8 constant DECIMALS = 18; 13 | uint8 constant ROUNDING = 2; 14 | 15 | function decimals() public pure override returns (uint8) { 16 | return DECIMALS; 17 | } 18 | 19 | function rounding() public pure returns (uint8) { 20 | return ROUNDING; 21 | } 22 | 23 | function name() public pure override returns (string memory) { 24 | return "TrueUSD"; 25 | } 26 | 27 | function symbol() public pure override returns (string memory) { 28 | return "TUSD"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/mocks/MockTrueCurrency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithProofOfReserve} from "../TrueCurrencyWithProofOfReserve.sol"; 5 | 6 | contract MockTrueCurrency is TrueCurrencyWithProofOfReserve { 7 | uint8 constant DECIMALS = 18; 8 | uint8 constant ROUNDING = 2; 9 | 10 | function initialize() external { 11 | require(!initialized); 12 | owner = msg.sender; 13 | initialized = true; 14 | } 15 | 16 | function decimals() public pure override returns (uint8) { 17 | return DECIMALS; 18 | } 19 | 20 | function rounding() public pure returns (uint8) { 21 | return ROUNDING; 22 | } 23 | 24 | function name() public pure override returns (string memory) { 25 | return "TrueCurrency"; 26 | } 27 | 28 | function symbol() public pure override returns (string memory) { 29 | return "TCUR"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/true-currencies/mocks/MockTrueCurrencyWithGasRefund.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithGasRefund} from "../TrueCurrencyWithGasRefund.sol"; 5 | 6 | contract MockTrueCurrencyWithGasRefund is TrueCurrencyWithGasRefund { 7 | uint8 constant DECIMALS = 18; 8 | uint8 constant ROUNDING = 2; 9 | 10 | function initialize() external { 11 | require(!initialized); 12 | owner = msg.sender; 13 | initialized = true; 14 | } 15 | 16 | function decimals() public pure override returns (uint8) { 17 | return DECIMALS; 18 | } 19 | 20 | function rounding() public pure returns (uint8) { 21 | return ROUNDING; 22 | } 23 | 24 | function name() public pure override returns (string memory) { 25 | return "TrueCurrency"; 26 | } 27 | 28 | function symbol() public pure override returns (string memory) { 29 | return "TCUR"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/true-currencies/tokens/TrueAUD.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithGasRefund} from "../TrueCurrencyWithGasRefund.sol"; 5 | 6 | /** 7 | * title TrueAUD 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract TrueAUD is TrueCurrencyWithGasRefund { 12 | uint8 constant DECIMALS = 18; 13 | uint8 constant ROUNDING = 2; 14 | 15 | function decimals() public pure override returns (uint8) { 16 | return DECIMALS; 17 | } 18 | 19 | function rounding() public pure returns (uint8) { 20 | return ROUNDING; 21 | } 22 | 23 | function name() public pure override returns (string memory) { 24 | return "TrueAUD"; 25 | } 26 | 27 | function symbol() public pure override returns (string memory) { 28 | return "TAUD"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /contracts/true-currencies/tokens/TrueCAD.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithGasRefund} from "../TrueCurrencyWithGasRefund.sol"; 5 | 6 | /** 7 | * @title TrueCAD 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract TrueCAD is TrueCurrencyWithGasRefund { 12 | uint8 constant DECIMALS = 18; 13 | uint8 constant ROUNDING = 2; 14 | 15 | function decimals() public pure override returns (uint8) { 16 | return DECIMALS; 17 | } 18 | 19 | function rounding() public pure returns (uint8) { 20 | return ROUNDING; 21 | } 22 | 23 | function name() public pure override returns (string memory) { 24 | return "TrueCAD"; 25 | } 26 | 27 | function symbol() public pure override returns (string memory) { 28 | return "TCAD"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /contracts/true-currencies/tokens/TrueGBP.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithGasRefund} from "../TrueCurrencyWithGasRefund.sol"; 5 | 6 | /** 7 | * @title TrueGBP 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract TrueGBP is TrueCurrencyWithGasRefund { 12 | uint8 constant DECIMALS = 18; 13 | uint8 constant ROUNDING = 2; 14 | 15 | function decimals() public pure override returns (uint8) { 16 | return DECIMALS; 17 | } 18 | 19 | function rounding() public pure returns (uint8) { 20 | return ROUNDING; 21 | } 22 | 23 | function name() public pure override returns (string memory) { 24 | return "TrueGBP"; 25 | } 26 | 27 | function symbol() public pure override returns (string memory) { 28 | return "TGBP"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /contracts/true-currencies/tokens/TrueHKD.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithGasRefund} from "../TrueCurrencyWithGasRefund.sol"; 5 | 6 | /** 7 | * @title TrueHKD 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract TrueHKD is TrueCurrencyWithGasRefund { 12 | uint8 constant DECIMALS = 18; 13 | uint8 constant ROUNDING = 2; 14 | 15 | function decimals() public pure override returns (uint8) { 16 | return DECIMALS; 17 | } 18 | 19 | function rounding() public pure returns (uint8) { 20 | return ROUNDING; 21 | } 22 | 23 | function name() public pure override returns (string memory) { 24 | return "TrueHKD"; 25 | } 26 | 27 | function symbol() public pure override returns (string memory) { 28 | return "THKD"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/mocks/MockTrueCurrency.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithProofOfReserve} from "../common/TrueCurrencyWithProofOfReserve.sol"; 5 | 6 | contract MockTrueCurrency is TrueCurrencyWithProofOfReserve { 7 | uint8 constant DECIMALS = 18; 8 | uint8 constant ROUNDING = 2; 9 | 10 | function initialize() external { 11 | require(!initialized); 12 | owner = msg.sender; 13 | initialized = true; 14 | } 15 | 16 | function decimals() public pure override returns (uint8) { 17 | return DECIMALS; 18 | } 19 | 20 | function rounding() public pure returns (uint8) { 21 | return ROUNDING; 22 | } 23 | 24 | function name() public pure override returns (string memory) { 25 | return "TrueCurrency"; 26 | } 27 | 28 | function symbol() public pure override returns (string memory) { 29 | return "TCUR"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /indexBuildHardhat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | ODline=$(grep 'artifacts' hardhat.config.ts) 6 | regex=': \"(.+)\"' 7 | [[ $ODline =~ $regex ]] 8 | outputDir=${BASH_REMATCH[1]} 9 | 10 | touch $outputDir/index.ts 11 | > $outputDir/index.ts 12 | 13 | for file in $outputDir/*.json 14 | do 15 | ODline=$(grep 'artifacts' hardhat.config.ts) 16 | regex='\/([a-zA-Z0-9_]+)\.' 17 | [[ $file =~ $regex ]] 18 | name=${BASH_REMATCH[1]} 19 | echo "const ${name}Json = require(\"./$name.json\")" >> $outputDir/index.ts 20 | done 21 | 22 | echo "export {" >> $outputDir/index.ts 23 | 24 | for file in $outputDir/*.json 25 | do 26 | ODline=$(grep 'artifacts' hardhat.config.ts) 27 | regex='\/([a-zA-Z0-9_]+)\.' 28 | [[ $file =~ $regex ]] 29 | name=${BASH_REMATCH[1]} 30 | echo " ${name}Json," >> $outputDir/index.ts 31 | done 32 | 33 | echo "}" >> $outputDir/index.ts 34 | 35 | echo "export * from './types'" >> $outputDir/index.ts 36 | 37 | echo "Index built succesfully!" -------------------------------------------------------------------------------- /contracts/truefi2/interface/I1Inch3.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | pragma experimental ABIEncoderV2; 4 | 5 | interface I1Inch3 { 6 | struct SwapDescription { 7 | address srcToken; 8 | address dstToken; 9 | address srcReceiver; 10 | address dstReceiver; 11 | uint256 amount; 12 | uint256 minReturnAmount; 13 | uint256 flags; 14 | bytes permit; 15 | } 16 | 17 | function swap( 18 | address caller, 19 | SwapDescription calldata desc, 20 | bytes calldata data 21 | ) 22 | external 23 | returns ( 24 | uint256 returnAmount, 25 | uint256 gasLeft, 26 | uint256 chiSpent 27 | ); 28 | 29 | function unoswap( 30 | address srcToken, 31 | uint256 amount, 32 | uint256 minReturn, 33 | bytes32[] calldata /* pools */ 34 | ) external payable returns (uint256 returnAmount); 35 | } 36 | -------------------------------------------------------------------------------- /contracts/true-currencies/tokens/TrueUSD.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithLegacyAutosweep} from "../TrueCurrencyWithLegacyAutosweep.sol"; 5 | 6 | /** 7 | * @title TrueUSD 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract TrueUSD is TrueCurrencyWithLegacyAutosweep { 12 | uint8 constant DECIMALS = 18; 13 | uint8 constant ROUNDING = 2; 14 | 15 | function decimals() public pure override returns (uint8) { 16 | return DECIMALS; 17 | } 18 | 19 | function rounding() public pure returns (uint8) { 20 | return ROUNDING; 21 | } 22 | 23 | function name() public pure override returns (string memory) { 24 | return "TrueUSD"; 25 | } 26 | 27 | function symbol() public pure override returns (string memory) { 28 | return "TUSD"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /docs/truefi/CrvPriceOracle.md: -------------------------------------------------------------------------------- 1 | ## `CrvPriceOracle` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `constructor()` (public) 9 | 10 | Network: Mainnet 11 | Aggregator: CRV/ETH 12 | Address: 0x8a12Be339B0cD1829b91Adc01977caa5E9ac121e 13 | Network: Mainnet 14 | Aggregator: ETH/USD 15 | Address: 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 16 | Mainnet deployed: https://etherscan.io/address/0x23DE9562bf8020f5B92a2A04C59b39deABbB2315#readContract 17 | 18 | 19 | 20 | ### `getLatestPrice() → uint256` (public) 21 | 22 | 23 | 24 | return the lastest price for CRV/USD with 18 decimals places 25 | 26 | 27 | ### `usdToCrv(uint256 amount) → uint256` (external) 28 | 29 | 30 | 31 | converts from USD with 18 decimals to CRV with 18 decimals 32 | 33 | 34 | ### `crvToUsd(uint256 amount) → uint256` (external) 35 | 36 | 37 | 38 | converts from CRV with 18 decimals to USD with 18 decimals 39 | 40 | 41 | ### `safeUint(int256 value) → uint256` (internal) 42 | 43 | 44 | 45 | convert int256 to uint256 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/tokens/TrueUSD.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrencyWithProofOfReserve} from "../TrueCurrencyWithProofOfReserve.sol"; 5 | 6 | /** 7 | * @title TrueUSD 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract TrueUSD is TrueCurrencyWithProofOfReserve { 12 | uint8 constant DECIMALS = 18; 13 | uint8 constant ROUNDING = 2; 14 | 15 | function decimals() public pure override returns (uint8) { 16 | return DECIMALS; 17 | } 18 | 19 | function rounding() public pure returns (uint8) { 20 | return ROUNDING; 21 | } 22 | 23 | function name() public pure override returns (string memory) { 24 | return "TrueUSD"; 25 | } 26 | 27 | function symbol() public pure override returns (string memory) { 28 | return "TUSD"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /contracts/true-currencies/mocks/MockTrueCurrencyWithAutosweep.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {MockTrueCurrencyWithLegacyAutosweep} from "./MockTrueCurrencyWithLegacyAutosweep.sol"; 5 | 6 | contract MockTrueCurrencyWithAutosweep is MockTrueCurrencyWithLegacyAutosweep { 7 | uint8 constant DECIMALS = 18; 8 | uint8 constant ROUNDING = 2; 9 | 10 | function initialize() external { 11 | require(!initialized); 12 | owner = msg.sender; 13 | initialized = true; 14 | } 15 | 16 | function decimals() public pure override returns (uint8) { 17 | return DECIMALS; 18 | } 19 | 20 | function rounding() public pure returns (uint8) { 21 | return ROUNDING; 22 | } 23 | 24 | function name() public pure override returns (string memory) { 25 | return "TrueCurrency"; 26 | } 27 | 28 | function symbol() public pure override returns (string memory) { 29 | return "TCUR"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/MockStrategy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | import {ITrueStrategy} from "../interface/ITrueStrategy.sol"; 7 | 8 | contract MockStrategy is ITrueStrategy { 9 | IERC20 token; 10 | address pool; 11 | 12 | constructor(IERC20 _token, address _pool) public { 13 | token = _token; 14 | pool = _pool; 15 | } 16 | 17 | function deposit(uint256 amount) external override { 18 | token.transferFrom(pool, address(this), amount); 19 | } 20 | 21 | function withdraw(uint256 minAmount) external override { 22 | token.transfer(pool, minAmount); 23 | } 24 | 25 | function withdrawAll() external override { 26 | token.transfer(pool, token.balanceOf(address(this))); 27 | } 28 | 29 | function value() external view override returns (uint256) { 30 | return token.balanceOf(address(this)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/MockTrueFiPoolOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "../interface/ITrueFiPoolOracle.sol"; 5 | 6 | contract MockTrueFiPoolOracle is ITrueFiPoolOracle { 7 | IERC20WithDecimals private _token; 8 | 9 | constructor(IERC20WithDecimals __token) public { 10 | _token = __token; 11 | } 12 | 13 | function token() external view override returns (IERC20WithDecimals) { 14 | return _token; 15 | } 16 | 17 | function tokenToTru(uint256 tokenAmount) external view override returns (uint256) { 18 | return (tokenAmount * 4 * 10**8) / 10**_token.decimals(); 19 | } 20 | 21 | function truToToken(uint256 truAmount) external view override returns (uint256) { 22 | return (truAmount * 1e10) / 4 / 10**(18 - _token.decimals()); 23 | } 24 | 25 | function tokenToUsd(uint256 tokenAmount) external view override returns (uint256) { 26 | return tokenAmount * 10**(18 - _token.decimals()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /contracts/true-gold/mocks/ERC20Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | 6 | // mock class using ERC20 7 | contract ERC20Mock is ERC20 { 8 | constructor(address initialAccount, uint256 initialBalance) public payable ERC20("Mock Token", "MOCK") { 9 | _mint(initialAccount, initialBalance); 10 | } 11 | 12 | function mint(address account, uint256 amount) public { 13 | _mint(account, amount); 14 | } 15 | 16 | function burn(address account, uint256 amount) public { 17 | _burn(account, amount); 18 | } 19 | 20 | function transferInternal( 21 | address from, 22 | address to, 23 | uint256 value 24 | ) public { 25 | _transfer(from, to, value); 26 | } 27 | 28 | function approveInternal( 29 | address owner, 30 | address spender, 31 | uint256 value 32 | ) public { 33 | _approve(owner, spender, value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /docs/true-currencies/mocks/IDelegateERC20.md: -------------------------------------------------------------------------------- 1 | ## `IDelegateERC20` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `delegateTotalSupply() → uint256` (external) 9 | 10 | 11 | 12 | 13 | 14 | ### `delegateBalanceOf(address who) → uint256` (external) 15 | 16 | 17 | 18 | 19 | 20 | ### `delegateTransfer(address to, uint256 value, address origSender) → bool` (external) 21 | 22 | 23 | 24 | 25 | 26 | ### `delegateAllowance(address owner, address spender) → uint256` (external) 27 | 28 | 29 | 30 | 31 | 32 | ### `delegateTransferFrom(address from, address to, uint256 value, address origSender) → bool` (external) 33 | 34 | 35 | 36 | 37 | 38 | ### `delegateApprove(address spender, uint256 value, address origSender) → bool` (external) 39 | 40 | 41 | 42 | 43 | 44 | ### `delegateIncreaseApproval(address spender, uint256 addedValue, address origSender) → bool` (external) 45 | 46 | 47 | 48 | 49 | 50 | ### `delegateDecreaseApproval(address spender, uint256 subtractedValue, address origSender) → bool` (external) 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /test/utils/writeAttributeFor.ts: -------------------------------------------------------------------------------- 1 | import Web3 from 'web3' 2 | 3 | const { utils } = new Web3() 4 | 5 | export const canWriteTo = Buffer.from(utils.sha3('canWriteTo-').slice(2), 'hex') 6 | 7 | export function writeAttributeFor (attribute) { 8 | const bytes = Buffer.from(attribute.slice(2), 'hex') 9 | for (let index = 0; index < canWriteTo.length; index++) { 10 | bytes[index] ^= canWriteTo[index] 11 | } 12 | return utils.sha3('0x' + bytes.toString('hex')) 13 | } 14 | 15 | // import { keccak256 } from '@ethersproject/solidity' 16 | // import { formatBytes32String } from '@ethersproject/strings' 17 | 18 | // export const canWriteTo = Buffer.from(keccak256(['string'], [formatBytes32String('canWriteTo-')]).slice(2), 'hex') 19 | 20 | // export const writeAttributeFor = (attribute: string) => { 21 | // const bytes = Buffer.from(attribute.slice(2), 'hex') 22 | // for (let index = 0; index < canWriteTo.length; index++) { 23 | // bytes[index] ^= canWriteTo[index] 24 | // } 25 | // return keccak256(['string'], ['0x' + bytes.toString('hex')]) 26 | // } 27 | -------------------------------------------------------------------------------- /docs/true-currencies/common/ClaimableOwnable.md: -------------------------------------------------------------------------------- 1 | ## `ClaimableOwnable` 2 | 3 | 4 | 5 | The ClamableOwnable contract is a copy of Claimable Contract by Zeppelin. 6 | and provides basic authorization control functions. Inherits storage layout of 7 | ProxyStorage. 8 | 9 | ### `onlyOwner()` 10 | 11 | 12 | 13 | Throws if called by any account other than the owner. 14 | 15 | ### `onlyPendingOwner()` 16 | 17 | 18 | 19 | Modifier throws if called by any account other than the pendingOwner. 20 | 21 | 22 | ### `constructor()` (public) 23 | 24 | 25 | 26 | sets the original `owner` of the contract to the sender 27 | at construction. Must then be reinitialized 28 | 29 | ### `transferOwnership(address newOwner)` (public) 30 | 31 | 32 | 33 | Allows the current owner to set the pendingOwner address. 34 | 35 | 36 | ### `claimOwnership()` (public) 37 | 38 | 39 | 40 | Allows the pendingOwner address to finalize the transfer. 41 | 42 | 43 | ### `OwnershipTransferred(address previousOwner, address newOwner)` 44 | 45 | 46 | 47 | emitted when ownership is transferred 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/true-gold/TrueMintableBurnable.md: -------------------------------------------------------------------------------- 1 | ## `TrueMintableBurnable` 2 | 3 | 4 | 5 | 6 | 7 | 8 | ### `__TrueMintableBurnable_init_unchained(uint256 minBurnAmount, uint256 maxBurnAmount)` (internal) 9 | 10 | 11 | 12 | 13 | 14 | ### `burnMin() → uint256` (public) 15 | 16 | 17 | 18 | 19 | 20 | ### `burnMax() → uint256` (public) 21 | 22 | 23 | 24 | 25 | 26 | ### `setBurnBounds(uint256 minAmount, uint256 maxAmount)` (public) 27 | 28 | 29 | 30 | 31 | 32 | ### `mint(address account, uint256 amount)` (public) 33 | 34 | 35 | 36 | 37 | 38 | ### `transfer(address recipient, uint256 amount) → bool` (public) 39 | 40 | 41 | 42 | 43 | 44 | ### `transferFrom(address sender, address recipient, uint256 amount) → bool` (public) 45 | 46 | 47 | 48 | 49 | 50 | ### `_burn(address account, uint256 amount)` (internal) 51 | 52 | 53 | 54 | 55 | 56 | 57 | ### `Mint(address to, uint256 value)` 58 | 59 | 60 | 61 | 62 | 63 | ### `Burn(address burner, uint256 value)` 64 | 65 | 66 | 67 | 68 | 69 | ### `SetBurnBounds(uint256 newMin, uint256 newMax)` 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /docs/trusttoken/TrustToken.md: -------------------------------------------------------------------------------- 1 | ## `TrustToken` 2 | 3 | 4 | 5 | The TrustToken contract is a claimable contract where the 6 | owner can only mint or transfer ownership. TrustTokens use 8 decimals 7 | in order to prevent rewards from getting stuck in the remainder on division. 8 | Tolerates dilution to slash stake and accept rewards. 9 | 10 | 11 | ### `_transfer(address _from, address _to, uint256 _amount)` (internal) 12 | 13 | 14 | 15 | 16 | 17 | ### `initialize()` (public) 18 | 19 | 20 | 21 | initialize trusttoken and give ownership to sender 22 | This is necessary to set ownership for proxy 23 | 24 | ### `mint(address _to, uint256 _amount)` (external) 25 | 26 | 27 | 28 | mint TRU 29 | Can never mint more than MAX_SUPPLY = 1.45 billion 30 | 31 | ### `burn(uint256 amount)` (external) 32 | 33 | 34 | 35 | 36 | 37 | ### `decimals() → uint8` (public) 38 | 39 | 40 | 41 | 42 | 43 | ### `rounding() → uint8` (public) 44 | 45 | 46 | 47 | 48 | 49 | ### `name() → string` (public) 50 | 51 | 52 | 53 | 54 | 55 | ### `symbol() → string` (public) 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /contracts/truefi2/mocks/TestCurveStrategy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | pragma experimental ABIEncoderV2; 4 | 5 | import "../strategies/CurveYearnStrategy.sol"; 6 | 7 | /// @dev Test helper that allows using any wallet as a pool 8 | contract TestCurveStrategy is CurveYearnStrategy { 9 | function testInitialize( 10 | IERC20WithDecimals _token, 11 | address _pool, 12 | ICurvePool _curvePool, 13 | ICurveGauge _curveGauge, 14 | ICurveMinter _minter, 15 | I1Inch3 _1inchExchange, 16 | ICrvPriceOracle _crvOracle, 17 | uint256 _maxPriceSlippage, 18 | uint8 _tokenIndex 19 | ) external initializer { 20 | UpgradeableClaimable.initialize(msg.sender); 21 | 22 | token = _token; 23 | pool = _pool; 24 | 25 | curvePool = _curvePool; 26 | curveGauge = _curveGauge; 27 | minter = _minter; 28 | _1Inch = _1inchExchange; 29 | crvOracle = _crvOracle; 30 | maxPriceSlippage = _maxPriceSlippage; 31 | tokenIndex = _tokenIndex; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /contracts/avalanche/AvalancheTrueUSD.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {TrueCurrency} from "../true-currencies/TrueCurrency.sol"; 5 | 6 | /** 7 | * @title TrueUSD 8 | * @dev This is the top-level ERC20 contract, but most of the interesting functionality is 9 | * inherited - see the documentation on the corresponding contracts. 10 | */ 11 | contract AvalancheTrueUSD is TrueCurrency { 12 | uint8 constant DECIMALS = 18; 13 | uint8 constant ROUNDING = 2; 14 | 15 | function initialize() external { 16 | require(!initialized); 17 | owner = msg.sender; 18 | initialized = true; 19 | } 20 | 21 | function decimals() public pure override returns (uint8) { 22 | return DECIMALS; 23 | } 24 | 25 | function rounding() public pure returns (uint8) { 26 | return ROUNDING; 27 | } 28 | 29 | function name() public pure override returns (string memory) { 30 | return "TrueUSD"; 31 | } 32 | 33 | function symbol() public pure override returns (string memory) { 34 | return "TUSD"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /contracts/truefi2/interface/ILoanFactory2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | import {ILoanToken2Deprecated} from "../deprecated/ILoanToken2Deprecated.sol"; 5 | import {IFixedTermLoan} from "./IFixedTermLoan.sol"; 6 | import {IDebtToken} from "./IDebtToken.sol"; 7 | import {ITrueFiPool2} from "./ITrueFiPool2.sol"; 8 | 9 | interface ILoanFactory2 { 10 | function createLoanToken( 11 | ITrueFiPool2 _pool, 12 | address _borrower, 13 | uint256 _amount, 14 | uint256 _term, 15 | uint256 _apy 16 | ) external returns (IFixedTermLoan); 17 | 18 | function createDebtToken( 19 | ITrueFiPool2 _pool, 20 | address _borrower, 21 | uint256 _debt 22 | ) external returns (IDebtToken); 23 | 24 | function isLegacyLoanToken(ILoanToken2Deprecated) external view returns (bool); 25 | 26 | function isLoanToken(IFixedTermLoan) external view returns (bool); 27 | 28 | function isDebtToken(IDebtToken) external view returns (bool); 29 | 30 | function debtTokens(address) external view returns (IDebtToken[] memory); 31 | } 32 | -------------------------------------------------------------------------------- /packages/contracts-bsc/contracts/interface/IProofOfReserveToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IProofOfReserveToken { 5 | /*** Admin Functions ***/ 6 | 7 | function setChainReserveFeed(address newFeed) external; 8 | 9 | function setChainReserveHeartbeat(uint256 newHeartbeat) external; 10 | 11 | function enableProofOfReserve() external; 12 | 13 | function disableProofOfReserve() external; 14 | 15 | /*** Events ***/ 16 | 17 | /** 18 | * @notice Event emitted when the feed is updated 19 | */ 20 | event NewChainReserveFeed(address oldFeed, address newFeed); 21 | 22 | /** 23 | * @notice Event emitted when the heartbeat of chain reserve feed is updated 24 | */ 25 | event NewChainReserveHeartbeat(uint256 oldHeartbeat, uint256 newHeartbeat); 26 | 27 | /** 28 | * @notice Event emitted when Proof of Reserve is enabled 29 | */ 30 | event ProofOfReserveEnabled(); 31 | 32 | /** 33 | * @notice Event emitted when Proof of Reserve is disabled 34 | */ 35 | event ProofOfReserveDisabled(); 36 | } 37 | -------------------------------------------------------------------------------- /packages/contracts-por/contracts/interface/IProofOfReserveToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IProofOfReserveToken { 5 | /*** Admin Functions ***/ 6 | 7 | function setChainReserveFeed(address newFeed) external; 8 | 9 | function setChainReserveHeartbeat(uint256 newHeartbeat) external; 10 | 11 | function enableProofOfReserve() external; 12 | 13 | function disableProofOfReserve() external; 14 | 15 | /*** Events ***/ 16 | 17 | /** 18 | * @notice Event emitted when the feed is updated 19 | */ 20 | event NewChainReserveFeed(address oldFeed, address newFeed); 21 | 22 | /** 23 | * @notice Event emitted when the heartbeat of chain reserve feed is updated 24 | */ 25 | event NewChainReserveHeartbeat(uint256 oldHeartbeat, uint256 newHeartbeat); 26 | 27 | /** 28 | * @notice Event emitted when Proof of Reserve is enabled 29 | */ 30 | event ProofOfReserveEnabled(); 31 | 32 | /** 33 | * @notice Event emitted when Proof of Reserve is disabled 34 | */ 35 | event ProofOfReserveDisabled(); 36 | } 37 | -------------------------------------------------------------------------------- /test/scripts/deployPausedTrueGold.test.ts: -------------------------------------------------------------------------------- 1 | import { solidity } from 'ethereum-waffle' 2 | import { expect, use } from 'chai' 3 | import { waffle } from 'hardhat' 4 | 5 | import { deployPausedTrueGold } from 'scripts/deploy_paused_true_gold' 6 | 7 | import { PausedTrueGold } from 'contracts' 8 | import { PausedTrueGoldJson } from 'build' 9 | 10 | use(solidity) 11 | 12 | describe('deployPausedTrueGold', () => { 13 | const pausedTokenBytecode = PausedTrueGoldJson.deployedBytecode 14 | 15 | const provider = waffle.provider 16 | const [deployer] = provider.getWallets() 17 | 18 | let pausedToken: PausedTrueGold 19 | 20 | before(async () => { 21 | pausedToken = await deployPausedTrueGold(deployer) 22 | }) 23 | 24 | it('deploys the contract', async () => { 25 | expect(await provider.getCode(pausedToken.address)).to.eq(pausedTokenBytecode) 26 | }) 27 | 28 | it('initializes the contract', async () => { 29 | await expect(pausedToken.initialize(0, 10)).to.be.revertedWith('Contract instance has already been initialized') 30 | expect(await pausedToken.owner()).to.eq(deployer.address) 31 | }) 32 | }) 33 | -------------------------------------------------------------------------------- /packages/contracts-watr/contracts/interface/IProofOfReserveToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.6.10; 3 | 4 | interface IProofOfReserveToken { 5 | /*** Admin Functions ***/ 6 | 7 | function setChainReserveFeed(address newFeed) external; 8 | 9 | function setChainReserveHeartbeat(uint256 newHeartbeat) external; 10 | 11 | function enableProofOfReserve() external; 12 | 13 | function disableProofOfReserve() external; 14 | 15 | /*** Events ***/ 16 | 17 | /** 18 | * @notice Event emitted when the feed is updated 19 | */ 20 | event NewChainReserveFeed(address oldFeed, address newFeed); 21 | 22 | /** 23 | * @notice Event emitted when the heartbeat of chain reserve feed is updated 24 | */ 25 | event NewChainReserveHeartbeat(uint256 oldHeartbeat, uint256 newHeartbeat); 26 | 27 | /** 28 | * @notice Event emitted when Proof of Reserve is enabled 29 | */ 30 | event ProofOfReserveEnabled(); 31 | 32 | /** 33 | * @notice Event emitted when Proof of Reserve is disabled 34 | */ 35 | event ProofOfReserveDisabled(); 36 | } 37 | --------------------------------------------------------------------------------