Skip to content
Draft
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
10 changes: 10 additions & 0 deletions common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export interface ITokens {
// Mountain
USDM?: string
wUSDM?: string

// Angle
USDA?: string
stUSD?: string
}

export type ITokensKeys = Array<keyof ITokens>
Expand Down Expand Up @@ -256,6 +260,8 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
sdUSDCUSDCPlus: '0x9bbF31E99F30c38a5003952206C31EEa77540BeF',
USDe: '0x4c9edd5852cd905f086c759e8383e09bff1e68b3',
sUSDe: '0x9D39A5DE30e57443BfF2A8307A4256c8797A3497',
USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274',
stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776',
},
chainlinkFeeds: {
RSR: '0x759bBC1be8F90eE6457C44abc7d443842a976d02',
Expand Down Expand Up @@ -513,6 +519,8 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
sUSDbC: '0x4c80e24119cfb836cdf0a6b53dc23f04f7e652ca',
wstETH: '0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452',
STG: '0xE3B53AF74a4BF62Ae5511055290838050bf764Df',
USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274',
stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776',
},
chainlinkFeeds: {
DAI: '0x591e79239a7d679378ec8c847e5038150364c78f', // 0.3%, 24hr
Expand Down Expand Up @@ -560,6 +568,8 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
saArbUSDT: '', // TODO our wrapper. remove from deployment script after placing here
USDM: '0x59d9356e565ab3a36dd77763fc0d87feaf85508c',
wUSDM: '0x57f5e098cad7a3d1eed53991d4d66c45c9af7812',
USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274',
stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776',
},
chainlinkFeeds: {
ARB: '0xb2A824043730FE05F3DA2efaFa1CBbe83fa548D6',
Expand Down
21 changes: 21 additions & 0 deletions contracts/plugins/assets/angle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Angle Staked USDA (stUSD) Collateral Plugin

## Summary

`USDA` is a stablecoin pegged to the dollar built by [Angle Labs](https://github.com/AngleProtocol). `USDA` holders can stake their stablecoins for `stUSD` in order to earn a native yield.

This plugin allows `stUSD` holders to use their tokens as collateral in the Reserve Protocol.

`stUSD` is an ERC4626 vault, most similar to the DAI savings module. The redeemable `USDA` amount can be obtained by dividing `stUSD.totalAssets()` by `stUSD.totalSupply()`.

`USDA` contract: <https://etherscan.io/address/0x0000206329b97DB379d5E1Bf586BbDB969C63274#code>

`stUSD` contract: <https://etherscan.io/address/0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776#code>

## Implementation

### Units

| tok | ref | target | UoA |
| ----- | ---- | ------ | --- |
| stUSD | USDA | USD | USD |
25 changes: 25 additions & 0 deletions contracts/plugins/assets/angle/StakedUSDAFiatCollateral.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: BlueOak-1.0.0
pragma solidity 0.8.19;

import { CollateralConfig } from "../AppreciatingFiatCollateral.sol";
import { ERC4626FiatCollateral, IERC4626 } from "../ERC4626FiatCollateral.sol";

/**
* @title Staked USDA Fiat Collateral
* @notice Collateral plugin for Staked USDA (stUSD)
* tok = stUSD (ERC4626 vault)
* ref = USDA
* tar = USD
* UoA = USD
*/

contract StakedUSDAFiatCollateral is ERC4626FiatCollateral {
/// config.erc20 must be stUSD
/// @param config.chainlinkFeed Feed units: {UoA/ref}
/// @param revenueHiding {1} A value like 1e-6 that represents the maximum refPerTok to hide
constructor(CollateralConfig memory config, uint192 revenueHiding)
ERC4626FiatCollateral(config, revenueHiding)
{
require(config.defaultThreshold != 0, "defaultThreshold zero");
}
}
5 changes: 3 additions & 2 deletions scripts/addresses/1-tmp-assets-collateral.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"CVX": "0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B",
"apxETH": "0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6",
"sUSDe": "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497",
"pyUSD": "0x6c3ea9036406852006290770bedfcaba0e23a0e8"
"pyUSD": "0x6c3ea9036406852006290770bedfcaba0e23a0e8",
"stUSD": "0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776"
}
}
}
92 changes: 92 additions & 0 deletions scripts/deployment/phase2-assets/collaterals/deploy_usda.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import fs from 'fs'
import hre from 'hardhat'
import { ContractFactory } from 'ethers'
import { expect } from 'chai'
import { getChainId } from '../../../../common/blockchain-utils'
import { networkConfig } from '../../../../common/configuration'
import { fp } from '../../../../common/numbers'
import { CollateralStatus } from '../../../../common/constants'
import {
getDeploymentFile,
getAssetCollDeploymentFilename,
IAssetCollDeployments,
getDeploymentFilename,
fileExists,
} from '../../common'
import { StakedUSDAFiatCollateral } from '../../../../typechain'
import {
DELAY_UNTIL_DEFAULT,
PRICE_TIMEOUT,
ORACLE_TIMEOUT,
ORACLE_ERROR,
} from '../../../../test/plugins/individual-collateral/angle/constants'

async function main() {
// ==== Read Configuration ====
const [deployer] = await hre.ethers.getSigners()

const chainId = await getChainId(hre)

console.log(`Deploying Collateral to network ${hre.network.name} (${chainId})
with burner account: ${deployer.address}`)

if (!networkConfig[chainId]) {
throw new Error(`Missing network configuration for ${hre.network.name}`)
}

// Get phase1 deployment
const phase1File = getDeploymentFilename(chainId)
if (!fileExists(phase1File)) {
throw new Error(`${phase1File} doesn't exist yet. Run phase 1`)
}
// Check previous step completed
const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId)
const assetCollDeployments = <IAssetCollDeployments>getDeploymentFile(assetCollDeploymentFilename)

const deployedCollateral: string[] = []

/******** Deploy Staked USDA (stUSD) Collateral **************************/
let collateral: StakedUSDAFiatCollateral

const StakedUSDAFiatCollateralFactory: ContractFactory = await hre.ethers.getContractFactory(
'StakedUSDAFiatCollateral'
)

collateral = <StakedUSDAFiatCollateral>await StakedUSDAFiatCollateralFactory.connect(deployer).deploy(
{
priceTimeout: PRICE_TIMEOUT.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.USDC,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USDA

oracleError: ORACLE_ERROR.toString(),
erc20: networkConfig[chainId].tokens.stUSD,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: ORACLE_TIMEOUT.toString(), // 24 hr
targetName: hre.ethers.utils.formatBytes32String('USD'),
defaultThreshold: fp('0.01').add(ORACLE_ERROR).toString(), // ~1.5%
delayUntilDefault: DELAY_UNTIL_DEFAULT.toString(), // 72h
},
fp('1e-6').toString()
)

await collateral.deployed()

console.log(
`Deployed Staked USDA (stUSD) Collateral to ${hre.network.name} (${chainId}): ${collateral.address}`
)
await (await collateral.refresh()).wait()
expect(await collateral.status()).to.equal(CollateralStatus.SOUND)

assetCollDeployments.collateral.stUSD = collateral.address
assetCollDeployments.erc20s.stUSD = networkConfig[chainId].tokens.stUSD
deployedCollateral.push(collateral.address.toString())

fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2))

console.log(`Deployed collateral to ${hre.network.name} (${chainId})
New deployments: ${deployedCollateral}
Deployment file: ${assetCollDeploymentFilename}`)
}

main().catch((error) => {
console.error(error)
process.exitCode = 1
})
59 changes: 59 additions & 0 deletions scripts/verification/collateral-plugins/verify_usda.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import hre from 'hardhat'
import { getChainId } from '../../../common/blockchain-utils'
import { developmentChains, networkConfig } from '../../../common/configuration'
import { fp } from '../../../common/numbers'
import {
getDeploymentFile,
getAssetCollDeploymentFilename,
IAssetCollDeployments,
} from '../../deployment/common'
import { verifyContract } from '../../deployment/utils'
import {
PRICE_TIMEOUT,
ORACLE_ERROR,
ORACLE_TIMEOUT,
DELAY_UNTIL_DEFAULT,
} from '../../../test/plugins/individual-collateral/angle/constants'

let deployments: IAssetCollDeployments

async function main() {
// ********** Read config **********
const chainId = await getChainId(hre)
if (!networkConfig[chainId]) {
throw new Error(`Missing network configuration for ${hre.network.name}`)
}

if (developmentChains.includes(hre.network.name)) {
throw new Error(`Cannot verify contracts for development chain ${hre.network.name}`)
}

const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId)
deployments = <IAssetCollDeployments>getDeploymentFile(assetCollDeploymentFilename)

/******** Verify stUSD COllateral **************************/
await verifyContract(
chainId,
deployments.collateral.stUSD,
[
{
priceTimeout: PRICE_TIMEOUT.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.USDC,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USDA

oracleError: ORACLE_ERROR.toString(),
erc20: networkConfig[chainId].tokens.stUSD,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: ORACLE_TIMEOUT.toString(),
targetName: hre.ethers.utils.formatBytes32String('USD'),
defaultThreshold: fp('0.01').add(ORACLE_ERROR).toString(),
delayUntilDefault: DELAY_UNTIL_DEFAULT.toString(),
},
fp('1e-6').toString(),
],
'contracts/plugins/assets/angle/StakedUSDAFiatCollateral.sol:StakedUSDAFiatCollateral'
)
}

main().catch((error) => {
console.error(error)
process.exitCode = 1
})
3 changes: 2 additions & 1 deletion scripts/verify_etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ async function main() {
'collateral-plugins/verify_re7weth.ts',
'collateral-plugins/verify_apxeth.ts',
'collateral-plugins/verify_USDe.ts',
'collateral-plugins/verify_pyusd.ts'
'collateral-plugins/verify_pyusd.ts',
'collateral-plugins/verify_usda.ts'
)
} else if (chainId == '8453' || chainId == '84531') {
// Base L2 chains
Expand Down
Loading