Skip to content

Commit

Permalink
Merge branch 'master' of github.com:studydefi/dedge into update-dacpr…
Browse files Browse the repository at this point in the history
…oxyfactory-address
  • Loading branch information
kendricktan committed Apr 9, 2020
2 parents 409a20e + 4be7b45 commit 9e354a4
Show file tree
Hide file tree
Showing 60 changed files with 60,330 additions and 60,369 deletions.
75 changes: 47 additions & 28 deletions packages/frontend/containers/DACProxy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,53 @@ function useDACProxy() {
dedgeCompoundManager,
} = contracts;
setLoading(true);
const tx = await dedgeHelpers.proxyFactory.buildAndEnterMarkets(
dacProxyFactory,
dedgeCompoundManager.address,
[
cEther.address,
cDai.address,
cRep.address,
cZrx.address,
cBat.address,
cUsdc.address,
cWbtc.address,
],
);

window.toastProvider.addMessage("Creating Smart Wallet...", {
secondaryMessage: "Check progress on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "processing",
});

await tx.wait();

window.toastProvider.addMessage("Smart Wallet created", {
variant: "success",
});
setLoading(false);

let tx = null;
try {
tx = await dedgeHelpers.proxyFactory.buildAndEnterMarkets(
dacProxyFactory,
dedgeCompoundManager.address,
[
cEther.address,
cDai.address,
cRep.address,
cZrx.address,
cBat.address,
cUsdc.address,
cWbtc.address,
]
);

window.toastProvider.addMessage("Creating Smart Wallet...", {
secondaryMessage: "Check progress on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "processing",
});

await tx.wait();

window.toastProvider.addMessage("Smart Wallet created", {
variant: "success",
});
} catch (e) {
if (tx === null) {
window.toastProvider.addMessage(`Transaction cancelled`, {
variant: "failure",
});
} else {
window.toastProvider.addMessage(`Failed to create wallet...`, {
secondaryMessage: "Check reason on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "failure",
});
}
setLoading(false);
return;
}

setLoading(false);
fetchProxyAddress();
};

Expand All @@ -86,7 +105,7 @@ function useDACProxy() {
if (proxyAddress) {
const { abi } = legos.dappsys.dsProxy;
const proxyContract = new ethers.Contract(proxyAddress, abi, signer);
window.analytics.identify(proxyAddress)
window.analytics.identify(proxyAddress);
setProxyContract(proxyContract);
}
}, [proxyAddress, signer]);
Expand Down
63 changes: 42 additions & 21 deletions packages/frontend/features/exit-position/ExitPosition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,50 @@ const ExitPositionsButton = () => {
collateralMarkets,
} = await dedgeHelpers.exit.getExitPositionParameters(
signer,
proxy.address,
proxy.address
);

const tx = await dedgeHelpers.exit.exitPositionToETH(
address,
etherToBorrowWeiBN,
proxy,
dedgeAddressRegistry.address,
dedgeExitManager.address,
debtMarkets,
collateralMarkets,
);
window.toastProvider.addMessage(`Exiting positions...`, {
secondaryMessage: "Check progress on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "processing",
});
await tx.wait();

window.toastProvider.addMessage(`Exited Positions!`, {
variant: "success",
});
let tx = null;
try {
tx = await dedgeHelpers.exit.exitPositionToETH(
address,
etherToBorrowWeiBN,
proxy,
dedgeAddressRegistry.address,
dedgeExitManager.address,
debtMarkets,
collateralMarkets
);
window.toastProvider.addMessage(`Exiting positions...`, {
secondaryMessage: "Check progress on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "processing",
});
await tx.wait();

window.toastProvider.addMessage(`Exited Positions!`, {
variant: "success",
});
} catch (e) {
if (tx === null) {
window.toastProvider.addMessage(`Transaction cancelled`, {
variant: "failure",
});
} else {
window.toastProvider.addMessage(
`Failed to exit poisitions...`,
{
secondaryMessage: "Check reason on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "failure",
}
);
}
setLoading(false);
return;
}

window.analytics.track("Exit Positions Success");
setLoading(false);
Expand Down
66 changes: 41 additions & 25 deletions packages/frontend/features/import-vault/useAllowVaultTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const useAllowVaultTransfer = (selectedVaultId: number) => {
const allowed = await dedgeHelpers.maker.isUserAllowedVault(
proxy.address,
selectedVaultId,
makerCdpManager,
makerCdpManager
);

setImportAllowed(Boolean(allowed));
Expand All @@ -44,38 +44,54 @@ const useAllowVaultTransfer = (selectedVaultId: number) => {
const makerDsProxyContract = new ethers.Contract(
userMakerdaoProxyAddress,
legos.dappsys.dsProxy.abi,
signer,
);

const tx = await dedgeHelpers.maker.dsProxyCdpAllowDacProxy(
makerDsProxyContract,
proxyAddress,
makerCdpManager.address,
makerProxyActions.address,
selectedVaultId.toString(),
signer
);

window.toastProvider.addMessage(`Allowing vault #${selectedVaultId}...`, {
secondaryMessage: "Check progress on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "processing",
});

await tx.wait();

window.toastProvider.addMessage(
`Vault #${selectedVaultId} allowance approved`,
{ variant: "success" },
);
window.analytics.track("Allow Vault Success", { selectedVaultId });
let tx = null;
try {
tx = await dedgeHelpers.maker.dsProxyCdpAllowDacProxy(
makerDsProxyContract,
proxyAddress,
makerCdpManager.address,
makerProxyActions.address,
selectedVaultId.toString()
);
window.toastProvider.addMessage(`Allowing vault #${selectedVaultId}...`, {
secondaryMessage: "Check progress on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "processing",
});
await tx.wait();

window.toastProvider.addMessage(
`Vault #${selectedVaultId} allowance approved`,
{ variant: "success" }
);
window.analytics.track("Allow Vault Success", { selectedVaultId });
} catch (e) {
if (tx === null) {
window.toastProvider.addMessage(`Transaction cancelled`, {
variant: "failure",
});
} else {
window.toastProvider.addMessage(`Failed to allow vault...`, {
secondaryMessage: "Check reason on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "failure",
});
}
setLoading(false);
return;
}

setLoading(false);
getAllowStatus();
};

useEffect(() => {
if (hasProxy) {
if (hasProxy && selectedVaultId !== null) {
getAllowStatus();
}
}, [selectedVaultId]);
Expand Down
61 changes: 41 additions & 20 deletions packages/frontend/features/import-vault/useImportVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,49 @@ const useImportVault = (selectedVaultId) => {
console.error("Invalid ilk", ilk);
}

const tx = await dedgeHelpers.maker.importMakerVault(
proxy,
dedgeMakerManager.address,
dedgeAddressRegistry.address,
selectedVaultId.toString(),
ilkCTokenEquilavent,
ilkJoinAddress,
decimals,
);
let tx = null;
try {
tx = await dedgeHelpers.maker.importMakerVault(
proxy,
dedgeMakerManager.address,
dedgeAddressRegistry.address,
selectedVaultId.toString(),
ilkCTokenEquilavent,
ilkJoinAddress,
decimals
);

window.toastProvider.addMessage(`Importing vault #${selectedVaultId}...`, {
secondaryMessage: "Check progress on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "processing",
});
window.toastProvider.addMessage(
`Importing vault #${selectedVaultId}...`,
{
secondaryMessage: "Check progress on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "processing",
}
);

await tx.wait();
window.toastProvider.addMessage(`Vault #${selectedVaultId} imported!`, {
variant: "success",
});
window.analytics.track("Import Vault Success", { selectedVaultId });
await tx.wait();
window.toastProvider.addMessage(`Vault #${selectedVaultId} imported!`, {
variant: "success",
});
window.analytics.track("Import Vault Success", { selectedVaultId });
} catch (e) {
if (tx === null) {
window.toastProvider.addMessage(`Transaction cancelled`, {
variant: "failure",
});
} else {
window.toastProvider.addMessage(`Failed to import vault...`, {
secondaryMessage: "Check reason on Etherscan",
actionHref: `https://etherscan.io/tx/${tx.hash}`,
actionText: "Check",
variant: "failure",
});
}
setLoading(false);
return;
}

setLoading(false);
getVaults();
Expand Down
Loading

0 comments on commit 9e354a4

Please sign in to comment.