Created
April 17, 2025 16:10
-
-
Save leanazulyoro/75482e0b0151369bbd4fab6391f79d44 to your computer and use it in GitHub Desktop.
wrap-eth_swap-naked-asset_open-synth-position
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const encodedTransactions = [ | |
[ | |
// deploy position | |
{ | |
"callData": "0xa2420976000000000000000000000000127316e7fd5f6d8a91dbf1f7c73ecd880045a819000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000196446bd406", | |
"target": "0xeE156D8ea7b96a5524CcC3CF9283ab85E80E9534", | |
"value": 0 | |
}, | |
// wrap ETH | |
{ | |
"callData": "0xd0e30db0", | |
"target": "0x4200000000000000000000000000000000000006", | |
"value": 10000000000000 | |
}, | |
// approve swapper to spend WETH | |
{ | |
"target": "0x4200000000000000000000000000000000000006", | |
"value": 0, | |
"callData": "0x095ea7b3000000000000000000000000017cbf62b53313d5ee3ad1288daa95cd39aa11fe000000000000000000000000000000000000000000000000000009184e72a000" | |
}, | |
// swapExactIn | |
{ | |
"target": "0x017CBF62b53313d5eE3aD1288daA95CD39AA11fE", | |
"value": 0, | |
"callData": "0x6ccb2b010000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ccf3d1acf799bae67f6e354d685295557cf64761000000000000000000000000000000000000000000000000000009184e72a000000000000000000000000000000000000000000000000000000008a3e4201800000000000000000000000000970369dce1e57489eb4cfce40c8f2a840d5e686a" | |
}, | |
// position.open | |
{ | |
"target": "0x970369DcE1E57489Eb4cFcE40C8F2a840d5E686A", | |
"value": 0, | |
"callData": "0x1af959a50000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ccf3d1acf799bae67f6e354d685295557cf6476100000000000000000000000000000000000000000000000000000000000000200000000000000000000000001610e3c85dd44af31ed7f33a63642012dca0c5a50000000000000000000000000000000000000000000000000000000000000060ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000001bc16d674ec80000000000000000000000000000000000000000000000000000000011bc3292b800" | |
} | |
] | |
] | |
const transactions = [ | |
// deploy position | |
{ | |
"callData": "0xa2420976000000000000000000000000127316e7fd5f6d8a91dbf1f7c73ecd880045a819000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000196446bd406", | |
"target": "0xeE156D8ea7b96a5524CcC3CF9283ab85E80E9534", | |
"value": 0 | |
}, | |
// wrap ETH | |
{ | |
"callData": encodeFunctionData({ | |
abi: [ | |
{ | |
name: 'deposit', | |
type: 'function', | |
stateMutability: 'payable', | |
inputs: [], | |
outputs: [] | |
} | |
], | |
functionName: 'deposit', | |
args: [] | |
}), | |
"target": "0x4200000000000000000000000000000000000006", | |
"value": 10000000000000 | |
}, | |
// approve swapper to spend WETH | |
{ | |
"target": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", | |
"value": 0, | |
"callData": encodeFunctionData({ | |
abi: erc20Abi, | |
args: [ | |
"0x017CBF62b53313d5eE3aD1288daA95CD39AA11fE", | |
10000000000000n | |
], | |
functionName: 'approve' | |
}) | |
}, | |
// swapExactIn | |
{ | |
"target": "0x229f19942612A8dbdec3643CB23F88685CCd56A5", | |
"value": 0, | |
"callData": encodeFunctionData({ | |
abi: swapperContract.abi, | |
args: [ | |
"0x4200000000000000000000000000000000000006", | |
"0xCcF3d1AcF799bAe67F6e354d685295557cf64761", | |
10000000000000n, | |
9500000000000n, | |
position.address | |
], | |
functionName: 'swapExactInput' | |
}) | |
}, | |
// open | |
{ | |
"target": "0xC0E900D4C83125Daf679bA4a156A05af7C377f37", | |
"value": 0, | |
"callData": position.encoder.encodeOpenCallData({ | |
amountIn: maxUint256, | |
borrowToken: "0x1610e3c85dd44Af31eD7f33a63642012Dca0C5A5", | |
depositAmountMin: 19500000000000n, | |
depositToken: "0xCcF3d1AcF799bAe67F6e354d685295557cf64761", | |
leverageX: 2000000000000000000n | |
}), | |
"callData": encodeFunctionData({ | |
abi: strategyABI, | |
args: [ | |
// position params: | |
encodeAbiParameters(parseAbiParameters('bytes genericParams, bytes customParams'), [ | |
// genericParams: | |
encodeAbiParameters( | |
parseAbiParameters('address asset'), | |
["0xCcF3d1AcF799bAe67F6e354d685295557cf64761"] | |
), | |
// customParams | |
encodeAbiParameters( | |
parseAbiParameters('address syntheticToken'), | |
["0x1610e3c85dd44Af31eD7f33a63642012Dca0C5A5"] | |
) | |
]), | |
// pushParams: | |
encodeAbiParameters( | |
parseAbiParameters('uint256 amountIn, uint256 leverageX, uint256 depositAmountMin'), | |
[ | |
maxUint256, | |
2000000000000000000n, | |
19500000000000n | |
] | |
) | |
], | |
functionName: 'open' | |
}) | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment