Skip to content

Commit

Permalink
Merge branch 'init-overview-page' of github.com:thesis/acre into acre…
Browse files Browse the repository at this point in the history
…-logo
  • Loading branch information
kkosiorowska committed Dec 8, 2023
2 parents 2b6aea6 + be3d4a5 commit 9b02c24
Show file tree
Hide file tree
Showing 13 changed files with 530 additions and 53 deletions.
3 changes: 1 addition & 2 deletions core/.solhint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"extends": "thesis",
"plugins": [],
"rules": {}
"plugins": []
}
45 changes: 41 additions & 4 deletions core/contracts/Acre.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

// Uncomment this line to use console.log
// import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol";

contract Acre {
// TODO: add your implementation
/// @title Acre
/// @notice This contract implements the ERC-4626 tokenized vault standard. By
/// staking tBTC, users acquire a liquid staking token called stBTC,
/// commonly referred to as "shares". The staked tBTC is securely
/// deposited into Acre's vaults, where it generates yield over time.
/// Users have the flexibility to redeem stBTC, enabling them to
/// withdraw their staked tBTC along with the accrued yield.
/// @dev ERC-4626 is a standard to optimize and unify the technical parameters
/// of yield-bearing vaults. This contract facilitates the minting and
/// burning of shares (stBTC), which are represented as standard ERC20
/// tokens, providing a seamless exchange with tBTC tokens.
contract Acre is ERC4626 {
event StakeReferral(bytes32 indexed referral, uint256 assets);

constructor(
IERC20 tbtc
) ERC4626(tbtc) ERC20("Acre Staked Bitcoin", "stBTC") {}

/// @notice Stakes a given amount of tBTC token and mints shares to a
/// receiver.
/// @dev This function calls `deposit` function from `ERC4626` contract. The
/// amount of the assets has to be pre-approved in the tBTC contract.
/// @param assets Approved amount for the transfer and stake.
/// @param receiver The address to which the shares will be minted.
/// @param referral Data used for referral program.
/// @return shares Minted shares.
function stake(
uint256 assets,
address receiver,
bytes32 referral
) public returns (uint256) {
// TODO: revisit the type of referral.
uint256 shares = deposit(assets, receiver);

if (referral != bytes32(0)) {
emit StakeReferral(referral, assets);
}

return shares;
}
}
12 changes: 12 additions & 0 deletions core/contracts/test/TestERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract TestERC20 is ERC20 {
constructor() ERC20("Test Token", "TEST") {}

function mint(address account, uint256 value) external {
_mint(account, value);
}
}
3 changes: 3 additions & 0 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@
"ts-node": "^10.9.1",
"typechain": "^8.3.2",
"typescript": "^5.3.2"
},
"dependencies": {
"@openzeppelin/contracts": "^5.0.0"
}
}
Loading

0 comments on commit 9b02c24

Please sign in to comment.