diff --git a/Connector_agent/src/agent.spec.ts b/Connector_agent/src/agent.spec.ts index b6d3f5f..fd98c43 100644 --- a/Connector_agent/src/agent.spec.ts +++ b/Connector_agent/src/agent.spec.ts @@ -112,7 +112,7 @@ describe('Detect Instadapp Connector Contract Event', () => { description: `Instadapp ADDED Connector Event is detected.`, alertId: 'INSTADAPP-16', protocol: 'INSTADAPP', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) @@ -137,7 +137,7 @@ describe('Detect Instadapp Connector Contract Event', () => { description: `Instadapp UPDATED Connector Event is detected.`, alertId: 'INSTADAPP-16', protocol: 'INSTADAPP', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) @@ -162,7 +162,7 @@ describe('Detect Instadapp Connector Contract Event', () => { description: `Instadapp REMOVED Connector Event is detected.`, alertId: 'INSTADAPP-16', protocol: 'INSTADAPP', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) diff --git a/Connector_agent/src/agent.ts b/Connector_agent/src/agent.ts index a5d52ba..c159036 100644 --- a/Connector_agent/src/agent.ts +++ b/Connector_agent/src/agent.ts @@ -44,7 +44,7 @@ const handleTransaction: HandleTransaction = async ( description: `Instadapp ${sig} Connector Event is detected.`, alertId: 'INSTADAPP-16', protocol: 'INSTADAPP', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }) ) diff --git a/Governance_agent/src/agent.spec.ts b/Governance_agent/src/agent.spec.ts index 43ee1c2..db1fdea 100644 --- a/Governance_agent/src/agent.spec.ts +++ b/Governance_agent/src/agent.spec.ts @@ -110,7 +110,7 @@ describe('Detect Instadapp Governance Event', () => { description: `Instadapp QUEUE Proposal Event is detected.`, alertId: 'Instadapp-12', protocol: 'Instadapp', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) @@ -135,7 +135,7 @@ describe('Detect Instadapp Governance Event', () => { description: `Instadapp EXECUTE Proposal Event is detected.`, alertId: 'Instadapp-12', protocol: 'Instadapp', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) @@ -160,7 +160,7 @@ describe('Detect Instadapp Governance Event', () => { description: `Instadapp CANCEL Proposal Event is detected.`, alertId: 'Instadapp-12', protocol: 'Instadapp', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) diff --git a/Governance_agent/src/agent.ts b/Governance_agent/src/agent.ts index a91a2e7..1c6c278 100644 --- a/Governance_agent/src/agent.ts +++ b/Governance_agent/src/agent.ts @@ -37,7 +37,7 @@ const handleTransaction: HandleTransaction = async ( description: `Instadapp ${sig} Proposal Event is detected.`, alertId: 'Instadapp-12', protocol: 'Instadapp', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }) ) diff --git a/INST_Tracking_agent/src/agent.js b/INST_Tracking_agent/src/agent.js index ec0dea9..ba46034 100644 --- a/INST_Tracking_agent/src/agent.js +++ b/INST_Tracking_agent/src/agent.js @@ -26,7 +26,7 @@ function provideHandleTransaction(amountThreshold) { InstTransfer.args.value.toString() ).dividedBy(10 ** INST_DECIMALS) - if (amount.isLessThan(amountThreshold)) return; + if (amount.isLessThan(amountThreshold)) return findings; const formattedAmount = amount.toFixed(2); findings.push( diff --git a/Implementation _agent/src/agent.spec.ts b/Implementation _agent/src/agent.spec.ts index f7cad48..3233fb6 100644 --- a/Implementation _agent/src/agent.spec.ts +++ b/Implementation _agent/src/agent.spec.ts @@ -110,7 +110,7 @@ describe('Detect Instadapp Implementation Contract Event', () => { description: `Instadapp SETDEFAULT Implementation Event is detected.`, alertId: 'Instadapp-14', protocol: 'Instadapp', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) @@ -135,7 +135,7 @@ describe('Detect Instadapp Implementation Contract Event', () => { description: `Instadapp ADD Implementation Event is detected.`, alertId: 'Instadapp-14', protocol: 'Instadapp', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) @@ -160,7 +160,7 @@ describe('Detect Instadapp Implementation Contract Event', () => { description: `Instadapp REMOVE Implementation Event is detected.`, alertId: 'Instadapp-14', protocol: 'Instadapp', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }), ]) diff --git a/Implementation _agent/src/agent.ts b/Implementation _agent/src/agent.ts index 0c5a0d0..a034e32 100644 --- a/Implementation _agent/src/agent.ts +++ b/Implementation _agent/src/agent.ts @@ -37,7 +37,7 @@ const handleTransaction: HandleTransaction = async ( description: `Instadapp ${sig} Implementation Event is detected.`, alertId: 'Instadapp-14', protocol: 'Instadapp', - type: FindingType.Unknown, + type: FindingType.Info, severity: FindingSeverity.Info, }) ) diff --git a/Token_Tracking_agent/src/agent.spec.js b/Token_Tracking_agent/src/agent.spec.js new file mode 100644 index 0000000..0119cfa --- /dev/null +++ b/Token_Tracking_agent/src/agent.spec.js @@ -0,0 +1,92 @@ + +const BigNumber = require("bignumber.js"); +const { Finding, FindingSeverity, FindingType } = require("forta-agent"); +const { provideHandleTransaction } = require("./agent"); + +const { + DAI_ADDRESS, + TRANSFER_EVENT, + DAI_DECIMALS, + USDC_ADDRESS, + USDC_DECIMALS +} = require("./constants"); + +describe("large transfer event agent", () => { + let handleTransaction; + const mockAmountThreshold = "1000"; + const mockTxEvent = { + filterLog: jest.fn(), + }; + + beforeAll(() => { + handleTransaction = provideHandleTransaction(mockAmountThreshold); + }); + + beforeEach(() => { + mockTxEvent.filterLog.mockReset(); + }); + + + + it("returns empty findings if there are no transfer events", async () => { + + mockTxEvent.filterLog.mockReturnValue([]); + const findings = await handleTransaction(mockTxEvent); + // console.log("findings", findings) + expect(findings).toStrictEqual([]); + }); + + it("returns empty findings if there are large token transfer events but no dsa address is involved", async () => { + const amount = new BigNumber("1001"); + const formattedAmount = amount.toFixed(2); + const mockDaiTransferEvent = { + args: { + from: "0x80f36f504c63b7663cebcdecb2ae7620a1fcb6e1", + to: "0x6b175474e89094c44da98b954eedeac495271d0f", + value: amount.multipliedBy(10 ** DAI_DECIMALS), + }, + }; + mockTxEvent.filterLog.mockReturnValueOnce([mockDaiTransferEvent]); + mockTxEvent.filterLog.mockReturnValueOnce([]); + + const findings = await handleTransaction(mockTxEvent); + + expect(findings).toStrictEqual([]); + }); + + it("returns findings if there are large token transfer events involving dsa address", async () => { + + const amount = new BigNumber("1001"); + const formattedAmount = amount.toFixed(2); + const mockDaiTransferEvent = { + args: { + from: "0xf151ed2caedbda83c17ae39d6990d92909fcf529", // dsa + to: "0x4f58985b75eec8f14c536878a19eadf4a1960d6c", + value: amount.multipliedBy(10 ** DAI_DECIMALS), + }, + }; + mockTxEvent.filterLog.mockReturnValueOnce([mockDaiTransferEvent]); + mockTxEvent.filterLog.mockReturnValueOnce([]); + + const findings = await handleTransaction(mockTxEvent); + + expect(findings).toStrictEqual([ + Finding.fromObject({ + name: "Large DAI Transfer", + description: `${formattedAmount} DAI Transferred`, + alertId: "INST-41", + severity: FindingSeverity.Info, + type: FindingType.Info, + metadata: { + from: mockDaiTransferEvent.args.from, + to: mockDaiTransferEvent.args.to, + amount: formattedAmount, + }, + }), + ]); + + }); + + + +}); \ No newline at end of file diff --git a/Token_Tracking_agent/src/constants.js b/Token_Tracking_agent/src/constants.js index 7c253e1..a01fb7e 100644 --- a/Token_Tracking_agent/src/constants.js +++ b/Token_Tracking_agent/src/constants.js @@ -19,8 +19,8 @@ function token(name, address, decimals) { } var tokens = [ - new token("USDC", USDC_ADDRESS, USDC_DECIMALS), - new token("DAI", DAI_ADDRESS, DAI_DECIMALS) + new token("DAI", DAI_ADDRESS, DAI_DECIMALS), + new token("USDC", USDC_ADDRESS, USDC_DECIMALS) ]