diff --git a/src/Extensions.ts b/src/Extensions.ts index b950c68..a83d717 100644 --- a/src/Extensions.ts +++ b/src/Extensions.ts @@ -55,5 +55,34 @@ export const extensions: Extension[] = [ supportedMarkets: { '1_USDC_0xc3d688B66703497DAA19211EEdff47f25384cdc3': null } + }, + { + id: 'collateral_swap', + name: 'Collateral Swap', + description: 'Enables swapping collateral on open loan positions without the need to repay the loan, in a single transaction', + developer: 'Wido Labs', + links: { + github: 'https://github.com/widolabs/compound-collateral-extension-ui', + website: 'https://www.joinwido.com/' + }, + permissions: { + sign: '*', + trx: [ + { + contract: '$operator', + abi: 'swapCollateral((address,uint256),(address,uint256),((uint8,bytes32,bytes32),(uint8,bytes32,bytes32)),(address,address,bytes),address)', + params: '*' + } + ] + }, + source: { + url: "https://ipfs.fleek.co/ipfs/QmcEEQekV9Vz4oN519uBsPLqjXUs7YathsvGvjNtbC3Y88/embedded.html" + }, + supportedMarkets: { + '1_USDC_0xc3d688B66703497DAA19211EEdff47f25384cdc3': '0xaAA9f2FeE419977804eBD06F6E121f76FbcE8498', + '1_ETH_0xA17581A9E3356d9A858b789D68B4d866e593aE94': '0xaAA9f2FeE419977804eBD06F6E121f76FbcE8498', + '137_USDC_0xF25212E676D1F7F89Cd72fFEe66158f541246445': '0x17000CdCCCFf2D0B2d8958BA40c751Fa9b4BE089', + '42161_USDC.e_0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA': '0x74436167012475749168f33324e84990C8013647' + } } ]; diff --git a/src/Permissions.ts b/src/Permissions.ts index 5e348b7..c578c07 100644 --- a/src/Permissions.ts +++ b/src/Permissions.ts @@ -93,6 +93,9 @@ function isTypeParams(params: any[]): params is [ string, TypeParams ] { } function checkSendTransaction(params: any[], { trx }: Permissions, operator: string | null): null | string { + console.log('params', params); + console.log('trx', trx); + console.log('operator', operator); if (trx === '*') { return null; } else { @@ -105,6 +108,8 @@ function checkSendTransaction(params: any[], { trx }: Permissions, operator: str let contract = trxPerm.contract; if (contract === '$operator') { if (!operator) { + console.log('Operator is null'); + console.log('operator', operator); return false; } @@ -112,6 +117,9 @@ function checkSendTransaction(params: any[], { trx }: Permissions, operator: str } if (!strEq(contract, callParams.to)) { + console.log('Contract is not equal to callParams.to'); + console.log('contract', contract); + console.log('callParams.to', callParams.to); return false; } } @@ -129,12 +137,18 @@ function checkSendTransaction(params: any[], { trx }: Permissions, operator: str } let func = Object.values(iface.functions)[0]; if (!strEq(callParams.data.slice(0, 10), iface.getSighash(func.name))) { + console.log(`Mismatch. Expected: ${iface.getSighash(func.name)}, Received: ${callParams.data.slice(0, 10)}`); + console.log('callParams.data', callParams.data); + console.log('func.name', func.name); + console.log('abi', abi.toString()); return false; } let funcParamsEnc = callParams.data.slice(10); if (trxPerm.params === undefined || trxPerm.params === '*') { return true; } else { + console.log('trxPerm.params is not equal to undefined or "*"'); + console.log('trxPerm.params', trxPerm.params); let decodedParams = iface.decodeFunctionData(func, callParams.data); let matchesParams = trxPerm.params.every((param, index) => { let decodedParam = decodedParams[index];