Skip to content

Commit 134f0a3

Browse files
committed
Merge
2 parents 838d6a7 + a0902b7 commit 134f0a3

File tree

21 files changed

+1098
-806
lines changed

21 files changed

+1098
-806
lines changed

.github/workflows/node.js.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/ousd.yml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,69 @@ jobs:
146146
env:
147147
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
148148
with:
149-
args: --severity-threshold=high --all-projects
149+
args: --severity-threshold=high --all-projects
150+
151+
build-image:
152+
name: "Deploy App"
153+
runs-on: ubuntu-latest
154+
needs: [contracts-lint, dapp-lint]
155+
environment:
156+
name: ${{ github.ref_name }}
157+
env:
158+
HEROKU_TOKEN: ${{ secrets.HEROKU_TOKEN }}
159+
CURR_BRANCH: ${{ github.ref_name }}
160+
if: ${{ contains(fromJSON('["master", "staging", "stable"]'), github.ref_name) }}
161+
steps:
162+
- uses: actions/checkout@v3
163+
164+
- name: Set up QEMU
165+
uses: docker/setup-qemu-action@v2
166+
167+
- name: Set up Docker Buildx
168+
uses: docker/setup-buildx-action@v2
169+
170+
- name: Identify Heroku App Name
171+
shell: bash
172+
run:
173+
if [[ $CURR_BRANCH == "stable" ]]; then
174+
echo "HEROKU_APP_NAME=ousd-dapp" >> $GITHUB_ENV;
175+
else
176+
echo "HEROKU_APP_NAME=ousd-dapp-staging" >> $GITHUB_ENV;
177+
fi;
178+
id: heroku_app
179+
180+
- name: Heroku Login
181+
uses: akhileshns/[email protected]
182+
if: ${{ contains(fromJSON('["staging", "stable"]'), github.ref_name) }}
183+
with:
184+
justlogin: true
185+
heroku_api_key: ${{secrets.HEROKU_TOKEN}}
186+
heroku_app_name: ${{env.HEROKU_APP_NAME}}
187+
heroku_email: ${{secrets.HEROKU_EMAIL}}
188+
189+
- name: Run Docker Login
190+
if: ${{ contains(fromJSON('["staging", "stable"]'), github.ref_name) }}
191+
run: docker login --username=_ --password=$HEROKU_TOKEN registry.heroku.com
192+
193+
- name: Extract Deployment Env
194+
env:
195+
HEROKU_APP_NAME: ${{env.HEROKU_APP_NAME}}
196+
working-directory: dapp
197+
run: heroku config -s -a $HEROKU_APP_NAME > deploy.env
198+
199+
- name: Build and Push
200+
uses: docker/build-push-action@v3
201+
if: ${{ contains(fromJSON('["staging", "stable"]'), github.ref_name) }}
202+
env:
203+
NODE_ENV: production
204+
with:
205+
context: .
206+
push: true
207+
tags: registry.heroku.com/${{env.HEROKU_APP_NAME}}/web
208+
provenance: false
209+
210+
- name: Deploy to Heroku
211+
if: ${{ contains(fromJSON('["staging", "stable"]'), github.ref_name) }}
212+
env:
213+
HEROKU_APP_NAME: ${{env.HEROKU_APP_NAME}}
214+
run: heroku container:release web -a $HEROKU_APP_NAME

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM node:16-alpine
2+
3+
# Install Git
4+
RUN apk update
5+
RUN apk add git
6+
7+
# Copy files over
8+
WORKDIR /app
9+
COPY contracts ./contracts
10+
COPY dapp ./dapp
11+
12+
# Build contract files
13+
WORKDIR /app/contracts
14+
RUN yarn install
15+
RUN yarn deploy
16+
17+
# Build DApp
18+
WORKDIR /app/dapp
19+
RUN yarn install
20+
RUN NODE_ENV=production yarn build
21+
22+
CMD ["yarn", "start"]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
OUSD is a new kind of stablecoin that passively accrues yield while you are holding it.
44
Checkout our [docs](https://docs.ousd.com) for more details about the product.
55

6+
| Branch | CI/CD Status |
7+
| ------------- | ------------- |
8+
| `master` | [![OUSD](https://github.com/OriginProtocol/origin-dollar/actions/workflows/ousd.yml/badge.svg)](https://github.com/OriginProtocol/origin-dollar/actions/workflows/ousd.yml) |
9+
| `staging` | [![OUSD](https://github.com/OriginProtocol/origin-dollar/actions/workflows/ousd.yml/badge.svg?branch=staging)](https://github.com/OriginProtocol/origin-dollar/actions/workflows/ousd.yml?query=branch%3Astaging) |
10+
| `stable` | [![OUSD](https://github.com/OriginProtocol/origin-dollar/actions/workflows/ousd.yml/badge.svg?branch=stable)](https://github.com/OriginProtocol/origin-dollar/actions/workflows/ousd.yml?query=branch%3Astable) |
11+
612
## Requirements
713
- Node Version
814
- `^8.11.2 >= node <=^14.0.0`

brownie/abi/vault_admin.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

brownie/metastrategy.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
import world
33
import math
44

5-
#CONFIGURATION - unfortunately this address changes until we deploy it to mainnet
6-
OUSD_META_STRATEGY = '0xb12C3410C44854054c217fbF79dFf38ffD1C0676'
7-
BUSD_STRATEGY = '0x6996352570817113965b0325005f868B1Fe2f2e9'
8-
# Define which meta strategy should be set as default USDT asset strategy. Important for
9-
# supplying liquidity when minting using USDT
10-
USDT_DEFAULT_META_STRATEGY = OUSD_META_STRATEGY
11-
#USDT_DEFAULT_META_STRATEGY = BUSD_STRATEGY
12-
#END COFIGURATION
135

146
me = ORIGINTEAM
157
some_gas_price = 100
@@ -30,6 +22,8 @@
3022
DAI_BAGS = '0x40ec5b33f54e0e8a33a975908c5ba1c14e5bbbdf' #polygon bridge
3123
DAI_BAGS_2 = '0x5d3a536e4d6dbd6114cc1ead35777bab948e3643' #this is compound cDai. Don't touch this!
3224
CURVE_FACTORY = '0xB9fC157394Af804a3578134A6585C0dc9cc990d4'
25+
OUSD_META_STRATEGY = '0x89Eb88fEdc50FC77ae8a18aAD1cA0ac27f777a90'
26+
USDT_DEFAULT_META_STRATEGY = OUSD_META_STRATEGY
3327

3428
threepool_lp = load_contract('threepool_lp', THREEPOOL_LP)
3529
ousd_metapool = load_contract('ousd_metapool', OUSD_METAPOOL)
@@ -52,7 +46,6 @@
5246
frax.transfer(me, frax.balanceOf(FRAX_BAGS), {'from': FRAX_BAGS})
5347
busd.transfer(me, busd.balanceOf(BUSD_BAGS), {'from': BUSD_BAGS})
5448
meta_strat = load_contract('convex_strat', OUSD_META_STRATEGY)
55-
busd_strat = load_contract('convex_strat', BUSD_STRATEGY)
5649

5750
# approve ousd and 3poolLp to be used by ousd_metapool
5851
threepool_lp.approve(ousd_metapool, int(0), OPTS)

contracts/contracts/interfaces/IVault.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ interface IVault {
113113
uint256[] calldata _amounts
114114
) external;
115115

116+
function withdrawFromStrategy(
117+
address _strategyFromAddress,
118+
address[] calldata _assets,
119+
uint256[] calldata _amounts
120+
) external;
121+
122+
function depositToStrategy(
123+
address _strategyToAddress,
124+
address[] calldata _assets,
125+
uint256[] calldata _amounts
126+
) external;
127+
116128
// VaultCore.sol
117129
function mint(
118130
address _asset,

contracts/contracts/vault/VaultAdmin.sol

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ contract VaultAdmin is VaultStorage {
233233
}
234234

235235
/**
236-
* @notice Move assets from one Strategy to another
236+
* @dev Move assets from one Strategy to another
237237
* @param _strategyFromAddress Address of Strategy to move assets from.
238238
* @param _strategyToAddress Address of Strategy to move assets to.
239239
* @param _assets Array of asset address that will be moved
@@ -246,27 +246,103 @@ contract VaultAdmin is VaultStorage {
246246
uint256[] calldata _amounts
247247
) external onlyGovernorOrStrategist {
248248
require(
249-
strategies[_strategyFromAddress].isSupported,
250-
"Invalid from Strategy"
249+
strategies[_strategyToAddress].isSupported,
250+
"Invalid to Strategy"
251251
);
252+
require(_assets.length == _amounts.length, "Parameter length mismatch");
253+
_withdrawFromStrategy(
254+
_strategyToAddress,
255+
_strategyFromAddress,
256+
_assets,
257+
_amounts
258+
);
259+
260+
IStrategy strategyTo = IStrategy(_strategyToAddress);
261+
for (uint256 i = 0; i < _assets.length; i++) {
262+
require(strategyTo.supportsAsset(_assets[i]), "Asset unsupported");
263+
}
264+
// Tell new Strategy to deposit into protocol
265+
strategyTo.depositAll();
266+
}
267+
268+
/**
269+
* @dev Deposit multiple assets from the vault into the strategy.
270+
* @param _strategyToAddress Address of the Strategy to deposit assets into.
271+
* @param _assets Array of asset address that will be deposited into the strategy.
272+
* @param _amounts Array of amounts of each corresponding asset to deposit.
273+
*/
274+
function depositToStrategy(
275+
address _strategyToAddress,
276+
address[] calldata _assets,
277+
uint256[] calldata _amounts
278+
) external onlyGovernorOrStrategist {
279+
_depositToStrategy(_strategyToAddress, _assets, _amounts);
280+
}
281+
282+
function _depositToStrategy(
283+
address _strategyToAddress,
284+
address[] calldata _assets,
285+
uint256[] calldata _amounts
286+
) internal {
252287
require(
253288
strategies[_strategyToAddress].isSupported,
254289
"Invalid to Strategy"
255290
);
256291
require(_assets.length == _amounts.length, "Parameter length mismatch");
257292

258-
IStrategy strategyFrom = IStrategy(_strategyFromAddress);
259293
IStrategy strategyTo = IStrategy(_strategyToAddress);
260294

261295
for (uint256 i = 0; i < _assets.length; i++) {
262296
require(strategyTo.supportsAsset(_assets[i]), "Asset unsupported");
263-
// Withdraw from Strategy and pass other Strategy as recipient
264-
strategyFrom.withdraw(address(strategyTo), _assets[i], _amounts[i]);
297+
// Send required amount of funds to the strategy
298+
IERC20(_assets[i]).safeTransfer(_strategyToAddress, _amounts[i]);
265299
}
266-
// Tell new Strategy to deposit into protocol
300+
301+
// Deposit all the funds that have been sent to the strategy
267302
strategyTo.depositAll();
268303
}
269304

305+
/**
306+
* @dev Withdraw multiple assets from the strategy to the vault.
307+
* @param _strategyFromAddress Address of the Strategy to withdraw assets from.
308+
* @param _assets Array of asset address that will be withdrawn from the strategy.
309+
* @param _amounts Array of amounts of each corresponding asset to withdraw.
310+
*/
311+
function withdrawFromStrategy(
312+
address _strategyFromAddress,
313+
address[] calldata _assets,
314+
uint256[] calldata _amounts
315+
) external onlyGovernorOrStrategist {
316+
_withdrawFromStrategy(
317+
address(this),
318+
_strategyFromAddress,
319+
_assets,
320+
_amounts
321+
);
322+
}
323+
324+
/**
325+
* @param _recipient can either be a strategy or the Vault
326+
*/
327+
function _withdrawFromStrategy(
328+
address _recipient,
329+
address _strategyFromAddress,
330+
address[] calldata _assets,
331+
uint256[] calldata _amounts
332+
) internal {
333+
require(
334+
strategies[_strategyFromAddress].isSupported,
335+
"Invalid from Strategy"
336+
);
337+
require(_assets.length == _amounts.length, "Parameter length mismatch");
338+
339+
IStrategy strategyFrom = IStrategy(_strategyFromAddress);
340+
for (uint256 i = 0; i < _assets.length; i++) {
341+
// Withdraw from Strategy to the recipient
342+
strategyFrom.withdraw(_recipient, _assets[i], _amounts[i]);
343+
}
344+
}
345+
270346
/**
271347
* @dev Sets the maximum allowable difference between
272348
* total supply and backing assets' value.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const { deploymentWithProposal } = require("../utils/deploy");
2+
const addresses = require("../utils/addresses");
3+
4+
module.exports = deploymentWithProposal(
5+
{ deployName: "048_deposit_withdraw_tooling", forceDeploy: false },
6+
async ({
7+
assetAddresses,
8+
deployWithConfirmation,
9+
ethers,
10+
getTxOpts,
11+
withConfirmation,
12+
}) => {
13+
const { deployerAddr, governorAddr } = await getNamedAccounts();
14+
const sDeployer = await ethers.provider.getSigner(deployerAddr);
15+
16+
// Current contracts
17+
const cVaultProxy = await ethers.getContract("VaultProxy");
18+
19+
const dVaultAdmin = await deployWithConfirmation("VaultAdmin");
20+
const cVault = await ethers.getContractAt("Vault", cVaultProxy.address);
21+
22+
// Governance Actions
23+
// ----------------
24+
return {
25+
name: "Deploy new withdrawal utils",
26+
actions: [
27+
// 1. Set VaultAdmin implementation
28+
{
29+
contract: cVault,
30+
signature: "setAdminImpl(address)",
31+
args: [dVaultAdmin.address],
32+
},
33+
],
34+
};
35+
}
36+
);

contracts/test/_fixture.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ async function defaultFixture() {
167167
tusd = await ethers.getContractAt(erc20Abi, addresses.mainnet.TUSD);
168168
usdc = await ethers.getContractAt(erc20Abi, addresses.mainnet.USDC);
169169
cusdt = await ethers.getContractAt(erc20Abi, addresses.mainnet.cUSDT);
170+
cdai = await ethers.getContractAt(erc20Abi, addresses.mainnet.cDAI);
170171
cusdc = await ethers.getContractAt(erc20Abi, addresses.mainnet.cUSDC);
171172
comp = await ethers.getContractAt(erc20Abi, addresses.mainnet.COMP);
172173
crv = await ethers.getContractAt(erc20Abi, addresses.mainnet.CRV);

0 commit comments

Comments
 (0)