-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
3d28a25
commit 4e6f0a6
Showing
33 changed files
with
2,784 additions
and
141 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
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
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,17 @@ | ||
node_modules | ||
.env | ||
|
||
# Hardhat files | ||
/cache | ||
/artifacts | ||
|
||
# TypeChain files | ||
/typechain | ||
/typechain-types | ||
|
||
# solidity-coverage files | ||
/coverage | ||
/coverage.json | ||
|
||
# Hardhat Ignition default folder for deployments against a local node | ||
ignition/deployments/chain-31337 |
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,27 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.7.4; | ||
|
||
import '@gnosis.pm/safe-contracts/contracts/accessors/SimulateTxAccessor.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/proxies/GnosisSafeProxyFactory.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/handler/DefaultCallbackHandler.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/handler/CompatibilityFallbackHandler.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/libraries/CreateCall.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/libraries/MultiSend.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/libraries/MultiSendCallOnly.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/examples/libraries/SignMessage.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/GnosisSafeL2.sol'; | ||
import '@gnosis.pm/safe-contracts/contracts/GnosisSafe.sol'; | ||
|
||
// Get the compiler to pick up these facets | ||
contract ImportSafe { | ||
SimulateTxAccessor public simulateTxAccessor; | ||
GnosisSafeProxyFactory public gnosisSafeProxyFactory; | ||
DefaultCallbackHandler public defaultCallbackHandler; | ||
CompatibilityFallbackHandler public compatibilityFallbackHandler; | ||
CreateCall public createCall; | ||
MultiSend public multiSend; | ||
MultiSendCallOnly public multiSendCallOnly; | ||
SignMessageLib public signMessageLib; | ||
GnosisSafeL2 public gnosisSafeL2; | ||
GnosisSafe public gnosisSafe; | ||
} |
8 changes: 8 additions & 0 deletions
8
apps/api/src/app/hardhat/contracts/interfaces/IAccessControlEvents.sol
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,8 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.7.6; | ||
|
||
interface IAccessControlEvents { | ||
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); | ||
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); | ||
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); | ||
} |
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,15 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.7.6; | ||
|
||
import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; | ||
|
||
contract BAL is ERC20 { | ||
constructor(address to, uint256 amount) ERC20('Balancer', 'BAL') { | ||
_mint(to, amount); | ||
} | ||
|
||
function mint(address to, uint256 amount) external { | ||
_mint(to, amount); | ||
} | ||
} |
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,31 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.7.6; | ||
|
||
import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; | ||
|
||
interface IWeightedPool is IERC20 { | ||
function setVault(address _vault) external; | ||
function getVault() external view returns (address); | ||
function getPoolId() external view returns (bytes32); | ||
} | ||
|
||
contract BPT is ERC20, IWeightedPool { | ||
address public vault; | ||
|
||
constructor(address _to, uint256 _amount) ERC20('20USDC-80THX', '20USDC-80THX') { | ||
_mint(_to, _amount); | ||
} | ||
|
||
function setVault(address _vault) external override { | ||
vault = _vault; | ||
} | ||
|
||
function getVault() external override view returns (address) { | ||
return vault; | ||
} | ||
|
||
function getPoolId() external override pure returns (bytes32) { | ||
return 0xb204bf10bc3a5435017d3db247f56da601dfe08a0002000000000000000000fe; | ||
} | ||
} |
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,60 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma abicoder v2; | ||
pragma solidity ^0.7.6; | ||
|
||
import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; | ||
|
||
interface IGauge is IERC20 { | ||
function deposit(uint256 _value) external; | ||
function withdraw(uint256 _value) external; | ||
function lp_token() external view returns (address); | ||
function working_supply() external view returns (uint256); | ||
} | ||
|
||
contract BPTGauge is ERC20, IGauge { | ||
IERC20 public bpt; | ||
|
||
event Deposit(address indexed user, uint256 value); | ||
event Withdraw(address indexed user, uint256 value); | ||
|
||
constructor(address _bpt) ERC20('Balancer 20USDC-80THX Gauge Deposit', '20USDC-80THX-gauge') { | ||
bpt = IERC20(_bpt); | ||
} | ||
|
||
/* | ||
* @dev Deposit LP tokens in the gauge and mint BPTGauge for msg.sender | ||
* @param _value Amount of LP tokens to deposit | ||
*/ | ||
function deposit(uint256 _value) external override { | ||
// Transfer BPT from the user to the gauge | ||
bpt.transferFrom(msg.sender, address(this), _value); | ||
|
||
// Mint BPTGauge tokens to the user | ||
_mint(msg.sender, _value); | ||
|
||
emit Deposit(msg.sender, _value); | ||
} | ||
|
||
/* | ||
* @dev Withdraw LP tokens from the gauge | ||
* @param _value Amount of LP tokens to withdraw | ||
* @notice This mock function will not decrease the totalSupply | ||
*/ | ||
function withdraw(uint256 _value) external override { | ||
// Transfer staked BPT from the gauge to the user | ||
bpt.transfer(msg.sender, _value); | ||
|
||
// Burn BPTGauge for the user | ||
transferFrom(msg.sender, address(0), _value); | ||
|
||
emit Withdraw(msg.sender, _value); | ||
} | ||
|
||
function lp_token() external override view returns (address) { | ||
return address(bpt); | ||
} | ||
|
||
function working_supply() external override pure returns (uint256) { | ||
return 585909572986408132343905; | ||
} | ||
} |
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,41 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma abicoder v2; | ||
pragma solidity ^0.7.6; | ||
|
||
import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; | ||
import "@openzeppelin/contracts/math/SafeMath.sol"; | ||
import 'hardhat/console.sol'; | ||
|
||
contract BalancerVault { | ||
using SafeMath for uint256; | ||
|
||
ERC20 public bpt; | ||
ERC20 public usdc; | ||
ERC20 public thx; | ||
|
||
struct JoinPoolRequest { | ||
address[] assets; | ||
uint256[] maxAmountsIn; | ||
bytes userData; | ||
bool fromInternalBalance; | ||
} | ||
|
||
constructor(address _bpt, address _usdc, address _thx) { | ||
bpt = ERC20(_bpt); | ||
usdc = ERC20(_usdc); | ||
thx = ERC20(_thx); | ||
} | ||
|
||
function joinPool(bytes32 poolId, address sender, address recipient, JoinPoolRequest memory request) external { | ||
usdc.transferFrom(sender, address(this), request.maxAmountsIn[0]); | ||
thx.transferFrom(sender, address(this), request.maxAmountsIn[1]); | ||
|
||
// Assumes BalancerVault has a BPT balance and transfers BPT to recipient | ||
// Aligns decimals in order to get to a workable BPT amount | ||
uint256 usdcAmount = request.maxAmountsIn[0].div(10**usdc.decimals()); | ||
uint256 thxAmount = request.maxAmountsIn[1].div(10**thx.decimals()); | ||
uint256 amount = usdcAmount.add(thxAmount).mul(10**bpt.decimals()); | ||
|
||
require(bpt.transfer(recipient, amount), 'BalancerVault: BPT transfer failed'); | ||
} | ||
} |
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,11 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.7.6; | ||
|
||
import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; | ||
|
||
contract ExampleToken is ERC20 { | ||
constructor(address to, uint256 amount) ERC20('Test Token', 'TEST') { | ||
_mint(to, amount); | ||
} | ||
} |
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,11 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.7.6; | ||
|
||
import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; | ||
|
||
contract THX is ERC20 { | ||
constructor(address to, uint256 amount) ERC20('THX Network (PoS)', 'THX') { | ||
_mint(to, amount); | ||
} | ||
} |
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,12 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.7.6; | ||
|
||
import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; | ||
|
||
contract USDC is ERC20 { | ||
constructor(address to, uint256 amount) ERC20('USD Coin (PoS)', 'USDC.e') { | ||
_setupDecimals(6); | ||
_mint(to, amount); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
apps/api/src/app/hardhat/contracts/utils/BondPurchaseChecker.sol
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,38 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma abicoder v2; | ||
pragma solidity ^0.7.6; | ||
|
||
interface ICustomBill { | ||
struct Bill { | ||
uint256 payout; | ||
uint256 payoutClaimed; | ||
uint256 vesting; | ||
uint256 vestingTerm; | ||
uint256 vestingStartTimestamp; | ||
uint256 lastClaimTimestamp; | ||
uint256 truePricePaid; | ||
} | ||
|
||
function getBillIds(address user) external view returns (uint[] memory); | ||
function getBillInfo(uint256 billId) external view returns (Bill memory); | ||
} | ||
|
||
contract BondPurchaseChecker { | ||
ICustomBill bond; | ||
|
||
constructor(address _bondContractAddress) { | ||
bond = ICustomBill(_bondContractAddress); | ||
} | ||
|
||
function largestPayoutOf(address _user) public view returns (uint256) { | ||
uint[] memory billIds = bond.getBillIds(_user); | ||
uint256 largestPayout = 0; | ||
|
||
for (uint i = 0; i < billIds.length; i++) { | ||
uint256 payout = bond.getBillInfo(billIds[i]).payout; | ||
largestPayout = payout > largestPayout ? payout : largestPayout; | ||
} | ||
|
||
return largestPayout; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
apps/api/src/app/hardhat/contracts/utils/ERC1155/ITHX_ERC1155.sol
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,14 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.7.6; | ||
|
||
import '@openzeppelin/contracts/token/ERC1155/IERC1155.sol'; | ||
|
||
interface ITHX_ERC1155 is IERC1155 { | ||
function mint(address to, uint256 id, uint256 amount, bytes memory data) external; | ||
function mintBatch( | ||
address to, | ||
uint256[] memory ids, | ||
uint256[] memory amounts, | ||
bytes memory data | ||
) external; | ||
} |
Oops, something went wrong.