-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
581 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
{ | ||
"solidity.packageDefaultDependenciesContractsDirectory": "pkg/contracts/src", | ||
"solidity.packageDefaultDependenciesDirectory": "lib", | ||
"[solidity]": { | ||
"editor.defaultFormatter": "JuanBlanco.solidity", | ||
"editor.formatOnSave": true | ||
}, | ||
"solidity.formatter": "forge", | ||
"solidity.compileUsingRemoteVersion": "v0.4.24", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# vscode | ||
.vscode | ||
|
||
# hardhat | ||
artifacts | ||
cache | ||
deployments | ||
node_modules | ||
|
||
|
||
cache/ | ||
artifacts/ | ||
|
||
coverage* | ||
typechain/ | ||
|
||
.vscode/* | ||
!.vscode/settings.json.default | ||
!.vscode/launch.json.default | ||
!.vscode/extensions.json.default | ||
|
||
node_modules/ | ||
.env | ||
|
||
.yalc | ||
yalc.lock | ||
|
||
contractsInfo.json | ||
deployments/hardhat | ||
deployments/localhost | ||
|
||
# don't push the environment vars! | ||
.env | ||
|
||
# Built application files | ||
.DS* | ||
*.apk | ||
*.ap_ | ||
*.aab | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
# Uncomment the following line in case you need and you don't have the release build type files in your app | ||
# release/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/gradle.xml | ||
.idea/assetWizardSettings.xml | ||
.idea/dictionaries | ||
.idea/libraries | ||
# Android Studio 3 in .gitignore file. | ||
.idea/caches | ||
.idea/modules.xml | ||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you | ||
.idea/navEditor.xml | ||
.idea | ||
|
||
# Keystore files | ||
# Uncomment the following lines if you do not want to check your keystore files in. | ||
#*.jks | ||
#*.keystore | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
# google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json | ||
|
||
# fastlane | ||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
fastlane/test_output | ||
fastlane/readme.md | ||
|
||
# Version control | ||
vcs.xml | ||
|
||
# lint | ||
lint/intermediates/ | ||
lint/generated/ | ||
lint/outputs/ | ||
lint/tmp/ | ||
# lint/reports/ | ||
|
||
node_modules | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ABC Template | ||
|
||
This package contains the smart contracts needed to deploy the ABC Template. | ||
|
||
## Usage | ||
|
||
Edit hardhat.config.js to add the API key for your Alchemy account and Etherscan API key. | ||
|
||
``` | ||
$ bun hardhat run scripts/deploy.js --network <network> | ||
``` | ||
|
||
## Deployed Contracts | ||
|
||
The contracts are deployed on the following networks: | ||
- Optimism: [0x65e4D3410CF41eAa906Ff3685D537a232144A559](https://optimistic.etherscan.io/address/0x65e4D3410CF41eAa906Ff3685D537a232144A559#code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "@aragon/os/contracts/common/IsContract.sol"; | ||
import "@aragon/os/contracts/acl/ACL.sol"; | ||
import "@aragon/os/contracts/kernel/Kernel.sol"; | ||
import "@aragon/os/contracts/common/Uint256Helpers.sol"; | ||
import "@aragon/apps-token-manager/contracts/TokenManager.sol"; | ||
import "@aragon/apps-vault/contracts/Vault.sol"; | ||
import "@aragon/templates-shared/contracts/BaseTemplate.sol"; | ||
import "./interfaces/IAugmentedBondingCurve.sol"; | ||
|
||
contract AbcBaseTemplate is BaseTemplate { | ||
using Uint256Helpers for uint256; | ||
|
||
/* Hardcoded constant to save gas | ||
* bytes32 constant internal ABC_APP_ID = keccak256(abi.encodePacked(apmNamehash("open"), keccak256("augmented-bonding-curve"))); // augmented-bonding-curve.open.aragonpm.eth | ||
*/ | ||
bytes32 internal constant ABC_APP_ID = 0x952fcbadf8d7288f1a8b47ed7ee931702318b527558093398674db0c93e3a75b; | ||
uint256 private constant VIRTUAL_SUPPLY = 0; | ||
uint256 private constant VIRTUAL_BALANCE = 0; | ||
string private constant ERROR_FORMULA_IS_NOT_CONTRACT = "TEMPLATE_FORMULA_IS_NOT_CONTRACT"; | ||
string private constant ERROR_CANNOT_CAST_VALUE_TO_TYPE = "TEMPLATE_CANNOT_CAST_VALUE_TO_TYPE"; | ||
address private formula; | ||
|
||
constructor(address _formula) public { | ||
require(isContract(_formula), ERROR_FORMULA_IS_NOT_CONTRACT); | ||
formula = _formula; | ||
} | ||
|
||
function _installAbcApp( | ||
Kernel _dao, | ||
TokenManager _tokenManager, | ||
Vault _reserve, | ||
address _beneficiary, | ||
uint256 _entryTribute, | ||
uint256 _exitTribute | ||
) internal returns (IAugmentedBondingCurve) { | ||
bytes memory initializeData = abi.encodeWithSelector( | ||
IAugmentedBondingCurve(0).initialize.selector, | ||
_tokenManager, | ||
formula, | ||
_reserve, | ||
_beneficiary, | ||
_entryTribute, | ||
_exitTribute | ||
); | ||
return IAugmentedBondingCurve(_installNonDefaultApp(_dao, ABC_APP_ID, initializeData)); | ||
} | ||
|
||
function _configureAbcApp(ACL _acl, IAugmentedBondingCurve _abc, address _collateralToken, uint32 _reserveRatio) | ||
internal | ||
{ | ||
_createPermissionForTemplate(_acl, _abc, _abc.MANAGE_COLLATERAL_TOKEN_ROLE()); | ||
_abc.addCollateralToken(_collateralToken, VIRTUAL_SUPPLY, VIRTUAL_BALANCE, _reserveRatio); | ||
_removePermissionFromTemplate(_acl, _abc, _abc.MANAGE_COLLATERAL_TOKEN_ROLE()); | ||
} | ||
|
||
function _createAbcAndReservePermissions( | ||
ACL _acl, | ||
IAugmentedBondingCurve _abc, | ||
address _collateralManager, | ||
address _permissionsManager | ||
) internal { | ||
Vault _reserve = _abc.reserve(); | ||
_acl.createPermission(_collateralManager, _abc, _abc.MANAGE_COLLATERAL_TOKEN_ROLE(), _permissionsManager); | ||
_acl.createPermission(_acl.ANY_ENTITY(), _abc, _abc.MAKE_BUY_ORDER_ROLE(), _permissionsManager); | ||
_acl.createPermission(_acl.ANY_ENTITY(), _abc, _abc.MAKE_SELL_ORDER_ROLE(), _permissionsManager); | ||
_acl.createPermission(_abc, _reserve, _reserve.TRANSFER_ROLE(), _permissionsManager); | ||
} | ||
|
||
function _unwrapAbcSettings(uint256[5] memory _abcSettings) | ||
internal | ||
pure | ||
returns ( | ||
uint256 entryTribute, | ||
uint256 exitTribute, | ||
address collateralToken, | ||
uint32 reserveRatio, | ||
uint256 initialBalance | ||
) | ||
{ | ||
entryTribute = _abcSettings[0]; | ||
exitTribute = _abcSettings[1]; | ||
collateralToken = _toAddress(_abcSettings[2]); | ||
reserveRatio = _toUint32(_abcSettings[3]); | ||
initialBalance = _abcSettings[4]; | ||
} | ||
|
||
/* HELPERS */ | ||
|
||
function _toAddress(uint256 _value) private pure returns (address) { | ||
require(_value <= uint160(-1), ERROR_CANNOT_CAST_VALUE_TO_TYPE); | ||
return address(_value); | ||
} | ||
|
||
function _toUint32(uint256 _value) private pure returns (uint32) { | ||
require(_value <= uint32(-1), ERROR_CANNOT_CAST_VALUE_TO_TYPE); | ||
return uint32(_value); | ||
} | ||
} |
Oops, something went wrong.