@@ -84,20 +84,60 @@ func (k Keeper) ExecuteInboundGasAndPayload(ctx context.Context, utx types.Unive
8484 }
8585
8686 if execErr == nil {
87- // --- Step 4: deposit + autoswap
87+ // --- Step 4: fetch swap quote and compute minPCOut with 5% slippage
8888 prc20AddressHex := common .HexToAddress (
8989 tokenConfig .NativeRepresentation .ContractAddress ,
9090 )
91- receipt , execErr = k .CallPRC20DepositAutoSwap (
92- sdkCtx ,
93- prc20AddressHex ,
94- ueaAddr ,
95- amount ,
91+
92+ var (
93+ quoterAddr common.Address
94+ wpcAddr common.Address
95+ fee * big.Int
96+ quote * big.Int
9697 )
98+
99+ quoterAddr , execErr = k .GetUniversalCoreQuoterAddress (sdkCtx )
97100 if execErr != nil {
98101 shouldRevert = true
99102 revertReason = execErr .Error ()
100103 }
104+
105+ if execErr == nil {
106+ wpcAddr , execErr = k .GetUniversalCoreWPCAddress (sdkCtx )
107+ if execErr != nil {
108+ shouldRevert = true
109+ revertReason = execErr .Error ()
110+ }
111+ }
112+
113+ if execErr == nil {
114+ fee , execErr = k .GetDefaultFeeTierForToken (sdkCtx , prc20AddressHex )
115+ if execErr != nil {
116+ shouldRevert = true
117+ revertReason = execErr .Error ()
118+ }
119+ }
120+
121+ if execErr == nil {
122+ quote , execErr = k .GetSwapQuote (sdkCtx , quoterAddr , prc20AddressHex , wpcAddr , fee , amount )
123+ if execErr != nil {
124+ shouldRevert = true
125+ revertReason = execErr .Error ()
126+ }
127+ }
128+
129+ if execErr == nil {
130+ // 5% slippage: minPCOut = quote * 95 / 100
131+ minPCOut := new (big.Int ).Mul (quote , big .NewInt (95 ))
132+ minPCOut .Div (minPCOut , big .NewInt (100 ))
133+
134+ // --- Step 5: deposit + autoswap
135+ receipt , execErr = k .CallPRC20DepositAutoSwap (sdkCtx , prc20AddressHex , ueaAddr , amount , fee , minPCOut )
136+ if execErr != nil {
137+ shouldRevert = true
138+ revertReason = execErr .Error ()
139+ }
140+ }
101141 }
102142 }
103143 }
@@ -160,7 +200,7 @@ func (k Keeper) ExecuteInboundGasAndPayload(ctx context.Context, utx types.Unive
160200
161201 ueModuleAddr , _ := k .GetUeModuleAddress (ctx )
162202
163- // --- Step 5 : payload hash
203+ // --- Step 6 : payload hash
164204 payloadHashErr := k .StoreVerifiedPayloadHash (sdkCtx , utx , ueaAddr , ueModuleAddr )
165205 if payloadHashErr != nil {
166206 errorPcTx := types.PCTx {
@@ -177,7 +217,7 @@ func (k Keeper) ExecuteInboundGasAndPayload(ctx context.Context, utx types.Unive
177217 return nil
178218 }
179219
180- // --- Step 6 : execute payload
220+ // --- Step 7 : execute payload
181221 // ueaAddr is already resolved and validated in step 3
182222 receipt , err = k .ExecutePayloadV2 (
183223 ctx ,
0 commit comments