Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation updated for doSwapAndWithdraw api. multiswapNetworkFIBERInformations and swapAndWithdrawTransactions model updated for forge #374

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/helpers/multiSwapHelpers/swapTransactionHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ module.exports = {
!req.query.destinationCabnId ||
!req.body.sourceAssetType ||
!req.body.destinationAssetType
// !req.body.gasPrices
) {
throw "swapTxId & sourceNetworkId & destinationNetworkId & sourceCabnId & destinationCabnId & sourceAssetType & destinationAssetType are required.";
throw "swapTxId & sourceNetworkId & destinationNetworkId & sourceCabnId & destinationCabnId & sourceAssetType & destinationAssetType & gasPrices are required.";
}

if (!mongoose.Types.ObjectId.isValid(req.query.sourceNetworkId)) {
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/web3Helpers/web3Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const getLogsFromTransactionReceipt = (data: any) => {

const findSwapEvent = (topics: any[], data: any) => {
let swapEventHash = Web3.utils.sha3(
"Swap(address,address,uint256,uint256,uint256,address,address,uint256,bytes32)"
"Swap(address,address,uint256,uint256,uint256,address,address,uint256,bytes32,uint256)"
);
if (data.isDestinationNonEVM != null && data.isDestinationNonEVM) {
swapEventHash = Web3.utils.sha3(
Expand Down
1 change: 1 addition & 0 deletions app/lib/httpCalls/fiberAxiosHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module.exports = {
body.sourceBridgeAmount = model.sourceBridgeAmount;
body.sourceAssetType = model.sourceAssetType;
body.destinationAssetType = model.destinationAssetType;
body.gasLimit = model.gasPrices?.destination?.gasLimit;

console.log("getWithdrawBody body", body);
return body;
Expand Down
33 changes: 20 additions & 13 deletions app/models/multiswapNetworkFIBERInformations.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
'use strict';
var mongoose = require('mongoose');
"use strict";
var mongoose = require("mongoose");

var schema = mongoose.Schema({
rpcUrl: { type: String, default: "" },
fundManager: { type: String, default: "" },
fiberRouter: { type: String, default: "" },
router: { type: String, default: "" },
foundryTokenAddress: { type: String, default: "" },
weth: { type: String, default: "" },
var schema = mongoose.Schema(
{
rpcUrl: { type: String, default: "" },
fundManager: { type: String, default: "" },
fiberRouter: { type: String, default: "" },
router: { type: String, default: "" },
foundryTokenAddress: { type: String, default: "" },
forgeContractAddress: { type: String, default: "" },
weth: { type: String, default: "" },

createdAt: { type: Date, default: new Date() },
updatedAt: { type: Date, default: new Date() },
},{ collection: 'multiswapNetworkFIBERInformations' });
createdAt: { type: Date, default: new Date() },
updatedAt: { type: Date, default: new Date() },
},
{ collection: "multiswapNetworkFIBERInformations" }
);

var multiswapNetworkFIBERInformationsModel = mongoose.model("multiswapNetworkFIBERInformations",schema);
var multiswapNetworkFIBERInformationsModel = mongoose.model(
"multiswapNetworkFIBERInformations",
schema
);
module.exports = multiswapNetworkFIBERInformationsModel;
12 changes: 12 additions & 0 deletions app/models/swapAndWithdrawTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ var schema = mongoose.Schema(
settledAmount: { type: String, default: "" },
sourceToken: { type: String, default: "" },
targetToken: { type: String, default: "" },
gasPrices: {
source: {
gasPrice: { type: String, default: "" },
gasPriceInUSD: { type: String, default: "" },
},
destination: {
gasPrice: { type: String, default: "" },
gasPriceInMachine: { type: String, default: "" },
gasPriceInUSD: { type: String, default: "" },
gasLimit: { type: String, default: "" },
},
},
},
{ collection: "swapAndWithdrawTransactions" }
);
Expand Down
98 changes: 43 additions & 55 deletions resources/FiberRouter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
"abi": [
{
"inputs": [
{ "internalType": "address", "name": "_weth", "type": "address" },
{
"internalType": "address",
"name": "_wethAddress",
"name": "_oneInchAggregatorRouter",
"type": "address"
},
{
"internalType": "address",
"name": "_oneInchAggregator",
"type": "address"
},
{ "internalType": "address", "name": "_poolAddress", "type": "address" }
{ "internalType": "address", "name": "_pool", "type": "address" }
],
"stateMutability": "nonpayable",
"type": "constructor"
Expand Down Expand Up @@ -156,6 +152,12 @@
"internalType": "bytes32",
"name": "withdrawalData",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "gasAmount",
"type": "uint256"
}
],
"name": "Swap",
Expand Down Expand Up @@ -309,49 +311,49 @@
{
"indexed": false,
"internalType": "address",
"name": "",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "",
"name": "amountIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "",
"name": "amountOutOneInch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "",
"name": "foundryToken",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "",
"name": "targetToken",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes",
"name": "",
"name": "oneInchData",
"type": "bytes"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "",
"name": "salt",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "bytes",
"name": "",
"name": "multiSignature",
"type": "bytes"
}
],
Expand All @@ -365,6 +367,15 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasWallet",
"outputs": [
{ "internalType": "address payable", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "inventory",
Expand All @@ -390,43 +401,6 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" },
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" },
{
"internalType": "string",
"name": "crossTargetNetwork",
"type": "string"
},
{
"internalType": "string",
"name": "crossTargetToken",
"type": "string"
},
{
"internalType": "string",
"name": "crossTargetAddress",
"type": "string"
},
{ "internalType": "bytes", "name": "oneInchData", "type": "bytes" },
{ "internalType": "address", "name": "fromToken", "type": "address" },
{
"internalType": "address",
"name": "foundryToken",
"type": "address"
},
{
"internalType": "bytes32",
"name": "withdrawalData",
"type": "bytes32"
}
],
"name": "nonEvmSwapAndCrossOneInch",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "oneInchAggregatorRouter",
Expand Down Expand Up @@ -455,6 +429,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_gasWallet",
"type": "address"
}
],
"name": "setGasWallet",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -500,7 +487,7 @@
],
"name": "swap",
"outputs": [],
"stateMutability": "nonpayable",
"stateMutability": "payable",
"type": "function"
},
{
Expand Down Expand Up @@ -537,7 +524,7 @@
],
"name": "swapAndCrossOneInch",
"outputs": [],
"stateMutability": "nonpayable",
"stateMutability": "payable",
"type": "function"
},
{
Expand Down Expand Up @@ -568,7 +555,8 @@
"internalType": "bytes32",
"name": "withdrawalData",
"type": "bytes32"
}
},
{ "internalType": "uint256", "name": "gasFee", "type": "uint256" }
],
"name": "swapAndCrossOneInchETH",
"outputs": [],
Expand Down
Loading