diff --git a/src/contracts/abis/UsdRateAbi.json b/src/contracts/abis/UsdRateAbi.json index e19a8796..d54d5b58 100644 --- a/src/contracts/abis/UsdRateAbi.json +++ b/src/contracts/abis/UsdRateAbi.json @@ -1 +1 @@ -[{"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"}] +[{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"},{"internalType":"address","name":"_accessController","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"int256","name":"current","type":"int256"},{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"updatedAt","type":"uint256"}],"name":"AnswerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":true,"internalType":"address","name":"startedBy","type":"address"},{"indexed":false,"internalType":"uint256","name":"startedAt","type":"uint256"}],"name":"NewRound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accessController","outputs":[{"internalType":"contract AccessControllerInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"}],"name":"confirmAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundId","type":"uint256"}],"name":"getAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"getRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundId","type":"uint256"}],"name":"getTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"phaseAggregators","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"phaseId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"}],"name":"proposeAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proposedAggregator","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"proposedGetRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposedLatestRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_accessController","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] diff --git a/src/contracts/createContracts.ts b/src/contracts/createContracts.ts index 8126adda..fbf57f63 100644 --- a/src/contracts/createContracts.ts +++ b/src/contracts/createContracts.ts @@ -4,6 +4,7 @@ import { Erc20Abi, VaultAbi, KeeperAbi, + UsdRateAbi, MintTokenAbi, MulticallAbi, Erc20VaultAbi, @@ -32,6 +33,7 @@ import type { SwiseTokenAbi as SwiseTokenType, MulticallAbi as MulticallType, MintTokenAbi as MintTokenType, + UsdRateAbi as UsdRateType, VaultAbi as VaultAbiType, KeeperAbi as KeeperType, Erc20Abi as Erc20Type, @@ -117,6 +119,7 @@ export const createContracts = (input: CreateContractsInput) => { createMulticall: multicall(multicallContract as MulticallType), createErc20: (address: string) => createContract(address, Erc20Abi, provider), createVaultContract: (address: string) => createContract(address, VaultAbi, provider), + createUsdRateContract: (address: string) => createContract(address, UsdRateAbi, provider), createErc20VaultContract: (address: string) => createContract(address, Erc20VaultAbi, provider), createPrivateVaultContract: (address: string) => createContract(address, PrivateVaultAbi, provider), createRewardSplitterContract: (address: string) => createContract(address, RewardSplitterAbi, provider), diff --git a/src/methods/osToken/requests/getOsTokenPosition/index.ts b/src/methods/osToken/requests/getOsTokenPosition/index.ts index d05db66b..3f2e4099 100644 --- a/src/methods/osToken/requests/getOsTokenPosition/index.ts +++ b/src/methods/osToken/requests/getOsTokenPosition/index.ts @@ -21,11 +21,11 @@ const getOsTokenPosition = async (values: GetOsTokenPositionInput) => { const vaultContract = contracts.helpers.createVaultContract(vaultAddress) - const gqlShares = await getOsTokenPositionShares({ options, vaultAddress, userAddress }) - const contractShares = await vaultContract.osTokenPositions(userAddress) + const gqlMintedShares = await getOsTokenPositionShares({ options, vaultAddress, userAddress }) + const mintedShares = await vaultContract.osTokenPositions(userAddress) const [ mintedAssets, feePercent ] = await Promise.all([ - contracts.tokens.mintToken.convertToAssets(contractShares), + contracts.tokens.mintToken.convertToAssets(mintedShares), contracts.tokens.mintToken.feePercent(), ]) @@ -35,8 +35,8 @@ const getOsTokenPosition = async (values: GetOsTokenPositionInput) => { return { minted: { assets: mintedAssets, - shares: contractShares, - fee: contractShares - gqlShares, + shares: mintedShares, + fee: mintedShares - gqlMintedShares, }, healthFactor, protocolFeePercent,