Skip to content

Commit

Permalink
feat: add types to registry (#21)
Browse files Browse the repository at this point in the history
* feat: add types to registry

* feat: deafult values

* feat: just use vault array

* chore: back info struct

* chore: update to new version

* fix: black

* chore: update work flow

* chore: reuse ivault

* feat: check losses

* fix: lint
  • Loading branch information
Schlagonia authored Oct 20, 2023
1 parent 274a3a2 commit 38fa04a
Show file tree
Hide file tree
Showing 11 changed files with 377 additions and 380 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: ApeWorX/github-action@v2
- uses: ApeWorX/github-action@v2.0
with:
python-version: '3.10'
ape-version-pin: "==0.6.8"
ape-plugins-list: 'solidity==0.6.3 vyper==0.6.5 hardhat==0.6.4 infura==0.6.1 etherscan==0.6.4'

- name: install vyper
run: pip install git+https://github.com/vyperlang/vyper
- run: ape compile --force --size
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,19 @@
export WEB3_INFURA_PROJECT_ID=your_infura_api_key

export ETHERSCAN_API_KEY=your_api_key

### Deployment

Deployment of periphery contracts such as the [Registry Factory](https://github.com/yearn/vault-periphery/blob/master/contracts/registry/RegistryFactory.sol) or [Address Provider](https://github.com/yearn/vault-periphery/blob/master/contracts/AddressProvider.vy) are done using a create2 factory in order to get a deterministic address that is the same on each EVM chain.

This can be done permissionlessly if the most recent contract has not yet been deployed on a chain you would like to use it on.

1. [Add an Ape account](https://docs.apeworx.io/ape/stable/commands/accounts.html)
2. Go to the contracts specific deployment script under `scripts/` and add your account name to the `accounts.load("you_acct_name")` at the top of the script.
3. Run the deployment script
```sh
ape run scripts/deploy_contract_name.py --network YOUR_RPC_URL
```
- For chains that don't support 1559 tx's you may need to add a `type="0x0"` argument at the end of the deployment tx.
- ie `tx = deployer_contract.deploy(bytecode, salt, sender=deployer, type="0x0")`
3. The address the contract was deployed at will print in the console and should match any other chain the same version has been deployed on.
6 changes: 5 additions & 1 deletion ape-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ dependencies:
- name: yearn-vaults
github: yearn/yearn-vaults-v3
ref: v3.0.1
exclude:
- test/
- name: tokenized-strategy
github: yearn/tokenized-strategy
ref: v3.0.1
contracts_folder: src
exclude:
- src/test/**/*
- test/
- name: periphery
github: yearn/tokenized-strategy-periphery
ref: master
contracts_folder: src
exclude:
- test/

solidity:
import_remapping:
Expand Down
6 changes: 3 additions & 3 deletions contracts/Mocks/MockFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity 0.8.18;

contract MockFactory {
string public api_version;
string public apiVersion;

address public vault_bluePrint;

constructor(string memory apiVersion) {
api_version = apiVersion;
constructor(string memory _apiVersion) {
apiVersion = _apiVersion;
}
}
10 changes: 10 additions & 0 deletions contracts/debtAllocators/GenericDebtAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ contract GenericDebtAllocator is Governance {

// Check if it's over the threshold.
if (toPull > config.minimumChange) {
// Can't lower debt if there is unrealised losses.
if (
_vault.assess_share_of_unrealised_losses(
_strategy,
params.current_debt
) > 0
) {
return (false, bytes("unrealised loss"));
}

// If so return true and the calldata.
return (
true,
Expand Down
Loading

0 comments on commit 38fa04a

Please sign in to comment.