Skip to content

Commit 7872e29

Browse files
committed
update contract script
1 parent 5d28394 commit 7872e29

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

script/demoScripts/demoPolymer.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ if echo "$ROUTES_RESPONSE" | grep -q "error"; then
9898
exit 1
9999
fi
100100

101-
echo response gotten: $ROUTES_RESPONSE
102-
103101
# Extract the first route and its first step
104102
FIRST_STEP=$(echo "$ROUTES_RESPONSE" | jq -r '.routes[1].steps[0]')
105103

@@ -137,8 +135,6 @@ fi
137135
echo "✓ Transaction calldata retrieved successfully"
138136
echo ""
139137

140-
echo $STEP_TX_RESPONSE
141-
142138
# Extract transaction details
143139
TX_TO=$(echo "$STEP_TX_RESPONSE" | jq -r '.transactionRequest.to')
144140
TX_DATA=$(echo "$STEP_TX_RESPONSE" | jq -r '.transactionRequest.data')
@@ -155,12 +151,16 @@ echo " Approval Amount: $APPROVAL_AMOUNT (Bridge Amount: $FROM_AMOUNT )"
155151
echo " Spender: $TX_TO"
156152
echo ""
157153

158-
APPROVE_TX_HASH=$(cast send "$FROM_TOKEN" \
154+
APPROVE_TX_OUTPUT=$(cast send "$FROM_TOKEN" \
159155
"approve(address,uint256)(bool)" \
160156
"$TX_TO" \
161157
"$APPROVAL_AMOUNT" \
162158
--private-key "$PRIVATE_KEY" \
163-
--rpc-url "$FROM_RPC_URL" | grep "transactionHash" | awk '{print $2}')
159+
--rpc-url "$FROM_RPC_URL" \
160+
--json)
161+
162+
APPROVE_TX_HASH=$(echo "$APPROVE_TX_OUTPUT" | jq -r '.transactionHash')
163+
echo Approve tx hash: $APPROVE_TX_HASH
164164

165165
if [ -z "$APPROVE_TX_HASH" ]; then
166166
echo "Error: Approval transaction failed"
@@ -172,7 +172,7 @@ echo "Approval Transaction Hash: $APPROVE_TX_HASH"
172172
echo ""
173173

174174

175-
echo "Sleeping to avoid nonce/tx replacement issues"
175+
echo "Sleeping to avoid nonce/tx replacement issues ..."
176176
sleep 4
177177

178178
# Step 3: Submit the transaction
@@ -181,11 +181,15 @@ echo "To Address: $TX_TO"
181181
echo "Gas Limit: $TX_GAS_LIMIT"
182182
echo ""
183183

184-
TX_HASH=$(cast send "$TX_TO" \
184+
TX_OUTPUT=$(cast send "$TX_TO" \
185185
--private-key "$PRIVATE_KEY" \
186186
--gas-limit "$TX_GAS_LIMIT" \
187187
--rpc-url "$FROM_RPC_URL" \
188-
"$TX_DATA" | grep "transactionHash" | awk '{print $2}')
188+
--json \
189+
"$TX_DATA")
190+
191+
TX_HASH=$(echo "$TX_OUTPUT" | jq -r '.transactionHash')
192+
echo Burn tx hash: $TX_HASH
189193

190194
if [ -z "$TX_HASH" ]; then
191195
echo "Error: Transaction submission failed"
@@ -213,7 +217,7 @@ echo "✓ Transaction mined successfully"
213217
echo ""
214218

215219
# Step 4: Monitor CCTP transfer status
216-
echo "Step 4: Monitoring CCTP transfer status..."
220+
echo "Step 4: Monitoring CCTP transfer status at url " "${API_URL}/v1/status/${TX_HASH}"
217221
MAX_RETRIES=60
218222
RETRY_INTERVAL=10
219223
RETRY_COUNT=0

src/Facets/PolymerCCTPFacet.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ contract PolymerCCTPFacet is IPolymerCCTPFacet, ILiFi, ReentrancyGuard, SwapperV
6565
}
6666

6767
// TODO: Do we need this check if it's always going to be usdc?
68-
LibAsset.depositAsset(_bridgeData.sendingAssetId, _bridgeData.minAmount - _polymerData.polymerTokenFee );
69-
LibAsset.transferFromERC20( usdc, msg.sender, polymerFeeReceiver, _polymerData.polymerTokenFee );
68+
LibAsset.depositAsset(_bridgeData.sendingAssetId, _bridgeData.minAmount );
69+
LibAsset.transferERC20( usdc, polymerFeeReceiver, _polymerData.polymerTokenFee );
7070

7171

7272
// TODO we don't need to use safe approve here?
73-
IERC20(usdc).approve(address(tokenMessenger), _bridgeData.minAmount);
73+
IERC20(usdc).approve(address(tokenMessenger), _bridgeData.minAmount - _polymerData.polymerTokenFee );
7474

7575
// Need tocheck: can we just use destinationChainID as the normal chain id? and can we just mpass in min Amount as the amountT?
7676
tokenMessenger.depositForBurn(
77-
_bridgeData.minAmount,
77+
_bridgeData.minAmount - _polymerData.polymerTokenFee ,
7878
uint32(_bridgeData.destinationChainId),
7979
_bridgeData.receiver == NON_EVM_ADDRESS
8080
? _polymerData.nonEvmAddress
@@ -97,7 +97,7 @@ contract PolymerCCTPFacet is IPolymerCCTPFacet, ILiFi, ReentrancyGuard, SwapperV
9797
_bridgeData.referrer,
9898
_bridgeData.sendingAssetId,
9999
_bridgeData.receiver,
100-
_bridgeData.minAmount,
100+
_bridgeData.minAmount - _polymerData.polymerTokenFee,
101101
_bridgeData.destinationChainId,
102102
_bridgeData.hasSourceSwaps,
103103
_bridgeData.hasDestinationCall

testnet-addresses.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
"usdc": "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
44
"polymerFeeRecipient": "0x81b5c1c0343ff0087C04F543D0f36dC4745b999F",
55
"tokenMessenger": "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA",
6-
"diamondProxy": "0xF58AAe05E206AB0eA2D40eEdCC99E532b7d0c442"
6+
"diamondProxy": "0x4d09Dd99652e20E6795D08d25ecC03e9600836a4"
77
},
88
"421614": {
99
"usdc": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
1010
"polymerFeeRecipient": "0x81b5c1c0343ff0087C04F543D0f36dC4745b999F",
1111
"tokenMessenger": "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA",
12-
"diamondProxy": "0x59730C6CB629E30845B5FEb0236c4532A236777C"
12+
"diamondProxy": "0x06B90798BAc18a7927e62a194523131502560911"
1313
},
1414
"84532": {
1515
"usdc": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
1616
"polymerFeeRecipient": "0x81b5c1c0343ff0087C04F543D0f36dC4745b999F",
1717
"tokenMessenger": "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA",
18-
"diamondProxy": "0x1C82E77c4Fe9cEA32aF1591D06cc20e4539026b7"
18+
"diamondProxy": "0x4a0258A6627e9D8cef54B52Bde9814B13570Cbb7"
1919
}
2020
}

0 commit comments

Comments
 (0)