Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated gh action and formatted #8

Merged
merged 10 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ env:
jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -19,7 +18,18 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- run: yarn

- uses: onbjerg/foundry-toolchain@v1
- run: forge test --ffi -vvv

- name: lint
run: forge fmt --check

- name: test
run: forge test --ffi -vvv

- name: snapshot
run: forge snapshot

4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

forge fmt && git update-index --again
3 changes: 3 additions & 0 deletions .husky/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

forge fmt
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"dependencies": {
"@chainlink/contracts": "^0.6.1",
"chai": "^4.3.7",
"husky": "^8.0.3",
"mocha": "^10.2.0",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.1.3"
Expand Down
81 changes: 37 additions & 44 deletions src/CapitalPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,45 @@ pragma solidity ^0.8.17;

import {ERC20, ERC4626} from "solady/src/tokens/ERC4626.sol";
import {LoanManager} from "src/LoanManager.sol";
import {
ConduitControllerInterface
} from "seaport-sol/src/ConduitControllerInterface.sol";
import {ConduitControllerInterface} from "seaport-sol/src/ConduitControllerInterface.sol";

import "forge-std/console.sol";

contract CapitalPool is ERC4626 {
address immutable underlying;

bytes32 conduitKey;
address public immutable conduit;

constructor(
address underlying_,
ConduitControllerInterface cc_,
address originator_
) {
bytes32 ck = bytes32(uint256(uint160(address(address(this)))) << 96);
address c = cc_.createConduit(ck, address(this));
cc_.updateChannel(c, originator_, true);
ERC20(underlying_).approve(c, type(uint256).max);
conduit = c;
conduitKey = ck;
underlying = underlying_;
}

function asset() public view override returns (address) {
return underlying;
}

function name() public pure override returns (string memory) {
return "AstariaV1Pool";
}

function symbol() public pure override returns (string memory) {
return "AV1P";
}

function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) public pure returns (bytes4) {
LoanManager.Loan memory loan = abi.decode(data, (LoanManager.Loan));
//handle any logic here from when you receive a loan
return this.onERC721Received.selector;
}
address immutable underlying;

bytes32 conduitKey;
address public immutable conduit;

constructor(address underlying_, ConduitControllerInterface cc_, address originator_) {
bytes32 ck = bytes32(uint256(uint160(address(address(this)))) << 96);
address c = cc_.createConduit(ck, address(this));
cc_.updateChannel(c, originator_, true);
ERC20(underlying_).approve(c, type(uint256).max);
conduit = c;
conduitKey = ck;
underlying = underlying_;
}

function asset() public view override returns (address) {
return underlying;
}

function name() public pure override returns (string memory) {
return "AstariaV1Pool";
}

function symbol() public pure override returns (string memory) {
return "AV1P";
}

function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)
public
pure
returns (bytes4)
{
LoanManager.Loan memory loan = abi.decode(data, (LoanManager.Loan));
//handle any logic here from when you receive a loan
return this.onERC721Received.selector;
}
}
Loading