Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI workflow #118

Closed
wants to merge 505 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
505 commits
Select commit Hold shift + click to select a range
fdaa752
WIP test multichain createDeposit flow
dmax10 Feb 18, 2025
76260fe
change token permit nonce and srcChainId
dmax10 Feb 18, 2025
b4fd7ae
Add provider specific function param on bridgeOut
dmax10 Feb 19, 2025
957a63b
Fix multichain transferOut logic
dmax10 Feb 19, 2025
170376a
Remove double validation for desChainId
dmax10 Feb 19, 2025
15b0f4c
Change transferRequests structure, update typehashes
dmax10 Feb 19, 2025
81baa9f
Test multichain deposit
dmax10 Feb 19, 2025
c7d699d
Fix ETH deposit and fee payment
dmax10 Feb 20, 2025
3447978
Split CreateWithdrawalParams into subgroups to solve relay typehash e…
dmax10 Feb 20, 2025
082d847
Add error params
dmax10 Feb 20, 2025
b252c9f
WIP test multichain withdrawal
dmax10 Feb 20, 2025
0e839d0
squash - refactor callbacks to eventdata
Feb 21, 2025
45b28d4
Merge pull request #115 from gmx-io/refactor-callbacks-to-event-structs
xvi10 Feb 21, 2025
9b51da4
squash - refactor callbacks to eventdata
Feb 21, 2025
5bd23ed
Merge branch 'refactor-callbacks-to-event-structs' of github.com:gmx-…
Feb 21, 2025
d52370b
fix tests
Feb 21, 2025
6a7a5f9
Merge branch 'refactor-callbacks-to-event-structs' into multichain
Feb 21, 2025
087476a
Merge branch 'gasless' into v2.2-branch
dmax10 Feb 22, 2025
4523ce7
Merge branch 'v2.2-branch' into multichain
dmax10 Feb 22, 2025
583cbab
Fix tests after gasless merge
dmax10 Feb 22, 2025
289c310
CI workflow
Feb 24, 2025
d70ff42
use yarn
Feb 24, 2025
9700a7e
run CI on every PR
Feb 24, 2025
8bcd04b
Add bracket spacing on auto-format
dmax10 Dec 4, 2024
7b7f6f7
Add multichain vault contract
dmax10 Dec 4, 2024
9bbeaf5
Add multichain balance key
dmax10 Dec 4, 2024
b9b8285
Add multichain utils contract
dmax10 Dec 4, 2024
af8c7a4
Add multichain handler contract
dmax10 Dec 4, 2024
4cba7e2
Add multichain event utils contract
dmax10 Dec 4, 2024
fce6a33
Add multichain withdrawal
dmax10 Dec 5, 2024
a3af8ec
Add multichain provider interface, multichain provider signature cont…
dmax10 Dec 8, 2024
f0040fa
Add multichain errors, small refactor
dmax10 Dec 8, 2024
3e44ef4
Add LayerZero provider, add 0.8.20 compiler
dmax10 Dec 8, 2024
5e0de7e
Add LZ event utils lib, emit withdraw receipt params on sending token…
dmax10 Dec 9, 2024
b99c34f
Simplify LayerZeroProvider contract (keep only lzCompose for now)
dmax10 Dec 9, 2024
d0b1da7
Make lib functions internal
dmax10 Dec 9, 2024
e4fd934
Fix compilers error, add source chain balance key under the allowed b…
dmax10 Dec 10, 2024
767b7c8
Remove multichain controller role, use controller role for provider c…
dmax10 Dec 11, 2024
f767a4c
Change lib method to internal
dmax10 Dec 11, 2024
41c32e8
Add simplified mock stargate pool contract
dmax10 Dec 11, 2024
bc4001c
Add deploy scripts
dmax10 Dec 11, 2024
ce5a1af
Add multichain utils
dmax10 Dec 11, 2024
e7d3f5b
Test deposit flow
dmax10 Dec 11, 2024
0fe57b7
Enable all tests
dmax10 Dec 11, 2024
69f9e10
Store open position price impact on position open instead of charging…
dmax10 Dec 16, 2024
2bdc205
Keep the original event key since it is used for e.g. analytics
dmax10 Dec 17, 2024
87c174a
Remove comments
dmax10 Dec 17, 2024
bf7adac
Track impact pending amount using a hash from account and market.
dmax10 Dec 17, 2024
a201b71
test: export functions to generate the impact pending key
dmax10 Dec 17, 2024
bf77025
test: wip with comments
dmax10 Dec 17, 2024
af78847
add @layerzerolabs/lz-evm-protocol-v2
xdev10 Dec 18, 2024
491e338
Remove combined key logic for storing the pending impact
dmax10 Dec 18, 2024
2c079d0
Use position store instead of the data store for storing/retrieving p…
dmax10 Dec 18, 2024
074ed28
Fix proportional impact pending amount on decrease
dmax10 Dec 18, 2024
4c64842
Update "uncapped price impact" and "negative price impact, negative p…
dmax10 Dec 18, 2024
d1d05a9
wip "capped price impact"
dmax10 Dec 18, 2024
e0b802c
update comments
dmax10 Dec 19, 2024
84d6bcb
test update
dmax10 Dec 19, 2024
5768620
wip PairMarket "price impact"
dmax10 Dec 19, 2024
0aebdd5
Remove blank lines
dmax10 Dec 20, 2024
a2be58a
Update comments
dmax10 Dec 20, 2024
d99f907
Fix claimable amount logic
dmax10 Dec 20, 2024
3f3e1bb
comments update
dmax10 Dec 20, 2024
77a4c55
Get the negative impact factor for position when calcualing the diff
dmax10 Dec 21, 2024
6698cce
Cap priceImpactUsd to the min negative value
dmax10 Dec 23, 2024
6de0bef
test "Positive & negative impact fees for positions"
dmax10 Dec 26, 2024
6cba14d
Remove impact pending value from data store when position is closed
dmax10 Dec 27, 2024
910626e
update test "negative price impact, positive pnl"
dmax10 Dec 27, 2024
fbda537
Update pnl test cases
dmax10 Dec 29, 2024
ea5e82b
Update tests
dmax10 Jan 2, 2025
c3cfee9
update test "price impact pair market"
dmax10 Jan 3, 2025
fc2bb0a
Update life cycle tests
dmax10 Jan 3, 2025
3029f46
update test and comments
dmax10 Jan 4, 2025
29b3a9f
test liquidatable position on collateral decrease
dmax10 Jan 5, 2025
260ad6d
comments update
dmax10 Jan 5, 2025
9ff8103
Combine PriceImpact struct into ProcessCollateralCache, add comment w…
dmax10 Jan 6, 2025
265585e
Add proportionalImpactPendingUsd to emitPositionDecrease event
dmax10 Jan 6, 2025
1eb159d
Split getCappedPositionImpactUsd into capPositiveImpactUsdByPositionI…
dmax10 Jan 6, 2025
deb5348
Update price impact capping as follows:
dmax10 Jan 6, 2025
17f3fee
Rename totalPriceImpactUsd to priceImpactUsd in the capping method
dmax10 Jan 6, 2025
3c44354
Remove cappedTotalImpactUsd and update totalImpactUsd instead.
dmax10 Jan 7, 2025
030681f
Update tests for the new price impact capping logic
dmax10 Jan 7, 2025
fd81380
update test values
dmax10 Jan 8, 2025
e3ecb10
update comments
dmax10 Jan 8, 2025
8edcfcd
update test and comments
dmax10 Jan 8, 2025
aa3a4a1
Update comments
dmax10 Jan 9, 2025
520cbdb
Use balanceWasImproved instead of priceImpactUsd > 0 as forPositiveIm…
dmax10 Jan 12, 2025
3af7ab7
Use balanceWasImproved for crossover rebalance
dmax10 Jan 13, 2025
6f7bdc0
small refactor
dmax10 Jan 13, 2025
49e84d6
Update affiliate reward tests when balance was improved
dmax10 Jan 14, 2025
4742b91
Update comments
dmax10 Jan 14, 2025
3afe1b7
rename PriceImpactCache to GetDepositAmountOutCache
dmax10 Jan 15, 2025
d9d49af
fundingUsd in MarketUtils.getNextFundingAmountPerSize should be based…
dmax10 Jan 15, 2025
f59ea52
Update Config.setPositionImpactDistributionRate to validate that posi…
dmax10 Jan 15, 2025
10f2f84
Add uiFeeReceiver to deposit, withdrawal, shifts events
dmax10 Jan 15, 2025
378de9e
Clear market salt in MarketStoreUtils.remove
dmax10 Jan 15, 2025
34cb61a
Add bool isSimulation to OrderHandler._executeOrder
dmax10 Jan 15, 2025
3d6ea54
Allow zero execution fee for atomic withdrawals, since there is no ke…
dmax10 Jan 15, 2025
0c2d3be
Emit events for funding and borrowing factors
dmax10 Jan 15, 2025
aa79fd0
Remove dataStore salt setter and pass salt as param to the remove fun…
dmax10 Jan 16, 2025
ff2a942
test setPositionImpactDistributionRate if position impact pool is ful…
dmax10 Jan 16, 2025
274b1cd
Add cancellationReceiver to OrderCreated event
dmax10 Jan 13, 2025
330916f
Add token address to OracleTimestampsAreSmallerThanRequired error
dmax10 Jan 13, 2025
f260c0f
Reverts from cancellations of auto cancel orders should have a differ…
dmax10 Jan 13, 2025
cbde571
Use InsufficientWntAmountForExecutionFee instead of InsufficientWntAm…
dmax10 Jan 13, 2025
6ccd38e
Remove USAGE_FACTOR_IGNORE_OPEN_INTEREST after migration and make thi…
dmax10 Jan 13, 2025
ca3411e
Include orderKey in response for Reader.getAccountOrders
dmax10 Jan 14, 2025
688062d
Include positionKey in response for Reader.getPositionInfoList and Re…
dmax10 Jan 14, 2025
530548e
Revert "Add token address to OracleTimestampsAreSmallerThanRequired e…
dmax10 Jan 16, 2025
ab3a93a
Order.market should be validated for swap orders
dmax10 Jan 16, 2025
85e98af
Revert "Order.market should be validated for swap orders"
dmax10 Jan 17, 2025
93cb7c6
update OrderUtils.createOrder to validate that market address is zero…
dmax10 Jan 17, 2025
448f2cb
comment for distributionAmount precision
dmax10 Jan 17, 2025
698c001
Add ConfigUtils lib and move logic from the Config to reduce the cont…
dmax10 Jan 22, 2025
57887b6
Remove IConfigUtils interface and import ConfigUtils directly.
dmax10 Jan 23, 2025
2e4cc5a
Remove contructor param from Config
dmax10 Jan 23, 2025
f472fd6
Fix custom error message not being found in test
dmax10 Jan 23, 2025
a80579b
Rename position.impactPendingAmount to position.pendingImpactAmount
dmax10 Jan 20, 2025
3c24fdb
Rename IMPACT_PENDING_AMOUNT to PENDING_IMPACT_AMOUNT
dmax10 Jan 22, 2025
8bdcaa1
Refactor ExchangeRouter to reduce it's size
dmax10 Jan 21, 2025
8f6bfa8
update yarn
xdev10 Jan 27, 2025
c938625
WIP multichain
dmax10 Jan 27, 2025
7089714
Add support for bytes type in DataStore (bytesValues, getBytes, setBy…
dmax10 Jan 21, 2025
0f97eef
WIP add data field for deposits, orders, withdrawals, shifts etc
dmax10 Jan 21, 2025
0327f40
Revert changes for the DataStore
dmax10 Jan 22, 2025
1e52cb1
Replace bytes data field with bytes32[] dataList
dmax10 Jan 22, 2025
bc91053
Fix tests: default dataList to empty array
dmax10 Jan 22, 2025
7e32dab
Fix tests: increase expectedPropsLength by one for the structs where …
dmax10 Jan 22, 2025
4fc7702
Fix "get, set, remove" tests: add _dataList to sampleItem
dmax10 Jan 23, 2025
839056f
Add data length validation
dmax10 Jan 23, 2025
e9d7699
Add dataList to Orders
dmax10 Jan 23, 2025
d30c60d
Revert "Refactor ExchangeRouter to reduce it's size"
dmax10 Jan 23, 2025
e76563b
Add MAX_DATA_LENGTH to allowedBaseKeys
dmax10 Jan 23, 2025
c91820d
Comments update
dmax10 Jan 24, 2025
484fd72
Revert dataList for GlvShift
dmax10 Jan 24, 2025
57d4bbe
Remove dataList from ADL orders
dmax10 Jan 27, 2025
0a569e9
Rename error and fn for validating the dataList
dmax10 Jan 27, 2025
cd5bde1
Allow dataList to be optionally passed in for deposits, shifts, withd…
dmax10 Jan 27, 2025
89663e0
Set dataList field for CreateOrderParams
dmax10 Jan 27, 2025
b2632a5
Test dataList filed with non-empty values for deposits, shifts, withd…
dmax10 Jan 27, 2025
4ec954c
Add setSampleItemBytes32Array function which is dynamically setting v…
dmax10 Jan 27, 2025
7f12b53
Add dataList length validation for deposits, glvDeposits, withdrawals…
dmax10 Jan 27, 2025
468869a
Test dataList length validation for deposits, glvDeposits, withdrawal…
dmax10 Jan 27, 2025
85d390a
WIP Allow setting a CLAIMABLE_COLLATERAL_REDUCTION_FACTOR for (accoun…
dmax10 Jan 22, 2025
30de5bb
Move claimable reduction method from ConfigSyncer to Config
dmax10 Jan 22, 2025
a62a8b2
Move setClaimableCollateralReductionFactorForAccount logic from Confi…
dmax10 Jan 23, 2025
f01384d
Update claimableFactor logic
dmax10 Jan 23, 2025
fd0c489
ExchangeRouter refactor to reduce contract size: move claimFundingFee…
dmax10 Jan 24, 2025
d167060
ExchangeRouter refactor to reduce contract size: move claimCollateral…
dmax10 Jan 24, 2025
565bafd
Add CLAIMABLE_COLLATERAL_DELAY key
dmax10 Jan 24, 2025
0e81ea4
Reduce the claimableCollateral by the claimableReductionFactor
dmax10 Jan 24, 2025
84a9639
test claimableReductionFactor
dmax10 Jan 24, 2025
79e3467
Rename test case
dmax10 Jan 27, 2025
a2a5007
Use empty list for the dataList field since the callbackContract is a…
dmax10 Jan 28, 2025
cdeae99
Refactor GlvDepositUtils to reduce bytecode size
dmax10 Jan 28, 2025
7aa959f
Rename glv deposit utility lib
dmax10 Jan 31, 2025
41c0e8a
Rename deploy script
dmax10 Jan 31, 2025
afcbed4
Make BaseGelatoRelayRouter._sendTokens virtual to be able to override…
dmax10 Feb 1, 2025
ee462ed
fix compile errors
dmax10 Feb 1, 2025
650c2f1
Rename MultichainHandler in MultichainVaultHandler
dmax10 Feb 1, 2025
3804124
Add GaslessCreateDepositParams
dmax10 Feb 1, 2025
9e1953d
Add chainId to Deposit.Props
dmax10 Feb 1, 2025
233a222
Update multichain createDeposit logic
dmax10 Feb 1, 2025
991185a
Emit dataList for createDeposit, createWithdrawal, createOrder, updat…
dmax10 Feb 2, 2025
a36b739
Rename sourceChain* to multichain*
dmax10 Feb 3, 2025
b70fb57
Add multichain increase and decrease utils methods
dmax10 Feb 3, 2025
609e39b
Add chainId to Withdrawal, Shift, GlvDeposit, GlvWithdrawal
dmax10 Feb 3, 2025
b1ca5af
Fix increaseBalance: incrementUint instead of decrementUint
dmax10 Feb 4, 2025
70f8881
Set chainId for Deposit on executeShift, remove position chainId rela…
dmax10 Feb 4, 2025
ca713b9
WIP multichain deposits and gm logic
dmax10 Feb 4, 2025
cb9ec4c
Update multichain logic for fee payment
dmax10 Feb 5, 2025
9a7883b
Remove chainId from multichain balance
dmax10 Feb 5, 2025
c4ab991
Rename chainId to srcChainId
dmax10 Feb 5, 2025
040d6f6
Move srcChainId into RelayParams
dmax10 Feb 5, 2025
27b69d1
Emit srcChainId for createWithdrawal, createShift, createGlvDeposit, …
dmax10 Feb 6, 2025
a986dc1
Fix tests after merging gasless branch
dmax10 Feb 6, 2025
f26ca73
Use block.chainid as the desChainId to genearte gaslessCreateDepositP…
dmax10 Feb 6, 2025
4d57333
Add in and out multichain transfers methods to MultichainUtils lib. R…
dmax10 Feb 7, 2025
1a45d5a
Add multichainVault address to contracts and stucts
dmax10 Feb 7, 2025
b1a5dfe
Validate desChainId provided is block.chainid, rename gasless to mult…
dmax10 Feb 7, 2025
e3df70a
Add srcChainId to _sendTokens
dmax10 Feb 7, 2025
c0af8d3
Change Contracts { OrderVault orderVault } into Contracts { StrictBan…
dmax10 Feb 7, 2025
b487b48
Split CreateDepositParams into subgroups
dmax10 Feb 8, 2025
b45331e
Add srcChainId to orders
dmax10 Feb 9, 2025
09c6756
Add srcChainId to _sendTokens
dmax10 Feb 9, 2025
bed8402
Rename multichainId to srcChainId, remove second topic log
dmax10 Feb 10, 2025
177e95d
reorder method params
dmax10 Feb 10, 2025
26a8db3
Record residualFee under user's multichain balance when the residualF…
dmax10 Feb 10, 2025
e0afc83
Add srcChiainId field to CreateOrderParams struct
dmax10 Feb 10, 2025
46b2098
Use multichainVault as withdrawal receiver for GM/GLV for source chai…
dmax10 Feb 11, 2025
841220e
Implement multichain createGlvDeposit
dmax10 Feb 11, 2025
ac2a488
Use MultichainUtils as external lib to avoid increasing the size of t…
dmax10 Feb 11, 2025
545bd03
Implement multichain createGlvWithdrawal
dmax10 Feb 11, 2025
90e3fde
Fix function params order
dmax10 Feb 12, 2025
3a1cab0
Implement multichain createShift
dmax10 Feb 12, 2025
99528d3
Fix refund fee receiver for multichain actions
dmax10 Feb 12, 2025
bd74241
Refactor BaseGelatoRelayRouter, GelatoRelayRouter, MultichainRouter t…
dmax10 Feb 13, 2025
9da0c58
Refactor MultichainRouter by spliting it's logic into MultichainGmRou…
dmax10 Feb 13, 2025
cc91019
Add TransferRequest[] param to create* multichain actions and _sendTo…
dmax10 Feb 13, 2025
6c08ca4
Refactor GlvDepositUtils to move the "execute" part into ExecuteGlvDe…
dmax10 Feb 13, 2025
931b4ee
Uncomment relay fee refund logic after solving the contract size error
dmax10 Feb 13, 2025
ae61efe
Refactor to add addresses subgroup to CreateGlvDepositParams to fix t…
dmax10 Feb 13, 2025
125e251
Refactor to add addresses subgroup to CreateGlvWithdrawalParams to fi…
dmax10 Feb 13, 2025
b4af55f
Remove "immutable" from state variables to reduce contract size bello…
dmax10 Feb 13, 2025
92bc5d5
Remove srcChainId from RelayParams struct
dmax10 Feb 14, 2025
e4f43bb
Remove outdated contracts
dmax10 Feb 14, 2025
3d0ab56
Remove srcChainId from RelayParams struct (continued)
dmax10 Feb 14, 2025
508c432
Move desChainId from multichain structs into RelayParams struct, remo…
dmax10 Feb 14, 2025
f5beb26
Add srcChainId to depositHandler.createDeposit, small DepositUtils re…
dmax10 Feb 14, 2025
539da1a
Add srcChainId to withdrawalHandler.createWithdrawal, small Withdrawa…
dmax10 Feb 14, 2025
010a004
Add srcChainId to shiftHandler.createShift
dmax10 Feb 14, 2025
a477866
Add srcChainId to glvHandler (createGlvDeposit, createGlvWithdrawal),…
dmax10 Feb 15, 2025
f97d21a
Add srcChainId to orderHandler.createOrder, small OrderUtils refactor…
dmax10 Feb 15, 2025
aad6e0e
Add MultichainGmRouter: createOrder, updateOrder, cancelOrder
dmax10 Feb 16, 2025
4b100e1
Rename contract, remove comment, add modifier
dmax10 Feb 16, 2025
a894cdc
Refactor: add function to validate destination chain
dmax10 Feb 16, 2025
f2595e6
Add bridgeOut function, validate multichain provider is whitelisted, …
dmax10 Feb 16, 2025
9ee242f
wip provider bridgeOut
dmax10 Feb 16, 2025
d92a7c4
Fix gasless merge
dmax10 Feb 17, 2025
cd9fb35
Add dataList field to relay create order params
dmax10 Feb 17, 2025
25186fc
Fix signatures and missing fields for gasless tests
dmax10 Feb 17, 2025
e799629
Include desChainId into relay signature
dmax10 Feb 17, 2025
7790a9c
Validate desChainId against block.chainid (for same chain actions, ch…
dmax10 Feb 17, 2025
5446078
Include dataList into relay signature, remove srcChainId from multich…
dmax10 Feb 17, 2025
fd3a8ed
Add deploy script for MultichainGmRouter
dmax10 Feb 18, 2025
4bab07c
Fix 'from' param for transferOut
dmax10 Feb 18, 2025
6b028c7
Fix multichain createDeposit typehash (without transferRequests)
dmax10 Feb 18, 2025
0e363d0
WIP test multichain createDeposit flow
dmax10 Feb 18, 2025
84cadb6
change token permit nonce and srcChainId
dmax10 Feb 18, 2025
bd17ba8
Add provider specific function param on bridgeOut
dmax10 Feb 19, 2025
7248c53
Fix multichain transferOut logic
dmax10 Feb 19, 2025
170c3cb
Remove double validation for desChainId
dmax10 Feb 19, 2025
6acc924
Change transferRequests structure, update typehashes
dmax10 Feb 19, 2025
b59ea96
Test multichain deposit
dmax10 Feb 19, 2025
1405562
Fix ETH deposit and fee payment
dmax10 Feb 20, 2025
a023522
Split CreateWithdrawalParams into subgroups to solve relay typehash e…
dmax10 Feb 20, 2025
3d189cf
Add error params
dmax10 Feb 20, 2025
2e8df23
WIP test multichain withdrawal
dmax10 Feb 20, 2025
e05f6a9
squash - refactor callbacks to eventdata
Feb 21, 2025
2fa1c38
squash - refactor callbacks to eventdata
Feb 21, 2025
86abe7d
fix tests
Feb 21, 2025
e09877a
CI workflow
Feb 24, 2025
58f44b5
use yarn
Feb 24, 2025
2f49ae1
run CI on every PR
Feb 24, 2025
81ecee8
Merge remote-tracking branch 'origin/run-tests-on-pr' into run-tests-…
Feb 25, 2025
5ae6627
Merge remote-tracking branch 'origin/run-tests-on-pr' into run-tests-…
Feb 25, 2025
4aef7d0
CI workflow
Feb 24, 2025
b782e2e
use yarn
Feb 24, 2025
db989d7
run CI on every PR
Feb 24, 2025
ca7d928
Merge remote-tracking branch 'origin/run-tests-on-pr' into run-tests-…
Feb 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI
on:
pull_request:
types: [opened, synchronize, edited, ready_for_review]

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install packages
uses: actions/setup-node@v3
with:
node-version: '18.x'
- run: yarn --ignore-scripts
shell: bash
- name: Run Tests
run: yarn hardhat test
shell: bash
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"printWidth": 120
}
6 changes: 0 additions & 6 deletions config/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export default async function ({ network }: HardhatRuntimeEnvironment) {

skipBorrowingFeeForSmallerSide: false,

ignoreOpenInterestForUsageFactor: false,

maxExecutionFeeMultiplierFactor: decimalToFloat(100),
};
}
Expand Down Expand Up @@ -120,8 +118,6 @@ export default async function ({ network }: HardhatRuntimeEnvironment) {

skipBorrowingFeeForSmallerSide: true,

ignoreOpenInterestForUsageFactor: false,

maxExecutionFeeMultiplierFactor: decimalToFloat(100),
};

Expand All @@ -145,12 +141,10 @@ export default async function ({ network }: HardhatRuntimeEnvironment) {
increaseOrderGasLimit: 3_000_000,
decreaseOrderGasLimit: 3_000_000,
swapOrderGasLimit: 2_500_000,
ignoreOpenInterestForUsageFactor: true,
},
avalanche: {
increaseOrderGasLimit: 3_500_000,
decreaseOrderGasLimit: 3_500_000,
ignoreOpenInterestForUsageFactor: true,
},
}[network.name];

Expand Down
6 changes: 4 additions & 2 deletions contracts/adl/AdlUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ library AdlUtils {
params.dataStore.getUint(Keys.MAX_CALLBACK_GAS_LIMIT), // callbackGasLimit
0, // minOutputAmount
params.updatedAtTime, // updatedAtTime
0 // validFromTime
0, // validFromTime
0 // srcChainId
);

Order.Flags memory flags = Order.Flags(
Expand All @@ -189,7 +190,8 @@ library AdlUtils {
Order.Props memory order = Order.Props(
addresses,
numbers,
flags
flags,
new bytes32[](0)
);

bytes32 key = NonceUtils.getNextKey(params.dataStore);
Expand Down
91 changes: 62 additions & 29 deletions contracts/callback/CallbackUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ import "./IGasFeeCallbackReceiver.sol";
import "./IGlvDepositCallbackReceiver.sol";
import "./IGlvWithdrawalCallbackReceiver.sol";

import "../order/OrderEventUtils.sol";
import "../withdrawal/WithdrawalEventUtils.sol";
import "../deposit/DepositEventUtils.sol";
import "../shift/ShiftEventUtils.sol";
import "../glv/glvDeposit/GlvDepositEventUtils.sol";
import "../glv/glvWithdrawal/GlvWithdrawalEventUtils.sol";

// @title CallbackUtils
// @dev most features require a two step process to complete
// the user first sends a request transaction, then a second transaction is sent
Expand Down Expand Up @@ -64,7 +71,7 @@ library CallbackUtils {
// executions to fail
// @param dataStore DataStore
// @param callbackGasLimit the callback gas limit
function validateCallbackGasLimit(DataStore dataStore, uint256 callbackGasLimit) internal view {
function validateCallbackGasLimit(DataStore dataStore, uint256 callbackGasLimit) external view {
uint256 maxCallbackGasLimit = dataStore.getUint(Keys.MAX_CALLBACK_GAS_LIMIT);
if (callbackGasLimit > maxCallbackGasLimit) {
revert Errors.MaxCallbackGasLimitExceeded(callbackGasLimit, maxCallbackGasLimit);
Expand All @@ -82,7 +89,7 @@ library CallbackUtils {
dataStore.setAddress(Keys.savedCallbackContract(account, market), callbackContract);
}

function getSavedCallbackContract(DataStore dataStore, address account, address market) internal view returns (address) {
function getSavedCallbackContract(DataStore dataStore, address account, address market) external view returns (address) {
return dataStore.getAddress(Keys.savedCallbackContract(account, market));
}

Expand Down Expand Up @@ -116,14 +123,16 @@ library CallbackUtils {
bytes32 key,
Deposit.Props memory deposit,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(deposit.callbackContract())) { return; }

validateGasLeftForCallback(deposit.callbackGasLimit());

EventUtils.EventLogData memory depositData = DepositEventUtils.createEventData(deposit, Deposit.DepositType.Normal);

try IDepositCallbackReceiver(deposit.callbackContract()).afterDepositExecution{ gas: deposit.callbackGasLimit() }(
key,
deposit,
depositData,
eventData
) {
} catch {
Expand All @@ -138,14 +147,16 @@ library CallbackUtils {
bytes32 key,
Deposit.Props memory deposit,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(deposit.callbackContract())) { return; }

validateGasLeftForCallback(deposit.callbackGasLimit());

EventUtils.EventLogData memory depositData = DepositEventUtils.createEventData(deposit, Deposit.DepositType.Normal);

try IDepositCallbackReceiver(deposit.callbackContract()).afterDepositCancellation{ gas: deposit.callbackGasLimit() }(
key,
deposit,
depositData,
eventData
) {
} catch {
Expand All @@ -160,14 +171,16 @@ library CallbackUtils {
bytes32 key,
Withdrawal.Props memory withdrawal,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(withdrawal.callbackContract())) { return; }

validateGasLeftForCallback(withdrawal.callbackGasLimit());

EventUtils.EventLogData memory withdrawalData = WithdrawalEventUtils.createEventData(withdrawal, Withdrawal.WithdrawalType.Normal);

try IWithdrawalCallbackReceiver(withdrawal.callbackContract()).afterWithdrawalExecution{ gas: withdrawal.callbackGasLimit() }(
key,
withdrawal,
withdrawalData,
eventData
) {
} catch {
Expand All @@ -182,14 +195,16 @@ library CallbackUtils {
bytes32 key,
Withdrawal.Props memory withdrawal,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(withdrawal.callbackContract())) { return; }

validateGasLeftForCallback(withdrawal.callbackGasLimit());

EventUtils.EventLogData memory withdrawalData = WithdrawalEventUtils.createEventData(withdrawal, Withdrawal.WithdrawalType.Normal);

try IWithdrawalCallbackReceiver(withdrawal.callbackContract()).afterWithdrawalCancellation{ gas: withdrawal.callbackGasLimit() }(
key,
withdrawal,
withdrawalData,
eventData
) {
} catch {
Expand All @@ -201,14 +216,16 @@ library CallbackUtils {
bytes32 key,
Shift.Props memory shift,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(shift.callbackContract())) { return; }

validateGasLeftForCallback(shift.callbackGasLimit());

EventUtils.EventLogData memory shiftData = ShiftEventUtils.createEventData(shift);

try IShiftCallbackReceiver(shift.callbackContract()).afterShiftExecution{ gas: shift.callbackGasLimit() }(
key,
shift,
shiftData,
eventData
) {
} catch {
Expand All @@ -219,14 +236,16 @@ library CallbackUtils {
bytes32 key,
Shift.Props memory shift,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(shift.callbackContract())) { return; }

validateGasLeftForCallback(shift.callbackGasLimit());

EventUtils.EventLogData memory shiftData = ShiftEventUtils.createEventData(shift);

try IShiftCallbackReceiver(shift.callbackContract()).afterShiftCancellation{ gas: shift.callbackGasLimit() }(
key,
shift,
shiftData,
eventData
) {
} catch {
Expand All @@ -244,14 +263,16 @@ library CallbackUtils {
bytes32 key,
Order.Props memory order,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(order.callbackContract())) { return; }

validateGasLeftForCallback(order.callbackGasLimit());

EventUtils.EventLogData memory orderData = OrderEventUtils.createEventData(order);

try IOrderCallbackReceiver(order.callbackContract()).afterOrderExecution{ gas: order.callbackGasLimit() }(
key,
order,
orderData,
eventData
) {
} catch {
Expand All @@ -266,14 +287,16 @@ library CallbackUtils {
bytes32 key,
Order.Props memory order,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(order.callbackContract())) { return; }

validateGasLeftForCallback(order.callbackGasLimit());

EventUtils.EventLogData memory orderData = OrderEventUtils.createEventData(order);

try IOrderCallbackReceiver(order.callbackContract()).afterOrderCancellation{ gas: order.callbackGasLimit() }(
key,
order,
orderData,
eventData
) {
} catch {
Expand All @@ -288,14 +311,16 @@ library CallbackUtils {
bytes32 key,
Order.Props memory order,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(order.callbackContract())) { return; }

validateGasLeftForCallback(order.callbackGasLimit());

EventUtils.EventLogData memory orderData = OrderEventUtils.createEventData(order);

try IOrderCallbackReceiver(order.callbackContract()).afterOrderFrozen{ gas: order.callbackGasLimit() }(
key,
order,
orderData,
eventData
) {
} catch {
Expand All @@ -310,16 +335,18 @@ library CallbackUtils {
bytes32 key,
GlvDeposit.Props memory glvDeposit,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(glvDeposit.callbackContract())) {
return;
}

validateGasLeftForCallback(glvDeposit.callbackGasLimit());

EventUtils.EventLogData memory glvData = GlvDepositEventUtils.createEventData(glvDeposit);

try IGlvDepositCallbackReceiver(glvDeposit.callbackContract()).afterGlvDepositExecution{ gas: glvDeposit.callbackGasLimit() }(
key,
glvDeposit,
glvData,
eventData
) {
} catch {
Expand All @@ -334,14 +361,16 @@ library CallbackUtils {
bytes32 key,
GlvDeposit.Props memory glvDeposit,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(glvDeposit.callbackContract())) { return; }

validateGasLeftForCallback(glvDeposit.callbackGasLimit());

EventUtils.EventLogData memory glvData = GlvDepositEventUtils.createEventData(glvDeposit);

try IGlvDepositCallbackReceiver(glvDeposit.callbackContract()).afterGlvDepositCancellation{ gas: glvDeposit.callbackGasLimit() }(
key,
glvDeposit,
glvData,
eventData
) {
} catch {
Expand All @@ -356,14 +385,16 @@ library CallbackUtils {
bytes32 key,
GlvWithdrawal.Props memory glvWithdrawal,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(glvWithdrawal.callbackContract())) { return; }

validateGasLeftForCallback(glvWithdrawal.callbackGasLimit());

EventUtils.EventLogData memory glvData = GlvWithdrawalEventUtils.createEventData(glvWithdrawal);

try IGlvWithdrawalCallbackReceiver(glvWithdrawal.callbackContract()).afterGlvWithdrawalExecution{ gas: glvWithdrawal.callbackGasLimit() }(
key,
glvWithdrawal,
glvData,
eventData
) {
} catch {
Expand All @@ -378,14 +409,16 @@ library CallbackUtils {
bytes32 key,
GlvWithdrawal.Props memory glvWithdrawal,
EventUtils.EventLogData memory eventData
) internal {
) external {
if (!isValidCallbackContract(glvWithdrawal.callbackContract())) { return; }

validateGasLeftForCallback(glvWithdrawal.callbackGasLimit());

EventUtils.EventLogData memory glvData = GlvWithdrawalEventUtils.createEventData(glvWithdrawal);

try IGlvWithdrawalCallbackReceiver(glvWithdrawal.callbackContract()).afterGlvWithdrawalCancellation{ gas: glvWithdrawal.callbackGasLimit() }(
key,
glvWithdrawal,
glvData,
eventData
) {
} catch {
Expand All @@ -395,7 +428,7 @@ library CallbackUtils {

// @dev validates that the given address is a contract
// @param callbackContract the contract to call
function isValidCallbackContract(address callbackContract) internal view returns (bool) {
function isValidCallbackContract(address callbackContract) public view returns (bool) {
if (callbackContract == address(0)) { return false; }
if (!callbackContract.isContract()) { return false; }

Expand Down
6 changes: 3 additions & 3 deletions contracts/callback/IDepositCallbackReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
pragma solidity ^0.8.0;

import "../event/EventUtils.sol";
import "../deposit/Deposit.sol";


// @title IDepositCallbackReceiver
// @dev interface for a deposit callback contract
interface IDepositCallbackReceiver {
// @dev called after a deposit execution
// @param key the key of the deposit
// @param deposit the deposit that was executed
function afterDepositExecution(bytes32 key, Deposit.Props memory deposit, EventUtils.EventLogData memory eventData) external;
function afterDepositExecution(bytes32 key, EventUtils.EventLogData memory depositData, EventUtils.EventLogData memory eventData) external;

// @dev called after a deposit cancellation
// @param key the key of the deposit
// @param deposit the deposit that was cancelled
function afterDepositCancellation(bytes32 key, Deposit.Props memory deposit, EventUtils.EventLogData memory eventData) external;
function afterDepositCancellation(bytes32 key, EventUtils.EventLogData memory depositData, EventUtils.EventLogData memory eventData) external;
}
Loading