Skip to content
Draft
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"typescript": "^5.7.3"
},
"dependencies": {
"@cowprotocol/cow-sdk": "6.0.0-RC.42",
"@cowprotocol/cow-sdk": "6.0.0-RC.47",
"@cowprotocol/app-data": "3.0.0-rc.1",
"@cowprotocol/contracts": "^1.7.0",
"axios": "^1.7.9",
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ import { run as getTradingQuote } from "./scripts/trading/getQuote";
import { run as getAcrossBridgingId } from "./scripts/bridging/getAcrossBridgingId";
import { run as getEthFlowId } from "./scripts/ethflow/getEthFlowId";
import { run as minimalAppData } from "./scripts/app-data/minimalAppData";
import { run as collateralSwapAave } from "./scripts/flash-loans/collateralSwapAave";

dotenv.config();

// Just to dev things easily using watch-mode :)
const JOBS: (() => Promise<unknown>)[] = [
// approveTokenSepolia, // Required to approve the token before trading
// getQuoteAndPostOrder, // Simplest way to integrate!
// getQuoteAndPostOrderNative,
//
// swapWithPk,
// swapSell,
Expand All @@ -64,7 +66,7 @@ const JOBS: (() => Promise<unknown>)[] = [
// nativeSell, // FIXME: Throws error creating the eth flow order. Doesn't recognize 'gas' property - I believe expects 'gasLimit')
//
// approveTokenMainnet,
getQuoteAndPostOrderMainnet,
// getQuoteAndPostOrderMainnet,
// swapAndBridgeUsingOmnibridge,
// swapAndBridgeUsingXdaiBridge,
//
Expand All @@ -83,6 +85,7 @@ const JOBS: (() => Promise<unknown>)[] = [
// getAcrossBridgingId,
// getEthFlowId,
// minimalAppData,
collateralSwapAave,
];

async function main() {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/bridging/swapAndBridgeSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export async function run() {
}

// Post the order
const orderId = await quote.postSwapOrderFromQuote();
const { orderId } = await quote.postSwapOrderFromQuote();

// Print the order creation
console.log(
Expand Down
156 changes: 156 additions & 0 deletions src/scripts/flash-loans/abi/OrderHelperAbi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
export const orderHelperAbi = [
{
type: "function",
name: "AAVE_LENDING_POOL",
inputs: [],
outputs: [{ name: "", type: "address", internalType: "address" }],
stateMutability: "view",
},
{
type: "function",
name: "SETTLEMENT",
inputs: [],
outputs: [{ name: "", type: "address", internalType: "address" }],
stateMutability: "view",
},
{
type: "function",
name: "appData",
inputs: [],
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
stateMutability: "view",
},
{
type: "function",
name: "borrower",
inputs: [],
outputs: [{ name: "", type: "address", internalType: "address" }],
stateMutability: "view",
},
{
type: "function",
name: "initialize",
inputs: [
{ name: "_owner", type: "address", internalType: "address" },
{ name: "_borrower", type: "address", internalType: "address" },
{
name: "_oldCollateral",
type: "address",
internalType: "address",
},
{
name: "_oldCollateralAmount",
type: "uint256",
internalType: "uint256",
},
{
name: "_newCollateral",
type: "address",
internalType: "address",
},
{
name: "_minSupplyAmount",
type: "uint256",
internalType: "uint256",
},
{ name: "_validTo", type: "uint32", internalType: "uint32" },
{ name: "_appData", type: "bytes32", internalType: "bytes32" },
],
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
name: "isValidSignature",
inputs: [
{ name: "_orderHash", type: "bytes32", internalType: "bytes32" },
{ name: "_signature", type: "bytes", internalType: "bytes" },
],
outputs: [{ name: "", type: "bytes4", internalType: "bytes4" }],
stateMutability: "view",
},
{
type: "function",
name: "minSupplyAmount",
inputs: [],
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
stateMutability: "view",
},
{
type: "function",
name: "newCollateral",
inputs: [],
outputs: [{ name: "", type: "address", internalType: "contract IERC20" }],
stateMutability: "view",
},
{
type: "function",
name: "oldCollateral",
inputs: [],
outputs: [{ name: "", type: "address", internalType: "contract IERC20" }],
stateMutability: "view",
},
{
type: "function",
name: "oldCollateralAmount",
inputs: [],
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
stateMutability: "view",
},
{
type: "function",
name: "owner",
inputs: [],
outputs: [{ name: "", type: "address", internalType: "address" }],
stateMutability: "view",
},
{
type: "function",
name: "swapCollateral",
inputs: [],
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
name: "validTo",
inputs: [],
outputs: [{ name: "", type: "uint32", internalType: "uint32" }],
stateMutability: "view",
},
{
type: "event",
name: "Initialized",
inputs: [
{
name: "version",
type: "uint64",
indexed: false,
internalType: "uint64",
},
],
anonymous: false,
},
{ type: "error", name: "AppDataDoesNotMatch", inputs: [] },
{ type: "error", name: "BadBuyToken", inputs: [] },
{ type: "error", name: "BadParameters", inputs: [] },
{ type: "error", name: "BadReceiver", inputs: [] },
{ type: "error", name: "BadSellAmount", inputs: [] },
{ type: "error", name: "BadSellToken", inputs: [] },
{ type: "error", name: "FeeIsNotZero", inputs: [] },
{ type: "error", name: "InvalidInitialization", inputs: [] },
{ type: "error", name: "NoPartiallyFillable", inputs: [] },
{ type: "error", name: "NotEnoughBuyAmount", inputs: [] },
{ type: "error", name: "NotEnoughSupplyAmount", inputs: [] },
{ type: "error", name: "NotInitializing", inputs: [] },
{ type: "error", name: "NotLongerValid", inputs: [] },
{ type: "error", name: "NotSellOrder", inputs: [] },
{ type: "error", name: "OnlyBalanceERC20", inputs: [] },
{ type: "error", name: "OrderDoesNotMatchMessageHash", inputs: [] },
{
type: "error",
name: "SafeERC20FailedOperation",
inputs: [{ name: "token", type: "address", internalType: "address" }],
},
{ type: "error", name: "WrongValidTo", inputs: [] },
];
112 changes: 112 additions & 0 deletions src/scripts/flash-loans/abi/OrderHelperFactoryAbi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
export const orderHelperFactoryAbi = [
{
type: "constructor",
inputs: [
{
name: "_helperImplementation",
type: "address",
internalType: "address",
},
],
stateMutability: "nonpayable",
},
{
type: "function",
name: "deployOrderHelper",
inputs: [
{ name: "_owner", type: "address", internalType: "address" },
{ name: "_borrower", type: "address", internalType: "address" },
{
name: "_oldCollateral",
type: "address",
internalType: "address",
},
{
name: "_oldCollateralAmount",
type: "uint256",
internalType: "uint256",
},
{
name: "_newCollateral",
type: "address",
internalType: "address",
},
{
name: "_minSupplyAmount",
type: "uint256",
internalType: "uint256",
},
{ name: "_validTo", type: "uint32", internalType: "uint32" },
],
outputs: [
{
name: "orderHelperAddress",
type: "address",
internalType: "address",
},
],
stateMutability: "nonpayable",
},
{
type: "function",
name: "getOrderHelperAddress",
inputs: [
{ name: "_owner", type: "address", internalType: "address" },
{ name: "_borrower", type: "address", internalType: "address" },
{
name: "_oldCollateral",
type: "address",
internalType: "address",
},
{
name: "_oldCollateralAmount",
type: "uint256",
internalType: "uint256",
},
{
name: "_newCollateral",
type: "address",
internalType: "address",
},
{
name: "_minSupplyAmount",
type: "uint256",
internalType: "uint256",
},
{ name: "_validTo", type: "uint32", internalType: "uint32" },
],
outputs: [
{
name: "orderHelperAddress",
type: "address",
internalType: "address",
},
],
stateMutability: "view",
},
{
type: "event",
name: "NewOrderHelper",
inputs: [
{
name: "helper",
type: "address",
indexed: true,
internalType: "address",
},
],
anonymous: false,
},
{ type: "error", name: "ContractAlreadyDeployed", inputs: [] },
{ type: "error", name: "FailedDeployment", inputs: [] },
{
type: "error",
name: "InsufficientBalance",
inputs: [
{ name: "balance", type: "uint256", internalType: "uint256" },
{ name: "needed", type: "uint256", internalType: "uint256" },
],
},
{ type: "error", name: "InvalidImplementationContract", inputs: [] },
{ type: "error", name: "OrderHelperDeploymentFailed", inputs: [] },
] as const;
Loading