npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@port.finance/sundial

v0.0.27

Published

Sundial

Downloads

28

Readme

⏰ Sundial

Sundial enables fixed rate borrowing and lending on Solana.

It tokenizes a user's position on Port into two parts:

  • principal tokens (maps one-to-one to the underlying token)
  • yield tokens (variable part which depends on the yield of the underlying protocols)

At maturity 1 principal tokens allow users to exchange for 1 underlying tokens. 1 yield tokens allow users to redeem the interest earned during the loan period.

Usage

Fixed Rate Lending & Borrowing

Principal tokens can be used to implement fixed rate lending using a zero coupon bond model, since principal tokens can always be redeemed one to one to the underlying.

Users can trade principal tokens in various DEX. The seller of the principal tokens can be considered as borrower while the buyers can be considered as lender.

Due to the time value of money, 1 principal tokens should always be traded at less than 1 underlying tokens. Concretely, 1 principal USDC should be traded at less than 1 USDC.

The interest rate of lending and borrowing can be calculated as:

Interest Paid = the difference between the Principal USDC price and 1

Say 1 Principal USDC (ppUSDC) is traded at 0.95 USDC. Then the interest that the lender is going to receive or borrower is going to pay is (1 - 0.95) = 0.05 USDC. Users can then annualize it to calculate the APY.

Interest Rate Swap

Since the yield tokens always maps to the lending interest rate over a given period. The buyer of the yield tokens can be considered as giving up fixed rate in favor of floating rate. The seller of the yield tokens can be considered as giving up the floating rate in favor of the fixed rate.

User Interactions

Users can create [Profile] to deposit Port LP tokens as collateral and mint Principal Token (ppToken) directly from Sundial and sell them in market for underlying, which is equivalent to borrow at a fixed rate.

Users must repay the liquidity that corresponds to the ppToken they minted before ppToken matures, i.e. the sundial pool ends. Otherwise, users will be liquidated by others.

For depositing and repaying, there is no need to refresh anything in advance, but if you want to withdraw collateral or borrow (mint) ppToken, you need to make sure the sundial collateral you want to withdraw from and your sundial profile is refreshed.

To refresh sundial collateral, you need to refresh the corresponded reserve before. To refresh sundial profile, you need refresh all the sundial collaterals you deposit in the profile before. They will become stale after 10 slots.

Liquidation

For liquidation, you need choose a certain sundial profile that you want to liquidate, and the loan you want to repay, and the collateral you want to withdraw, and refresh all the sundial collaterals in it, then send the liquidation transaction.

The on-chain program checks if the liquidation can be performed. If so, users repay the loan and withdraw the collateral with a bonus.

The value of collateral you get will be the value of the loan you repay * (100 + liquidation penalty of that collateral).

Development

Version Requirements

  • Nodejs > v15.0
  • Anchor v0.18.0
  • Solana v1.7.8

To start a front-end test environment

npm install -g ts-node
anchor localnet

In a separate terminal run the following command to set up all the on-chain program:

anchor migrate

To run the tests locally

yarn idl:generate
yarn test:e2e

Mac users need to install GNU Sed for yarn idl:generate to work properly.

brew install gnu-sed