Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
8ce8b26
refactor extensions
EvanWang-TKSpring Apr 22, 2025
821cc67
add aave buffer staking contract
EvanWang-TKSpring Apr 22, 2025
41d0da5
fix issue
EvanWang-TKSpring Apr 22, 2025
a633a34
burn ft xt directly
EvanWang-TKSpring Apr 24, 2025
8e836a0
fix issues
EvanWang-TKSpring May 13, 2025
ba91122
Merge branch 'dev' into feat/external_staking
EvanWang-TKSpring May 13, 2025
b3c404f
integration
EvanWang-TKSpring May 13, 2025
3ab7cbb
market v2
EvanWang-TKSpring May 13, 2025
f87228f
rollover and ut
EvanWang-TKSpring May 15, 2025
ef1aad4
images
EvanWang-TKSpring May 15, 2025
3a2e6cf
rollover v1
EvanWang-TKSpring May 16, 2025
69b14ad
flashrepay ut
EvanWang-TKSpring May 16, 2025
67ad4b1
add batch pause/unpause functions
EvanWang-TKSpring May 19, 2025
318e080
Enhance GearingTokenEvents and AbstractGearingToken with FlashRepay f…
EvanWang-TKSpring May 19, 2025
e3d418d
fix issues
EvanWang-TKSpring May 20, 2025
9f77a3c
fix issues
EvanWang-TKSpring May 20, 2025
eaae2f3
new flash repay router function
EvanWang-TKSpring May 20, 2025
ca616db
fix ut
EvanWang-TKSpring May 20, 2025
fbfc496
add ut for rollover with additional collateral
EvanWang-TKSpring May 20, 2025
0ba5ce6
test revert sence
EvanWang-TKSpring May 20, 2025
a8cf9c8
fix issues and add ut for new functions
EvanWang-TKSpring May 21, 2025
3d2da9f
Merge branch 'dev' into 'feat/gt_roll_up'
EvanWang-TKSpring May 21, 2025
ffb9a7d
Merge branch 'feat/gt_roll_up' into 'dev'
EvanWang-TKSpring May 21, 2025
2bc6f48
Merge branch 'batch_swtich' into 'dev'
EvanWang-TKSpring May 21, 2025
b41e348
fix ut
EvanWang-TKSpring May 21, 2025
81efc48
add gt initialize events
EvanWang-TKSpring May 22, 2025
ae279a0
remove check of gt approvement
EvanWang-TKSpring May 22, 2025
2721a32
add market name fucntion
EvanWang-TKSpring May 22, 2025
3674ae4
Merge branch 'dev' into feat/external_staking
EvanWang-TKSpring May 22, 2025
e6cbf7e
TermMaxToken contract
EvanWang-TKSpring May 22, 2025
e9e694e
new diagrams
EvanWang-TKSpring May 23, 2025
a626492
contract and test for preTMX
0xAaronTK May 24, 2025
f10535d
doc
EvanWang-TKSpring May 26, 2025
10cf68d
refer docs
EvanWang-TKSpring May 26, 2025
1942668
add timelock
EvanWang-TKSpring May 26, 2025
0a99846
mock aave
EvanWang-TKSpring May 26, 2025
f2daf8c
1. AccessContorl -> Ownable2Step 2. Internal function with event
0xAaronTK May 26, 2025
c711c1d
update script for deploying PreTMX
0xAaronTK May 26, 2025
865e688
Merge branch 'feat/preTMX' into 'dev'
0xAaronTK May 26, 2025
4ca4761
update scripts
0xAaronTK May 26, 2025
944a844
Merge branch 'main' into 'dev'
0xAaronTK May 26, 2025
01e57ee
update script
0xAaronTK May 26, 2025
59be3a6
ut
EvanWang-TKSpring May 26, 2025
626a4b5
fix ut
EvanWang-TKSpring May 26, 2025
d744268
fix ut
EvanWang-TKSpring May 27, 2025
dd51f60
fuzz test
EvanWang-TKSpring May 27, 2025
1877c54
add ut for revert situation
EvanWang-TKSpring May 27, 2025
97d1f7a
Merge branch 'feat/external_staking' into feat/version_managenent
EvanWang-TKSpring May 27, 2025
da56079
add v1 contracts
EvanWang-TKSpring May 27, 2025
3a021ad
fix pt oracle issues
EvanWang-TKSpring May 28, 2025
eb26cd3
migration
EvanWang-TKSpring May 28, 2025
9cd9369
v2 contracts
EvanWang-TKSpring May 29, 2025
493071f
V2 router contract
EvanWang-TKSpring May 29, 2025
1d6b18b
v2 termmax token contract
EvanWang-TKSpring May 29, 2025
a28d3e7
v2 factory and access
EvanWang-TKSpring May 29, 2025
85f3ecd
add tokennomics to v2 folder
EvanWang-TKSpring May 29, 2025
bf71ea5
ut utils
EvanWang-TKSpring May 30, 2025
af28109
fix version
EvanWang-TKSpring Jun 2, 2025
ceff13c
fix ut
EvanWang-TKSpring Jun 2, 2025
f0da590
v2 unit tests
EvanWang-TKSpring Jun 2, 2025
0751e70
router v2 ut
EvanWang-TKSpring Jun 2, 2025
d1bc228
fork tests
EvanWang-TKSpring Jun 3, 2025
0f3977a
Integration test
EvanWang-TKSpring Jun 3, 2025
10dba36
remove old ut
EvanWang-TKSpring Jun 3, 2025
a9e3394
remove old contracts
EvanWang-TKSpring Jun 3, 2025
c01e035
fix changes
EvanWang-TKSpring Jun 3, 2025
46d3619
fix changes
EvanWang-TKSpring Jun 3, 2025
0e49634
termmax v1 unit tests
EvanWang-TKSpring Jun 4, 2025
ac2b003
add comments
EvanWang-TKSpring Jun 4, 2025
21053d5
Merge branch 'feat/version_managenent' into 'dev'
EvanWang-TKSpring Jun 4, 2025
1d04126
v2 adapters
EvanWang-TKSpring Jun 10, 2025
8b43056
remove supply and withdraw queue
EvanWang-TKSpring Jun 10, 2025
48b38c2
fix ut
EvanWang-TKSpring Jun 10, 2025
62d4528
fix vault v2 uts
EvanWang-TKSpring Jun 10, 2025
1e14462
check minApy
EvanWang-TKSpring Jun 10, 2025
d723daf
factory events
EvanWang-TKSpring Jun 10, 2025
dc3360e
check idle funds
EvanWang-TKSpring Jun 10, 2025
56a808a
functions for update min apy and min idleFundRate
EvanWang-TKSpring Jun 10, 2025
8247a61
add ut for idle fund rate
EvanWang-TKSpring Jun 10, 2025
75ee1ef
ut for apy protection
EvanWang-TKSpring Jun 10, 2025
fc0f8cd
add event for interest changes
EvanWang-TKSpring Jun 11, 2025
d7f5171
add tx reentrant guard for vault
EvanWang-TKSpring Jun 11, 2025
a5a8431
update termmax vault factory v2
EvanWang-TKSpring Jun 11, 2025
8fa9893
fork test
EvanWang-TKSpring Jun 11, 2025
49ecd17
add nonTxReentrantBetweenActions modifier and update vault methods; e…
EvanWang-TKSpring Jun 11, 2025
e89acc9
add minPrice parameter to IOracleV2 and update related contracts; enh…
EvanWang-TKSpring Jun 13, 2025
e390e6a
ut for minium price
EvanWang-TKSpring Jun 13, 2025
a1ba351
refactor: update action constants to use keccak256 for uniqueness; im…
EvanWang-TKSpring Jun 13, 2025
36b5464
feat: implement PlaceOrderForV1 event and update related functions; e…
EvanWang-TKSpring Jun 13, 2025
918b2d6
feat: add ITermMaxOrderV2 interface and related events; enhance order…
EvanWang-TKSpring Jun 15, 2025
4254b66
fix ut
EvanWang-TKSpring Jun 16, 2025
7053e0e
feat: update PlaceOrder event and implement placeOrderForV2 function;…
EvanWang-TKSpring Jun 16, 2025
1e2173a
add check when dealing baddebt
EvanWang-TKSpring Jun 16, 2025
3cef295
add missing interace and comments
EvanWang-TKSpring Jun 16, 2025
7b2c976
fix: change _processPriceRange function to internal pure for better g…
EvanWang-TKSpring Jun 17, 2025
00f4968
fix issue no.1
EvanWang-TKSpring Jun 19, 2025
b940cba
add comments
EvanWang-TKSpring Jun 19, 2025
a0a81dd
fix issue no.4
EvanWang-TKSpring Jun 19, 2025
4a758c0
round up div operations
EvanWang-TKSpring Jun 19, 2025
f65af75
fix issue no.8
EvanWang-TKSpring Jun 19, 2025
ab89f97
fix issue no.9
EvanWang-TKSpring Jun 19, 2025
ca1ca11
fix issue no. 13
EvanWang-TKSpring Jun 19, 2025
8e5e1e5
fix issues
EvanWang-TKSpring Jun 19, 2025
897298b
Fix typos
EvanWang-TKSpring Jun 20, 2025
e4fcb2f
sepecial adapters for v1 router
EvanWang-TKSpring Jun 20, 2025
aae7dc1
rename folder
EvanWang-TKSpring Jun 20, 2025
30b47a2
ut for it
EvanWang-TKSpring Jun 20, 2025
33c0826
scripts
EvanWang-TKSpring Jun 20, 2025
d19a1e4
merge deploy data
EvanWang-TKSpring Jun 20, 2025
53496c4
clean scripts
EvanWang-TKSpring Jun 20, 2025
abc18e2
update adapter to v2
0xAaronTK Jun 21, 2025
e817861
update
0xAaronTK Jun 21, 2025
91637cf
Deploy USDC/PT-cUSDO market. Deploy ETH and ARB adapters
TKSpringVincent Jun 21, 2025
1e847ba
simulate bnb mainnet adapters deployment
TKSpringVincent Jun 21, 2025
60b3daa
upadte
0xAaronTK Jun 21, 2025
907b45e
update log
0xAaronTK Jun 21, 2025
ab470cc
Deploy BNB adapter
TKSpringVincent Jun 21, 2025
a17ee9e
fork test for bnb pairs
EvanWang-TKSpring Jun 23, 2025
89cafe2
support repay for gt in router
EvanWang-TKSpring Jun 24, 2025
0e94198
upgrade script
EvanWang-TKSpring Jun 24, 2025
e94e05a
fix issue 4
EvanWang-TKSpring Jun 26, 2025
28a1506
fix issues 5
EvanWang-TKSpring Jun 26, 2025
c6cbea8
deploy USDC/SPK market
TKSpringVincent Jun 26, 2025
5af620d
fix issue 7
EvanWang-TKSpring Jun 26, 2025
200eb95
fix issue 8
EvanWang-TKSpring Jun 26, 2025
dff4f2e
fix issue 9
EvanWang-TKSpring Jun 26, 2025
fcc4afa
add check when initializing
EvanWang-TKSpring Jun 26, 2025
81365c0
fix issue 14
EvanWang-TKSpring Jun 26, 2025
d426aa1
fix issue 16
EvanWang-TKSpring Jun 26, 2025
51cd8a9
fix issue 19
EvanWang-TKSpring Jun 26, 2025
e154de3
fix issue 29
EvanWang-TKSpring Jun 26, 2025
89f6893
fix issue 30 and 31
EvanWang-TKSpring Jun 26, 2025
7a0b428
fix issue 35
EvanWang-TKSpring Jun 26, 2025
4d0e1c1
fix issue 36
EvanWang-TKSpring Jun 26, 2025
815bcc3
fix issue 43
EvanWang-TKSpring Jun 26, 2025
75000e7
fix issue 49
EvanWang-TKSpring Jun 26, 2025
0008a5e
fix issue 55
EvanWang-TKSpring Jun 26, 2025
b37a632
fix issue 58
EvanWang-TKSpring Jun 26, 2025
23b76ca
upgrade router on Ethereum and Arbitrum. BNB failed to verify
TKSpringVincent Jun 26, 2025
2a236e0
fix issue 58
EvanWang-TKSpring Jun 26, 2025
15748ae
fix issue 60
EvanWang-TKSpring Jun 26, 2025
01da9cc
fix issue 60
EvanWang-TKSpring Jun 26, 2025
455369d
fix issue 67
EvanWang-TKSpring Jun 26, 2025
2c69968
fix issue 74
EvanWang-TKSpring Jun 26, 2025
1a78bdf
add repay gt function to avoid ddos attack
EvanWang-TKSpring Jun 26, 2025
863c198
Compatible with V1 market
EvanWang-TKSpring Jun 26, 2025
01db0f8
update DeployAdapters and script.sh
0xAaronTK Jun 27, 2025
6df7308
deploye new adapters on ETH, ARB, BNB
TKSpringVincent Jun 30, 2025
9c6a90d
Merge branch 'v1_special_adapter' into 'dev'
EvanWang-TKSpring Jul 3, 2025
1fe5792
fix warning and compile error
0xAaronTK Jul 3, 2025
4d69bfa
update license
EvanWang-TKSpring Jul 8, 2025
a62a9f6
fix issues 1
EvanWang-TKSpring Jul 17, 2025
afc2126
fix issues 4
EvanWang-TKSpring Jul 17, 2025
854402a
fix issue 5
EvanWang-TKSpring Jul 17, 2025
5f0edc1
fix issue 7
EvanWang-TKSpring Jul 17, 2025
728252f
fix issue 8
EvanWang-TKSpring Jul 17, 2025
2aa37c0
add flash repay output checking
EvanWang-TKSpring Jul 17, 2025
45746fd
fix issue 10
EvanWang-TKSpring Jul 17, 2025
e51ef56
add check for gt initilization
EvanWang-TKSpring Jul 17, 2025
7ef4db1
fix issue 15
EvanWang-TKSpring Jul 17, 2025
e585248
fix issue 15
EvanWang-TKSpring Jul 17, 2025
9073fdf
fix issue 17
EvanWang-TKSpring Jul 17, 2025
15b383d
fix issue 21
EvanWang-TKSpring Jul 17, 2025
ba1e1cf
fix issues 22
EvanWang-TKSpring Jul 17, 2025
3c03b86
fix issues and remove comments
EvanWang-TKSpring Jul 17, 2025
1db5a50
simplify liquidate process
EvanWang-TKSpring Jul 18, 2025
71b5651
simplify liquidate process
EvanWang-TKSpring Jul 18, 2025
00b48c5
fix issue 31
EvanWang-TKSpring Jul 18, 2025
0340da5
remove trasfer to whitelist from PreTMX
EvanWang-TKSpring Jul 18, 2025
3769827
fix interfaces
EvanWang-TKSpring Jul 18, 2025
29ba9fb
fix issue 39
EvanWang-TKSpring Jul 18, 2025
28c2926
fix issues 40
EvanWang-TKSpring Jul 18, 2025
cc5d242
fix issues 45
EvanWang-TKSpring Jul 18, 2025
4a39d02
fix issue 44,45
EvanWang-TKSpring Jul 18, 2025
193ad9f
fix issue 48
EvanWang-TKSpring Jul 18, 2025
43bf5cf
fix issue 51,52
EvanWang-TKSpring Jul 18, 2025
a0f453e
fix issue 53
EvanWang-TKSpring Jul 18, 2025
c55a043
fix doc
EvanWang-TKSpring Jul 18, 2025
5bb2c75
fix docs
EvanWang-TKSpring Jul 18, 2025
f402bdb
fix issue 60
EvanWang-TKSpring Jul 18, 2025
ac53443
fix issue 61
EvanWang-TKSpring Jul 21, 2025
3bc1aac
fix issue 62
EvanWang-TKSpring Jul 21, 2025
be098f9
fix issue 65
EvanWang-TKSpring Jul 21, 2025
538d1c1
fix issue 69
EvanWang-TKSpring Jul 21, 2025
cdfbfdd
fix issue 75
EvanWang-TKSpring Jul 21, 2025
34c3770
remove unused interface
EvanWang-TKSpring Jul 21, 2025
51e83b1
solidity version
EvanWang-TKSpring Jul 21, 2025
eb2c06f
fix issue 115
EvanWang-TKSpring Jul 21, 2025
be99fad
fix issue 118
EvanWang-TKSpring Jul 21, 2025
cd0b252
fix issue 125
EvanWang-TKSpring Jul 21, 2025
3e69cd2
fix issue 132
EvanWang-TKSpring Jul 21, 2025
545957f
fix issue 144
EvanWang-TKSpring Jul 21, 2025
eb45ee5
fix issue 146
EvanWang-TKSpring Jul 21, 2025
0a686c1
fix issue 148
EvanWang-TKSpring Jul 21, 2025
fc1bb0c
fix issue 148
EvanWang-TKSpring Jul 22, 2025
80aa2c1
fix issue 185
EvanWang-TKSpring Jul 22, 2025
a90d6aa
fix issue 184
EvanWang-TKSpring Jul 22, 2025
cd2eb10
fix issue 189
EvanWang-TKSpring Jul 22, 2025
3edffdd
fix issue 2002
EvanWang-TKSpring Jul 22, 2025
08b74ef
fix issue 203
EvanWang-TKSpring Jul 22, 2025
31231e1
merge from deploy/preTMX
EvanWang-TKSpring Jul 22, 2025
ed0aa1e
Merge branch 'dev' into feat/preTMX
EvanWang-TKSpring Jul 22, 2025
0636bd4
fix test error
0xAaronTK Jul 22, 2025
95e52e0
fix ut
EvanWang-TKSpring Jul 22, 2025
bbc76ae
Merge branch 'feat/preTMX' into 'dev'
0xAaronTK Jul 23, 2025
26ae575
create specific vault v1.1.0
EvanWang-TKSpring Jul 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ The Business Source License (this document, or the "License") is not an Open Sou
This project incorporates code from or depends upon the following projects:

### GPL-licensed dependencies:
- **Uniswap V3 Core and Periphery** ([v3-core](https://github.com/Uniswap/v3-core), [v3-periphery](https://github.com/Uniswap/v3-periphery)), licensed under GPL-2.0-or-later
- **Morpho's MetaMorpho** ([metamorpho](https://github.com/morpho-org/metamorpho)), licensed under GPL-2.0
- **Uniswap V3 Core and Periphery** (use its interface for the AMM model without modification to the dependency) ([v3-core](https://github.com/Uniswap/v3-core), [v3-periphery](https://github.com/Uniswap/v3-periphery)), licensed under GPL-2.0-or-later
- **Morpho's MetaMorpho**( use its interface to swap tokens on Morpho without modification to the dependency) ([metamorpho](https://github.com/morpho-org/metamorpho)), licensed under GPL-2.0
- **Pendle Core V2** (use its interface to swap tokens on Pendle without modification to the dependency) ([pendle-core-v2-public](https://github.com/pendle-finance/pendle-core-v2-public)), licensed under GPL-3.0-or-later

### Other dependencies:
### MIT-licensed dependencies:
- **OpenZeppelin Contracts** ([openzeppelin-contracts](https://github.com/OpenZeppelin/openzeppelin-contracts), [openzeppelin-contracts-upgradeable](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable)), licensed under MIT
- **Chainlink** ([chainlink](https://github.com/smartcontractkit/chainlink)), licensed under MIT
- **Pendle Core V2** ([pendle-core-v2-public](https://github.com/pendle-finance/pendle-core-v2-public)), licensed under BUSL-1.1
- **Foundry's forge-std** ([forge-std](https://github.com/foundry-rs/forge-std)), licensed under MIT

Users of this software must comply with the terms of all applicable licenses.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Test without fork.
$ forge test --skip Fork
```

Using '--isolate' when testing TermMaxVault.

```shell
$ forge test --skip Fork --isolate
```

Using test scripts can configure multiple environments more flexibly, it will automatically configure the environment variables you need.
Do unit test if you have an env file named sepolia.env.

Expand Down
273 changes: 272 additions & 1 deletion SCRIPT_USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The `script.sh` utility is a flexible command runner that can handle both deploy
- `deploy:market` - Deploy Market contracts
- `deploy:order` - Deploy Order contracts
- `deploy:vault` - Deploy Vault contracts
- `deploy:pretmx` - Deploy PreTMX token contract
- Script commands:
- `script:<script-name>` - Run a custom script (e.g., `script:GrantRoles`, `script:SubmitOracles`)

Expand Down Expand Up @@ -63,6 +64,15 @@ The `script.sh` utility is a flexible command runner that can handle both deploy

# Run E2ETest script on Arbitrum Sepolia
./script.sh arb-sepolia script:E2ETest

# Deploy PreTMX token contract on Ethereum Sepolia (dry run)
./script.sh eth-sepolia deploy:pretmx

# Deploy PreTMX token contract on Arbitrum Mainnet and broadcast transactions
./script.sh arb-mainnet deploy:pretmx --broadcast

# Deploy PreTMX token contract with verification on Ethereum Mainnet
./script.sh eth-mainnet deploy:pretmx --broadcast --verify
```

## System Setup Flow
Expand Down Expand Up @@ -114,6 +124,46 @@ The proper sequence for setting up the TermMax system is as follows:

Following this sequence ensures that contracts are deployed with the correct dependency chain and permissions setup.

## PreTMX Token Deployment

The PreTMX token can be deployed independently of the main system flow as it's a standalone tokenomics contract:

```bash
# Deploy PreTMX token contract
./script.sh <network> deploy:pretmx --broadcast
```

This creates a `<network>-pretmx.json` file containing the PreTMX token contract details.

### PreTMX Token Features

- **Token Name**: "Pre TermMax Token"
- **Symbol**: "pTMX"
- **Initial Supply**: 1,000,000,000 tokens (1e9 ether)
- **Access Control**: Uses `Ownable2Step` for secure ownership transfer
- **Transfer Restrictions**: Transfers are initially restricted and require whitelisting
- **Initial State**: Admin is whitelisted for both sending and receiving transfers

### Post-Deployment Management

After deployment, the admin can manage the token through the following functions:

1. **Transfer Restrictions**:
- `enableTransfer()` - Remove all transfer restrictions
- `disableTransfer()` - Re-enable transfer restrictions

2. **Whitelist Management**:
- `whitelistTransferFrom(address, bool)` - Allow/disallow an address to send tokens
- `whitelistTransferTo(address, bool)` - Allow/disallow an address to receive tokens

3. **Token Operations**:
- `mint(address, uint256)` - Mint additional tokens (admin only)
- `burn(uint256)` - Burn tokens (any token holder)

4. **Ownership Transfer** (Two-step process for security):
- `transferOwnership(address)` - Initiate ownership transfer
- New owner calls `acceptOwnership()` - Complete the transfer

## Special Environment Variables

Some scripts require specific environment variables:
Expand Down Expand Up @@ -165,4 +215,225 @@ The oracle update process consists of two steps:
2. **Accept Oracles**: After the timelock period, use the `AcceptOracles` script to accept the pending oracles.
```bash
./script.sh <network> script:AcceptOracles --broadcast
```
```

## Date Suffix System for Script JSON Output

The script system automatically appends date suffixes to JSON output files to create unique, timestamped records for each execution.

### Overview

The system automatically appends date suffixes to JSON output files to:
- Create unique records for each script execution
- Prevent overwriting previous execution results
- Enable historical tracking of deployments and contract interactions
- Facilitate auditing and debugging

### Date Format

The date suffix uses the format: `DDMMMYYYY` (e.g., `15JAN2024`)
- `DD`: Two-digit day (01-31)
- `MMM`: Three-letter month abbreviation (JAN, FEB, MAR, etc.)
- `YYYY`: Four-digit year

### File Structure

#### Deployment Scripts
Deployment scripts save JSON files to: `/deployments/{network}/{network}-{contractType}-{dateSuffix}.json`

Examples:
- `/deployments/eth-sepolia/eth-sepolia-pretmx-15JAN2024.json`
- `/deployments/arb-mainnet/arb-mainnet-core-15JAN2024.json`
- `/deployments/eth-mainnet/eth-mainnet-access-manager-15JAN2024.json`

#### Contract Call Scripts
Contract call scripts save JSON files to: `/executions/{network}/{network}-{scriptName}-{dateSuffix}.json`

Examples:
- `/executions/eth-sepolia/eth-sepolia-SubmitOracles-15JAN2024.json`
- `/executions/arb-mainnet/arb-mainnet-AcceptOracles-15JAN2024.json`
- `/executions/eth-mainnet/eth-mainnet-GrantRoles-15JAN2024.json`

### Implementation

#### For Deployment Scripts

Deployment scripts inherit from `DeployBase` which provides:

```solidity
// Helper function to generate date suffix
function getDateSuffix() internal view returns (string memory) {
return StringHelper.convertTimestampToDateString(block.timestamp);
}

// Helper function to create deployment file path with date suffix
function getDeploymentFilePath(string memory network, string memory contractType)
internal view returns (string memory) {
string memory dateSuffix = getDateSuffix();
string memory deploymentsDir = string.concat(vm.projectRoot(), "/deployments/", network);
return string.concat(deploymentsDir, "/", network, "-", contractType, "-", dateSuffix, ".json");
}
```

Usage in deployment scripts:
```solidity
// Write the JSON file with date suffix
string memory filePath = getDeploymentFilePath(network, "pretmx");
vm.writeFile(filePath, deploymentJson);
```

#### For Contract Call Scripts

Contract call scripts inherit from `ScriptBase` which provides:

```solidity
// Helper function to create script execution file path with date suffix
function getScriptExecutionFilePath(string memory network, string memory scriptName)
internal view returns (string memory) {
string memory dateSuffix = getDateSuffix();
string memory executionsDir = string.concat(vm.projectRoot(), "/executions/", network);
return string.concat(executionsDir, "/", network, "-", scriptName, "-", dateSuffix, ".json");
}

// Helper function to write script execution results to JSON
function writeScriptExecutionResults(
string memory network,
string memory scriptName,
string memory executionData
) internal {
// Create executions directory if it doesn't exist
string memory executionsDir = string.concat(vm.projectRoot(), "/executions/", network);
if (!vm.exists(executionsDir)) {
vm.createDir(executionsDir, true);
}

// Write the JSON file with date suffix
string memory filePath = getScriptExecutionFilePath(network, scriptName);
vm.writeFile(filePath, executionData);
console.log("Script execution information written to:", filePath);
}
```

Usage in contract call scripts:
```solidity
// Generate execution results JSON
uint256 currentBlock = block.number;
uint256 currentTimestamp = block.timestamp;

string memory baseJson = createBaseExecutionJson(network, "SubmitOracles", currentBlock, currentTimestamp);

// Add script-specific data
string memory executionJson = string(
abi.encodePacked(
baseJson,
',\n',
' "results": {\n',
' "totalConfigs": "',
vm.toString(configs.length),
'"\n',
" }\n",
"}"
)
);

writeScriptExecutionResults(network, "SubmitOracles", executionJson);
```

### JSON Structure

#### Deployment Scripts JSON
```json
{
"network": "eth-sepolia",
"deployedAt": "1705334400",
"gitBranch": "main",
"gitCommitHash": "0xabc123...",
"blockInfo": {
"number": "12345678",
"timestamp": "1705334400"
},
"deployer": "0x123...",
"admin": "0x456...",
"contracts": {
"preTMX": {
"address": "0x789...",
"name": "PreTMX Token",
"symbol": "PreTMX",
"totalSupply": "1000000000000000000000000000",
"owner": "0x456...",
"transferRestricted": true
}
}
}
```

#### Contract Call Scripts JSON
```json
{
"network": "eth-sepolia",
"scriptName": "SubmitOracles",
"executedAt": "1705334400",
"gitBranch": "main",
"gitCommitHash": "0xabc123...",
"blockInfo": {
"number": "12345678",
"timestamp": "1705334400"
},
"results": {
"totalConfigs": "5",
"oracleAggregatorAddress": "0x123...",
"accessManagerAddress": "0x456..."
}
}
```

### Updated Scripts

#### Deployment Scripts
- ✅ `DeployBase.s.sol` - Base contract with date suffix utilities
- ✅ `DeployPretmx.s.sol` - Updated to use date suffixes

#### Contract Call Scripts
- ✅ `ScriptBase.sol` - Base contract with JSON output and date suffix utilities
- ✅ `SubmitOracles.s.sol` - Updated with JSON output and date suffixes
- ✅ `AcceptOracles.s.sol` - Updated with JSON output and date suffixes
- ✅ `GrantRoles.s.sol` - Updated with JSON output and date suffixes

#### Scripts to Update
Other contract call scripts can be updated by:
1. Changing inheritance from `Script` to `ScriptBase`
2. Adding JSON output generation at the end of the `run()` function
3. Using `writeScriptExecutionResults()` to save the JSON file

### Benefits

1. **Historical Tracking**: Each execution creates a unique record
2. **Audit Trail**: Complete history of deployments and contract interactions
3. **Debugging**: Easy to compare different execution results
4. **No Overwrites**: Previous execution data is preserved
5. **Organized Storage**: Clear separation between deployments and executions
6. **Timestamped Records**: Easy to identify when operations occurred

### Directory Structure

```
project-root/
├── deployments/
│ ├── eth-sepolia/
│ │ ├── eth-sepolia-pretmx-15JAN2024.json
│ │ ├── eth-sepolia-core-15JAN2024.json
│ │ └── eth-sepolia-access-manager-14JAN2024.json
│ └── arb-mainnet/
│ ├── arb-mainnet-pretmx-15JAN2024.json
│ └── arb-mainnet-core-15JAN2024.json
└── executions/
├── eth-sepolia/
│ ├── eth-sepolia-SubmitOracles-15JAN2024.json
│ ├── eth-sepolia-AcceptOracles-15JAN2024.json
│ └── eth-sepolia-GrantRoles-14JAN2024.json
└── arb-mainnet/
├── arb-mainnet-SubmitOracles-15JAN2024.json
└── arb-mainnet-AcceptOracles-15JAN2024.json
```

This system ensures comprehensive tracking of all script executions while maintaining organized, timestamped records for audit and debugging purposes.
Loading
Loading