bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 15쪽 중 10쪽
r uses
join
to add collateral to the
urn
immediately after the transaction is mined, there is a chance that a reorganization of the chain occurs. This would result in the user losing the ownership of that
cdpId
/
urn
pair, therefore losing their collateral. However, this issue can only arise when avoiding the use of the
proxy functions
via a
profile proxy
as the user will
open
the
cdp
and
join
collateral in the same transaction.
Released into the public domain (CC0 1.0 Universal)
– trademarks remain with their owners; no warranty. See
full license
.
## /protocol/liquidity/skylink
SkyLink
Please refer to the following user guides:
SkyLink Guide- Base ETH Native Bridge
Released into the public domain (CC0 1.0 Universal)
– trademarks remain with their owners; no warranty. See
full license
.
## /protocol/liquidity/litepsm
LitePSM
LitePSM is a gas-efficient implementation of the Peg Stability Module (PSM), designed to facilitate seamless swaps between DAI, USDS, and external stablecoins such as USDC, with no slippage. Unlike the original PSM, which was gas-intensive due to direct interactions with the Sky Protocol Vat, LitePSM enables swaps using a pool of pre-minted DAI or USDS, reducing each transaction to two simple ERC-20 token transfers.
Key features of LitePSM include permissionless functions to maintain pool stability, the ability for authorized parties to execute no-fee swaps, and the option to segregate gem balances for yield generation. This version is backward compatible and designed to optimize gas costs while supporting the security and operational requirements of the Sky ecosystem.
Please refer to the
LitePSM User Guide
for additional details about the module.
Deployments
Section titled “Deployments”
LitePSM-DAI-USDC @ Ethereum
Section titled “LitePSM-DAI-USDC @ Ethereum”
Codebase
Deployment Addresses
Details
Fees have not been activated for DAI → USDC and USDC → DAI.
Fees could change in the future.
LitePSMWrapper-USDS-USDC @ Ethereum
Section titled “LitePSMWrapper-USDS-USDC @ Ethereum”
Codebase
Deployment Addresses
Details
Fees have not been activated for USDS → USDC and USDC → USDS.
Fees could change in the future.
Released into the public domain (CC0 1.0 Universal)
– trademarks remain with their owners; no warranty. See
full license
.
## /protocol/liquidity/dai-flash-mint
Dai Flash Mint
The
Flash
module allows anyone to mint Dai up to a limit set by Sky Governance with the one condition that they pay it all back in the same transaction with a fee. This allows anyone to exploit arbitrage opportunities in the DeFi space without having to commit upfront capital.
Flash
provides many benefits to the Dai ecosystem including, but not limited to:
Improved market efficiencies for Dai.
Democratization of arbitrage - anyone can participate.
Exploits requiring a large amount of capital will be found quicker which makes the DeFi space safer overall.
Fees provide an income source for the protocol.
Contract Details
Section titled “Contract Details”
Glossary (Flash)
Section titled “Glossary (Flash)”
Debt Ceiling
: The maximum amount of Dai any single transaction can borrow. Encoded as
line
in
rad
units.
Minting Fees
: How much additional Dai must be returned to the
Flash
module at the end of the transaction. This fee is transferred into the
vow
at the end of a successful
mint
. Encoded as
toll
in
wad
units.
Key Mechanisms & Concepts
Section titled “Key Mechanisms & Concepts”
Usage
Section titled “Usage”
Since the Flash module conforms to the ERC3156 spec, you can just use the reference borrower implementation from the spec:
pragma solidity ^0.8.0;
import "./interfaces/IERC20.sol";
import "./interfaces/IERC3156FlashBorrower.sol";
import "./interfaces/IERC3156FlashLender.sol";
contract FlashBorrower is IERC3156FlashBorrower {
enum Action {NORMAL, OTHER}
IERC3156FlashLender lender;
constructor (
IERC3156FlashLender lender_
) public {
lender = lender_;
}
/// @dev ERC-3156 Flash loan callback
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external override returns (bytes32) {
require(
msg.sender == address(lender),
"FlashBorrower: Untrusted lender"
);
require(
initiator == address(this),
"FlashBorrower: Untrusted loan initiator"
);
(Action action) = abi.decode(data, (Action));
if (action == Action.NORMAL) {
require(IERC20(token).balanceOf(address(this)) >= amount);
// make a profitable trade here
IERC20(token).transfer(initiator, amount + fee);
} else if (action == Action.OTHER) {
// do another
}
return keccak256("ERC3156FlashBorrower.onFlashLoan");
}
/// @dev Initiate a flash loan
function flashBorrow(
address token,
uint256 amount
) public {
bytes memory data = abi.encode(Action.NORMAL);
uint256 _allowance = IERC20(token).allowance(address(this), address(lender));
uint256 _fee = lender.flashFee(token, amount);
uint256 _repayment = amount + _fee;
IERC20(token).approve(address(lender), _allowance + _repayment);
lender.flashLoan(this, token, amount, data);
}
}
Vat Dai
Section titled “Vat Dai”
It may be that users are interested in moving dai around in the internal vat balances. Instead of wasting gas by minting/burning ERC20 dai you can instead use the vat dai flash mint function to short cut this.
The vat dai version of flash mint is roughly the same as the ERC20 dai version with a few caveats:
Function Signature
vatDaiFlashLoan(IVatDaiFlashBorrower receiver, uint256 amount, bytes calldata data)
vs
flashLoan(IERC3156FlashBorrower receiver, address token, uint256 amount, bytes calldata data)
Notice that no token is required because it is assumed to be vat dai. Also, the
amount
is in
rad
and not in
wad
.
Approval Mechanism
ERC3156 specifies using a token approval to approve the amount to repay to the lender. Unfortunately vat dai does not have a way to specify delegation amounts, so instead of giving the flash mint module full rights to withdraw any amount of vat dai we have instead opted to have the receiver push the balance owed at the end of the transaction.
Example
Here is an example similar to the one above to showcase the differences:
pragma solidity ^0.6.12;
import "dss-interfaces/dss/VatAbstract.sol";
import "./interfaces/IERC3156FlashLender.sol";
import "./interfaces/IVatDaiFlashBorrower.sol";
contract FlashBorrower is IVatDaiFlashBorrower {
enum Action {NORMAL, OTHER}
VatAbstract vat;
IVatDaiFlashLender lender;
constructor (
VatAbstract vat_,
IVatDaiFlashLender lender_
) public {
vat = vat_;
lender = lender_;
}
/// @dev Vat Dai Flash loan callback
function onVatDaiFlashLoan(
address initiator,
uint256 amount,
uint256 fee,
bytes calldata data
) external override returns (bytes32) {
require(
msg.sender == address(lender),
"FlashBorrower: Untrusted lender"
);
require(
initiator == address(this),
"FlashBorrower: Untrusted loan initiator"
);
(Action action) = abi.decode(data, (Action));
if (action == Action.NORMAL) {
// do one thing
} else if (action == Action.OTHER) {
// do another
}
// Repay the loan amount + fee
// Be sure not to overpay as there are no safety guards for this
vat.move(address(this), lender, amount + fee);
return keccak256("VatDaiFlashBorrower.onVatDaiFlashLoan");
}
/// @dev Initiate a flash loan
function vatDaiFlashBorrow(
uint256 amount
) public {
bytes memory data = abi.encode(Action.NORMAL);
lender.vatDaiFlashLoan(this, amount, data);
}
}
Released into the public domain (CC0 1.0 Universal)
– trademarks remain with their owners; no warranty. See
full license
.
## /protocol/governance/ovreview
Overview
The Governance Module contains the contracts that facilitate SKY voting, proposal execution, and voting security of the Sky Protocol.
Governance Components
Section titled “Governance Components”
The Governance Module has 3 core components consisting of the
Chief
,
Pause
and
Spell
contracts.
Chief
Pause
Spell
Key Mechanism and Concepts
Section titled “Key Mechanism and Concepts”
Summary of the Governance
Module Components
Section titled “Summary of the Governance Module Components”
Chief
- The Ds-Chief smart contract provides a method to elect a
“chief”
contract via an approval voting system. This may be combined with another contract, such as
DSAuthority
, to elect a ruleset for a smart contract system.
Pause
- The
ds-pause
is a
delegatecall
based proxy with an enforced delay. This allows authorized users to schedule function calls that can only be executed once a predetermined waiting period has elapsed. The configurable delay attribute sets the minimum wait time that will be used during the governance of the system.
Spell
- A
DS-Spell
is an un-owned object that performs one action or series of atomic actions (multiple transactions) one time only. This can be thought of as a one-off DSProxy with no owner (no DSAuth mixing, it is not a DSThing).
Gotchas (Potential sources of user error)
Section titled “Gotchas (Potential sources of user error)”
Chief
In general, when we refer to the
“chief”
, it can be both addresses or people that represent contracts. Thus, ds-chief can work well as a method for selecting code for execution just as well as it can for realizing political processes.
IOU Token:
The purpose of the IOU token is to allow for the chaining of governance contracts. In other words, this allows you to have a number of
DSChief
,
DSPrism
, or other similar contracts use the same governance token by means of accepting the IOU token of the
DSChief
contract before it is a governance token.
Approval Voting:
This type of voting is when each voter selects which candidates they approve of, with the top n “most approved” candidates being then elected. Each voter can cast up to n + k votes, where k equals some non-zero positive integer.
Implementations:
If you are writing a front-end UI for this smart contract, please note that the address[] parameters that are passed to the
etch
and
vote
functions must be byte-ordered sets.
Pause
Identity & Trust:
In order to protect the internal storage of the pause from malicious writes during plan execution, a
delegatecall
operation is performed in a separate contract with an isolated storage context (DSPauseProxy), where each pause has its own individual proxy. This means that plans are executed with the identity of the
proxy
. Thus when integrating the pause into some auth scheme, you will want to trust the pause’s proxy and not the pause itself.
Spell
The spell is only marked as “done” if the CALL it makes succeeds, meaning it did not end in an exceptional condition and it did not revert. Conversely, contracts that use return values instead of exceptions to signal errors could be successfully called without having the effect you might desire. “Approving” spells to take action on a system after the spell is deployed generally requires the system to use exception-based error handling to avoid griefing.
Failure Modes (Bounds on Operating Conditions & External Risk Factors)
Section titled “Failure Modes (Bounds on Operating Conditions & External Risk Factors)”
Chief
SKY users moving their votes from one spell to another:
One of the biggest potential failure modes occurs when people are moving their votes from one spell to another. This opens up a gap/period of time when only a small amount of SKY is needed to lift a random hat.
Pause
There is no way to bypass the delay.
The code executed by the
delegatecall
cannot directly modify storage on the pause.
The pause will always retain ownership of it’s proxy.
Spell
The main failure mode of the
spell
arises when there is an instance of the spell remaining uncast when it has an amount of SKY voting for it that later becomes a target.
Released into the public domain (CC0 1.0 Universal)
– trademarks remain with their owners; no warranty. See
full license
.
## /protocol/governance/chief
Chief
The
Chief
smart contract provides a method to elect a “chief” contract via an approval voting system. This may be combined with another contract, such as
DSAuthority
, to elect a ruleset for a smart contract system.
In short, voters will lock up their voting tokens in order to give their votes some weight in the system. The voting is then done by continuous
approval voting
, where users receive IOU tokens when they lock their voting tokens up, which is useful for secondary governance mechanisms. The IOU tokens may not be exchanged for the locked tokens except by individuals who have actually locked funds in the contract itself, and only up to the amount they have locked.
Key Mechanisms & Concepts
Section titled “Key Mechanisms & Concepts”
There are two contracts in ds-chief:
DSChiefApprovals
DSChief, which inherits from DSChiefApprovals.
Key Functionalities (as defined in the smart contract)
Section titled “Key Functionalities (as defined in the smart contract)”
DSChiefApprovals
Section titled “DSChiefApprovals”
DSChiefApprovals(DSToken GOV_, DSToken IOU_, uint MAX_YAYS_)
Section titled “DSChiefApprovals(DSToken GOV_, DSToken IOU_, uint MAX_YAYS_)”
The constructor. Sets
GOV
,
IOU
, and
MAX_YAYS
.
lock(uint wad)
Section titled “lock(uint wad)”
Charges the user
wad
GOV
tokens, issues an equal amount of
IOU
tokens to the user, and adds
wad
weight to the candidates on the user’s selected slate. Fires a
LogLock
event.
free(uint wad)
Section titled “free(uint wad)”
Charges the user
wad
IOU
tokens, issues an equal amount of
GOV
tokens to the user, and subtracts
wad
weight from the candidates on the user’s selected slate. Fires a
LogFree
event.
etch(address[] yays) returns (bytes32 slate)
Section titled “etch(address[] yays) returns (bytes32 slate)”
Save a set of ordered addresses as a
slate
and return a unique identifier for it.
vote(address[] yays) returns (bytes32 slate)
Section titled “vote(address[] yays) returns (bytes32 slate)”
Save a set of ordered addresses as a
slate
, moves the voter’s weight from their current slate to the new slate, and returns the slate’s identifier.
vote(bytes32 slate)
Section titled “vote(bytes32 slate)”
Removes voter’s weight from their current slate and adds it to the specified slate.
lift(address whom)
Section titled “lift(address whom)”
Checks the given address and promotes it to
s/chief/hat
if it has more weight than the current
s/chief/hat
.
DSChief
Section titled “DSChief”
DSChief
is a combination of
DSRoles
from the
ds-roles
package and
DSChiefApprovals
. It can be used in conjunction with
ds-auth
(as an authority object) to govern smart contract systems.
Public Functions
Section titled “Public Functions”
DSChief(DSToken GOV_, DSToken IOU_, uint MAX_YAYS_)
Section titled “DSChief(DSToken GOV_, DSToken IOU_, uint MAX_YAYS_)”
The constructor. Sets
GOV
,
IOU
, and
MAX_YAYS
.
setOwner(address owner_)
Section titled “setOwner(address owner_)”
Reverts the transaction. Overridden from
DSAuth
.
setAuthority(DSAuthority authority_)
Section titled “setAuthority(DSAuthority authority_)”
Reverts the transaction. Overridden from
DSAuth
.
isUserRoot(address who) constant returns (bool)
Section titled “isUserRoot(address who) constant returns (bool)”
Returns
true
if the given address is the chief.
setRootUser(address who, bool enabled)
Section titled “setRootUser(address who, bool enabled)”
Reverts the transaction. Overridden from
DSRoles
.
DSRoles
Section titled “DSRoles”
See
ds-roles
for inherited features.
Gotchas (Potential source of user error)
Section titled “Gotchas (Potential source of user error)”
In general, when we refer to the
“hat”
, it can be any address — be it a single-use contract like ds-spell, a multi-use contract or an individual’s wallet. Thus, ds-chief can work well as a method for selecting code for execution just as well as it can for realizing political processes.
Example:
The
ds-chief
could be used as a token-weighted voting system governing another set of smart contracts that uses the
ds-auth
with
ds-roles
. In a scenario such as this, “candidates” would consist of contracts changing the state of the smart contract set under governance. Such a contract being elected as ”hat“ would be granted all of the permissions to execute whatever changes are necessary. The
ds-chief
could also be used within such a contract set in conjunction with a proxy contract, such as
ds-proxy
or a name resolution system like ENS for the purpose of voting in new versions of contracts.
Understanding the IOU Token
Section titled “Understanding the IOU Token”
The purpose of the IOU token is to allow for the chaining of governance contracts. In other words, this allows you to have a number of
DSChief
or other similar contracts use the same governance token by means of accepting the IOU token of the
DSChief
contract before it is a governance token.
Example:
Let’s say there are three
DSChief
contracts (chiefA, chiefB, and chiefC) and a
chiefA.GOV
that is the SKY token. If we set
chiefB.GOV
to
chiefA.IOU
and
chiefC.GOV
to
chiefB.IOU
, this allows all three contracts to run using a common group of SKY.
Approval Voting
Section titled “Approval Voting”
This type of voting is when each voter selects which candidates they approve of, with the top n “most approved” candidates being then elected. Each voter can cast up to n + k votes, where k equals some non-zero positive integer. This way voters to move their approval from one candidate to another without needing to first withdraw support from the candidate being replaced. Without this in place, moving approval to a new candidate could result in a less-approved candidate moving momentarily into the set of the elected candidates.
Note:
In the case of
ds-chief
, n is equal to 1.
In addition, the
ds-chief
weighs votes according to the quantity of a voting token that has been chosen to lock up in the
DSChief
or the
DSChiefApprovals
contract. It’s important to note that the voting token used in a
ds-chief
deployment must be specified at the time of deployment and cannot be changed afterward.
Implementations
Section titled “Implementations”
If you are writing a front-end UI for this smart contract, please note that the address[] parameters that are passed to the
etch
and
vote
functions must be byte-ordered sets.
Example:
Using
[0x0, 0x1, 0x2, ...]
is valid but using
[0x1, 0x0, ...]
and
[0x0, 0x0, 0x1, ...]
is not. This ordering constraint allows the contract to cheaply ensure voters cannot multiply their weights by listing the same candidate on their slate multiple times.
Failure Modes (Bounds on Operating Conditions & External Risk Factors)
Section titled “Failure Modes (Bounds on Operating Conditions & External Risk Factors)”
SKY users moving their votes from one spell to another
One of the biggest potential failure modes occurs when people are moving their votes from one spell to another. This opens up a gap/period of time when only a small amount of SKY is needed to lift a random hat.
Lift is not called on spells that have more SKY than the current hat
The only way a spell can get the hat is if
lift
is called on it. So, even if a spell gains much more SKY on it than the hat, if
lift
is never called on it, the hat will remain on a spell that no longer has the most SKY. This could lower the bar for the amount of SKY needed to pass something, potentially making the system less safe.
Stray spells without expiration
Due to the continuous nature of voting, a spell will remain live in the system even if it was not approved to be the governing proposal. This means that SKY holders can continue to vote on the candidate and in times of lower voter participation there is potential for them to introduce a failure mode by voting for an unexpected and/or older candidate. This illustrates why increased voter participation is impo프로젝트로 돌아가기