@reef-chain/react-lib 2.0.0

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.
Files changed (141) hide show
  1. package/README.md +32 -0
  2. package/dist/api/index.d.ts +2 -0
  3. package/dist/api/prices.d.ts +8 -0
  4. package/dist/api/tokens.d.ts +2 -0
  5. package/dist/appState/accountState.d.ts +15 -0
  6. package/dist/appState/accountStateUtil.d.ts +6 -0
  7. package/dist/appState/appState.d.ts +3 -0
  8. package/dist/appState/index.d.ts +1 -0
  9. package/dist/appState/nftTokenState.d.ts +12 -0
  10. package/dist/appState/providerState.d.ts +4 -0
  11. package/dist/appState/tokenState.d.ts +13 -0
  12. package/dist/appState/updateStateModel.d.ts +14 -0
  13. package/dist/appState/util.d.ts +22 -0
  14. package/dist/assets/abi/ERC1155Uri.d.ts +2 -0
  15. package/dist/assets/abi/ERC20.d.ts +2 -0
  16. package/dist/assets/abi/ERC721Uri.d.ts +2 -0
  17. package/dist/assets/abi/ReefswapFactory.d.ts +2 -0
  18. package/dist/assets/abi/ReefswapPair.d.ts +2 -0
  19. package/dist/assets/abi/ReefswapRouter.d.ts +2 -0
  20. package/dist/components/AccountSelector/AccountInlineInfo.d.ts +10 -0
  21. package/dist/components/AccountSelector/AccountListModal.d.ts +11 -0
  22. package/dist/components/AccountSelector/AccountSelector.d.ts +17 -0
  23. package/dist/components/AddLiquidity/index.d.ts +10 -0
  24. package/dist/components/EvmBind/EvmBindComponent.d.ts +15 -0
  25. package/dist/components/OverlayAction/index.d.ts +12 -0
  26. package/dist/components/PoolActions/ConfirmPopups/Address.d.ts +7 -0
  27. package/dist/components/PoolActions/ConfirmPopups/Bond.d.ts +11 -0
  28. package/dist/components/PoolActions/ConfirmPopups/Provide.d.ts +14 -0
  29. package/dist/components/PoolActions/ConfirmPopups/Send.d.ts +11 -0
  30. package/dist/components/PoolActions/ConfirmPopups/SummaryItem.d.ts +7 -0
  31. package/dist/components/PoolActions/ConfirmPopups/Token.d.ts +11 -0
  32. package/dist/components/PoolActions/ConfirmPopups/Trade.d.ts +14 -0
  33. package/dist/components/PoolActions/ConfirmPopups/Withdraw.d.ts +15 -0
  34. package/dist/components/PoolActions/Finalizing.d.ts +2 -0
  35. package/dist/components/PoolActions/Provide.d.ts +19 -0
  36. package/dist/components/PoolActions/TokenDropdown.d.ts +9 -0
  37. package/dist/components/PoolActions/TokenField.d.ts +11 -0
  38. package/dist/components/PoolActions/Trade.d.ts +23 -0
  39. package/dist/components/PoolActions/Withdraw.d.ts +12 -0
  40. package/dist/components/PoolActions/index.d.ts +6 -0
  41. package/dist/components/RemoveLiquidity/RemoveConfirmationModal.d.ts +10 -0
  42. package/dist/components/RemoveLiquidity/index.d.ts +7 -0
  43. package/dist/components/SelectToken/index.d.ts +14 -0
  44. package/dist/components/SwapComponent/SwapConfirmationModal.d.ts +10 -0
  45. package/dist/components/SwapComponent/index.d.ts +11 -0
  46. package/dist/components/TokenFields/TokenAmountField.d.ts +24 -0
  47. package/dist/components/TokenFields/TokenAmountView.d.ts +8 -0
  48. package/dist/components/TokenFields/index.d.ts +2 -0
  49. package/dist/components/TransactionSettings/index.d.ts +10 -0
  50. package/dist/components/Transfer/Send.d.ts +14 -0
  51. package/dist/components/Transfer/SendConfirmationModal.d.ts +9 -0
  52. package/dist/components/Transfer/TransferComponent.d.ts +14 -0
  53. package/dist/components/Transfer/index.d.ts +2 -0
  54. package/dist/components/common/Alert/index.d.ts +2 -0
  55. package/dist/components/common/Button/index.d.ts +27 -0
  56. package/dist/components/common/Card/index.d.ts +19 -0
  57. package/dist/components/common/Display/index.d.ts +35 -0
  58. package/dist/components/common/Dropdown/index.d.ts +11 -0
  59. package/dist/components/common/Icons/index.d.ts +33 -0
  60. package/dist/components/common/Input/index.d.ts +52 -0
  61. package/dist/components/common/Label/index.d.ts +12 -0
  62. package/dist/components/common/List/index.d.ts +10 -0
  63. package/dist/components/common/Loading/index.d.ts +9 -0
  64. package/dist/components/common/Modal/index.d.ts +27 -0
  65. package/dist/components/common/Text/index.d.ts +18 -0
  66. package/dist/components/common/Tooltip/index.d.ts +6 -0
  67. package/dist/components/common/index.d.ts +13 -0
  68. package/dist/components/index.d.ts +12 -0
  69. package/dist/graphql/apollo.d.ts +15 -0
  70. package/dist/graphql/evmEvents.d.ts +6 -0
  71. package/dist/graphql/gql.d.ts +3 -0
  72. package/dist/graphql/index.d.ts +1 -0
  73. package/dist/graphql/pools.d.ts +323 -0
  74. package/dist/graphql/utils.d.ts +5 -0
  75. package/dist/hooks/index.d.ts +16 -0
  76. package/dist/hooks/poolHooks.d.ts +25 -0
  77. package/dist/hooks/useAddLiquidity.d.ts +29 -0
  78. package/dist/hooks/useAllNfts.d.ts +4 -0
  79. package/dist/hooks/useAllPools.d.ts +7 -0
  80. package/dist/hooks/useAsyncEffect.d.ts +2 -0
  81. package/dist/hooks/useFromTime.d.ts +7 -0
  82. package/dist/hooks/useInitReefState.d.ts +2 -0
  83. package/dist/hooks/useKeepTokenUpdated.d.ts +3 -0
  84. package/dist/hooks/useLoadPool.d.ts +14 -0
  85. package/dist/hooks/useLoadPools.d.ts +4 -0
  86. package/dist/hooks/useLoadSignerTokens.d.ts +3 -0
  87. package/dist/hooks/useLoadSigners.d.ts +11 -0
  88. package/dist/hooks/useLoader.d.ts +9 -0
  89. package/dist/hooks/useObservableState.d.ts +2 -0
  90. package/dist/hooks/usePoolData.d.ts +34 -0
  91. package/dist/hooks/usePoolLists.d.ts +25 -0
  92. package/dist/hooks/usePoolStats.d.ts +29 -0
  93. package/dist/hooks/usePriceEstimator.d.ts +2 -0
  94. package/dist/hooks/useProvider.d.ts +3 -0
  95. package/dist/hooks/useReefPriceInterval.d.ts +2 -0
  96. package/dist/hooks/useRemoveLiquidity.d.ts +28 -0
  97. package/dist/hooks/useSwapState.d.ts +31 -0
  98. package/dist/hooks/useUpdateAccountBalance.d.ts +2 -0
  99. package/dist/hooks/useUpdateAmount.d.ts +11 -0
  100. package/dist/hooks/userInterval.d.ts +2 -0
  101. package/dist/index.css +2 -0
  102. package/dist/index.css.map +1 -0
  103. package/dist/index.d.ts +10 -0
  104. package/dist/index.js +5 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/index.modern.js +5 -0
  107. package/dist/index.modern.js.map +1 -0
  108. package/dist/rpc/accounts.d.ts +16 -0
  109. package/dist/rpc/index.d.ts +3 -0
  110. package/dist/rpc/rpc.d.ts +20 -0
  111. package/dist/rpc/tokens.d.ts +7 -0
  112. package/dist/state/index.d.ts +6 -0
  113. package/dist/state/network.d.ts +26 -0
  114. package/dist/state/nft.d.ts +14 -0
  115. package/dist/state/pool.d.ts +33 -0
  116. package/dist/state/settings.d.ts +15 -0
  117. package/dist/state/token.d.ts +71 -0
  118. package/dist/state/types.d.ts +76 -0
  119. package/dist/store/actionTypes.d.ts +16 -0
  120. package/dist/store/actions/addLiquidity.d.ts +21 -0
  121. package/dist/store/actions/defaultActions.d.ts +70 -0
  122. package/dist/store/actions/index.d.ts +4 -0
  123. package/dist/store/actions/removeLiquidity.d.ts +9 -0
  124. package/dist/store/actions/swap.d.ts +22 -0
  125. package/dist/store/index.d.ts +2 -0
  126. package/dist/store/reducers/addLiquidity.d.ts +15 -0
  127. package/dist/store/reducers/index.d.ts +3 -0
  128. package/dist/store/reducers/removeLiquidity.d.ts +14 -0
  129. package/dist/store/reducers/swap.d.ts +15 -0
  130. package/dist/utils/bindUtil.d.ts +10 -0
  131. package/dist/utils/dataWithProgress.d.ts +8 -0
  132. package/dist/utils/index.d.ts +11 -0
  133. package/dist/utils/math.d.ts +55 -0
  134. package/dist/utils/modalUtil.d.ts +2 -0
  135. package/dist/utils/nftUtil.d.ts +7 -0
  136. package/dist/utils/providerUtil.d.ts +3 -0
  137. package/dist/utils/rpcErrorMessageHandler.d.ts +4 -0
  138. package/dist/utils/tokenUtil.d.ts +12 -0
  139. package/dist/utils/transactionUtil.d.ts +37 -0
  140. package/dist/utils/utils.d.ts +32 -0
  141. package/package.json +97 -0
@@ -0,0 +1,16 @@
1
+ import type { InjectedAccountWithMeta, InjectedExtension } from '@polkadot/extension-inject/types';
2
+ import { Provider, Signer } from '@reef-chain/evm-provider';
3
+ import type { Signer as InjectedSigner } from '@polkadot/api/types';
4
+ import type { InjectedAccount, InjectedAccountWithMeta as InjectedAccountWithMetaReef, InjectedExtension as InjectedExtensionReef } from '@reef-defi/extension-inject/types';
5
+ import { BigNumber } from 'ethers';
6
+ import { AccountJson } from '@reef-defi/extension-base/background/types';
7
+ import { ReefSigner } from '../state/types';
8
+ export declare const getAccountSigner: (address: string, source: string, provider: Provider, injSigner?: InjectedSigner) => Promise<Signer | undefined>;
9
+ export declare const getReefCoinBalance: (address: string, provider: Provider) => Promise<BigNumber>;
10
+ export declare const metaAccountToSigner: (account: InjectedAccountWithMeta | InjectedAccountWithMetaReef, provider: Provider, injSigner: InjectedSigner) => Promise<ReefSigner | undefined>;
11
+ export declare const metaAccountsToSigners: (accounts: (InjectedAccountWithMeta | InjectedAccountWithMetaReef)[], provider: Provider, sign: InjectedSigner) => Promise<ReefSigner[]>;
12
+ export declare const accountToSigner: (account: InjectedAccount, provider: Provider, sign: InjectedSigner, source: string) => Promise<ReefSigner>;
13
+ export declare function accountJsonToMeta(acc: AccountJson, source?: string): InjectedAccountWithMeta;
14
+ export declare const getExtensionSigners: (extensions: InjectedExtension[] | InjectedExtensionReef[], provider: Provider) => Promise<ReefSigner[]>;
15
+ export declare const bindSigner: (signer: Signer) => Promise<void>;
16
+ export declare const getSignerIdent: (signer: ReefSigner) => string;
@@ -0,0 +1,3 @@
1
+ export * from './rpc';
2
+ export * from './tokens';
3
+ export * from './accounts';
@@ -0,0 +1,20 @@
1
+ import { Signer } from '@reef-chain/evm-provider';
2
+ import { BigNumber, Contract } from 'ethers';
3
+ import { ReefSigner, Token } from '../state';
4
+ export declare const checkIfERC20ContractExist: (address: string, signer: Signer) => Promise<{
5
+ name: string;
6
+ symbol: string;
7
+ decimals: number;
8
+ } | undefined>;
9
+ export declare const getREEF20Contract: (address: string, signer: Signer) => Promise<{
10
+ contract: Contract;
11
+ values: {
12
+ name: string;
13
+ symbol: string;
14
+ decimals: number;
15
+ };
16
+ } | null>;
17
+ export declare const contractToToken: (tokenContract: Contract, signer: ReefSigner) => Promise<Token>;
18
+ export declare const balanceOf: (address: string, balanceAddress: string, signer: Signer) => Promise<BigNumber | null>;
19
+ export declare const getReefswapRouter: (address: string, signer: Signer) => Contract;
20
+ export declare const getReefswapFactory: (address: string, signer: Signer) => Contract;
@@ -0,0 +1,7 @@
1
+ import { Signer } from '@reef-chain/evm-provider';
2
+ import { BasicToken, Token, TokenWithAmount } from '../state';
3
+ export declare const retrieveTokenAddresses: (tokens: Token[]) => string[];
4
+ export declare const approveTokenAmount: (token: TokenWithAmount, routerAddress: string, signer: Signer) => Promise<void>;
5
+ export declare const approveAmount: (from: string, to: string, amount: string, signer: Signer) => Promise<void>;
6
+ export declare const loadToken: (address: string, signer: Signer, iconUrl?: string) => Promise<Token | null>;
7
+ export declare const loadTokens: (addresses: BasicToken[], signer: Signer) => Promise<(Token | null)[]>;
@@ -0,0 +1,6 @@
1
+ export * from './network';
2
+ export * from './settings';
3
+ export * from './token';
4
+ export * from './nft';
5
+ export * from './pool';
6
+ export * from './types';
@@ -0,0 +1,26 @@
1
+ import { Token } from './token';
2
+ export type AvailableNetworks = 'mainnet' | 'testnet' | 'localhost';
3
+ export interface Bond {
4
+ name: string;
5
+ description: string;
6
+ contractAddress: string;
7
+ validatorAddress: string;
8
+ stake: Token;
9
+ farm: Token;
10
+ apy: string;
11
+ }
12
+ export interface Network {
13
+ rpcUrl: string;
14
+ reefscanUrl: string;
15
+ verificationApiUrl: string;
16
+ factoryAddress: string;
17
+ routerAddress: string;
18
+ name: AvailableNetworks;
19
+ graphqlExplorerUrl: string;
20
+ graphqlDexsUrl: string;
21
+ genesisHash: string;
22
+ bonds: Bond[];
23
+ }
24
+ export declare const SS58_REEF = 42;
25
+ export type Networks = Record<AvailableNetworks, Network>;
26
+ export declare const availableNetworks: Networks;
@@ -0,0 +1,14 @@
1
+ import { ContractType, Token } from './token';
2
+ export interface ERC721ContractData {
3
+ type: ContractType.ERC721;
4
+ name: string;
5
+ symbol: string;
6
+ }
7
+ export interface ERC1155ContractData {
8
+ type: ContractType.ERC1155;
9
+ }
10
+ export interface NFT extends Token {
11
+ nftId: string;
12
+ contractType: ContractType;
13
+ mimetype?: string;
14
+ }
@@ -0,0 +1,33 @@
1
+ import { Token } from './token';
2
+ export interface Pool {
3
+ token1: Token;
4
+ token2: Token;
5
+ decimals: number;
6
+ reserve1: string;
7
+ reserve2: string;
8
+ totalSupply: string;
9
+ poolAddress: string;
10
+ userPoolBalance: string;
11
+ }
12
+ export interface BasicPoolInfo {
13
+ address: string;
14
+ token1: string;
15
+ token2: string;
16
+ symbol1: string;
17
+ symbol2: string;
18
+ decimals1: number;
19
+ decimals2: number;
20
+ }
21
+ export interface LastPoolReserves extends BasicPoolInfo {
22
+ reserved1: string;
23
+ reserved2: string;
24
+ }
25
+ export interface PoolWithReserves extends LastPoolReserves {
26
+ name1: string;
27
+ name2: string;
28
+ iconUrl1: string;
29
+ iconUrl2: string;
30
+ }
31
+ export type TokenPrices = {
32
+ [tokenAddress: string]: number;
33
+ };
@@ -0,0 +1,15 @@
1
+ export interface Settings {
2
+ gasLimit: string;
3
+ percentage: number;
4
+ deadline: number;
5
+ }
6
+ export declare const DEFAULT_SLIPPAGE_TOLERANCE = 0.8;
7
+ export declare const MAX_SLIPPAGE_TOLERANCE = 0.5;
8
+ export declare const DEFAULT_DEADLINE = 1;
9
+ export declare const DEFAULT_GAS_LIMIT = "0.000003";
10
+ export declare const REMOVE_DEFAULT_SLIPPAGE_TOLERANCE = 5;
11
+ export declare const defaultSettings: () => Settings;
12
+ export declare const resolveSettings: ({ deadline, gasLimit, percentage }: Settings, defaultPercentage?: number) => Settings;
13
+ export declare const toGasLimitObj: (gasLimit: string) => {
14
+ gasLimit: string;
15
+ };
@@ -0,0 +1,71 @@
1
+ import { BigNumber } from 'ethers';
2
+ import { BigNumber as BN } from 'bignumber.js';
3
+ import { TokenPrices } from './pool';
4
+ import { NFT } from './nft';
5
+ export declare enum ContractType {
6
+ ERC20 = "ERC20",
7
+ ERC721 = "ERC721",
8
+ ERC1155 = "ERC1155",
9
+ other = "other"
10
+ }
11
+ export interface ERC20ContractData {
12
+ name: string;
13
+ symbol: string;
14
+ decimals: number;
15
+ }
16
+ export interface BasicToken {
17
+ name: string;
18
+ address: string;
19
+ iconUrl: string;
20
+ }
21
+ export interface Token extends BasicToken {
22
+ symbol: string;
23
+ balance: BigNumber;
24
+ decimals: number;
25
+ }
26
+ export interface TokenWithAmount extends Token {
27
+ amount: string;
28
+ price: number;
29
+ isEmpty: boolean;
30
+ }
31
+ export interface TokenState {
32
+ index: number;
33
+ amount: string;
34
+ price: number;
35
+ }
36
+ export interface NFTMetadata {
37
+ image?: string;
38
+ iconUrl?: string;
39
+ name?: string;
40
+ mimetype?: string;
41
+ }
42
+ export interface TransferExtrinsic {
43
+ blockId: string;
44
+ index: number;
45
+ hash: string;
46
+ }
47
+ export interface TokenTransfer {
48
+ from: string;
49
+ to: string;
50
+ inbound: boolean;
51
+ timestamp: number;
52
+ token: Token | NFT;
53
+ extrinsic: TransferExtrinsic;
54
+ url: string;
55
+ }
56
+ export declare const defaultTokenState: (index?: number) => TokenState;
57
+ export declare const createEmptyToken: () => Token;
58
+ export declare const createEmptyTokenWithAmount: (isEmpty?: boolean) => TokenWithAmount;
59
+ export declare const toTokenAmount: (token: Token, state: TokenState) => TokenWithAmount;
60
+ export declare function isNativeTransfer(token: Token): boolean;
61
+ export declare const checkMinExistentialReefAmount: (token: TokenWithAmount, reefBalance: BigNumber) => {
62
+ valid: boolean;
63
+ message?: string | undefined;
64
+ maxTransfer: BigNumber;
65
+ };
66
+ export declare const ensureTokenAmount: (token: TokenWithAmount) => void;
67
+ export declare const ensureExistentialReefAmount: (token: TokenWithAmount, reefBalance: BigNumber) => void;
68
+ export declare const REEF_TOKEN: Token;
69
+ export declare const reefTokenWithAmount: () => TokenWithAmount;
70
+ export declare const getTokenPrice: (address: string, prices: TokenPrices) => BN;
71
+ export declare const isNativeAddress: (toAddress: string) => boolean;
@@ -0,0 +1,76 @@
1
+ import { Signer } from '@reef-chain/evm-provider';
2
+ import { BigNumber } from 'ethers';
3
+ import type { Signer as InjectedSigner } from '@polkadot/api/types';
4
+ export interface ReefSigner {
5
+ name: string;
6
+ signer: Signer;
7
+ balance: BigNumber;
8
+ address: string;
9
+ evmAddress: string;
10
+ isEvmClaimed: boolean;
11
+ source: string;
12
+ genesisHash?: string;
13
+ sign: InjectedSigner;
14
+ }
15
+ export type Color = 'success' | 'danger' | 'warning';
16
+ export type Notify = 'success' | 'error' | 'warning' | 'info';
17
+ export type TokenSelector = 'token1' | 'token2';
18
+ export type NotifyFun = (message: string, type?: Notify) => void;
19
+ type OnTokenSelect = (address: string, type?: TokenSelector) => void;
20
+ export type OptionalPick<T, K extends keyof T> = {
21
+ [P in keyof Pick<T, K>]?: T[P];
22
+ };
23
+ export type SelectPartial<T, K extends keyof T> = OptionalPick<T, K> | Pick<T, Exclude<keyof T, K>>;
24
+ export interface DefaultOptions {
25
+ back: () => void;
26
+ notify: NotifyFun;
27
+ onTokenSelect: OnTokenSelect;
28
+ updateTokenState: () => Promise<void>;
29
+ onAddressChange: (address: string) => Promise<void>;
30
+ }
31
+ export type PartialOptions = Partial<DefaultOptions>;
32
+ export type AddressToNumber<T> = {
33
+ [address: string]: T;
34
+ };
35
+ export declare const defaultOptions: DefaultOptions;
36
+ interface Timeframe {
37
+ timeframe: string;
38
+ }
39
+ export interface BaseCandlestickData {
40
+ close: number;
41
+ high: number;
42
+ low: number;
43
+ open: number;
44
+ }
45
+ export interface BaseFeeData {
46
+ fee1: number;
47
+ fee2: number;
48
+ }
49
+ export interface BaseVolumeData {
50
+ amount1: number;
51
+ amount2: number;
52
+ }
53
+ export interface BaseReservedData {
54
+ reserved1: number;
55
+ reserved2: number;
56
+ }
57
+ export interface BasePriceData {
58
+ price: number;
59
+ }
60
+ export interface CandlestickData extends BaseCandlestickData, Timeframe {
61
+ }
62
+ export interface FeeData extends BaseFeeData, Timeframe {
63
+ }
64
+ export interface VolumeData extends BaseVolumeData, Timeframe {
65
+ }
66
+ export interface ReservedData extends BaseReservedData, Timeframe {
67
+ }
68
+ export interface PriceData extends BasePriceData, Timeframe {
69
+ }
70
+ export interface PoolData {
71
+ fee: FeeData[];
72
+ volume: VolumeData[];
73
+ reserves: ReservedData[];
74
+ price: PriceData[];
75
+ }
76
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const SET_POOL = "SET_POOL";
2
+ export declare const SET_FOCUS = "SET_FOCUS";
3
+ export declare const SET_TOKEN1 = "SET_TOKEN1";
4
+ export declare const SET_TOKEN2 = "SET_TOKEN2";
5
+ export declare const SET_SETTINGS = "SET_SETTINGS";
6
+ export declare const SWITCH_TOKENS = "SWITCH_TOKENS";
7
+ export declare const SET_TOKEN1_AMOUNT = "SET_TOKEN1_AMOUNT";
8
+ export declare const SET_TOKEN2_AMOUNT = "SET_TOKEN2_AMOUNT";
9
+ export declare const SET_TOKEN_PRICES = "SET_TOKEN_PRICES";
10
+ export declare const CLEAR_TOKEN_AMOUNTS = "CLEAR_TOKEN_AMOUNTS";
11
+ export declare const SET_STATUS = "SET_STATUS";
12
+ export declare const SET_COMPLETE_STATUS = "SET_COMPLETE_STATUS";
13
+ export declare const SET_LOADING = "SET_LOADING";
14
+ export declare const SET_VALIDITY = "SET_VALIDITY";
15
+ export declare const SET_NEW_POOL_SUPPLY = "SET_NEW_POOL_SUPPLY";
16
+ export declare const SET_PERCENTAGE = "SET_PERCENTAGE";
@@ -0,0 +1,21 @@
1
+ import { Settings, Token } from '../../state';
2
+ import { SET_NEW_POOL_SUPPLY } from '../actionTypes';
3
+ import { ClearTokenAmounts, SetCompleteStatus, SetLoading, SetPercentage, SetPool, SetSettings, SetStatus, SetToken1, SetToken1Amount, SetToken2, SetToken2Amount, SetValidity } from './defaultActions';
4
+ type SetNewPoolSupply = {
5
+ type: typeof SET_NEW_POOL_SUPPLY;
6
+ supply: string;
7
+ };
8
+ export declare const SetNewPoolSupplyAction: (supply: string) => SetNewPoolSupply;
9
+ export type AddLiquidityActions = SetPool | SetStatus | SetLoading | SetToken1 | SetToken2 | SetSettings | SetPercentage | SetToken1Amount | SetToken2Amount | SetNewPoolSupply | SetCompleteStatus | ClearTokenAmounts | SetValidity;
10
+ export interface AddLiquidityComponentActions {
11
+ back: () => void;
12
+ onAddLiquidity: () => Promise<void>;
13
+ selectToken1: (token: Token) => void;
14
+ selectToken2: (token: Token) => void;
15
+ setPercentage: (amount: number) => void;
16
+ setSettings: (settings: Settings) => void;
17
+ setToken1Amount: (amount: string) => void;
18
+ setToken2Amount: (amount: string) => void;
19
+ onAddressChange: (address: string) => Promise<void>;
20
+ }
21
+ export {};
@@ -0,0 +1,70 @@
1
+ import { AddressToNumber, Pool, Settings, Token, TokenWithAmount } from '../../state';
2
+ import { CLEAR_TOKEN_AMOUNTS, SET_COMPLETE_STATUS, SET_LOADING, SET_PERCENTAGE, SET_POOL, SET_SETTINGS, SET_STATUS, SET_TOKEN1, SET_TOKEN1_AMOUNT, SET_TOKEN2, SET_TOKEN2_AMOUNT, SET_VALIDITY, SWITCH_TOKENS, SET_TOKEN_PRICES } from '../actionTypes';
3
+ type SetAmount<T> = {
4
+ type: T;
5
+ amount: string;
6
+ };
7
+ type SetToken<T> = {
8
+ type: T;
9
+ token: TokenWithAmount;
10
+ };
11
+ type SetPrices<T> = {
12
+ type: T;
13
+ tokenPrices: AddressToNumber<number>;
14
+ };
15
+ export type SetToken1 = SetToken<typeof SET_TOKEN1>;
16
+ export type SetToken2 = SetToken<typeof SET_TOKEN2>;
17
+ export type SetToken1Amount = SetAmount<typeof SET_TOKEN1_AMOUNT>;
18
+ export type SetToken2Amount = SetAmount<typeof SET_TOKEN2_AMOUNT>;
19
+ export type SetTokenPrices = SetPrices<typeof SET_TOKEN_PRICES>;
20
+ export type SetSettings = {
21
+ type: typeof SET_SETTINGS;
22
+ settings: Settings;
23
+ };
24
+ export type SwitchTokens = {
25
+ type: typeof SWITCH_TOKENS;
26
+ };
27
+ export type SetPool = {
28
+ type: typeof SET_POOL;
29
+ pool?: Pool;
30
+ };
31
+ export type SetLoading = {
32
+ type: typeof SET_LOADING;
33
+ loading: boolean;
34
+ };
35
+ export type SetCompleteStatus = {
36
+ type: typeof SET_COMPLETE_STATUS;
37
+ status: string;
38
+ isValid: boolean;
39
+ isLoading: boolean;
40
+ };
41
+ export type SetStatus = {
42
+ type: typeof SET_STATUS;
43
+ status: string;
44
+ };
45
+ export type SetValidity = {
46
+ type: typeof SET_VALIDITY;
47
+ isValid: boolean;
48
+ };
49
+ export type ClearTokenAmounts = {
50
+ type: typeof CLEAR_TOKEN_AMOUNTS;
51
+ };
52
+ export type SetPercentage = {
53
+ type: typeof SET_PERCENTAGE;
54
+ percentage: number;
55
+ };
56
+ export declare const setPercentageAction: (percentage: number) => SetPercentage;
57
+ export declare const setPoolAction: (pool?: Pool) => SetPool;
58
+ export declare const setToken1Action: (token: Token) => SetToken1;
59
+ export declare const setToken2Action: (token: Token) => SetToken2;
60
+ export declare const setSettingsAction: (settings: Settings) => SetSettings;
61
+ export declare const setToken1AmountAction: (amount: string) => SetToken1Amount;
62
+ export declare const setToken2AmountAction: (amount: string) => SetToken2Amount;
63
+ export declare const setTokenPricesAction: (tokenPrices: AddressToNumber<number>) => SetTokenPrices;
64
+ export declare const switchTokensAction: () => SwitchTokens;
65
+ export declare const setLoadingAction: (loading: boolean) => SetLoading;
66
+ export declare const setStatusAction: (status: string) => SetStatus;
67
+ export declare const setCompleteStatusAction: (status: string, isValid: boolean, isLoading: boolean) => SetCompleteStatus;
68
+ export declare const setValidityAction: (isValid: boolean) => SetValidity;
69
+ export declare const clearTokenAmountsAction: () => ClearTokenAmounts;
70
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './addLiquidity';
2
+ export * from './defaultActions';
3
+ export * from './swap';
4
+ export * from './removeLiquidity';
@@ -0,0 +1,9 @@
1
+ import { Settings } from '../../state';
2
+ import { SetCompleteStatus, SetLoading, SetPercentage, SetPool, SetSettings, SetStatus, SetToken1, SetToken2, SetValidity } from './defaultActions';
3
+ export type RemoveLiquidityActions = SetLoading | SetPool | SetToken1 | SetToken2 | SetStatus | SetValidity | SetCompleteStatus | SetPercentage | SetSettings;
4
+ export interface RemoveLiquidityComponentActions {
5
+ back: () => void;
6
+ onRemoveLiquidity: () => Promise<void>;
7
+ setPercentage: (percentage: number) => void;
8
+ setSettings: (settings: Settings) => void;
9
+ }
@@ -0,0 +1,22 @@
1
+ import { Settings, Token } from '../../state';
2
+ import { SET_FOCUS } from '../actionTypes';
3
+ import { ClearTokenAmounts, SetCompleteStatus, SetLoading, SetPercentage, SetPool, SetSettings, SetStatus, SetToken1, SetToken1Amount, SetToken2, SetToken2Amount, SetTokenPrices, SetValidity, SwitchTokens } from './defaultActions';
4
+ export type SwapFocus = 'buy' | 'sell';
5
+ type SetFocus = {
6
+ type: typeof SET_FOCUS;
7
+ focus: SwapFocus;
8
+ };
9
+ export type SwapAction = SetToken2 | SetPool | SetToken1 | SetFocus | SetStatus | SetLoading | SetValidity | SetSettings | SetPercentage | SwitchTokens | SetToken2Amount | SetCompleteStatus | ClearTokenAmounts | SetToken1Amount | SetTokenPrices;
10
+ export declare const setFocusAction: (focus: SwapFocus) => SetFocus;
11
+ export interface SwapComponentActions {
12
+ onSwap: () => Promise<void>;
13
+ onSwitch: () => void;
14
+ selectToken1: (token: Token) => void;
15
+ selectToken2: (token: Token) => void;
16
+ setSettings: (settings: Settings) => void;
17
+ setPercentage: (amount: number) => void;
18
+ setToken1Amount: (amount: string) => void;
19
+ setToken2Amount: (amount: string) => void;
20
+ onAddressChange: (address: string) => Promise<void>;
21
+ }
22
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './actions';
2
+ export * from './reducers';
@@ -0,0 +1,15 @@
1
+ import { Pool, Settings, TokenWithAmount } from '../../state';
2
+ import { AddLiquidityActions } from '../actions/addLiquidity';
3
+ export interface AddLiquidityState {
4
+ status: string;
5
+ percentage: number;
6
+ isValid: boolean;
7
+ settings: Settings;
8
+ isLoading: boolean;
9
+ token2: TokenWithAmount;
10
+ token1: TokenWithAmount;
11
+ pool: Pool | undefined;
12
+ newPoolSupply: string;
13
+ }
14
+ export declare const initialAddLiquidityState: AddLiquidityState;
15
+ export declare const addLiquidityReducer: (state: AddLiquidityState | undefined, action: AddLiquidityActions) => AddLiquidityState;
@@ -0,0 +1,3 @@
1
+ export * from './addLiquidity';
2
+ export * from './swap';
3
+ export * from './removeLiquidity';
@@ -0,0 +1,14 @@
1
+ import { Pool, Settings, TokenWithAmount } from '../../state';
2
+ import { RemoveLiquidityActions } from '../actions';
3
+ export interface RemoveLiquidityState {
4
+ token1: TokenWithAmount;
5
+ token2: TokenWithAmount;
6
+ status: string;
7
+ percentage: number;
8
+ isLoading: boolean;
9
+ isValid: boolean;
10
+ pool?: Pool;
11
+ settings: Settings;
12
+ }
13
+ export declare const initialRemoveLiquidityState: RemoveLiquidityState;
14
+ export declare const removeLiquidityReducer: (state: RemoveLiquidityState | undefined, action: RemoveLiquidityActions) => RemoveLiquidityState;
@@ -0,0 +1,15 @@
1
+ import { Pool, Settings, TokenWithAmount } from '../../state';
2
+ import { SwapAction, SwapFocus } from '../actions/swap';
3
+ export interface SwapState {
4
+ status: string;
5
+ focus: SwapFocus;
6
+ percentage: number;
7
+ isValid: boolean;
8
+ settings: Settings;
9
+ isLoading: boolean;
10
+ token2: TokenWithAmount;
11
+ token1: TokenWithAmount;
12
+ pool: Pool | undefined;
13
+ }
14
+ export declare const initialSwapState: SwapState;
15
+ export declare const swapReducer: (state: SwapState | undefined, action: SwapAction) => SwapState;
@@ -0,0 +1,10 @@
1
+ import { Provider } from '@reef-chain/evm-provider';
2
+ import { ReefSigner } from '../state';
3
+ import { TxStatusHandler } from './transactionUtil';
4
+ export declare const bindEvmAddress: (signer: ReefSigner, provider: Provider, onTxChange?: TxStatusHandler) => string;
5
+ export declare const bindCustomEvmAddress: (signer: ReefSigner, provider: Provider, evmAddress: string, signature: string, onTxChange?: TxStatusHandler) => string;
6
+ export declare const signBindEvmAddress: (signer: ReefSigner) => Promise<{
7
+ evmAddress?: string;
8
+ signature?: string;
9
+ error?: string;
10
+ }>;
@@ -0,0 +1,8 @@
1
+ export declare enum DataProgress {
2
+ LOADING = "DataProgress_LOADING",
3
+ NO_DATA = "DataProgress_NO_DATA"
4
+ }
5
+ export type DataWithProgress<T> = T | DataProgress;
6
+ export declare const isDataSet: (dataOrProgress: DataWithProgress<any>) => boolean;
7
+ export declare const getData: <T>(dataOrProgress: DataWithProgress<T>) => T | undefined;
8
+ export declare const getProgress: (dataOrProgress: DataWithProgress<any>) => DataProgress | undefined;
@@ -0,0 +1,11 @@
1
+ export * from './math';
2
+ export * from './utils';
3
+ export * from './dataWithProgress';
4
+ export * from './rpcErrorMessageHandler';
5
+ export * from '../graphql/gql';
6
+ export * from './tokenUtil';
7
+ export * from './transactionUtil';
8
+ export * from './bindUtil';
9
+ export * from './providerUtil';
10
+ export * from './modalUtil';
11
+ export * from './modalUtil';
@@ -0,0 +1,55 @@
1
+ import { BigNumber } from 'ethers';
2
+ import { NFT, Pool, Token, TokenWithAmount } from '../state';
3
+ export declare const transformAmount: (decimals: number, amount: string) => string;
4
+ export declare const assertAmount: (amount?: string) => string;
5
+ export declare const convert2Normal: (decimals: number, inputAmount: string) => number;
6
+ interface CalculateAmount {
7
+ decimals: number;
8
+ amount: string;
9
+ }
10
+ export declare const calculateAmount: ({ decimals, amount, }: CalculateAmount) => string;
11
+ export declare const calculateAmountWithPercentage: ({ amount: oldAmount, decimals }: CalculateAmount, percentage: number) => string;
12
+ export declare const minimumReceiveAmount: ({ amount }: CalculateAmount, percentage: number) => number;
13
+ interface CalculateUsdAmount extends CalculateAmount {
14
+ price: number;
15
+ }
16
+ export declare const calculateUsdAmount: ({ amount, price, }: CalculateUsdAmount) => number;
17
+ export declare const calculateDeadline: (minutes: number) => number;
18
+ export declare const calculateBalance: ({ balance, decimals }: Token) => string;
19
+ export declare const calculatePoolSupply: (token1: TokenWithAmount, token2: TokenWithAmount, pool?: Pool) => number;
20
+ export declare const removeSupply: (percentage: number, supply?: string, decimals?: number) => number;
21
+ export declare const removePoolTokenShare: (percentage: number, token?: Token) => string;
22
+ export declare const showRemovePoolTokenShare: (percentage: number, token?: Token) => string;
23
+ export declare const removeUserPoolSupply: (percentage: number, pool?: Pool) => number;
24
+ export declare const convertAmount: (amount: string, fromPrice: number, toPrice: number) => number;
25
+ export declare const calculatePoolRatio: (pool?: Pool, first?: boolean) => number;
26
+ export declare const calculatePoolShare: (pool?: Pool) => number;
27
+ interface ToBalance {
28
+ balance: BigNumber;
29
+ decimals: number;
30
+ }
31
+ interface ShowBalance extends ToBalance {
32
+ name: string;
33
+ symbol?: string;
34
+ }
35
+ export declare const showBalance: ({ decimals, balance, name, symbol, }: ShowBalance | Token | NFT, decimalPoints?: number) => string;
36
+ export declare const toBalance: ({ balance, decimals }: ToBalance) => number;
37
+ export declare const toUnits: ({ balance, decimals }: ToBalance) => string;
38
+ export declare const exponentNrSplit: (numberVal: string) => {
39
+ isExponent: boolean;
40
+ split: string[];
41
+ };
42
+ export declare const noExponents: (valueNr: string) => string;
43
+ export declare const toDecimalPlaces: (value: string, maxDecimalPlaces: number) => string;
44
+ export declare const poolRatio: ({ token1, token2 }: Pool) => number;
45
+ export declare const ensureAmount: (token: TokenWithAmount) => void;
46
+ export declare const getOutputAmount: (token: TokenWithAmount, pool: Pool) => number;
47
+ export declare const getInputAmount: (token: TokenWithAmount, pool: Pool) => number;
48
+ export declare const calculateImpactPercentage: (sell: TokenWithAmount, buy: TokenWithAmount) => number;
49
+ export declare const getHashSumLastNr: (address: string) => number;
50
+ export declare const toHumanAmount: (amount: string) => string;
51
+ export declare const formatAmount: (amount: number, decimals: number) => string;
52
+ export declare const mean: (arr: number[]) => number;
53
+ export declare const variance: (arr: number[]) => number;
54
+ export declare const std: (arr: number[]) => number;
55
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const openModal: (id: string) => void;
2
+ export declare const closeModal: (id: string) => void;
@@ -0,0 +1,7 @@
1
+ import { Observable } from 'rxjs';
2
+ import { Signer } from '@reef-chain/evm-provider';
3
+ import { NFT } from '../state';
4
+ export declare const toIpfsProviderUrl: (ipfsUriStr: string, ipfsUrlResolver?: ipfsUrlResolverFn) => string | null;
5
+ export declare const getResolveNftPromise: (nft: NFT | null, signer: Signer, ipfsUrlResolver?: ipfsUrlResolverFn) => Promise<NFT | null>;
6
+ export declare const resolveNftImageLinks: (nfts: (NFT | null)[], signer: Signer, ipfsUrlResolver?: ipfsUrlResolverFn) => Observable<(NFT | null)[]>;
7
+ export type ipfsUrlResolverFn = (ipfsHash: any) => string;
@@ -0,0 +1,3 @@
1
+ import { Provider } from '@reef-chain/evm-provider';
2
+ export declare function initProvider(providerUrl: string): Promise<Provider>;
3
+ export declare function disconnectProvider(provider: Provider): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { FrameSystemEventRecord } from '@polkadot/types/lookup';
2
+ export type Event = FrameSystemEventRecord;
3
+ export declare const errorHandler: (message: string) => string;
4
+ export declare const captureError: (events: Event[]) => string | undefined;
@@ -0,0 +1,12 @@
1
+ import { BigNumber } from 'ethers';
2
+ import { BigNumber as BN } from 'bignumber.js';
3
+ import { DataWithProgress } from './dataWithProgress';
4
+ import { Token, TokenWithAmount } from '../state';
5
+ import { PoolReserves } from '../graphql/pools';
6
+ export declare const calculateTokenPrice: (token: Token, pools: PoolReserves[], reefPrice: DataWithProgress<number>) => DataWithProgress<number>;
7
+ export declare const calculateBalanceValue: ({ price, balance, }: {
8
+ price: DataWithProgress<number>;
9
+ balance: BigNumber;
10
+ } | TokenWithAmount) => DataWithProgress<number>;
11
+ export declare const toCurrencyFormat: (value: number, options?: {}) => string;
12
+ export declare const normalize: (amount: string | number, decimals: number) => BN;