Skip to content

Commit

Permalink
fix: set fee rate to 0 in e2e testing
Browse files Browse the repository at this point in the history
  • Loading branch information
chouandy committed Sep 6, 2023
1 parent c82276e commit e0daa64
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E Test Mainnet
name: E2E Test

on:
push:
Expand Down
1 change: 1 addition & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Pull Request Template

---

## Protocol Information

- **Name:**
Expand Down
70 changes: 39 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,55 @@ An SDK that build protocol logics for Protocolink
### Contribution Steps

1. **Create a New Logic:**
- Add a new folder under `src/logics` named after the protocol (protocolId), using Hyphenation format.
- Create a new logic file under `src/logics/{protocolId}`, named with the action name (logicId). Prefix it with `logic.` and use Hyphenation format. The file name should be `logic.{logicId}.ts`.

- Add a new folder under `src/logics` named after the protocol (protocolId), using Hyphenation format.
- Create a new logic file under `src/logics/{protocolId}`, named with the action name (logicId). Prefix it with `logic.` and use Hyphenation format. The file name should be `logic.{logicId}.ts`.

2. **Implement the Logic:**
- Implement the Logic class in the logic file using PascalCase. Append `Logic` to the action name.
- Extend the `core.Logic` class.
- Implement the following interfaces based on the requirements:
- `core.LogicTokenListInterface`: The tokens list function.
- `core.LogicOracleInterface`: The quotation function.
- `core.LogicBuilderInterface`: The txdata encode function for interacting with contracts.

**Example:**
```typescript
class LogicExampleLogic extends core.Logic implements
core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface {
// Your implementation here
}
```

- Implement the Logic class in the logic file using PascalCase. Append `Logic` to the action name.
- Extend the `core.Logic` class.
- Implement the following interfaces based on the requirements:
- `core.LogicTokenListInterface`: The tokens list function.
- `core.LogicOracleInterface`: The quotation function.
- `core.LogicBuilderInterface`: The txdata encode function for interacting with contracts.

**Example:**

```typescript
class LogicExampleLogic
extends core.Logic
implements core.LogicTokenListInterface, core.LogicOracleInterface, core.LogicBuilderInterface {
// Your implementation here
}
```

3. **Reference Examples:**
- Explore reference examples for different categories:
- Lending: [Aave V3](src/logics/aave-v2/), [Compound V3](src/logics/comopound-v3/)
- Swap: [Uniswap V3](src/logics/uniswap-v3/), [ParaSwap V5](src/logics/paraswap-v5/)
- FlashLoan: [Aave V3](src/logics/aave-v3/), [Balancer V2](src/logics/balancer-v2/)
- More: [GO](src/logics/)

- Explore reference examples for different categories:
- Lending: [Aave V3](src/logics/aave-v2/), [Compound V3](src/logics/comopound-v3/)
- Swap: [Uniswap V3](src/logics/uniswap-v3/), [ParaSwap V5](src/logics/paraswap-v5/)
- FlashLoan: [Aave V3](src/logics/aave-v3/), [Balancer V2](src/logics/balancer-v2/)
- More: [GO](src/logics/)

4. **Unit Testing:**
- Write tests that won't fail based on block number increments.
- Test files are in the same path as the logic files, named `logic.{logicId}.test.ts`.
- Write tests for functions like `getTokenList()` and `build()` as needed.

- Write tests that won't fail based on block number increments.
- Test files are in the same path as the logic files, named `logic.{logicId}.test.ts`.
- Write tests for functions like `getTokenList()` and `build()` as needed.

5. **Integration Testing:**
- Write tests that interact with the Router contract in real time.
- Test files are in `test/logics/{protocolId}/`, named `{logicId}.test.ts`.
- Utilize Logic's quotation functions to generate Logic Data for contract interactions.
- Verify transaction success and expected changes in user asset balances.

- Write tests that interact with the Router contract in real time.
- Test files are in `test/logics/{protocolId}/`, named `{logicId}.test.ts`.
- Utilize Logic's quotation functions to generate Logic Data for contract interactions.
- Verify transaction success and expected changes in user asset balances.

6. **Submit a Pull Request (PR)**:
- Use the [PR template](PULL_REQUEST_TEMPLATE.md) for PR content. Fill in the template and submit the PR.
- Enable "Allow edits by maintainers" when creating the PR.
- If your PR isn't merged promptly, feel free to ask for assistance on our Discord.

- Use the [PR template](PULL_REQUEST_TEMPLATE.md) for PR content. Fill in the template and submit the PR.
- Enable "Allow edits by maintainers" when creating the PR.
- If your PR isn't merged promptly, feel free to ask for assistance on our Discord.

### Get Involved and Learn More

Expand Down
2 changes: 2 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import '@nomicfoundation/hardhat-chai-matchers';
import '@protocolink/test-helpers';

import { HardhatUserConfig } from 'hardhat/config';
import { setup } from 'test/hooks';

const config: HardhatUserConfig = {
networks: {
Expand All @@ -22,6 +23,7 @@ const config: HardhatUserConfig = {
mocha: {
timeout: 1200000,
retries: 3,
rootHooks: { beforeAll: [setup] },
},
};

Expand Down
14 changes: 14 additions & 0 deletions test/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as core from '@protocolink/core';
import { getChainId } from '@protocolink/test-helpers';
import * as helpers from '@nomicfoundation/hardhat-network-helpers';

export async function setup() {
const hre = await import('hardhat');
const chainId = await getChainId();

const router = core.Router__factory.connect(core.getContractAddress(chainId, 'Router'), hre.ethers.provider);
const ownerAddress = await router.owner();
await helpers.impersonateAccount(ownerAddress);
const owner = hre.ethers.provider.getSigner(ownerAddress);
await router.connect(owner).setFeeRate(0);
}

0 comments on commit e0daa64

Please sign in to comment.