-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from balancer/8020-support
Add support for 80/20 in pool creation flow
- Loading branch information
Showing
8 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from "react"; | ||
import { SupportedTokenWeight } from "~~/utils/token-weights"; | ||
|
||
interface Props { | ||
items: { | ||
label: string; | ||
id: SupportedTokenWeight; | ||
}[]; | ||
selectedId: SupportedTokenWeight; | ||
onSelect: (id: SupportedTokenWeight) => void; | ||
} | ||
|
||
export const ButtonTabs: React.FC<Props> = ({ items, selectedId, onSelect }) => { | ||
return ( | ||
<div className="w-full flex flex-col gap-3"> | ||
<div className="tabs"> | ||
<div className="flex"> | ||
<div className="flex flex-1 rounded-xl transition-all duration-300 -mb-px overflow-hidden"> | ||
{items.map(({ id, label }) => { | ||
const isSelected = id === selectedId; | ||
|
||
return ( | ||
<button | ||
key={id} | ||
className={`text-neutral-700 bg-gradient-to-b from-custom-beige-start to-custom-beige-end to-100% flex-1 py-3 font-medium text-lg front-bold ${ | ||
isSelected ? "" : "opacity-50 hover:opacity-90" | ||
}`} | ||
onClick={() => { | ||
if (selectedId !== id) { | ||
onSelect(id); | ||
} | ||
}} | ||
> | ||
{label} | ||
</button> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export type SupportedTokenWeight = "5050" | "8020"; | ||
export interface TokenWeightSelectItem { | ||
id: SupportedTokenWeight; | ||
label: string; | ||
} | ||
|
||
export const TokenWeightSelectItems: TokenWeightSelectItem[] = [ | ||
{ id: "5050", label: "50/50" }, | ||
{ id: "8020", label: "80/20" }, | ||
]; | ||
|
||
export function getPerTokenWeights(tokenWeights: SupportedTokenWeight) { | ||
return { | ||
token1Weight: tokenWeights === "8020" ? "80" : "50", | ||
token2Weight: tokenWeights === "8020" ? "20" : "50", | ||
}; | ||
} | ||
|
||
export function getDenormalizedTokenWeight(tokenWeights: SupportedTokenWeight, isToken1: boolean) { | ||
if (tokenWeights === "8020") { | ||
if (isToken1) { | ||
return 8000000000000000000n; | ||
} else { | ||
return 2000000000000000000n; | ||
} | ||
} | ||
|
||
return 1000000000000000000n; // bind 2 tokens with 1e18 weight for each to get a 50/50 pool | ||
} |