-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16514f1
commit 2b9328b
Showing
51 changed files
with
4,981 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Solidity API | ||
|
||
## AbstractSwapper | ||
|
||
_base class for swappers, makes common checks | ||
internal _swapUsdpToAsset and _swapAssetToUsdp must be overridden instead of external swapUsdpToAsset and swapAssetToUsdp_ | ||
|
||
### USDP | ||
|
||
```solidity | ||
contract IERC20 USDP | ||
``` | ||
|
||
### constructor | ||
|
||
```solidity | ||
constructor(address _vaultParameters, address _usdp) internal | ||
``` | ||
|
||
### _swapUsdpToAsset | ||
|
||
```solidity | ||
function _swapUsdpToAsset(address _user, address _asset, uint256 _usdpAmount, uint256 _minAssetAmount) internal virtual returns (uint256 swappedAssetAmount) | ||
``` | ||
|
||
_usdp already transferred to swapper_ | ||
|
||
### _swapAssetToUsdp | ||
|
||
```solidity | ||
function _swapAssetToUsdp(address _user, address _asset, uint256 _assetAmount, uint256 _minUsdpAmount) internal virtual returns (uint256 swappedUsdpAmount) | ||
``` | ||
|
||
_asset already transferred to swapper_ | ||
|
||
### swapUsdpToAsset | ||
|
||
```solidity | ||
function swapUsdpToAsset(address _user, address _asset, uint256 _usdpAmount, uint256 _minAssetAmount) external returns (uint256 swappedAssetAmount) | ||
``` | ||
|
||
usdp must be approved to swapper | ||
|
||
_asset must be sent to user after swap_ | ||
|
||
### swapAssetToUsdp | ||
|
||
```solidity | ||
function swapAssetToUsdp(address _user, address _asset, uint256 _assetAmount, uint256 _minUsdpAmount) external returns (uint256 swappedUsdpAmount) | ||
``` | ||
|
||
asset must be approved to swapper | ||
|
||
_usdp must be sent to user after swap_ | ||
|
||
### swapUsdpToAssetWithDirectSending | ||
|
||
```solidity | ||
function swapUsdpToAssetWithDirectSending(address _user, address _asset, uint256 _usdpAmount, uint256 _minAssetAmount) public returns (uint256 swappedAssetAmount) | ||
``` | ||
|
||
DO NOT SEND tokens to contract manually. For usage in contracts only. | ||
|
||
_for gas saving with usage in contracts tokens must be send directly to contract instead | ||
asset must be sent to user after swap_ | ||
|
||
### swapAssetToUsdpWithDirectSending | ||
|
||
```solidity | ||
function swapAssetToUsdpWithDirectSending(address _user, address _asset, uint256 _assetAmount, uint256 _minUsdpAmount) public returns (uint256 swappedUsdpAmount) | ||
``` | ||
|
||
DO NOT SEND tokens to contract manually. For usage in contracts only. | ||
|
||
_for gas saving with usage in contracts tokens must be send directly to contract instead | ||
usdp must be sent to user after swap_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Solidity API | ||
|
||
## AssetParameters | ||
|
||
### PARAM_FORCE_TRANSFER_ASSET_TO_OWNER_ON_LIQUIDATION | ||
|
||
```solidity | ||
uint8 PARAM_FORCE_TRANSFER_ASSET_TO_OWNER_ON_LIQUIDATION | ||
``` | ||
|
||
Some assets require a transfer of at least 1 unit of token | ||
to update internal logic related to staking rewards in case of full liquidation | ||
|
||
### PARAM_FORCE_MOVE_WRAPPED_ASSET_POSITION_ON_LIQUIDATION | ||
|
||
```solidity | ||
uint8 PARAM_FORCE_MOVE_WRAPPED_ASSET_POSITION_ON_LIQUIDATION | ||
``` | ||
|
||
Some wrapped assets that require a manual position transfer between users | ||
since `transfer` doesn't do this | ||
|
||
### needForceTransferAssetToOwnerOnLiquidation | ||
|
||
```solidity | ||
function needForceTransferAssetToOwnerOnLiquidation(uint256 assetBoolParams) internal pure returns (bool) | ||
``` | ||
|
||
### needForceMoveWrappedAssetPositionOnLiquidation | ||
|
||
```solidity | ||
function needForceMoveWrappedAssetPositionOnLiquidation(uint256 assetBoolParams) internal pure returns (bool) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Solidity API | ||
|
||
## AssetParametersViewer | ||
|
||
Views collaterals in one request to save node requests and speed up dapps. | ||
|
||
_It makes no sense to clog a node with hundreds of RPC requests and slow a client app/dapp. Since usually | ||
a huge amount of gas is available to node static calls, we can aggregate asset data in a huge batch on the | ||
node's side and pull it to the client._ | ||
|
||
### vaultParameters | ||
|
||
```solidity | ||
contract IVaultParameters vaultParameters | ||
``` | ||
|
||
### vaultManagerParameters | ||
|
||
```solidity | ||
contract IVaultManagerParameters vaultManagerParameters | ||
``` | ||
|
||
### vaultManagerBorrowFeeParameters | ||
|
||
```solidity | ||
contract IVaultManagerBorrowFeeParameters vaultManagerBorrowFeeParameters | ||
``` | ||
|
||
### assetsBooleanParameters | ||
|
||
```solidity | ||
contract IAssetsBooleanParameters assetsBooleanParameters | ||
``` | ||
|
||
### AssetParametersStruct | ||
|
||
```solidity | ||
struct AssetParametersStruct { | ||
address asset; | ||
uint256 stabilityFee; | ||
uint256 liquidationFee; | ||
uint256 initialCollateralRatio; | ||
uint256 liquidationRatio; | ||
uint256 liquidationDiscount; | ||
uint256 devaluationPeriod; | ||
uint256 tokenDebtLimit; | ||
uint256[] oracles; | ||
uint256 minColPercent; | ||
uint256 maxColPercent; | ||
uint256 borrowFee; | ||
bool forceTransferAssetToOwnerOnLiquidation; | ||
bool forceMoveWrappedAssetPositionOnLiquidation; | ||
} | ||
``` | ||
|
||
### constructor | ||
|
||
```solidity | ||
constructor(address _vaultManagerParameters, address _vaultManagerBorrowFeeParameters, address _assetsBooleanParameters) public | ||
``` | ||
|
||
### getAssetParameters | ||
|
||
```solidity | ||
function getAssetParameters(address asset, uint256 maxOracleTypesToSearch) public view returns (struct AssetParametersViewer.AssetParametersStruct r) | ||
``` | ||
|
||
Get parameters of one asset | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| ---- | ---- | ----------- | | ||
| asset | address | asset address | | ||
| maxOracleTypesToSearch | uint256 | since complete list of oracle types is unknown, we'll check types up to this number | | ||
|
||
### getMultiAssetParameters | ||
|
||
```solidity | ||
function getMultiAssetParameters(address[] assets, uint256 maxOracleTypesToSearch) external view returns (struct AssetParametersViewer.AssetParametersStruct[] r) | ||
``` | ||
|
||
Get parameters of many assets | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| ---- | ---- | ----------- | | ||
| assets | address[] | asset addresses | | ||
| maxOracleTypesToSearch | uint256 | since complete list of oracle types is unknown, we'll check types up to this number | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Solidity API | ||
|
||
## AssetsBooleanParameters | ||
|
||
### values | ||
|
||
```solidity | ||
mapping(address => uint256) values | ||
``` | ||
|
||
### constructor | ||
|
||
```solidity | ||
constructor(address _vaultParameters, address[] _initialAssets, uint8[] _initialParams) public | ||
``` | ||
|
||
### get | ||
|
||
```solidity | ||
function get(address _asset, uint8 _param) external view returns (bool) | ||
``` | ||
|
||
Get value of _param for _asset | ||
|
||
_see ParametersConstants_ | ||
|
||
### getAll | ||
|
||
```solidity | ||
function getAll(address _asset) external view returns (uint256) | ||
``` | ||
|
||
Get values of all params for _asset. The 0th bit of returned uint id the value of param=0, etc | ||
|
||
### set | ||
|
||
```solidity | ||
function set(address _asset, uint8 _param, bool _value) public | ||
``` | ||
|
||
Set value of _param for _asset | ||
|
||
_see ParametersConstants_ | ||
|
||
### _set | ||
|
||
```solidity | ||
function _set(address _asset, uint8 _param, bool _value) internal | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Solidity API | ||
|
||
## Auth2 | ||
|
||
_Manages USDP's system access | ||
copy of Auth from VaultParameters.sol but with immutable vaultParameters for saving gas_ | ||
|
||
### vaultParameters | ||
|
||
```solidity | ||
contract VaultParameters vaultParameters | ||
``` | ||
|
||
### constructor | ||
|
||
```solidity | ||
constructor(address _parameters) public | ||
``` | ||
|
||
### onlyManager | ||
|
||
```solidity | ||
modifier onlyManager() | ||
``` | ||
|
||
### hasVaultAccess | ||
|
||
```solidity | ||
modifier hasVaultAccess() | ||
``` | ||
|
||
### onlyVault | ||
|
||
```solidity | ||
modifier onlyVault() | ||
``` | ||
|
Oops, something went wrong.