Skip to content

Commit

Permalink
Merge pull request #191 from lc-labs/development
Browse files Browse the repository at this point in the history
chore: fix broken collateral wrapping
  • Loading branch information
lcamargof authored Oct 4, 2023
2 parents a43443e + 9101c8d commit 9a4493d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
48 changes: 48 additions & 0 deletions src/abis/CollateralWrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,52 @@ export default [
stateMutability: 'nonpayable',
type: 'function',
},
// COMPv3
{
inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }],
name: 'deposit',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
// AAVE v3
{
inputs: [
{ internalType: 'uint256', name: 'assets', type: 'uint256' },
{ internalType: 'address', name: 'receiver', type: 'address' },
{ internalType: 'uint16', name: 'referralCode', type: 'uint16' },
{ internalType: 'bool', name: 'depositToAave', type: 'bool' },
],
name: 'deposit',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'uint256', name: 'assets', type: 'uint256' },
{ internalType: 'address', name: 'receiver', type: 'address' },
{ internalType: 'uint16', name: 'referralCode', type: 'uint16' },
{ internalType: 'bool', name: 'depositToAave', type: 'bool' },
],
name: 'deposit',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'uint256', name: 'shares', type: 'uint256' },
{ internalType: 'address', name: 'receiver', type: 'address' },
{ internalType: 'address', name: 'owner', type: 'address' },
{ internalType: 'bool', name: 'withdrawFromAave', type: 'bool' },
],
name: 'redeem',
outputs: [
{ internalType: 'uint256', name: '', type: 'uint256' },
{ internalType: 'uint256', name: '', type: 'uint256' },
],
stateMutability: 'nonpayable',
type: 'function',
},
] as const
35 changes: 35 additions & 0 deletions src/views/issuance/components/wrapping/CollateralItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ const CollateralItem = ({ collateral, wrapping, ...props }: Props) => {
return undefined
}

const COMPv2ABI = [
{
inputs: [
{ internalType: 'uint256', name: '_amount', type: 'uint256' },
{ internalType: 'address', name: '_to', type: 'address' },
],
name: 'deposit',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'uint256', name: '_amount', type: 'uint256' },
{ internalType: 'address', name: '_to', type: 'address' },
],
name: 'withdraw',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
]
const parsedAmount = safeParseEther(debouncedAmount, data.decimals)
const call = { abi: CollateralWrap, address: collateral.erc20 }

Expand All @@ -88,6 +110,12 @@ const CollateralItem = ({ collateral, wrapping, ...props }: Props) => {
: [wallet, parsedAmount, true], // change 1 to 0 when going from aToken
}
case 'CURVE':
return {
...call,
abi: COMPv2ABI,
functionName: wrapping ? 'deposit' : 'withdraw',
args: [parsedAmount, wallet],
}
case 'CONVEX':
return {
...call,
Expand All @@ -104,9 +132,16 @@ const CollateralItem = ({ collateral, wrapping, ...props }: Props) => {
: [parsedAmount, wallet, wallet],
}
case 'FLUX':
return {
...call,
abi: COMPv2ABI,
functionName: wrapping ? 'deposit' : 'withdraw',
args: [parsedAmount, wallet],
}
case 'COMP':
return {
...call,
abi: COMPv2ABI,
functionName: wrapping ? 'deposit' : 'withdraw',
args: [parsedAmount, wallet],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const WrapCollateralList = () => {

{collateralsByProtocol[protocol].map((c) => (
<CollateralItem
key={c.address}
key={`${wrapping ? 'wrap' : 'unwrap'}-${c.address}`}
mt={3}
collateral={c}
wrapping={wrapping}
Expand Down

0 comments on commit 9a4493d

Please sign in to comment.