Skip to content

Commit

Permalink
feat: new zap executor (#2382)
Browse files Browse the repository at this point in the history
* feat: new zap executor

* feat: new zap executor

* feat(zap): add gasInclude=1 when getRoute

* chore: update new contract zap
  • Loading branch information
viet-nv authored Nov 17, 2023
1 parent 08e4e63 commit 2116782
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/constants/networks/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ const arbitrumInfo: EVMNetworkInfo = {
zap: {
router: '0x30C5322E4e08AD500c348007f92f120ab4E2b79e',
validator: '0xf0096e5B4AAfeEA1DF557264091569ba125c1172',
executor: '0x4f097F7074D52952006a0763312724929Ff95Cf0',
helper: '0x4E8419EFa0b0A149Dad77b689D37AF17f762f20A',
executor: '0x8ac7895130e3be8654fff544ae20bf2a93ef19d1',
helper: '0x214061F0e250A27a49f609d9caf2987a7bC8fA6B',
},
},
limitOrder: '*',
Expand Down
4 changes: 2 additions & 2 deletions src/constants/networks/avax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ const avaxInfo: EVMNetworkInfo = {
zap: {
router: '0x30C5322E4e08AD500c348007f92f120ab4E2b79e',
validator: '0xf0096e5B4AAfeEA1DF557264091569ba125c1172',
executor: '0x4f097F7074D52952006a0763312724929Ff95Cf0',
helper: '0x4E8419EFa0b0A149Dad77b689D37AF17f762f20A',
executor: '0x8ac7895130e3be8654fff544ae20bf2a93ef19d1',
helper: '0x214061F0e250A27a49f609d9caf2987a7bC8fA6B',
},
},
limitOrder: '*',
Expand Down
4 changes: 2 additions & 2 deletions src/constants/networks/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const base: EVMNetworkInfo = {
zap: {
router: '0x30C5322E4e08AD500c348007f92f120ab4E2b79e',
validator: '0xf0096e5B4AAfeEA1DF557264091569ba125c1172',
executor: '0x4f097F7074D52952006a0763312724929Ff95Cf0',
helper: '0x4E8419EFa0b0A149Dad77b689D37AF17f762f20A',
executor: '0x8ac7895130e3be8654fff544ae20bf2a93ef19d1',
helper: '0x214061F0e250A27a49f609d9caf2987a7bC8fA6B',
},
},
limitOrder: '*',
Expand Down
4 changes: 2 additions & 2 deletions src/constants/networks/matic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const maticInfo: EVMNetworkInfo = {
zap: {
router: '0x30C5322E4e08AD500c348007f92f120ab4E2b79e',
validator: '0xf0096e5B4AAfeEA1DF557264091569ba125c1172',
executor: '0x4f097F7074D52952006a0763312724929Ff95Cf0',
helper: '0x4E8419EFa0b0A149Dad77b689D37AF17f762f20A',
executor: '0x8ac7895130e3be8654fff544ae20bf2a93ef19d1',
helper: '0x214061F0e250A27a49f609d9caf2987a7bC8fA6B',
},
'farmV2.1S': [],
},
Expand Down
4 changes: 2 additions & 2 deletions src/constants/networks/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const optimismInfo: EVMNetworkInfo = {
zap: {
router: '0x30C5322E4e08AD500c348007f92f120ab4E2b79e',
validator: '0xf0096e5B4AAfeEA1DF557264091569ba125c1172',
executor: '0x4f097F7074D52952006a0763312724929Ff95Cf0',
helper: '0x4E8419EFa0b0A149Dad77b689D37AF17f762f20A',
executor: '0x8ac7895130e3be8654fff544ae20bf2a93ef19d1',
helper: '0x214061F0e250A27a49f609d9caf2987a7bC8fA6B',
},
},
limitOrder: '*',
Expand Down
4 changes: 2 additions & 2 deletions src/constants/networks/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const scroll: EVMNetworkInfo = {
zap: {
router: '0x30C5322E4e08AD500c348007f92f120ab4E2b79e',
validator: '0xf0096e5B4AAfeEA1DF557264091569ba125c1172',
executor: '0x4f097F7074D52952006a0763312724929Ff95Cf0',
helper: '0x4E8419EFa0b0A149Dad77b689D37AF17f762f20A',
executor: '0x8ac7895130e3be8654fff544ae20bf2a93ef19d1',
helper: '0x214061F0e250A27a49f609d9caf2987a7bC8fA6B',
},
},
limitOrder: NOT_SUPPORT,
Expand Down
9 changes: 7 additions & 2 deletions src/hooks/elasticZap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function useZapInPoolResult(params?: {
saveGas: '',
amountIn: item.quotient.toString(),
excludedPools: poolAddress,
gasInclude: 'true',
},
clientId: 'kyberswap-zap',
})
Expand Down Expand Up @@ -273,9 +274,10 @@ export function useZapInAction() {
exp6,
).toString(2)

const minZapAmount = BigInt(
const minZapAmounts = BigInt(
'0b' + (zeros + minZapAmount0).slice(-128) + (zeros + minZapAmount1).slice(-128),
).toString()
const minRefundAmounts = minZapAmounts

const zapExecutorData = abiEncoder.encode(
[
Expand All @@ -286,6 +288,7 @@ export function useZapInAction() {
'address',
'uint256',
'uint256',
'uint256',
'int24',
'int24',
'int24[2]',
Expand All @@ -299,7 +302,8 @@ export function useZapInAction() {
tokenId,
account,
1,
minZapAmount,
minZapAmounts,
minRefundAmounts,
tickLower,
tickUpper,
tickPrevious,
Expand Down Expand Up @@ -354,6 +358,7 @@ export function useZapInAction() {
value: options.zapWithNative ? amountIn : undefined,
data: callData,
to: zapRouterAddress,
minRefundAmounts,
})

const gasEstimated = await zapRouterContract.estimateGas[options.zapWithNative ? 'zapInWithNative' : 'zapIn'](
Expand Down

0 comments on commit 2116782

Please sign in to comment.