Skip to content

Commit

Permalink
Use - instead of / for swap pairs i.e. tzBTC-USDT instead of tzBTC/US…
Browse files Browse the repository at this point in the history
…DT in UI
  • Loading branch information
glottologist committed Nov 13, 2023
1 parent c4f5bca commit f08ca8f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions batcher-ui/src/components/batcher/SelectPair.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const SelectPair = ({ isFrom }: SelectPairProps) => {
const [availableTokens, setAvailableTokens] = useState<any[]>([]);
const [availableSwaps, setAvailableSwaps] = useState<any[]>([]);


const displayValue = useCallback(() => {
if (isReverse && isFrom) return swap.to.name;
if (isReverse && !isFrom) return swap.from.token.name;
Expand Down Expand Up @@ -52,10 +51,10 @@ const SelectPair = ({ isFrom }: SelectPairProps) => {
<Select.Root
value={displayValue()}
onValueChange={value => {
//const pair = isFrom ? `${value}/${swap.to.name}` : `${swap.from.name}/${value}`;
//const pair = isFrom ? `${value}-${swap.to.name}` : `${swap.from.name}-${value}`;
//const availableSwap = availableSwaps[pair];
// const reversed = (!isFrom && value === ${swap.from.name}) || (isFrom && value === ${swap.to.name});
const pair = 'tzBTC/USDT';
const pair = 'tzBTC-USDT';
const reversed = false;
dispatch(changePair(pair, reversed));
}}
Expand Down
2 changes: 1 addition & 1 deletion batcher-ui/src/types/contracts/batcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export enum PriceStrategy {
// ------ BATCHER STORAGE REPRESENTATION ------ //

export type TokenNames = 'tzBTC' | 'EURL' | 'USDT';
export type SwapNames = 'tzBTC/USDT' | 'tzBTC/EURL';
export type SwapNames = 'tzBTC-USDT' | 'tzBTC-EURL';

type Swap = {
from: {
Expand Down
7 changes: 3 additions & 4 deletions batcher-ui/src/utils/token-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export const getLexicographicalPairName = (
from: string
): string => {
if (to > from) {
return `${to}/${from}`;
return `${to}-${from}`;
} else {
return `${from}/${to}`;
return `${from}-${to}`;
}
};

Expand All @@ -74,7 +74,6 @@ export const getSwapsMetadata = async () => {
const validSwaps = storage['valid_swaps'];
const names = validSwaps.keys;
const bm = await api.bigMapsGetBigMapById(validSwaps.values);
console.info('DEBUG - validSwaps bm ', bm.value);
return Promise.all(
names.map(async swap => {
const escapedPair = encodeURIComponent(swap);
Expand Down Expand Up @@ -110,7 +109,7 @@ export const getPairsInformation = async (
const storage = await getTokenManagerStorage();
//const validSwaps = storage['valid_swaps']; //TODO - Only swaps pairs allowed by the contract should be displayed. A token might not be swappable with every other token
const validTokens = storage['valid_tokens'];
const pairs = pair.split('/');
const pairs = pair.split('-');
const left = (await getTokenFromBigmap(validTokens.values, pairs[0])).value;
const right = (await getTokenFromBigmap(validTokens.values, pairs[1])).value;

Expand Down

0 comments on commit f08ca8f

Please sign in to comment.