Skip to content

Commit

Permalink
mynt amm pool (#1961)
Browse files Browse the repository at this point in the history
* feat(mynt): add amm testnet contracts

* fix(portfolio): use amm price for mynt instead of bonding curve

* feat(amm): mynt mainnet contracts

* fix(amm): show spinner only when data is actually loading
  • Loading branch information
creed-victor authored Dec 17, 2021
1 parent b7dcace commit fcbaaef
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 87 deletions.
8 changes: 1 addition & 7 deletions src/app/components/UserAssets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { ConversionDialog } from './ConversionDialog';
import { BridgeLink } from './BridgeLink';
import { UnWrapDialog } from './UnWrapDialog';
import { useDollarValue } from '../../hooks/useDollarValue';
import { useDollarValueMynt } from '../../hooks/useDollarValueMynt';
import styles from './index.module.scss';
import { CrossBridgeAsset } from 'app/pages/BridgeDepositPage/types/cross-bridge-asset';

Expand Down Expand Up @@ -250,12 +249,7 @@ function AssetRow({
get().catch();
}, [item.asset, account, blockSync]);

const dollarValue = useDollarValue(item.asset, tokens);
const dollarValueMynt = useDollarValueMynt(tokens);
const assetDollarValue = useMemo(
() => (item.asset === Asset.MYNT ? dollarValueMynt : dollarValue),
[dollarValue, dollarValueMynt, item.asset],
);
const assetDollarValue = useDollarValue(item.asset, tokens);

if (tokens === '0' && item.hideIfZero)
return <React.Fragment key={item.asset} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const assetsWithoutOracle: Asset[] = [
Asset.BNB,
Asset.RIF,
Asset.RDOC,
Asset.MYNT,
];

const excludeAssets: Asset[] = [Asset.CSOV, Asset.RDOC, Asset.MYNT];
Expand Down
27 changes: 0 additions & 27 deletions src/app/hooks/useDollarValueMynt.ts

This file was deleted.

50 changes: 0 additions & 50 deletions src/app/hooks/useEstimateMyntToSov.ts

This file was deleted.

16 changes: 14 additions & 2 deletions src/app/pages/LiquidityMining/components/MiningPool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ import type { AmmHistory } from './types';
interface Props {
pool: LiquidityPool;
ammData: AmmHistory;
ammDataLoading: boolean;
linkAsset?: Asset;
}

type DialogType = 'none' | 'add' | 'remove';

export function MiningPool({ pool, ammData, linkAsset }: Props) {
export function MiningPool({
pool,
ammData,
ammDataLoading,
linkAsset,
}: Props) {
const { t } = useTranslation();
const [dialog, setDialog] = useState<DialogType>(
pool.poolAsset === linkAsset ? 'add' : 'none',
Expand Down Expand Up @@ -93,7 +99,13 @@ export function MiningPool({ pool, ammData, linkAsset }: Props) {
)
}
ChartSection={
ammData ? <PoolChart pool={pool} history={ammData} /> : <Spinner />
ammDataLoading ? (
<Spinner />
) : ammData ? (
<PoolChart pool={pool} history={ammData} />
) : (
<></>
)
}
Actions={<Actions />}
DataSection={
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/LiquidityMining/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function LiquidityMining() {
setHasOldPools,
]);

const { value: ammData } = useFetch(
const { value: ammData, loading } = useFetch(
`${backendUrl[currentChainId]}/amm/apy/all`,
);

Expand Down Expand Up @@ -146,6 +146,7 @@ export function LiquidityMining() {
ammData &&
ammData[item?.assetDetails?.ammContract?.address?.toLowerCase()]
}
ammDataLoading={loading}
linkAsset={location.state?.asset}
/>
))}
Expand Down
30 changes: 30 additions & 0 deletions src/app/pages/SpotTradingPage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export enum SpotPairType {
RIF_ETH = 'RIF_ETH',
RIF_BNB = 'RIF_BNB',
RIF_FISH = 'RIF_FISH',
// MYNT
MYNT_RBTC = 'MYNT_RBTC',
MYNT_SOV = 'MYNT_SOV',
MYNT_XUSD = 'MYNT_XUSD',
MYNT_USDT = 'MYNT_USDT',
MYNT_DOC = 'MYNT_DOC',
MYNT_ETH = 'MYNT_ETH',
MYNT_BNB = 'MYNT_BNB',
MYNT_FISH = 'MYNT_FISH',
MYNT_RIF = 'MYNT_RIF',
}

export const pairs = {
Expand Down Expand Up @@ -106,6 +116,16 @@ export const pairs = {
[SpotPairType.RIF_ETH]: [Asset.RIF, Asset.ETH],
[SpotPairType.RIF_BNB]: [Asset.RIF, Asset.BNB],
[SpotPairType.RIF_FISH]: [Asset.RIF, Asset.FISH],
// MYNT
[SpotPairType.MYNT_RBTC]: [Asset.MYNT, Asset.RBTC],
[SpotPairType.MYNT_SOV]: [Asset.MYNT, Asset.SOV],
[SpotPairType.MYNT_XUSD]: [Asset.MYNT, Asset.XUSD],
[SpotPairType.MYNT_USDT]: [Asset.MYNT, Asset.USDT],
[SpotPairType.MYNT_DOC]: [Asset.MYNT, Asset.DOC],
[SpotPairType.MYNT_ETH]: [Asset.MYNT, Asset.ETH],
[SpotPairType.MYNT_BNB]: [Asset.MYNT, Asset.BNB],
[SpotPairType.MYNT_FISH]: [Asset.MYNT, Asset.FISH],
[SpotPairType.MYNT_RIF]: [Asset.MYNT, Asset.RIF],
};

export const pairList = [
Expand Down Expand Up @@ -159,6 +179,16 @@ export const pairList = [
SpotPairType.RIF_ETH,
SpotPairType.RIF_BNB,
SpotPairType.RIF_FISH,
// MYNT
SpotPairType.MYNT_RBTC,
SpotPairType.MYNT_SOV,
SpotPairType.MYNT_XUSD,
SpotPairType.MYNT_USDT,
SpotPairType.MYNT_DOC,
SpotPairType.MYNT_ETH,
SpotPairType.MYNT_BNB,
SpotPairType.MYNT_FISH,
SpotPairType.MYNT_RIF,
];

export interface SpotTradingPageState {
Expand Down
4 changes: 4 additions & 0 deletions src/utils/blockchain/contracts.testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,8 @@ export const contracts = {
address: '0xf75170ce8d4060b8D5fc24E996FA00A94bb8A232',
abi: MYNTMarketMakerAbi,
},
MYNT_amm: {
address: '0x84953dAF0E7a9fFb8B4fDf7F948185e1cF85852e',
abi: LiquidityPoolV1Converter,
},
};
4 changes: 4 additions & 0 deletions src/utils/blockchain/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,8 @@ export const contracts = {
address: '0x722935fF8A99D801D802bb3EE528408C11C18656',
abi: MYNTMarketMakerAbi,
},
MYNT_amm: {
address: '0x25B8D024B39174824424f032423E03dd7dcCF044',
abi: LiquidityPoolV1Converter,
},
};
13 changes: 13 additions & 0 deletions src/utils/dictionaries/liquidity-pool-dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ export class LiquidityPoolDictionary {
}),
]).setVersion(1),
],
[
Asset.MYNT,
new LiquidityPool(Asset.MYNT, [
new LiquidityPoolSupplyAsset(Asset.MYNT, {
mainnet: '0x36263AC99ecDcf1aB20513D580B7d8D32D3C439d',
testnet: '0xB12FA09a50c56e9a0C826b98e76DA7645017AB4D',
}),
new LiquidityPoolSupplyAsset(Asset.RBTC, {
mainnet: '0x7Fef930ebaA90B2f8619722adc55e3f1D965B79b',
testnet: '0x6e03DEFD0ae9091Be74f64c8CB9BE319994E5deB',
}),
]).setVersion(1),
],
]);

public static get(asset: Asset): LiquidityPool {
Expand Down

0 comments on commit fcbaaef

Please sign in to comment.