Skip to content

Commit

Permalink
Update to use uint64 and re-deploy to staging
Browse files Browse the repository at this point in the history
  • Loading branch information
ezynda3 committed Jan 2, 2025
1 parent 2f0493d commit fb4c7a4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
10 changes: 10 additions & 0 deletions deployments/_deployments_log_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -24768,6 +24768,16 @@
"SALT": "",
"VERIFIED": "true"
}
],
"1.1.0": [
{
"ADDRESS": "0x7A7dA456a99B5C8fef3D3E3c032a9F13949AdF07",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2025-01-02 06:15:45",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000006f26bf09b1c792e3228e5467807a900a503c02810000000000000000000000004200000000000000000000000000000000000006",
"SALT": "",
"VERIFIED": "true"
}
]
},
"production": {
Expand Down
4 changes: 4 additions & 0 deletions deployments/optimism.diamond.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@
"0x605Daee0FF23B5d678D47BF17037789115bF5750": {
"Name": "AcrossFacetV3",
"Version": "1.0.0"
},
"0x7A7dA456a99B5C8fef3D3E3c032a9F13949AdF07": {
"Name": "AcrossFacetV3",
"Version": "1.1.0"
}
},
"Periphery": {
Expand Down
2 changes: 1 addition & 1 deletion deployments/optimism.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"RelayerCelerIM": "0xC1906dC6b43EbE6AE511cc4abeB8711120Ab622e",
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70",
"EmergencyPauseFacet": "0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b",
"AcrossFacetV3": "0x605Daee0FF23B5d678D47BF17037789115bF5750",
"AcrossFacetV3": "0x7A7dA456a99B5C8fef3D3E3c032a9F13949AdF07",
"ReceiverAcrossV3": "0x3877f47B560819E96BBD7e7700a02dfACe36D696",
"AcrossFacetPackedV3": "0x4352459F6BE1C7D1278F8c34Bb598b0feeB50f8b",
"RelayFacet": "0x3cf7dE0e31e13C93c8Aada774ADF1C7eD58157f5"
Expand Down
19 changes: 8 additions & 11 deletions script/demoScripts/demoAcrossV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,16 @@ const getAcrossQuote = async (
return resp
}

const calculateOutputAmountPercentage = (quote: AcrossV3Quote): number => {
// Convert the relay fee percentage to basis points (10000 = 100.00%)
const calculateOutputAmountPercentage = (quote: AcrossV3Quote): string => {
// Convert the relay fee percentage from basis points to 18 decimal fixed point
const totalFeePercent = BigNumber.from(quote.relayFeePct)

// Convert from 18 decimals to basis points (10000 = 100.00%)
const scalingFactor = BigNumber.from(10).pow(18 - 4)
const scaledFeePercent = totalFeePercent.div(scalingFactor)
// Calculate output percentage as (100% - fee%) where 100% = 1e18
const oneHundredPercent = BigNumber.from(10).pow(18) // 1e18 represents 100%
const outputPercent = oneHundredPercent.sub(totalFeePercent)

// Calculate output percentage as (100% - fee%)
const outputPercent = BigNumber.from(10000).sub(scaledFeePercent)

// Ensure the percentage is between 0 and 10000
return Math.max(0, Math.min(10000, outputPercent.toNumber()))
// Ensure the percentage is between 0 and 1e18
return outputPercent.toString()
}

const getMinAmountOut = (quote: AcrossV3Quote, fromAmount: string) => {
Expand Down Expand Up @@ -252,7 +249,7 @@ const createDestCallPayload = (
}

// ########################################## CONFIGURE SCRIPT HERE ##########################################
const TRANSACTION_TYPE = TX_TYPE.NATIVE_WITH_SRC as TX_TYPE // define which type of transaction you want to send
const TRANSACTION_TYPE = TX_TYPE.ERC20_WITH_SRC as TX_TYPE // define which type of transaction you want to send
const SEND_TX = true // allows you to the script run without actually sending a transaction (=false)
const DEBUG = false // set to true for higher verbosity in console output

Expand Down
6 changes: 3 additions & 3 deletions src/Facets/AcrossFacetV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract AcrossFacetV3 is ILiFi, ReentrancyGuard, SwapperV2, Validatable {
/// @param refundAddress The address that will be used for potential bridge refunds
/// @param receivingAssetId The address of the token to be received at destination chain
/// @param outputAmount The amount to be received at destination chain (after fees)
/// @param outputAmountPercent The percentage of the output amount with 2 decimal precision (7550 = 75.50%, 9900 = 99.00%)
/// @param outputAmountPercent The percentage of the output amount with 18 decimal precision (0.7550e18 = 75.50%, 0.99e18 = 99.00%)
/// @param exclusiveRelayer This is the exclusive relayer who can fill the deposit before the exclusivity deadline.
/// @param quoteTimestamp The timestamp of the Across quote that was used for this transaction
/// @param fillDeadline The destination chain timestamp until which the order can be filled
Expand All @@ -41,7 +41,7 @@ contract AcrossFacetV3 is ILiFi, ReentrancyGuard, SwapperV2, Validatable {
address refundAddress;
address receivingAssetId;
uint256 outputAmount;
uint16 outputAmountPercent;
uint64 outputAmountPercent; // Now represents percentage with 18 decimal places
address exclusiveRelayer;
uint32 quoteTimestamp;
uint32 fillDeadline;
Expand Down Expand Up @@ -109,7 +109,7 @@ contract AcrossFacetV3 is ILiFi, ReentrancyGuard, SwapperV2, Validatable {
AcrossV3Data memory modifiedAcrossData = _acrossData;
modifiedAcrossData.outputAmount =
(_bridgeData.minAmount * _acrossData.outputAmountPercent) /
10000;
1e18;

_startBridge(_bridgeData, modifiedAcrossData);
}
Expand Down
6 changes: 3 additions & 3 deletions test/solidity/Facets/AcrossFacetV3.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ contract AcrossFacetV3Test is TestBaseFacet {
refundAddress: USER_REFUND,
receivingAssetId: ADDRESS_USDC_POL,
outputAmount: (defaultUSDCAmount * 9) / 10,
outputAmountPercent: 10000, // 100.00%
outputAmountPercent: 1000000000000000000, // 100.00% (1e18)
exclusiveRelayer: address(0),
quoteTimestamp: quoteTimestamp,
fillDeadline: uint32(quoteTimestamp + 1000),
Expand Down Expand Up @@ -141,7 +141,7 @@ contract AcrossFacetV3Test is TestBaseFacet {
setDefaultSwapDataSingleDAItoUSDC();

// Set output amount percent to 85%
validAcrossData.outputAmountPercent = 8500; // 85.00%
validAcrossData.outputAmountPercent = uint64(850000000000000000); // 85.00%
validAcrossData.outputAmount = 10000; // This will be ignored

// approval
Expand Down Expand Up @@ -214,7 +214,7 @@ contract AcrossFacetV3Test is TestBaseFacet {
);

// Set output amount percent to 93.75%
validAcrossData.outputAmountPercent = 9375; // 93.75%
validAcrossData.outputAmountPercent = uint64(937500000000000000); // 93.75%
validAcrossData.outputAmount = 10000; // This will be ignored

// approval
Expand Down

0 comments on commit fb4c7a4

Please sign in to comment.