Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

feat: add tempus finance #597

Merged
merged 7 commits into from Jun 8, 2022
Merged

feat: add tempus finance #597

merged 7 commits into from Jun 8, 2022

Conversation

tonzgao
Copy link
Contributor

@tonzgao tonzgao commented Jun 8, 2022

Description

add tempus finance. see https://discord.com/channels/647279669388771329/964569348243075082/983794842830250065

not affiliated with project, but they are giving me a grant for this.

discussions below:

RTP() — Today at 1:38 PM
Hey - Just adding Yuval from the backend team here so we can answer any Qs
@Yuval | Tempus just pasting what Tonz asked previously
firstly, im looking at the ui and it seems like the steth-eth price is pegged in the lido pool?
secondly, the rif says that there should be a token and contract position, but afaics there are only tokens: the p token, y token, and the amm token?
tonz — Today at 1:38 PM
cool, another question is regarding the amm fee. i see here it is https://etherscan.io//address/0x200e41BE620928351F98Da8031BAEB7BD401a129#readContract 10000000000000000, what is that actually in percent terms? I assume 1e-18 -> 0.01%? 
Ethereum (ETH) Blockchain Explorer
[TempusAMM | Address 0x200e41BE620928351F98Da8031BAEB7BD401a129 | Et...](https://etherscan.io//address/0x200e41BE620928351F98Da8031BAEB7BD401a129)
The Contract Address 0x200e41BE620928351F98Da8031BAEB7BD401a129 page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on Etherscan.
Image
Yuval | Tempus — Today at 1:41 PM
gm @tonz
Yuval | Tempus — Today at 1:43 PM
this number is indeed denominated in 1e18 base, but that means that 10000000000000000/1e18 = 0.01 = 1%
so the fee here is 1%
does that make sense?
tonz — Today at 1:44 PM
yep
RTP() — Today at 1:44 PM
And the steth-eth rice is pegged and pulled from the Lido pool right @Yuval | Tempus ?
RTP() — Today at 1:46 PM
I think you're right, there are only tokens so that should suffice

Checklist

How to test?

http://localhost:5001/apps/tempus/tokens?network=ethereum&groupIds%5B%5D=pool
http://localhost:5001/apps/tempus/tokens?network=ethereum&groupIds%5B%5D=amm
http://localhost:5001/apps/tempus/balances?network=ethereum&addresses%5B%5D=0xab40a7e3cef4afb323ce23b6565012ac7c76bfef

tempus team, please confirm the below looks correct:

{
  "0xab40a7e3cef4afb323ce23b6565012ac7c76bfef": {
    "products": [
      {
        "label": "Pools",
        "assets": [
          {
            "type": "app-token",
            "address": "0x5a5cba78ae5ebd7142d0b8c796565388ba4b5732",
            "network": "ethereum",
            "appId": "tempus",
            "groupId": "pool",
            "symbol": "TPS-stETH-31-2-2022",
            "decimals": 18,
            "supply": 310.16369843451486,
            "price": 1799.68,
            "pricePerShare": 1,
            "tokens": [
              {
                "id": "1496",
                "networkId": 1,
                "address": "0x0000000000000000000000000000000000000000",
                "name": "Ether",
                "symbol": "ETH",
                "decimals": 18,
                "coingeckoId": "ethereum",
                "status": "pending",
                "hide": false,
                "canExchange": true,
                "updatedAt": "2022-06-08T12:41:24.406Z",
                "createdAt": "2022-05-18T12:54:47.695Z",
                "price": 1799.68,
                "networkEnumValue": "ethereum",
                "type": "base-token",
                "network": "ethereum",
                "balance": 4.017774815278494,
                "balanceRaw": "4017774815278493679",
                "balanceUSD": 7230.7089795604
              }
            ],
            "dataProps": {
              "liquidity": 558195.4047986277,
              "reserve": 0
            },
            "displayProps": {
              "label": "TPS-stETH-31-2-2022",
              "secondaryLabel": {
                "type": "dollar",
                "value": 1799.68
              },
              "tertiaryLabel": "",
              "images": [
                "https://storage.googleapis.com/zapper-fi-assets/tokens/ethereum/0x0000000000000000000000000000000000000000.png"
              ],
              "statsItems": [
                {
                  "label": "Liquidity",
                  "value": {
                    "type": "dollar",
                    "value": 558195.4047986277
                  }
                },
                {
                  "label": "Share",
                  "value": {
                    "type": "pct",
                    "value": 1.2953723583892491
                  }
                }
              ]
            },
            "balance": 4.017774815278494,
            "balanceRaw": "4017774815278493679",
            "balanceUSD": 7230.7089795604
          },
          {
            "type": "app-token",
            "address": "0x2c4ac125044e853f0f6d66b95365cbba204ffcfd",
            "network": "ethereum",
            "appId": "tempus",
            "groupId": "pool",
            "symbol": "TPS-stETH-30-7-2022",
            "decimals": 18,
            "supply": 570.4555511983942,
            "price": 1781.201682494716,
            "pricePerShare": 0.9897324427091015,
            "tokens": [
              {
                "id": "1496",
                "networkId": 1,
                "address": "0x0000000000000000000000000000000000000000",
                "name": "Ether",
                "symbol": "ETH",
                "decimals": 18,
                "coingeckoId": "ethereum",
                "status": "pending",
                "hide": false,
                "canExchange": true,
                "updatedAt": "2022-06-08T12:41:24.406Z",
                "createdAt": "2022-05-18T12:54:47.695Z",
                "price": 1799.68,
                "networkEnumValue": "ethereum",
                "type": "base-token",
                "network": "ethereum",
                "balance": 192.19433297912784,
                "balanceRaw": "192194332979127841006",
                "balanceUSD": 345888.2971758768
              }
            ],
            "dataProps": {
              "liquidity": 1016096.3875830304,
              "reserve": 0
            },
            "displayProps": {
              "label": "TPS-stETH-30-7-2022",
              "secondaryLabel": {
                "type": "dollar",
                "value": 1781.201682494716
              },
              "tertiaryLabel": "",
              "images": [
                "https://storage.googleapis.com/zapper-fi-assets/tokens/ethereum/0x0000000000000000000000000000000000000000.png"
              ],
              "statsItems": [
                {
                  "label": "Liquidity",
                  "value": {
                    "type": "dollar",
                    "value": 1016096.3875830304
                  }
                },
                {
                  "label": "Share",
                  "value": {
                    "type": "pct",
                    "value": 34.040894289432025
                  }
                }
              ]
            },
            "balance": 194.18817115164214,
            "balanceRaw": "194188171151642129924",
            "balanceUSD": 345888.29717587685
          }
        ],
        "meta": []
      },
      {
        "label": "Farms",
        "assets": [
          {
            "type": "app-token",
            "address": "0x200e41be620928351f98da8031baeb7bd401a129",
            "network": "ethereum",
            "appId": "tempus",
            "groupId": "amm",
            "symbol": "TLPstETH",
            "decimals": 18,
            "supply": 37.983074392252966,
            "price": 57100.711750741626,
            "pricePerShare": [
              0.8387544523804996,
              6.246478386209733
            ],
            "tokens": [
              {
                "type": "app-token",
                "address": "0x2c4ac125044e853f0f6d66b95365cbba204ffcfd",
                "network": "ethereum",
                "appId": "tempus",
                "groupId": "pool",
                "symbol": "TPS-stETH-30-7-2022",
                "decimals": 18,
                "supply": 570.4555511983942,
                "price": 1781.201682494716,
                "pricePerShare": 0.9897324427091015,
                "tokens": [
                  {
                    "id": "1496",
                    "networkId": 1,
                    "address": "0x0000000000000000000000000000000000000000",
                    "name": "Ether",
                    "symbol": "ETH",
                    "decimals": 18,
                    "coingeckoId": "ethereum",
                    "status": "pending",
                    "hide": false,
                    "canExchange": true,
                    "updatedAt": "2022-06-08T12:41:24.406Z",
                    "createdAt": "2022-05-18T12:54:47.695Z",
                    "price": 1799.68,
                    "networkEnumValue": "ethereum",
                    "type": "base-token",
                    "network": "ethereum",
                    "balance": 10.824365979563721,
                    "balanceRaw": "10824365979563720796",
                    "balanceUSD": 19480.394966101238
                  }
                ],
                "dataProps": {
                  "liquidity": 1016096.3875830304,
                  "reserve": 0
                },
                "displayProps": {
                  "label": "TPS-stETH-30-7-2022",
                  "secondaryLabel": {
                    "type": "dollar",
                    "value": 1781.201682494716
                  },
                  "tertiaryLabel": "",
                  "images": [
                    "https://storage.googleapis.com/zapper-fi-assets/tokens/ethereum/0x0000000000000000000000000000000000000000.png"
                  ],
                  "statsItems": [
                    {
                      "label": "Liquidity",
                      "value": {
                        "type": "dollar",
                        "value": 1016096.3875830304
                      }
                    },
                    {
                      "label": "Share",
                      "value": {
                        "type": "pct",
                        "value": 1.9171798270475986
                      }
                    }
                  ]
                },
                "balance": 10.9366587498488,
                "balanceRaw": "10936658749848799714",
                "balanceUSD": 19480.394966101238
              },
              {
                "type": "app-token",
                "address": "0xffacf0b02851e440fa207ea2f9afdf7ffe0be095",
                "network": "ethereum",
                "appId": "tempus",
                "groupId": "pool",
                "symbol": "TYS-stETH-30-7-2022",
                "decimals": 18,
                "supply": 570.4555511983942,
                "price": 56.727398088257814,
                "pricePerShare": 0.03152082486234098,
                "tokens": [
                  {
                    "id": "1496",
                    "networkId": 1,
                    "address": "0x0000000000000000000000000000000000000000",
                    "name": "Ether",
                    "symbol": "ETH",
                    "decimals": 18,
                    "coingeckoId": "ethereum",
                    "status": "pending",
                    "hide": false,
                    "canExchange": true,
                    "updatedAt": "2022-06-08T12:41:24.406Z",
                    "createdAt": "2022-05-18T12:54:47.695Z",
                    "price": 1799.68,
                    "networkEnumValue": "ethereum",
                    "type": "base-token",
                    "network": "ethereum",
                    "balance": 2.567335571933016,
                    "balanceRaw": "2567335571933015979",
                    "balanceUSD": 4620.38248209641
                  }
                ],
                "dataProps": {
                  "liquidity": 32360.459144487846,
                  "reserve": 0
                },
                "displayProps": {
                  "label": "TYS-stETH-30-7-2022",
                  "secondaryLabel": {
                    "type": "dollar",
                    "value": 56.727398088257814
                  },
                  "tertiaryLabel": "",
                  "images": [
                    "https://storage.googleapis.com/zapper-fi-assets/tokens/ethereum/0x0000000000000000000000000000000000000000.png"
                  ],
                  "statsItems": [
                    {
                      "label": "Liquidity",
                      "value": {
                        "type": "dollar",
                        "value": 32360.459144487846
                      }
                    },
                    {
                      "label": "Share",
                      "value": {
                        "type": "pct",
                        "value": 14.277864419248909
                      }
                    }
                  ]
                },
                "balance": 81.44887017218578,
                "balanceRaw": "81448870172185773279",
                "balanceUSD": 4620.38248209641
              }
            ],
            "dataProps": {
              "swapAddress": "0x200e41be620928351f98da8031baeb7bd401a129",
              "liquidity": 70205.53346582653,
              "volume": 0,
              "fee": 0.01
            },
            "displayProps": {
              "label": "TPS-stETH-30-7-2022 / TYS-stETH-30-7-2022",
              "secondaryLabel": "80% / 19%",
              "images": [
                "https://storage.googleapis.com/zapper-fi-assets/tokens/ethereum/0x0000000000000000000000000000000000000000.png",
                "https://storage.googleapis.com/zapper-fi-assets/tokens/ethereum/0x0000000000000000000000000000000000000000.png"
              ],
              "statsItems": [
                {
                  "label": "Liquidity",
                  "value": {
                    "type": "dollar",
                    "value": 70205.53346582653
                  }
                },
                {
                  "label": "Supply",
                  "value": {
                    "type": "number",
                    "value": 37.983074392252966
                  }
                },
                {
                  "label": "Volume",
                  "value": {
                    "type": "dollar",
                    "value": 0
                  }
                },
                {
                  "label": "Fee",
                  "value": {
                    "type": "pct",
                    "value": 0.01
                  }
                },
                {
                  "label": "Share",
                  "value": {
                    "type": "pct",
                    "value": 34.328885856168334
                  }
                }
              ]
            },
            "balance": 13.039166252780024,
            "balanceRaw": "13039166252780023599",
            "balanceUSD": 744545.67366999
          }
        ],
        "meta": []
      }
    ],
    "meta": [
      {
        "label": "Total",
        "value": 1097664.6798254272,
        "type": "dollar"
      },
      {
        "label": "Assets",
        "value": 1097664.6798254272,
        "type": "dollar"
      },
      {
        "label": "Debt",
        "value": 0,
        "type": "dollar"
      }
    ]
  }
}

const decimals = await multicall.wrap(contract).decimals();
const pricePerShare = await multicall.wrap(contract).getPricePerFullShareStored();
return Number(pricePerShare) / 10 ** Number(decimals);
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the default label as the symbol isn't great: TYS-stETH-31-2-2022

I'd suggest we override the label with resolvePrimaryLabel, and set it to stETH Yield Share (Maturity: 31/02/2022) (or for principal, stETH Principal Share (Maturity: 31/02/2022)). You can also adjust the vault helper to add a resolveTertiaryLabel if you want the maturity outside of the primary label.

Copy link
Contributor Author

@tonzgao tonzgao Jun 8, 2022

Choose a reason for hiding this comment

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

hmm, the symbol names dont seem to be consistent between eth mainnet and fantom, and im not sure how they might change in the future. is it okay to just leave this as it for now? or if the tempus team has a suggestion about deriving labels?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup it's ok to come back and address this later. I'll update the VaultTokenHelper between now and then so that you'll be able to update the tertiaryLabel in the future if necessary.

@tonzgao tonzgao requested a review from immasandwich June 8, 2022 13:49
@tonzgao
Copy link
Contributor Author

tonzgao commented Jun 8, 2022

note

RTP() — Today at 3:51 PM
Oh nice! That was quick!
Give us a chance to review and get back to you

@immasandwich immasandwich merged commit 4e941b2 into Zapper-fi:main Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants