Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
floatcapital committed Sep 16, 2021
1 parent c0537ec commit 9a59e79
Show file tree
Hide file tree
Showing 218 changed files with 93,021 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
node_modules

# Buidler files
cache
artifacts
build

# Test codegen
codegen

# Secrets
secretsManager.js

# rescript
.merlin
.bsb.lock
lib

coverage.json

coverage-all
coverage-unit
coverage-integration

abis
ast

# No need to keep javascript files in contract tests
test/**/*.js

test/library/contracts/*
!test/library/contracts/.gitkeep
test/library/smock/*
!test/library/smock/.gitkeep

contracts/testing/generated/*

contract-docs

deployments/*
!deployments/mumbai
!deployments/polygon

deploymentSummary.json
7 changes: 7 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
overrides:
- files: "*.sol"
options:
printWidth: 100
tabWidth: 2
explicitTypes: "always"
compiler: "0.8.3"
79 changes: 79 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
let coverageReportOutputDirectory = "coverage-all"

let extraFilesToIgnore = []

let isUnitTests =
!!process.env.DONT_RUN_INTEGRATION_TESTS && process.env.DONT_RUN_INTEGRATION_TESTS.toUpperCase() == "TRUE"
let isIntegrationTests =
!!process.env.DONT_RUN_UNIT_TESTS && process.env.DONT_RUN_UNIT_TESTS.toUpperCase() == "TRUE"
if (isUnitTests) {
coverageReportOutputDirectory = "coverage-unit"
extraFilesToIgnore = [
"FloatToken.sol",
"SyntheticToken.sol",
"TokenFactory.sol",
"Treasury_v0.sol",
]
} else if (isIntegrationTests) {
coverageReportOutputDirectory = "coverage-integration"
} else if (!isUnitTests && !isIntegrationTests) { // if it is neither then it is both (wierd logic but it works)
// Don't do anything in this case
} else {
throw Error("Invalid config, don't set both 'DONT_RUN_INTEGRATION_TESTS' and 'DONT_RUN_UNIT_TESTS' to true")
}

module.exports = {
skipFiles: [
"FloatCapital_v0.sol",
"Treasury_v0.sol",
"AlphaTestFLT.sol",
"StakingStrategy.sol",
"StrategyToken.sol",
"SyntheticTokenUpgradeable.sol",
"TreasuryAlpha.sol",
"YieldManagerAave.sol",

"deployment/UUPSProxy.sol",

"interfaces/IFloatToken.sol",
"interfaces/ILongShort.sol",
"interfaces/IOracleManager.sol",
"interfaces/IStaker.sol",
"interfaces/ISyntheticToken.sol",
"interfaces/ITokenFactory.sol",
"interfaces/IYieldManager.sol",
"interfaces/aave/DataTypes.sol",
"interfaces/aave/ILendingPool.sol",
"interfaces/aave/ILendingPoolAddressesProvider.sol",

"mocks/BandOracleMock.sol",
"mocks/Dai.sol",
"mocks/MockERC20.sol",
"mocks/OracleManagerMock.sol",
"mocks/YieldManagerMock.sol",
"mocks/AggregatorV3Mock.sol",
"mocks/ERC20Mock.sol",
"mocks/LendingPoolAaveMock.sol",
"mocks/LendingPoolAddressesProviderMock.sol",
"mocks/LendingPoolAddressesProvider.sol",

"oracles/OracleManagerChainlink.sol",
"oracles/OracleManagerEthKillerChainlink.sol",
"oracles/OracleManagerEthKillerChainlinkTestnet.sol",
"oracles/OracleManagerEthVsBtc.sol",
"oracles/OracleManagerFlippening_V0.sol",
"oracles/OracleManagerChainlinkTestnet.sol",
"oracles/OracleManagerFlipp3ning.sol",

"testing/StakerInternalStateSetters.sol",
"testing/LongShortInternalStateSetters.sol",

"testing/generated/LongShortForInternalMocking.sol",
"testing/generated/StakerForInternalMocking.sol",
"testing/generated/LongShortMockable.sol",
"testing/generated/StakerMockable.sol",
].concat(extraFilesToIgnore),
istanbulFolder: coverageReportOutputDirectory,
configureYulOptimizer: true
};

3 changes: 3 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "solhint:default"
}
100 changes: 100 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Business Source License 1.1

License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
"Business Source License" is a trademark of MariaDB Corporation Ab.

-----------------------------------------------------------------------------

Parameters

Licensor: Float Capital

Licensed Work: Float Capital
The Licensed Work is (c) 2021 Float Capital

Additional Use Grant: Any uses listed and defined at
https://docs.float.capital/docs

Change Date: The earlier of 2024-06-01 or a date specified at
https://docs.float.capital/docs

Change License: GNU General Public License v2.0 or later

-----------------------------------------------------------------------------

Terms

The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited
production use.

Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.

If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.

All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.

You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.

Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.

This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).

TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.

MariaDB hereby grants you permission to use this License’s text to license
your works, and to refer to it using the trademark "Business Source License",
as long as you comply with the Covenants of Licensor below.

-----------------------------------------------------------------------------

Covenants of Licensor

In consideration of the right to use this License’s text and the "Business
Source License" name and trademark, Licensor covenants to MariaDB, and to all
other recipients of the licensed work to be provided by Licensor:

1. To specify as the Change License the GPL Version 2.0 or any later version,
or a license that is compatible with GPL Version 2.0 or a later version,
where "compatible" means that software provided under the Change License can
be included in a program with software provided under GPL Version 2.0 or a
later version. Licensor may specify additional Change Licenses without
limitation.

2. To either: (a) specify an additional grant of rights to use that does not
impose any additional restriction on the right granted in this License, as
the Additional Use Grant; or (b) insert the text "None".

3. To specify a Change Date.

4. Not to modify this License in any other way.

-----------------------------------------------------------------------------

Notice

The Business Source License (this document, or the "License") is not an Open
Source license. However, the Licensed Work will eventually be made available
under an Open Source License, as stated in this License.
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,45 @@
# contracts
## General

## Testing

the current javascript test are going to be refactored into rescript a some point

## Commands

format the solidity code:

```bash
yarn format-contracts
```

lint the solidity code:

```bash
yarn lint-contracts
```

## Network forking

It is sometimes useful to fork the network to test deployments that rely on other contracts etc before running those deployments on production networks. Note, network forking has only been tested with alchemy RPC API endpoints, but others may work too.

To use this feature run `HARDHAT_FORK=<network name> yarn deploy`. So for example to run this on mumbai run `HARDHAT_FORK="mumbai" yarn deploy`.

You can test that this is working correctly by validating some data from the blockchain such as the blocknumber or a token balance.

eg you could use code like below.:

```javascript
let pTokenBalance = await paymentToken.balanceOf(accounts[2].address);
console.log(
"The paymentToken balance is",
accounts[2].address,
pTokenBalance.toString()
);

let blockNumber = await accounts[0].provider.getBlockNumber();
console.log("The balance is", blockNumber.toString());
```

## Troubleshooting

Please add your known troubles ;)
28 changes: 28 additions & 0 deletions bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "float-contracts",
"namespace": false,
"bs-dependencies": [],
"ppx-flags": [
"bs-let/ppx"
],
"sources": [
{
"dir": "test",
"subdirs": true
},
{
"dir": "deployTests",
"subdirs": true
}
],
"package-specs": {
"module": "commonjs",
"in-source": true
},
"warnings": {
"error": "+101+8"
},
"bsc-flags": [
"-open Belt"
]
}
Loading

0 comments on commit 9a59e79

Please sign in to comment.