Skip to content

Commit

Permalink
Use variables for common formChange props
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangoree committed Nov 2, 2024
1 parent 925f7e2 commit c631359
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ export function CloseLongForm({
const isAmountLargerThanPositionSize = !!(
bondAmountAsBigInt && bondAmountAsBigInt > long.bondAmount
);

// Plausible event props
const formName = "Close Long";
const chainId = hyperdrive.chainId;
const poolAddress = hyperdrive.address;

return (
<TransactionView
tokenInput={
Expand All @@ -166,11 +172,11 @@ export function CloseLongForm({
onChange={(newAmount) => {
window.plausible("formChange", {
props: {
formName: "Close Long",
formName,
inputName: "amount",
inputValue: newAmount,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setAmount(newAmount);
Expand All @@ -195,11 +201,11 @@ export function CloseLongForm({
onChange={(tokenAddress) => {
window.plausible("formChange", {
props: {
formName: "Close Long",
formName,
inputName: "token",
inputValue: tokenAddress,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setActiveWithdrawToken(tokenAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ export function OpenLongForm({
);
}

// Plausible event props
const formName = "Open Long";
const chainId = hyperdrive.chainId;
const poolAddress = hyperdrive.address;

return (
<TransactionView
tokenInput={
Expand All @@ -254,11 +259,11 @@ export function OpenLongForm({
onSlippageChange={(slippage) => {
window.plausible("formChange", {
props: {
formName: "Open Long",
formName,
inputName: "slippage",
inputValue: slippage,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
inputValue: slippage.toString(),
chainId,
poolAddress,
},
});
setSlippage(slippage);
Expand All @@ -279,11 +284,11 @@ export function OpenLongForm({
onChange={(tokenAddress) => {
window.plausible("formChange", {
props: {
formName: "Open Long",
formName,
inputName: "token",
inputValue: tokenAddress,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setActiveToken(tokenAddress);
Expand All @@ -297,11 +302,11 @@ export function OpenLongForm({
onChange={(tokenAddress) => {
window.plausible("formChange", {
props: {
formName: "Open Long",
formName,
inputName: "token",
inputValue: tokenAddress,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setActiveToken(tokenAddress);
Expand Down Expand Up @@ -349,11 +354,11 @@ export function OpenLongForm({
onChange={(newAmount) => {
window.plausible("formChange", {
props: {
formName: "Open Long",
formName,
inputName: "amount",
inputValue: newAmount,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setAmount(newAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ export function AddLiquidityForm({
},
});

// Plausible event props
const formName = "Add Liquidity";
const chainId = hyperdrive.chainId;
const poolAddress = hyperdrive.address;

return (
<TransactionView
tokenInput={
Expand Down Expand Up @@ -280,11 +285,11 @@ export function AddLiquidityForm({
onChange={(tokenAddress) => {
window.plausible("formChange", {
props: {
formName: "Add Liquidity",
formName,
inputName: "token",
inputValue: tokenAddress,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setActiveToken(tokenAddress);
Expand All @@ -297,11 +302,11 @@ export function AddLiquidityForm({
onSlippageChange={(slippage) => {
window.plausible("formChange", {
props: {
formName: "Add Liquidity",
formName,
inputName: "slippage",
inputValue: slippage,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setSlippage(slippage);
Expand All @@ -328,11 +333,11 @@ export function AddLiquidityForm({
onChange={(newAmount) => {
window.plausible("formChange", {
props: {
formName: "Add Liquidity",
formName,
inputName: "amount",
inputValue: newAmount,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setAmount(newAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ export function AddLiquidityForm2({
},
});

// Plausible event props
const formName = "Add Liquidity";
const chainId = hyperdrive.chainId;
const poolAddress = hyperdrive.address;

return (
<TransactionView
tokenInput={
Expand Down Expand Up @@ -269,11 +274,11 @@ export function AddLiquidityForm2({
onChange={(tokenAddress) => {
window.plausible("formChange", {
props: {
formName: "Add Liquidity",
formName,
inputName: "token",
inputValue: tokenAddress,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setActiveToken(tokenAddress);
Expand All @@ -288,11 +293,11 @@ export function AddLiquidityForm2({
onSlippageChange={(slippage) => {
window.plausible("formChange", {
props: {
formName: "Add Liquidity",
formName,
inputName: "slippage",
inputValue: slippage,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setSlippage(slippage);
Expand Down Expand Up @@ -320,11 +325,11 @@ export function AddLiquidityForm2({
onChange={(newAmount) => {
window.plausible("formChange", {
props: {
formName: "Add Liquidity",
formName,
inputName: "amount",
inputValue: newAmount,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setAmount(newAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ export function RemoveLiquidityForm({
})()
: 0n;

// Plausible event props
const formName = "Remove Liquidity";
const chainId = hyperdrive.chainId;
const poolAddress = hyperdrive.address;

return (
<TransactionView
tokenInput={
Expand All @@ -240,11 +245,11 @@ export function RemoveLiquidityForm({
onSlippageChange={(slippage) => {
window.plausible("formChange", {
props: {
formName: "Remove Liquidity",
formName,
inputName: "slippage",
inputValue: slippage,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setSlippage(slippage);
Expand All @@ -269,11 +274,11 @@ export function RemoveLiquidityForm({
onChange={(newAmount) => {
window.plausible("formChange", {
props: {
formName: "Remove Liquidity",
formName,
inputName: "amount",
inputValue: newAmount,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setAmount(newAmount);
Expand All @@ -289,11 +294,11 @@ export function RemoveLiquidityForm({
onChange={(tokenAddress) => {
window.plausible("formChange", {
props: {
formName: "Remove Liquidity",
formName,
inputName: "token",
inputValue: tokenAddress,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setActiveWithdrawToken(tokenAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ export function CloseShortForm({
});
}

// Plausible event props
const formName = "Close Short";
const chainId = hyperdrive.chainId;
const poolAddress = hyperdrive.address;

return (
<TransactionView
tokenInput={
Expand All @@ -157,11 +162,11 @@ export function CloseShortForm({
onChange={(newAmount) => {
window.plausible("formChange", {
props: {
formName: "Close Short",
formName,
inputName: "amount",
inputValue: newAmount,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setAmount(newAmount);
Expand All @@ -188,11 +193,11 @@ export function CloseShortForm({
onChange={(tokenAddress) => {
window.plausible("formChange", {
props: {
formName: "Close Short",
formName,
inputName: "token",
inputValue: tokenAddress,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setActiveWithdrawToken(tokenAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ export function OpenShortForm({
Date.now() + Number(hyperdrive.poolConfig.positionDuration * 1000n),
);

// Plausible event props
const formName = "Open Short";
const chainId = hyperdrive.chainId;
const poolAddress = hyperdrive.address;

return (
<TransactionView
tokenInput={
Expand All @@ -325,11 +330,11 @@ export function OpenShortForm({
onChange={(tokenAddress) => {
window.plausible("formChange", {
props: {
formName: "Open Short",
formName,
inputName: "token",
inputValue: tokenAddress,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setActiveToken(tokenAddress);
Expand All @@ -353,11 +358,11 @@ export function OpenShortForm({
onSlippageChange={(slippage) => {
window.plausible("formChange", {
props: {
formName: "Open Short",
formName,
inputName: "slippage",
inputValue: slippage,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setSlippage(slippage);
Expand All @@ -372,11 +377,11 @@ export function OpenShortForm({
onChange={(newAmount) => {
window.plausible("formChange", {
props: {
formName: "Open Short",
formName,
inputName: "size",
inputValue: newAmount,
chainId: hyperdrive.chainId,
poolAddress: hyperdrive.address,
chainId,
poolAddress,
},
});
setShortAmount(newAmount);
Expand Down

0 comments on commit c631359

Please sign in to comment.