Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add total OD and ETH for a user in the Camelot Swap pool #1

Closed
wants to merge 5 commits into from

Conversation

jahabeebs
Copy link
Member

Description

  • Calculates total OD and ETH for a user in the Camelot Swap pool, even if they've staked their position in Nitro

totalBalance includes the balance of a given token in the main pool + the Nitro pool
userShare represents the amount of each collateral that corresponds to the user's share of the pools (userPoolPercentage * totalBalance)

  • parses TVL as a float because before it was being console logged as [Object object]

Does my math make sense?

example output:

Collateral Tokens: [
  {
    symbol: 'OD',
    userBalance: 0,
    nitroPoolBalance: 0,
    poolBalance: 111644.33240143773,
    address: '0x221A0f68770658C15B525d0F89F5da2baAB5f321'
  },
  {
    symbol: 'WETH',
    userBalance: 0.000051234660104319,
    nitroPoolBalance: 0,
    poolBalance: 36.17168578894545,
    address: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1'
  }
]
User Info: [
  BigNumber { _hex: '0x54f6c4ea399a5b', _isBigNumber: true },
  BigNumber { _hex: '0x10196ea80d160e95d7', _isBigNumber: true },
  BigNumber { _hex: '0x04bcf6e5c4adb90a6c', _isBigNumber: true },
  BigNumber { _hex: '0x00', _isBigNumber: true },
  BigNumber { _hex: '0x00', _isBigNumber: true },
  totalDepositAmount: BigNumber { _hex: '0x54f6c4ea399a5b', _isBigNumber: true },
  rewardDebtToken1: BigNumber { _hex: '0x10196ea80d160e95d7', _isBigNumber: true },
  rewardDebtToken2: BigNumber { _hex: '0x04bcf6e5c4adb90a6c', _isBigNumber: true },
  pendingRewardsToken1: BigNumber { _hex: '0x00', _isBigNumber: true },
  pendingRewardsToken2: BigNumber { _hex: '0x00', _isBigNumber: true }
]
User Deposit Amount: 0.023915223647361625
Total Deposit Amount: 2.044209657916788
User Pool Percentage: 1.17%
User Dollar Value: $2918.00
TVL USD: $249422.46
User Collateral Balances: [
  { symbol: 'OD', userShare: 1306.1278563088808 },
  { symbol: 'WETH', userShare: 0.42317281497744286 }
]

@jahabeebs jahabeebs requested a review from pi0neerpat May 16, 2024 19:48
@jahabeebs jahabeebs self-assigned this May 16, 2024
Copy link
Member

@pi0neerpat pi0neerpat left a comment

Choose a reason for hiding this comment

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

Include deposit amounts from spNFT as well. Can hardcode these positions for now
OD-ETH spNFT: 0x7647da336cf43f894ac7a0bf87f04806b2e03bb8
ODG-ETH spNFT: ???

@jahabeebs jahabeebs requested a review from pi0neerpat May 16, 2024 22:32
@jahabeebs
Copy link
Member Author

pushed spNFT counting logic

@pi0neerpat
Copy link
Member

Done. This code has been moved to od-bot in open-dollar/od-bot#87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants