@moonwell-fi/moonwell-sdk 0.2.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +36 -15
- package/_cjs/actions/core/getUserBalances.js +46 -5
- package/_cjs/actions/core/getUserBalances.js.map +1 -1
- package/_cjs/actions/core/markets/common.js +19 -16
- package/_cjs/actions/core/markets/common.js.map +1 -1
- package/_cjs/actions/core/markets/getMarketSnapshots.js +192 -0
- package/_cjs/actions/core/markets/getMarketSnapshots.js.map +1 -0
- package/_cjs/actions/core/markets/getMarkets.js +26 -0
- package/_cjs/actions/core/markets/getMarkets.js.map +1 -1
- package/_cjs/actions/core/user-positions/common.js.map +1 -1
- package/_cjs/actions/core/user-rewards/common.js.map +1 -1
- package/_cjs/actions/governance/getCirculatingSupplySnapshots.js +53 -0
- package/_cjs/actions/governance/getCirculatingSupplySnapshots.js.map +1 -0
- package/_cjs/actions/governance/getDelegates.js +31 -2
- package/_cjs/actions/governance/getDelegates.js.map +1 -1
- package/_cjs/actions/governance/getDiscussions.js +30 -1
- package/_cjs/actions/governance/getDiscussions.js.map +1 -1
- package/_cjs/actions/governance/getGovernanceTokenInfo.js +27 -0
- package/_cjs/actions/governance/getGovernanceTokenInfo.js.map +1 -1
- package/_cjs/actions/governance/getStakingSnapshots.js +4 -1
- package/_cjs/actions/governance/getStakingSnapshots.js.map +1 -1
- package/_cjs/actions/governance/getUserVoteReceipt.js +7 -6
- package/_cjs/actions/governance/getUserVoteReceipt.js.map +1 -1
- package/_cjs/actions/governance/proposals/common.js +4 -18
- package/_cjs/actions/governance/proposals/common.js.map +1 -1
- package/_cjs/actions/governance/proposals/getProposals.js +34 -2
- package/_cjs/actions/governance/proposals/getProposals.js.map +1 -1
- package/_cjs/actions/governance/snapshot/common.js +4 -1
- package/_cjs/actions/governance/snapshot/common.js.map +1 -1
- package/_cjs/actions/governance/snapshot/getSnapshotProposals.js +28 -1
- package/_cjs/actions/governance/snapshot/getSnapshotProposals.js.map +1 -1
- package/_cjs/actions/index.js +19 -15
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/morpho/markets/common.js +19 -13
- package/_cjs/actions/morpho/markets/common.js.map +1 -1
- package/_cjs/actions/morpho/markets/getMorphoMarkets.js +28 -1
- package/_cjs/actions/morpho/markets/getMorphoMarkets.js.map +1 -1
- package/_cjs/actions/morpho/user-positions/common.js.map +1 -1
- package/_cjs/actions/morpho/user-positions/getMorphoMarketUserPositions.js +3 -1
- package/_cjs/actions/morpho/user-positions/getMorphoMarketUserPositions.js.map +1 -1
- package/_cjs/actions/morpho/user-positions/getMorphoVaultUserPositions.js +3 -1
- package/_cjs/actions/morpho/user-positions/getMorphoVaultUserPositions.js.map +1 -1
- package/_cjs/actions/morpho/user-rewards/common.js +8 -2
- package/_cjs/actions/morpho/user-rewards/common.js.map +1 -1
- package/_cjs/actions/morpho/user-rewards/getMorphoUserRewards.js +3 -1
- package/_cjs/actions/morpho/user-rewards/getMorphoUserRewards.js.map +1 -1
- package/_cjs/actions/morpho/utils/graphql.js +1 -1
- package/_cjs/actions/morpho/utils/graphql.js.map +1 -1
- package/_cjs/actions/morpho/vaults/common.js +9 -8
- package/_cjs/actions/morpho/vaults/common.js.map +1 -1
- package/_cjs/actions/morpho/vaults/getMorphoVaults.js +29 -2
- package/_cjs/actions/morpho/vaults/getMorphoVaults.js.map +1 -1
- package/_cjs/client/createActions.js +7 -3
- package/_cjs/client/createActions.js.map +1 -1
- package/_cjs/client/createMoonwellClient.js +8 -2
- package/_cjs/client/createMoonwellClient.js.map +1 -1
- package/_cjs/common/amount.js +6 -0
- package/_cjs/common/amount.js.map +1 -1
- package/_cjs/common/index.js +16 -3
- package/_cjs/common/index.js.map +1 -1
- package/_cjs/environments/abis/index.js +25 -20
- package/_cjs/environments/abis/index.js.map +1 -1
- package/_cjs/environments/abis/tokenSaleAbi.js +785 -0
- package/_cjs/environments/abis/tokenSaleAbi.js.map +1 -0
- package/_cjs/environments/definitions/arbitrum/environment.js +26 -0
- package/_cjs/environments/definitions/arbitrum/environment.js.map +1 -0
- package/_cjs/environments/definitions/arbitrum/tokens.js +21 -0
- package/_cjs/environments/definitions/arbitrum/tokens.js.map +1 -0
- package/_cjs/environments/definitions/avalanche/environment.js +26 -0
- package/_cjs/environments/definitions/avalanche/environment.js.map +1 -0
- package/_cjs/environments/definitions/avalanche/tokens.js +21 -0
- package/_cjs/environments/definitions/avalanche/tokens.js.map +1 -0
- package/_cjs/environments/definitions/base/core-markets.js +8 -0
- package/_cjs/environments/definitions/base/core-markets.js.map +1 -1
- package/_cjs/environments/definitions/base/environment.js +1 -1
- package/_cjs/environments/definitions/base/environment.js.map +1 -1
- package/_cjs/environments/definitions/base/morpho-markets.js +1 -0
- package/_cjs/environments/definitions/base/morpho-markets.js.map +1 -1
- package/_cjs/environments/definitions/base/morpho-vaults.js +4 -0
- package/_cjs/environments/definitions/base/morpho-vaults.js.map +1 -1
- package/_cjs/environments/definitions/base/tokens.js +36 -0
- package/_cjs/environments/definitions/base/tokens.js.map +1 -1
- package/_cjs/environments/definitions/ethereum/environment.js +26 -0
- package/_cjs/environments/definitions/ethereum/environment.js.map +1 -0
- package/_cjs/environments/definitions/ethereum/tokens.js +20 -0
- package/_cjs/environments/definitions/ethereum/tokens.js.map +1 -0
- package/_cjs/environments/definitions/governance.js +1 -1
- package/_cjs/environments/definitions/governance.js.map +1 -1
- package/_cjs/environments/definitions/moonbeam/contracts.js +1 -0
- package/_cjs/environments/definitions/moonbeam/contracts.js.map +1 -1
- package/_cjs/environments/definitions/moonbeam/core-markets.js +31 -15
- package/_cjs/environments/definitions/moonbeam/core-markets.js.map +1 -1
- package/_cjs/environments/definitions/moonbeam/tokens.js +61 -19
- package/_cjs/environments/definitions/moonbeam/tokens.js.map +1 -1
- package/_cjs/environments/definitions/moonriver/core-markets.js +4 -0
- package/_cjs/environments/definitions/moonriver/core-markets.js.map +1 -1
- package/_cjs/environments/definitions/optimism/core-markets.js +4 -0
- package/_cjs/environments/definitions/optimism/core-markets.js.map +1 -1
- package/_cjs/environments/definitions/optimism/environment.js +3 -2
- package/_cjs/environments/definitions/optimism/environment.js.map +1 -1
- package/_cjs/environments/definitions/optimism/tokens.js +12 -0
- package/_cjs/environments/definitions/optimism/tokens.js.map +1 -1
- package/_cjs/environments/definitions/polygon/environment.js +26 -0
- package/_cjs/environments/definitions/polygon/environment.js.map +1 -0
- package/_cjs/environments/definitions/polygon/tokens.js +21 -0
- package/_cjs/environments/definitions/polygon/tokens.js.map +1 -0
- package/_cjs/environments/index.js +34 -5
- package/_cjs/environments/index.js.map +1 -1
- package/_cjs/environments/types/config.js +1 -0
- package/_cjs/environments/types/config.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +4 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/logger/console.js +37 -0
- package/_cjs/logger/console.js.map +1 -0
- package/_cjs/types/circulatingSupply.js +3 -0
- package/_cjs/types/circulatingSupply.js.map +1 -0
- package/_cjs/types/proposal.js.map +1 -1
- package/_esm/actions/core/getUserBalances.js +46 -5
- package/_esm/actions/core/getUserBalances.js.map +1 -1
- package/_esm/actions/core/markets/common.js +10 -7
- package/_esm/actions/core/markets/common.js.map +1 -1
- package/_esm/actions/core/markets/getMarketSnapshots.js +185 -0
- package/_esm/actions/core/markets/getMarketSnapshots.js.map +1 -0
- package/_esm/actions/core/markets/getMarkets.js +3 -0
- package/_esm/actions/core/markets/getMarkets.js.map +1 -1
- package/_esm/actions/core/user-positions/common.js.map +1 -1
- package/_esm/actions/core/user-rewards/common.js.map +1 -1
- package/_esm/actions/governance/getCirculatingSupplySnapshots.js +46 -0
- package/_esm/actions/governance/getCirculatingSupplySnapshots.js.map +1 -0
- package/_esm/actions/governance/getDelegates.js +5 -2
- package/_esm/actions/governance/getDelegates.js.map +1 -1
- package/_esm/actions/governance/getDiscussions.js +3 -0
- package/_esm/actions/governance/getDiscussions.js.map +1 -1
- package/_esm/actions/governance/getGovernanceTokenInfo.js +4 -0
- package/_esm/actions/governance/getGovernanceTokenInfo.js.map +1 -1
- package/_esm/actions/governance/getUserVoteReceipt.js +7 -6
- package/_esm/actions/governance/getUserVoteReceipt.js.map +1 -1
- package/_esm/actions/governance/proposals/common.js +14 -20
- package/_esm/actions/governance/proposals/common.js.map +1 -1
- package/_esm/actions/governance/proposals/getProposals.js +11 -2
- package/_esm/actions/governance/proposals/getProposals.js.map +1 -1
- package/_esm/actions/governance/snapshot/getSnapshotProposals.js +5 -1
- package/_esm/actions/governance/snapshot/getSnapshotProposals.js.map +1 -1
- package/_esm/actions/index.js +9 -7
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/morpho/markets/common.js +19 -13
- package/_esm/actions/morpho/markets/common.js.map +1 -1
- package/_esm/actions/morpho/markets/getMorphoMarkets.js +5 -1
- package/_esm/actions/morpho/markets/getMorphoMarkets.js.map +1 -1
- package/_esm/actions/morpho/user-positions/common.js.map +1 -1
- package/_esm/actions/morpho/user-positions/getMorphoMarketUserPositions.js +3 -1
- package/_esm/actions/morpho/user-positions/getMorphoMarketUserPositions.js.map +1 -1
- package/_esm/actions/morpho/user-positions/getMorphoVaultUserPositions.js +3 -1
- package/_esm/actions/morpho/user-positions/getMorphoVaultUserPositions.js.map +1 -1
- package/_esm/actions/morpho/user-rewards/common.js +8 -3
- package/_esm/actions/morpho/user-rewards/common.js.map +1 -1
- package/_esm/actions/morpho/user-rewards/getMorphoUserRewards.js +3 -1
- package/_esm/actions/morpho/user-rewards/getMorphoUserRewards.js.map +1 -1
- package/_esm/actions/morpho/utils/graphql.js +1 -1
- package/_esm/actions/morpho/utils/graphql.js.map +1 -1
- package/_esm/actions/morpho/vaults/common.js +9 -8
- package/_esm/actions/morpho/vaults/common.js.map +1 -1
- package/_esm/actions/morpho/vaults/getMorphoVaults.js +6 -2
- package/_esm/actions/morpho/vaults/getMorphoVaults.js.map +1 -1
- package/_esm/client/createActions.js +5 -1
- package/_esm/client/createActions.js.map +1 -1
- package/_esm/client/createMoonwellClient.js +10 -4
- package/_esm/client/createMoonwellClient.js.map +1 -1
- package/_esm/common/amount.js +6 -0
- package/_esm/common/amount.js.map +1 -1
- package/_esm/common/index.js +11 -2
- package/_esm/common/index.js.map +1 -1
- package/_esm/environments/abis/index.js +2 -1
- package/_esm/environments/abis/index.js.map +1 -1
- package/_esm/environments/abis/tokenSaleAbi.js +783 -0
- package/_esm/environments/abis/tokenSaleAbi.js.map +1 -0
- package/_esm/environments/definitions/arbitrum/environment.js +21 -0
- package/_esm/environments/definitions/arbitrum/environment.js.map +1 -0
- package/_esm/environments/definitions/arbitrum/tokens.js +18 -0
- package/_esm/environments/definitions/arbitrum/tokens.js.map +1 -0
- package/_esm/environments/definitions/avalanche/environment.js +21 -0
- package/_esm/environments/definitions/avalanche/environment.js.map +1 -0
- package/_esm/environments/definitions/avalanche/tokens.js +18 -0
- package/_esm/environments/definitions/avalanche/tokens.js.map +1 -0
- package/_esm/environments/definitions/base/core-markets.js +8 -0
- package/_esm/environments/definitions/base/core-markets.js.map +1 -1
- package/_esm/environments/definitions/base/environment.js +1 -1
- package/_esm/environments/definitions/base/morpho-markets.js +1 -0
- package/_esm/environments/definitions/base/morpho-markets.js.map +1 -1
- package/_esm/environments/definitions/base/morpho-vaults.js +4 -0
- package/_esm/environments/definitions/base/morpho-vaults.js.map +1 -1
- package/_esm/environments/definitions/base/tokens.js +36 -0
- package/_esm/environments/definitions/base/tokens.js.map +1 -1
- package/_esm/environments/definitions/ethereum/environment.js +21 -0
- package/_esm/environments/definitions/ethereum/environment.js.map +1 -0
- package/_esm/environments/definitions/ethereum/tokens.js +17 -0
- package/_esm/environments/definitions/ethereum/tokens.js.map +1 -0
- package/_esm/environments/definitions/governance.js +2 -2
- package/_esm/environments/definitions/governance.js.map +1 -1
- package/_esm/environments/definitions/moonbeam/contracts.js +1 -0
- package/_esm/environments/definitions/moonbeam/contracts.js.map +1 -1
- package/_esm/environments/definitions/moonbeam/core-markets.js +31 -15
- package/_esm/environments/definitions/moonbeam/core-markets.js.map +1 -1
- package/_esm/environments/definitions/moonbeam/tokens.js +61 -19
- package/_esm/environments/definitions/moonbeam/tokens.js.map +1 -1
- package/_esm/environments/definitions/moonriver/core-markets.js +4 -0
- package/_esm/environments/definitions/moonriver/core-markets.js.map +1 -1
- package/_esm/environments/definitions/optimism/core-markets.js +4 -0
- package/_esm/environments/definitions/optimism/core-markets.js.map +1 -1
- package/_esm/environments/definitions/optimism/environment.js +3 -2
- package/_esm/environments/definitions/optimism/environment.js.map +1 -1
- package/_esm/environments/definitions/optimism/tokens.js +12 -0
- package/_esm/environments/definitions/optimism/tokens.js.map +1 -1
- package/_esm/environments/definitions/polygon/environment.js +21 -0
- package/_esm/environments/definitions/polygon/environment.js.map +1 -0
- package/_esm/environments/definitions/polygon/tokens.js +18 -0
- package/_esm/environments/definitions/polygon/tokens.js.map +1 -0
- package/_esm/environments/index.js +33 -9
- package/_esm/environments/index.js.map +1 -1
- package/_esm/environments/types/config.js +1 -0
- package/_esm/environments/types/config.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/logger/console.js +32 -0
- package/_esm/logger/console.js.map +1 -0
- package/_esm/types/circulatingSupply.js +2 -0
- package/_esm/types/circulatingSupply.js.map +1 -0
- package/_esm/types/proposal.js.map +1 -1
- package/_types/actions/core/getUserBalances.d.ts +3 -3
- package/_types/actions/core/getUserBalances.d.ts.map +1 -1
- package/_types/actions/core/markets/common.d.ts.map +1 -1
- package/_types/actions/core/markets/getMarketSnapshots.d.ts +11 -0
- package/_types/actions/core/markets/getMarketSnapshots.d.ts.map +1 -0
- package/_types/actions/core/markets/getMarkets.d.ts.map +1 -1
- package/_types/actions/core/user-positions/common.d.ts.map +1 -1
- package/_types/actions/core/user-positions/getUserPositions.d.ts +2 -2
- package/_types/actions/core/user-positions/getUserPositions.d.ts.map +1 -1
- package/_types/actions/core/user-rewards/common.d.ts.map +1 -1
- package/_types/actions/core/user-rewards/getUserRewards.d.ts +2 -2
- package/_types/actions/core/user-rewards/getUserRewards.d.ts.map +1 -1
- package/_types/actions/governance/getCirculatingSupplySnapshots.d.ts +8 -0
- package/_types/actions/governance/getCirculatingSupplySnapshots.d.ts.map +1 -0
- package/_types/actions/governance/getDelegates.d.ts.map +1 -1
- package/_types/actions/governance/getDiscussions.d.ts.map +1 -1
- package/_types/actions/governance/getGovernanceTokenInfo.d.ts.map +1 -1
- package/_types/actions/governance/getUserStakingInfo.d.ts +2 -2
- package/_types/actions/governance/getUserStakingInfo.d.ts.map +1 -1
- package/_types/actions/governance/getUserVoteReceipt.d.ts.map +1 -1
- package/_types/actions/governance/getUserVotingPowers.d.ts +2 -2
- package/_types/actions/governance/getUserVotingPowers.d.ts.map +1 -1
- package/_types/actions/governance/proposals/common.d.ts.map +1 -1
- package/_types/actions/governance/proposals/getProposals.d.ts +3 -3
- package/_types/actions/governance/proposals/getProposals.d.ts.map +1 -1
- package/_types/actions/governance/snapshot/getSnapshotProposals.d.ts.map +1 -1
- package/_types/actions/index.d.ts +31 -29
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/morpho/getMorphoUserBalances.d.ts +2 -2
- package/_types/actions/morpho/getMorphoUserBalances.d.ts.map +1 -1
- package/_types/actions/morpho/markets/common.d.ts.map +1 -1
- package/_types/actions/morpho/markets/getMorphoMarkets.d.ts +2 -2
- package/_types/actions/morpho/markets/getMorphoMarkets.d.ts.map +1 -1
- package/_types/actions/morpho/user-positions/common.d.ts.map +1 -1
- package/_types/actions/morpho/user-positions/getMorphoMarketUserPositions.d.ts +2 -2
- package/_types/actions/morpho/user-positions/getMorphoMarketUserPositions.d.ts.map +1 -1
- package/_types/actions/morpho/user-positions/getMorphoVaultUserPositions.d.ts +2 -2
- package/_types/actions/morpho/user-positions/getMorphoVaultUserPositions.d.ts.map +1 -1
- package/_types/actions/morpho/user-rewards/common.d.ts.map +1 -1
- package/_types/actions/morpho/user-rewards/getMorphoUserRewards.d.ts +2 -2
- package/_types/actions/morpho/user-rewards/getMorphoUserRewards.d.ts.map +1 -1
- package/_types/actions/morpho/vaults/common.d.ts.map +1 -1
- package/_types/actions/morpho/vaults/getMorphoVaults.d.ts +3 -3
- package/_types/actions/morpho/vaults/getMorphoVaults.d.ts.map +1 -1
- package/_types/client/createActions.d.ts +44 -27
- package/_types/client/createActions.d.ts.map +1 -1
- package/_types/client/createMoonwellClient.d.ts +2353 -41209
- package/_types/client/createMoonwellClient.d.ts.map +1 -1
- package/_types/common/amount.d.ts +2 -0
- package/_types/common/amount.d.ts.map +1 -1
- package/_types/common/index.d.ts +3 -2
- package/_types/common/index.d.ts.map +1 -1
- package/_types/environments/abis/index.d.ts +2 -1
- package/_types/environments/abis/index.d.ts.map +1 -1
- package/_types/environments/abis/tokenSaleAbi.d.ts +602 -0
- package/_types/environments/abis/tokenSaleAbi.d.ts.map +1 -0
- package/_types/environments/definitions/arbitrum/environment.d.ts +6 -0
- package/_types/environments/definitions/arbitrum/environment.d.ts.map +1 -0
- package/_types/environments/definitions/arbitrum/tokens.d.ts +15 -0
- package/_types/environments/definitions/arbitrum/tokens.d.ts.map +1 -0
- package/_types/environments/definitions/avalanche/environment.d.ts +6 -0
- package/_types/environments/definitions/avalanche/environment.d.ts.map +1 -0
- package/_types/environments/definitions/avalanche/tokens.d.ts +15 -0
- package/_types/environments/definitions/avalanche/tokens.d.ts.map +1 -0
- package/_types/environments/definitions/base/core-markets.d.ts +8 -0
- package/_types/environments/definitions/base/core-markets.d.ts.map +1 -1
- package/_types/environments/definitions/base/environment.d.ts +1 -1
- package/_types/environments/definitions/base/morpho-markets.d.ts +1 -0
- package/_types/environments/definitions/base/morpho-markets.d.ts.map +1 -1
- package/_types/environments/definitions/base/morpho-vaults.d.ts +4 -0
- package/_types/environments/definitions/base/morpho-vaults.d.ts.map +1 -1
- package/_types/environments/definitions/base/tokens.d.ts +36 -0
- package/_types/environments/definitions/base/tokens.d.ts.map +1 -1
- package/_types/environments/definitions/ethereum/environment.d.ts +6 -0
- package/_types/environments/definitions/ethereum/environment.d.ts.map +1 -0
- package/_types/environments/definitions/ethereum/tokens.d.ts +15 -0
- package/_types/environments/definitions/ethereum/tokens.d.ts.map +1 -0
- package/_types/environments/definitions/moonbeam/contracts.d.ts +1 -0
- package/_types/environments/definitions/moonbeam/contracts.d.ts.map +1 -1
- package/_types/environments/definitions/moonbeam/core-markets.d.ts +31 -15
- package/_types/environments/definitions/moonbeam/core-markets.d.ts.map +1 -1
- package/_types/environments/definitions/moonbeam/environment.d.ts +90 -31
- package/_types/environments/definitions/moonbeam/environment.d.ts.map +1 -1
- package/_types/environments/definitions/moonbeam/tokens.d.ts +61 -19
- package/_types/environments/definitions/moonbeam/tokens.d.ts.map +1 -1
- package/_types/environments/definitions/moonriver/core-markets.d.ts +4 -0
- package/_types/environments/definitions/moonriver/core-markets.d.ts.map +1 -1
- package/_types/environments/definitions/moonriver/environment.d.ts +4 -0
- package/_types/environments/definitions/moonriver/environment.d.ts.map +1 -1
- package/_types/environments/definitions/optimism/core-markets.d.ts +4 -0
- package/_types/environments/definitions/optimism/core-markets.d.ts.map +1 -1
- package/_types/environments/definitions/optimism/environment.d.ts +16 -0
- package/_types/environments/definitions/optimism/environment.d.ts.map +1 -1
- package/_types/environments/definitions/optimism/tokens.d.ts +12 -0
- package/_types/environments/definitions/optimism/tokens.d.ts.map +1 -1
- package/_types/environments/definitions/polygon/environment.d.ts +6 -0
- package/_types/environments/definitions/polygon/environment.d.ts.map +1 -0
- package/_types/environments/definitions/polygon/tokens.d.ts +15 -0
- package/_types/environments/definitions/polygon/tokens.d.ts.map +1 -0
- package/_types/environments/index.d.ts +321 -661
- package/_types/environments/index.d.ts.map +1 -1
- package/_types/environments/types/config.d.ts +12 -7
- package/_types/environments/types/config.d.ts.map +1 -1
- package/_types/environments/types/contracts.d.ts +2 -1
- package/_types/environments/types/contracts.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +7 -5
- package/_types/index.d.ts.map +1 -1
- package/_types/logger/console.d.ts +3 -0
- package/_types/logger/console.d.ts.map +1 -0
- package/_types/types/circulatingSupply.d.ts +8 -0
- package/_types/types/circulatingSupply.d.ts.map +1 -0
- package/_types/types/market.d.ts +14 -0
- package/_types/types/market.d.ts.map +1 -1
- package/_types/types/morphoMarket.d.ts +3 -0
- package/_types/types/morphoMarket.d.ts.map +1 -1
- package/_types/types/morphoVault.d.ts +4 -2
- package/_types/types/morphoVault.d.ts.map +1 -1
- package/_types/types/proposal.d.ts +0 -8
- package/_types/types/proposal.d.ts.map +1 -1
- package/actions/core/getUserBalances.ts +72 -9
- package/actions/core/markets/common.ts +19 -7
- package/actions/core/markets/getMarketSnapshots.ts +293 -0
- package/actions/core/markets/getMarkets.ts +5 -0
- package/actions/core/user-positions/common.ts +1 -0
- package/actions/core/user-positions/getUserPositions.ts +2 -2
- package/actions/core/user-rewards/common.ts +1 -0
- package/actions/core/user-rewards/getUserRewards.ts +2 -2
- package/actions/governance/getCirculatingSupplySnapshots.ts +84 -0
- package/actions/governance/getDelegates.ts +12 -2
- package/actions/governance/getDiscussions.ts +8 -0
- package/actions/governance/getGovernanceTokenInfo.ts +9 -0
- package/actions/governance/getUserStakingInfo.ts +2 -2
- package/actions/governance/getUserVoteReceipt.ts +7 -6
- package/actions/governance/getUserVotingPowers.ts +2 -2
- package/actions/governance/proposals/common.ts +15 -28
- package/actions/governance/proposals/getProposals.ts +32 -11
- package/actions/governance/snapshot/getSnapshotProposals.ts +11 -1
- package/actions/index.ts +66 -55
- package/actions/morpho/getMorphoUserBalances.ts +2 -2
- package/actions/morpho/markets/common.ts +34 -13
- package/actions/morpho/markets/getMorphoMarkets.ts +13 -3
- package/actions/morpho/user-positions/common.ts +3 -0
- package/actions/morpho/user-positions/getMorphoMarketUserPositions.ts +10 -8
- package/actions/morpho/user-positions/getMorphoVaultUserPositions.ts +10 -8
- package/actions/morpho/user-rewards/common.ts +12 -5
- package/actions/morpho/user-rewards/getMorphoUserRewards.ts +10 -8
- package/actions/morpho/utils/graphql.ts +1 -1
- package/actions/morpho/vaults/common.ts +18 -10
- package/actions/morpho/vaults/getMorphoVaults.ts +12 -5
- package/client/createActions.ts +185 -136
- package/client/createMoonwellClient.ts +54 -6
- package/common/amount.ts +8 -0
- package/common/index.ts +16 -4
- package/environments/abis/index.ts +15 -13
- package/environments/abis/tokenSaleAbi.ts +782 -0
- package/environments/definitions/arbitrum/environment.ts +29 -0
- package/environments/definitions/arbitrum/tokens.ts +18 -0
- package/environments/definitions/avalanche/environment.ts +29 -0
- package/environments/definitions/avalanche/tokens.ts +18 -0
- package/environments/definitions/base/core-markets.ts +8 -0
- package/environments/definitions/base/environment.ts +1 -1
- package/environments/definitions/base/morpho-markets.ts +1 -0
- package/environments/definitions/base/morpho-vaults.ts +4 -0
- package/environments/definitions/base/tokens.ts +36 -0
- package/environments/definitions/ethereum/environment.ts +29 -0
- package/environments/definitions/ethereum/tokens.ts +17 -0
- package/environments/definitions/governance.ts +2 -2
- package/environments/definitions/moonbeam/contracts.ts +1 -0
- package/environments/definitions/moonbeam/core-markets.ts +31 -15
- package/environments/definitions/moonbeam/tokens.ts +61 -19
- package/environments/definitions/moonriver/core-markets.ts +4 -0
- package/environments/definitions/optimism/core-markets.ts +4 -0
- package/environments/definitions/optimism/environment.ts +4 -2
- package/environments/definitions/optimism/tokens.ts +12 -0
- package/environments/definitions/polygon/environment.ts +29 -0
- package/environments/definitions/polygon/tokens.ts +18 -0
- package/environments/index.ts +105 -22
- package/environments/types/config.ts +21 -5
- package/environments/types/contracts.ts +6 -0
- package/errors/version.ts +1 -1
- package/index.ts +14 -7
- package/logger/console.ts +51 -0
- package/package.json +1 -1
- package/types/circulatingSupply.ts +7 -0
- package/types/market.ts +15 -0
- package/types/morphoMarket.ts +3 -0
- package/types/morphoVault.ts +4 -2
- package/types/proposal.ts +0 -8
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
import utc from "dayjs/plugin/utc.js";
|
|
4
|
+
import type { MoonwellClient } from "../../../client/createMoonwellClient.js";
|
|
5
|
+
import {
|
|
6
|
+
Amount,
|
|
7
|
+
getEnvironmentFromArgs,
|
|
8
|
+
isStartOfDay,
|
|
9
|
+
} from "../../../common/index.js";
|
|
10
|
+
import type { NetworkParameterType } from "../../../common/types.js";
|
|
11
|
+
import type { Chain, Environment } from "../../../environments/index.js";
|
|
12
|
+
import type { MarketSnapshot } from "../../../types/market.js";
|
|
13
|
+
|
|
14
|
+
dayjs.extend(utc);
|
|
15
|
+
|
|
16
|
+
export type GetMarketSnapshotsParameters<
|
|
17
|
+
environments,
|
|
18
|
+
network extends Chain | undefined,
|
|
19
|
+
> = NetworkParameterType<environments, network> & {
|
|
20
|
+
type: "core" | "isolated";
|
|
21
|
+
marketId: `0x${string}`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type GetMarketSnapshotsReturnType = Promise<MarketSnapshot[]>;
|
|
25
|
+
|
|
26
|
+
export async function getMarketSnapshots<
|
|
27
|
+
environments,
|
|
28
|
+
Network extends Chain | undefined,
|
|
29
|
+
>(
|
|
30
|
+
client: MoonwellClient,
|
|
31
|
+
args: GetMarketSnapshotsParameters<environments, Network>,
|
|
32
|
+
): GetMarketSnapshotsReturnType {
|
|
33
|
+
const environment = getEnvironmentFromArgs(client, args);
|
|
34
|
+
|
|
35
|
+
if (!environment) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (args?.type === "core") {
|
|
40
|
+
return fetchCoreMarketSnapshots(args.marketId, environment);
|
|
41
|
+
} else {
|
|
42
|
+
return fetchIsolatedMarketSnapshots(args.marketId, environment);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function fetchCoreMarketSnapshots(
|
|
47
|
+
marketAddress: string,
|
|
48
|
+
environment: Environment,
|
|
49
|
+
): Promise<MarketSnapshot[]> {
|
|
50
|
+
const dailyData: MarketDailyData[] = [];
|
|
51
|
+
let hasNextPage = true;
|
|
52
|
+
let endCursor: string | undefined;
|
|
53
|
+
|
|
54
|
+
interface MarketDailyData {
|
|
55
|
+
totalBorrows: number;
|
|
56
|
+
totalBorrowsUSD: number;
|
|
57
|
+
totalSupplies: number;
|
|
58
|
+
totalSuppliesUSD: number;
|
|
59
|
+
timestamp: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
while (hasNextPage) {
|
|
63
|
+
const result = await axios.post<{
|
|
64
|
+
data: {
|
|
65
|
+
marketDailySnapshots: {
|
|
66
|
+
items: MarketDailyData[];
|
|
67
|
+
pageInfo: {
|
|
68
|
+
hasNextPage: boolean;
|
|
69
|
+
endCursor: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}>(environment.indexerUrl, {
|
|
74
|
+
query: `
|
|
75
|
+
query {
|
|
76
|
+
marketDailySnapshots (
|
|
77
|
+
limit: 1000,
|
|
78
|
+
orderBy: "timestamp"
|
|
79
|
+
orderDirection: "desc"
|
|
80
|
+
where: {marketAddress: "${marketAddress.toLowerCase()}", chainId: ${environment.chainId}}
|
|
81
|
+
${endCursor ? `after: "${endCursor}"` : ""}
|
|
82
|
+
) {
|
|
83
|
+
items {
|
|
84
|
+
totalBorrows
|
|
85
|
+
totalBorrowsUSD
|
|
86
|
+
totalSupplies
|
|
87
|
+
totalSuppliesUSD
|
|
88
|
+
timestamp
|
|
89
|
+
}
|
|
90
|
+
pageInfo {
|
|
91
|
+
hasNextPage
|
|
92
|
+
endCursor
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
dailyData.push(
|
|
100
|
+
...result.data.data.marketDailySnapshots.items.filter(
|
|
101
|
+
(f: { timestamp: number }) => isStartOfDay(f.timestamp),
|
|
102
|
+
),
|
|
103
|
+
);
|
|
104
|
+
hasNextPage = result.data.data.marketDailySnapshots.pageInfo.hasNextPage;
|
|
105
|
+
endCursor = result.data.data.marketDailySnapshots.pageInfo.endCursor;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (dailyData.length > 0) {
|
|
109
|
+
return dailyData.map((point: any) => {
|
|
110
|
+
const supplied = Number(point.totalSupplies);
|
|
111
|
+
const borrow = Number(point.totalBorrows);
|
|
112
|
+
|
|
113
|
+
const borrowUsd = Number(point.totalBorrowsUSD);
|
|
114
|
+
const suppliedUsd = Number(point.totalSuppliesUSD);
|
|
115
|
+
|
|
116
|
+
let liquidity = supplied - borrow > 0 ? supplied - borrow : 0;
|
|
117
|
+
let liquidityUsd = supplied - borrow > 0 ? suppliedUsd - borrowUsd : 0;
|
|
118
|
+
liquidity = Math.max(liquidity, 0);
|
|
119
|
+
liquidityUsd = Math.max(liquidityUsd, 0);
|
|
120
|
+
|
|
121
|
+
const result: MarketSnapshot = {
|
|
122
|
+
marketId: marketAddress.toLowerCase(),
|
|
123
|
+
chainId: environment.chainId,
|
|
124
|
+
timestamp: point.timestamp * 1000,
|
|
125
|
+
totalSupply: supplied,
|
|
126
|
+
totalSupplyUsd: suppliedUsd,
|
|
127
|
+
totalBorrows: borrow,
|
|
128
|
+
totalBorrowsUsd: borrowUsd,
|
|
129
|
+
totalLiquidity: liquidity,
|
|
130
|
+
totalLiquidityUsd: liquidityUsd,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return result;
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function fetchMorphoGraphQL(
|
|
141
|
+
query: string,
|
|
142
|
+
operationName?: string,
|
|
143
|
+
variables?: any,
|
|
144
|
+
) {
|
|
145
|
+
try {
|
|
146
|
+
const response = await axios.post(
|
|
147
|
+
"https://blue-api.morpho.org/graphql",
|
|
148
|
+
{ query: query, operationName, variables },
|
|
149
|
+
{ timeout: 5000 },
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
if (response.status !== 200 || response.data.errors) {
|
|
153
|
+
console.log(
|
|
154
|
+
`Non-200 (${response.statusText}
|
|
155
|
+
}) or other error from Morpho GraphQL! - ${JSON.stringify(response.data)}`,
|
|
156
|
+
);
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return response.data.data;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function fetchIsolatedMarketSnapshots(
|
|
167
|
+
marketAddress: string,
|
|
168
|
+
environment: Environment,
|
|
169
|
+
): Promise<MarketSnapshot[]> {
|
|
170
|
+
const operationName = "getMarketTotalTimeseries";
|
|
171
|
+
|
|
172
|
+
const variables = {
|
|
173
|
+
options: {
|
|
174
|
+
startTimestamp: dayjs.utc().subtract(1, "year").unix(),
|
|
175
|
+
interval: "DAY",
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const query = `
|
|
180
|
+
query getMarketTotalTimeseries($options: TimeseriesOptions) {
|
|
181
|
+
marketTotalTimeseries: marketByUniqueKey(
|
|
182
|
+
chainId: ${environment.chainId}
|
|
183
|
+
uniqueKey: "${marketAddress.toLowerCase()}"
|
|
184
|
+
) {
|
|
185
|
+
uniqueKey
|
|
186
|
+
loanAsset {
|
|
187
|
+
priceUsd
|
|
188
|
+
decimals
|
|
189
|
+
}
|
|
190
|
+
collateralAsset {
|
|
191
|
+
priceUsd
|
|
192
|
+
decimals
|
|
193
|
+
}
|
|
194
|
+
historicalState {
|
|
195
|
+
borrowAssets(options: $options) {
|
|
196
|
+
x
|
|
197
|
+
y
|
|
198
|
+
}
|
|
199
|
+
borrowAssetsUsd(options: $options) {
|
|
200
|
+
x
|
|
201
|
+
y
|
|
202
|
+
}
|
|
203
|
+
supplyAssets(options: $options) {
|
|
204
|
+
x
|
|
205
|
+
y
|
|
206
|
+
}
|
|
207
|
+
supplyAssetsUsd(options: $options) {
|
|
208
|
+
x
|
|
209
|
+
y
|
|
210
|
+
}
|
|
211
|
+
liquidityAssets(options: $options) {
|
|
212
|
+
x
|
|
213
|
+
y
|
|
214
|
+
}
|
|
215
|
+
liquidityAssetsUsd(options: $options) {
|
|
216
|
+
x
|
|
217
|
+
y
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}`;
|
|
222
|
+
|
|
223
|
+
const result = await fetchMorphoGraphQL(query, operationName, variables);
|
|
224
|
+
|
|
225
|
+
if (result) {
|
|
226
|
+
try {
|
|
227
|
+
const markets: MarketSnapshot[] =
|
|
228
|
+
result.marketTotalTimeseries.historicalState.borrowAssets.map(
|
|
229
|
+
(
|
|
230
|
+
borrowAssets: {
|
|
231
|
+
x: number;
|
|
232
|
+
y: number;
|
|
233
|
+
},
|
|
234
|
+
index: number,
|
|
235
|
+
): MarketSnapshot => {
|
|
236
|
+
const loanDecimals =
|
|
237
|
+
result.marketTotalTimeseries.loanAsset.decimals;
|
|
238
|
+
const collateralPrice =
|
|
239
|
+
result.marketTotalTimeseries.collateralAsset.priceUsd;
|
|
240
|
+
const loanPrice = result.marketTotalTimeseries.loanAsset.priceUsd;
|
|
241
|
+
|
|
242
|
+
const borrowAssetsUsd =
|
|
243
|
+
result.marketTotalTimeseries.historicalState.borrowAssetsUsd[
|
|
244
|
+
index
|
|
245
|
+
];
|
|
246
|
+
const supplyAssets =
|
|
247
|
+
result.marketTotalTimeseries.historicalState.supplyAssets[index];
|
|
248
|
+
const supplyAssetsUsd =
|
|
249
|
+
result.marketTotalTimeseries.historicalState.supplyAssetsUsd[
|
|
250
|
+
index
|
|
251
|
+
];
|
|
252
|
+
const liquidityAssets =
|
|
253
|
+
result.marketTotalTimeseries.historicalState.liquidityAssets[
|
|
254
|
+
index
|
|
255
|
+
];
|
|
256
|
+
const liquidityAssetsUsd =
|
|
257
|
+
result.marketTotalTimeseries.historicalState.liquidityAssetsUsd[
|
|
258
|
+
index
|
|
259
|
+
];
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
chainId: environment.chainId,
|
|
263
|
+
timestamp: borrowAssets.x * 1000,
|
|
264
|
+
marketId: marketAddress.toLowerCase(),
|
|
265
|
+
totalBorrows: new Amount(
|
|
266
|
+
BigInt(borrowAssets.y),
|
|
267
|
+
Number(loanDecimals),
|
|
268
|
+
).value,
|
|
269
|
+
totalBorrowsUsd: Number(borrowAssetsUsd.y),
|
|
270
|
+
totalSupply:
|
|
271
|
+
(new Amount(BigInt(supplyAssets.y), Number(loanDecimals))
|
|
272
|
+
.value *
|
|
273
|
+
loanPrice) /
|
|
274
|
+
collateralPrice,
|
|
275
|
+
totalSupplyUsd: Number(supplyAssetsUsd.y),
|
|
276
|
+
totalLiquidity:
|
|
277
|
+
(new Amount(BigInt(liquidityAssets.y), Number(loanDecimals))
|
|
278
|
+
.value *
|
|
279
|
+
loanPrice) /
|
|
280
|
+
collateralPrice,
|
|
281
|
+
totalLiquidityUsd: Number(liquidityAssetsUsd.y),
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
return markets;
|
|
287
|
+
} catch (ex) {
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { Chain } from "viem";
|
|
|
2
2
|
import type { MoonwellClient } from "../../../client/createMoonwellClient.js";
|
|
3
3
|
import { getEnvironmentsFromArgs } from "../../../common/index.js";
|
|
4
4
|
import type { NetworkParameterType } from "../../../common/types.js";
|
|
5
|
+
import * as logger from "../../../logger/console.js";
|
|
5
6
|
import type { Market } from "../../../types/market.js";
|
|
6
7
|
import { getMarketsData } from "./common.js";
|
|
7
8
|
|
|
@@ -21,9 +22,13 @@ export async function getMarkets<
|
|
|
21
22
|
): GetMarketsReturnType {
|
|
22
23
|
const environments = getEnvironmentsFromArgs(client, args);
|
|
23
24
|
|
|
25
|
+
const logId = logger.start("getMarkets", "Starting to get markets...");
|
|
26
|
+
|
|
24
27
|
const result = await Promise.all(
|
|
25
28
|
environments.map((environment) => getMarketsData(environment)),
|
|
26
29
|
);
|
|
27
30
|
|
|
31
|
+
logger.end(logId);
|
|
32
|
+
|
|
28
33
|
return result.flat();
|
|
29
34
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Address, Chain } from "viem";
|
|
2
2
|
import type { MoonwellClient } from "../../../client/createMoonwellClient.js";
|
|
3
3
|
import { getEnvironmentsFromArgs } from "../../../common/index.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { OptionalNetworkParameterType } from "../../../common/types.js";
|
|
5
5
|
import type { UserPosition } from "../../../types/userPosition.js";
|
|
6
6
|
import { getUserPositionData } from "./common.js";
|
|
7
7
|
|
|
8
8
|
export type GetUserPositionsParameters<
|
|
9
9
|
environments,
|
|
10
10
|
network extends Chain | undefined,
|
|
11
|
-
> =
|
|
11
|
+
> = OptionalNetworkParameterType<environments, network> & {
|
|
12
12
|
/** User address*/
|
|
13
13
|
userAddress: Address;
|
|
14
14
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { MoonwellClient } from "../../../client/createMoonwellClient.js";
|
|
3
3
|
import { getEnvironmentsFromArgs } from "../../../common/index.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { OptionalNetworkParameterType } from "../../../common/types.js";
|
|
5
5
|
import type { Chain } from "../../../environments/index.js";
|
|
6
6
|
import type { UserReward } from "../../../types/userReward.js";
|
|
7
7
|
import { getUserRewardsData } from "./common.js";
|
|
@@ -9,7 +9,7 @@ import { getUserRewardsData } from "./common.js";
|
|
|
9
9
|
export type GetUserRewardsParameters<
|
|
10
10
|
environments,
|
|
11
11
|
network extends Chain | undefined,
|
|
12
|
-
> =
|
|
12
|
+
> = OptionalNetworkParameterType<environments, network> & {
|
|
13
13
|
/** User address*/
|
|
14
14
|
userAddress: Address;
|
|
15
15
|
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import type { MoonwellClient } from "../../client/createMoonwellClient.js";
|
|
3
|
+
import { getEnvironmentFromArgs } from "../../common/index.js";
|
|
4
|
+
import type { OptionalNetworkParameterType } from "../../common/types.js";
|
|
5
|
+
import type { Chain } from "../../environments/index.js";
|
|
6
|
+
import type { CirculatingSupplySnapshot } from "../../types/circulatingSupply.js";
|
|
7
|
+
|
|
8
|
+
export type GetCirculatingSupplySnapshotsParameters<
|
|
9
|
+
environments,
|
|
10
|
+
network extends Chain | undefined,
|
|
11
|
+
> = OptionalNetworkParameterType<environments, network>;
|
|
12
|
+
|
|
13
|
+
export type GetCirculatingSupplySnapshotsReturnType = Promise<
|
|
14
|
+
CirculatingSupplySnapshot[]
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
export async function getCirculatingSupplySnapshots<
|
|
18
|
+
environments,
|
|
19
|
+
Network extends Chain | undefined,
|
|
20
|
+
>(
|
|
21
|
+
client: MoonwellClient,
|
|
22
|
+
args?: GetCirculatingSupplySnapshotsParameters<environments, Network>,
|
|
23
|
+
): GetCirculatingSupplySnapshotsReturnType {
|
|
24
|
+
const environment = getEnvironmentFromArgs(client, args);
|
|
25
|
+
|
|
26
|
+
if (!environment) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const response = await axios.post<{
|
|
32
|
+
data: {
|
|
33
|
+
circulatingSupplyDailySnapshots: {
|
|
34
|
+
items: {
|
|
35
|
+
chainId: number;
|
|
36
|
+
tokenAddress: string;
|
|
37
|
+
circulatingSupply: number;
|
|
38
|
+
timestamp: number;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}>(environment.indexerUrl, {
|
|
43
|
+
query: `
|
|
44
|
+
{
|
|
45
|
+
circulatingSupplyDailySnapshots(
|
|
46
|
+
where: { chainId: ${environment.chainId} }
|
|
47
|
+
orderBy: "timestamp"
|
|
48
|
+
orderDirection: "desc"
|
|
49
|
+
limit: 1000
|
|
50
|
+
) {
|
|
51
|
+
items {
|
|
52
|
+
chainId
|
|
53
|
+
tokenAddress
|
|
54
|
+
circulatingSupply
|
|
55
|
+
timestamp
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
response.status === 200 &&
|
|
64
|
+
response.data?.data?.circulatingSupplyDailySnapshots
|
|
65
|
+
) {
|
|
66
|
+
return response.data?.data?.circulatingSupplyDailySnapshots.items.map(
|
|
67
|
+
(item) => ({
|
|
68
|
+
chainId: item.chainId,
|
|
69
|
+
token: Object.values(environment.config.tokens).find(
|
|
70
|
+
(token) =>
|
|
71
|
+
token.address.toLowerCase() === item.tokenAddress.toLowerCase(),
|
|
72
|
+
)!,
|
|
73
|
+
circulatingSupply: item.circulatingSupply,
|
|
74
|
+
timestamp: item.timestamp,
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
} else {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
} catch (ex) {
|
|
81
|
+
console.error("An error occured while fetching getStakingSnapshots...", ex);
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -2,7 +2,11 @@ import axios from "axios";
|
|
|
2
2
|
import { isAddress } from "viem";
|
|
3
3
|
import type { MoonwellClient } from "../../client/createMoonwellClient.js";
|
|
4
4
|
import { HttpRequestError } from "../../common/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type Environment,
|
|
7
|
+
publicEnvironments,
|
|
8
|
+
} from "../../environments/index.js";
|
|
9
|
+
import * as logger from "../../logger/console.js";
|
|
6
10
|
import type { Delegate } from "../../types/delegate.js";
|
|
7
11
|
|
|
8
12
|
export type GetDelegatesErrorType = HttpRequestError;
|
|
@@ -19,6 +23,8 @@ export async function getDelegates(
|
|
|
19
23
|
): GetDelegatesReturnType {
|
|
20
24
|
let users: Delegate[] = [];
|
|
21
25
|
|
|
26
|
+
const logId = logger.start("getDelegates", "Starting to get delegates...");
|
|
27
|
+
|
|
22
28
|
const getUsersPaginated = async (page = 0) => {
|
|
23
29
|
const response = await axios.get<{
|
|
24
30
|
directory_items: {
|
|
@@ -91,7 +97,9 @@ export async function getDelegates(
|
|
|
91
97
|
users: users.map((r) => r.wallet),
|
|
92
98
|
});
|
|
93
99
|
//Get delegate voting powers
|
|
94
|
-
const envs = Object.values(client.environments)
|
|
100
|
+
const envs = Object.values(client.environments as Environment[]).filter(
|
|
101
|
+
(env) => env.contracts.views !== undefined,
|
|
102
|
+
);
|
|
95
103
|
|
|
96
104
|
const votingPowers = await Promise.all(
|
|
97
105
|
users.map(async (user) =>
|
|
@@ -105,6 +113,8 @@ export async function getDelegates(
|
|
|
105
113
|
),
|
|
106
114
|
);
|
|
107
115
|
|
|
116
|
+
logger.end(logId);
|
|
117
|
+
|
|
108
118
|
users = users.map((user, index) => {
|
|
109
119
|
let votingPower: {
|
|
110
120
|
[chainId: string]: number;
|
|
@@ -2,6 +2,7 @@ import axios from "axios";
|
|
|
2
2
|
import { isEqual, uniqWith } from "lodash";
|
|
3
3
|
import type { MoonwellClient } from "../../client/createMoonwellClient.js";
|
|
4
4
|
import { HttpRequestError } from "../../common/index.js";
|
|
5
|
+
import * as logger from "../../logger/console.js";
|
|
5
6
|
import type { Discussion } from "../../types/discussion.js";
|
|
6
7
|
|
|
7
8
|
export type GetDiscussionsReturnType = Promise<Discussion[]>;
|
|
@@ -35,6 +36,11 @@ export async function getDiscussions(
|
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
38
|
|
|
39
|
+
const logId = logger.start(
|
|
40
|
+
"getDiscussions",
|
|
41
|
+
"Starting to get discussions...",
|
|
42
|
+
);
|
|
43
|
+
|
|
38
44
|
const moonwellProposalsResult = await axios.get<ForumTopicRequestResponse>(
|
|
39
45
|
"https://forum.moonwell.fi/c/proposals/moonwell-improvement-proposals/9/l/latest.json",
|
|
40
46
|
);
|
|
@@ -54,6 +60,8 @@ export async function getDiscussions(
|
|
|
54
60
|
throw new HttpRequestError(communityProposalsResult.statusText);
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
logger.end(logId);
|
|
64
|
+
|
|
57
65
|
const toType = (item: ForumTopicRequestResponse) => {
|
|
58
66
|
return item.topic_list.topics.map((topic) => {
|
|
59
67
|
const result: Discussion = {
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type GovernanceToken,
|
|
5
5
|
publicEnvironments,
|
|
6
6
|
} from "../../environments/index.js";
|
|
7
|
+
import * as logger from "../../logger/console.js";
|
|
7
8
|
|
|
8
9
|
export type GetGovernanceTokenInfoParameters = {
|
|
9
10
|
governanceToken: GovernanceToken;
|
|
@@ -20,10 +21,17 @@ export async function getGovernanceTokenInfo(
|
|
|
20
21
|
_client: MoonwellClient,
|
|
21
22
|
args: GetGovernanceTokenInfoParameters,
|
|
22
23
|
): GetGovernanceTokenInfoReturnType {
|
|
24
|
+
const logId = logger.start(
|
|
25
|
+
"getGovernanceTokenInfo",
|
|
26
|
+
"Starting to get governance token info...",
|
|
27
|
+
);
|
|
28
|
+
|
|
23
29
|
if (args.governanceToken === "WELL") {
|
|
24
30
|
const totalSupply =
|
|
25
31
|
await publicEnvironments.moonbeam.contracts.governanceToken.read.totalSupply();
|
|
26
32
|
|
|
33
|
+
logger.end(logId);
|
|
34
|
+
|
|
27
35
|
return {
|
|
28
36
|
totalSupply: new Amount(totalSupply || 0n, 18),
|
|
29
37
|
};
|
|
@@ -31,6 +39,7 @@ export async function getGovernanceTokenInfo(
|
|
|
31
39
|
const totalSupply =
|
|
32
40
|
await publicEnvironments.moonriver.contracts.governanceToken.read.totalSupply();
|
|
33
41
|
|
|
42
|
+
logger.end(logId);
|
|
34
43
|
return {
|
|
35
44
|
totalSupply: new Amount(totalSupply || 0n, 18),
|
|
36
45
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, Chain } from "viem";
|
|
2
2
|
import type { MoonwellClient } from "../../client/createMoonwellClient.js";
|
|
3
3
|
import { Amount, getEnvironmentsFromArgs } from "../../common/index.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { OptionalNetworkParameterType } from "../../common/types.js";
|
|
5
5
|
import {
|
|
6
6
|
type Environment,
|
|
7
7
|
type TokensType,
|
|
@@ -12,7 +12,7 @@ import type { UserStakingInfo } from "../../types/staking.js";
|
|
|
12
12
|
export type GetUserStakingInfoParameters<
|
|
13
13
|
environments,
|
|
14
14
|
network extends Chain | undefined,
|
|
15
|
-
> =
|
|
15
|
+
> = OptionalNetworkParameterType<environments, network> & {
|
|
16
16
|
/** User address*/
|
|
17
17
|
userAddress: Address;
|
|
18
18
|
};
|
|
@@ -28,7 +28,7 @@ export async function getUserVoteReceipt<
|
|
|
28
28
|
client: MoonwellClient,
|
|
29
29
|
args: GetUserVoteReceiptParameters<environments, Network>,
|
|
30
30
|
): GetUserVoteReceiptReturnType {
|
|
31
|
-
|
|
31
|
+
const { proposalId, userAddress } = args;
|
|
32
32
|
|
|
33
33
|
const environment = getEnvironmentFromArgs(client, args);
|
|
34
34
|
|
|
@@ -37,12 +37,13 @@ export async function getUserVoteReceipt<
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
let isMultichain = false;
|
|
40
|
+
let getReceiptProposalId = proposalId;
|
|
40
41
|
|
|
41
42
|
if (environment.contracts.multichainGovernor) {
|
|
42
43
|
if (environment.custom?.governance?.proposalIdOffset) {
|
|
43
44
|
if (proposalId > environment.custom?.governance?.proposalIdOffset) {
|
|
44
45
|
isMultichain = true;
|
|
45
|
-
|
|
46
|
+
getReceiptProposalId =
|
|
46
47
|
proposalId - environment.custom?.governance?.proposalIdOffset;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -55,7 +56,7 @@ export async function getUserVoteReceipt<
|
|
|
55
56
|
|
|
56
57
|
const receipt =
|
|
57
58
|
await environment.contracts.multichainGovernor?.read.getReceipt([
|
|
58
|
-
BigInt(
|
|
59
|
+
BigInt(getReceiptProposalId),
|
|
59
60
|
userAddress,
|
|
60
61
|
]);
|
|
61
62
|
|
|
@@ -77,14 +78,14 @@ export async function getUserVoteReceipt<
|
|
|
77
78
|
if (multichainEnvironment) {
|
|
78
79
|
const receipt =
|
|
79
80
|
await multichainEnvironment.contracts.voteCollector?.read.getReceipt([
|
|
80
|
-
BigInt(
|
|
81
|
+
BigInt(getReceiptProposalId),
|
|
81
82
|
userAddress,
|
|
82
83
|
]);
|
|
83
84
|
|
|
84
85
|
const [hasVoted, voteValue, votes] = receipt || [false, 0, 0];
|
|
85
86
|
|
|
86
87
|
result.push({
|
|
87
|
-
chainId:
|
|
88
|
+
chainId: multichainEnvironment.chainId,
|
|
88
89
|
proposalId,
|
|
89
90
|
account: userAddress,
|
|
90
91
|
option: voteValue,
|
|
@@ -95,7 +96,7 @@ export async function getUserVoteReceipt<
|
|
|
95
96
|
}
|
|
96
97
|
} else {
|
|
97
98
|
const receipt = await environment.contracts.governor?.read.getReceipt([
|
|
98
|
-
BigInt(
|
|
99
|
+
BigInt(getReceiptProposalId),
|
|
99
100
|
userAddress,
|
|
100
101
|
]);
|
|
101
102
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type Address, zeroAddress } from "viem";
|
|
2
2
|
import type { MoonwellClient } from "../../client/createMoonwellClient.js";
|
|
3
3
|
import { Amount, getEnvironmentsFromArgs } from "../../common/index.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { OptionalNetworkParameterType } from "../../common/types.js";
|
|
5
5
|
import type { Chain, GovernanceToken } from "../../environments/index.js";
|
|
6
6
|
import type { UserVotingPowers } from "../../types/userVotingPowers.js";
|
|
7
7
|
|
|
8
8
|
export type GetUserVotingPowersParameters<
|
|
9
9
|
environments,
|
|
10
10
|
network extends Chain | undefined,
|
|
11
|
-
> =
|
|
11
|
+
> = OptionalNetworkParameterType<environments, network> & {
|
|
12
12
|
/** Governance token */
|
|
13
13
|
governanceToken: GovernanceToken;
|
|
14
14
|
|