Nima's notes

Logo

View on GitHub nimakam/nimakam-notes

Scenarios

Transferring money (pegged currency tokens)

The money user performs one of the following actions with the pegged currency:

Whether this is transfer being called to send, or to exchange through buy or sell, all of these actions are currently being performed on the main chain using the transfer() functionality of other ERC20 tokens. No further features are needed to enable this scenario for the pegged currency on the main chain.

Question - What’s being used on layer 2 networks (like Optimism or Connext Network)?

Getting a loan

Potential loan takers own a significant amount of ETH often based on the speculation that its value will increase in the long term. However, they also want to be able to use that ETH value, in liquid form, to participate in other profitable economic transactions.

The loan taker would make an on-chain call to their corresponding loan contract on the public blockchain to:

  1. Create a new instance of the loan contract.
  2. Allocate a number of trusted price feeds with % values, for a total of 100%.
  3. Deposit and lock ETH into that loan contract instance.
  4. Issue a valid amount of pegged currency on said loan contract instance.
  5. Withdraw all or part of the issued pegged currency to use as money.

The act of taking a loan is independent of any subsequent use of the withdrawn money.

Loan creation through proxy

It is expected that most (or at least many) loans will be interacted with directly using an external account, however in some cases, where the loan is managed by another service (eg in the case of InstaDapp proxy wallet), the loan can also be created and controlled by a proxy contract. In such a case the controller contract is considered as the owner of that loan and all calls come through the controller contract.

See Contract controller section for more information.

Closing a loan

The loan taker would make an on-chain call to their corresponding loan contract on the public blockchain to:

  1. Acquire pegged currency money from the market.
  2. Depositing the outstanding amount of pegged currency to cover what has been issued as well as any fees.
  3. Close the loan, which reverses the issuance of pegged currency as well as pays off any remaining fees.
  4. Withdraw the remaining ETH balance from the contract.

Lifetime changes to a loan

Loan takers can change the following aspects of a loan at a date after creation, by making an on-chain call to their corresponding loan contract on the public blockchain:

Creating a price feed

As a business, the price feed provider is responsible for providing accurate pricing information, while promoting and maintaining the loan takers’ (and to a lesser extent money users’) trust in consistency and integrity of their business. Price feed providers rely on loan takers to be allocated a portion of currency issuance, which in turn increases their trust ranking in the system. Price feed providers take the following steps:

Feed reporting delayed prices

The price feed providers are responsible for reporting the designated median prices (by volume) daily, and have until the end of the next day to report. Every day, after gathering data and confirming the market activities of the previous day, and reporting the median prices for the following:

  1. Daily median by volume rate of ETH in reference currency
  2. Daily median by volume rate of pegged currency
  3. Any time during the day of price
  4. Any time during the day of reporting

The steps for reporting delayed prices are as follows:

Feed reporting instant prices

The price feed providers, that are in the trusted category, are responsible for reporting significant changes to the price of native currency in reference currency, within a minute of occurring. The following should be reported

  1. Up to the minute native currency price
  2. Price time

The steps for reporting instant prices are as follows:

Creating a savings account

Accumulating interest on savings account

Closing a savings account

Liquidation request

Liquidation finalization

Price feed trust transitions

Price feed collecting revenue payments

Monetary system scenarios

system raises rates

This type of adjustment is performed after a sustained period of oversupply.

Upon finalization of the day’s reported prices:

System lowers rates

This type of adjustment is performed after a sustained period of overdemand.

Upon finalization of the day’s reported prices:

System adjusts savings rate

The adjustment is made based on sizes of savings pool and registered savings

Upon finalization of the day’s reported prices:

### System adjusts the collateral ratio

this adjustment is made based on a measure of prolonged stability in the system.

System adjusts price feed fee rate

This adjustment is made based on total issuance on a logarithmic curve.

System variable scenarios

System records rates

Upon finalization of the day’s reported prices:

Calculate savings rate on request

At any time and given any start day and end day any caller can query for the savings rate:

Calculate loan fee on request

At any time and given any start day and end day any caller can query for the loan fee rate:

Penalty scenarios

The system enforces penalties on deviations from stable operations, ones designed to incentivize the ecosystem participants to behave constructively. The most important of these ecosystem participants is the price feed providers, who are trusted with the most important part of maintaining the system’s health and integrity.

Price feed instability penalty

Price feed dispute penalty

Price feed banning

Price feeds that fail to report delayed prices for more than a week are banned from the medium trust list, and the entirety of their revenue pool is transferred to the savings pool.

### Price feed down-voting penalty

Negative scenarios

In software engineering and testing we have the “happy path” which represents the system functioning in the most productive state, and then we have “un-happy path” or negative scenarios which represents the scenarios where something goes wrong and the system must handle them.

Loan negative scenarios

Price feed negative scenarios

Savings account negative scenarios

Edge case scenarios

System lifetime management

Controller accounts

When creating an on-chain price feed contract, the price feed providers are expected to provide a very high level of security in controlling the contract’s activities. This would also be true for particularly high value loan and savings account contracts. Although the instances of price feed, loan and savings account have to be created by the system itself, the controller of those contract instances can be a multi-security-level contract. This proxy contract could be controlled in turn by other relatively less secure external accounts.

External account controller

For example in the case of price feeds, a feed provider can choose to alternatively use an external account to create and control the price feed. With this option, security of the private key representing that account becomes equivalent to the security of private key itself, and is therefore of paramount importance for the provider.

Contract controller

The controller contracts would create the price feed, loan or savings account contract instance programmatically, by calling into the main system contract, and proxy all subsequent calls securely to the contract instances throughout their lifetime.

Down-voting price feeds from savings accounts

Appendix

Personas

Money user and holder

Knowledge: Superficial understanding of the internet, public blockchain and digital finance. Experience: None assumed. Needs: Use a dependable form of money for everyday economic transactions. Have that money be accepted in as many contexts as possible. Wants: Get interest on that money when not used.

Loan taker

Knowledge: Basic to intermediate understanding of public blockchain, smart contracts and decentralized finance Experience: Use of centralized exchanges, public blockchain and smart contracts to buy, exchange, and use decentralized finance. Needs: Keep custody of owned ETH, while also freely using its value to perform profitable economic transactions. Basic understanding of how their loan works in common conditions. Peace of mind that long term risks are minimal Want: Peace of mind that they will be notified when action is needed, to protect their investment.

Price feed provider

Knowledge: Advanced understanding of public blockchain, smart contracts, cryptoeconomics, business, marketing, traditional and decentralized finance Experience: Building a finance business and marketing. Development and deployment of blockchain-based systems using smart contracts and integration systems. Designing, building and operating secure digital systems. Needs: Be able to run a profitable business sustainably. Be able to trust in the system’s correct operation. Wants: Reach a level of scale that results in high margins and thus a higher return on investment.

Loan liquidator

Knowledge: Advanced understanding of public blockchain, smart contracts, cryptoeconomics, decentralized finance. Experience: Automated interaction with blockchain-based systems using smart contracts and integration systems. Managing security of digital programs. Needs: Not lose money on any subjectively valid liquidation requests. Wants: More returns on investment.