Skip to content

Instantly share code, notes, and snippets.

@szemate
Created June 26, 2024 11:13
Show Gist options
  • Save szemate/05183733925791cd523144398763126e to your computer and use it in GitHub Desktop.
Save szemate/05183733925791cd523144398763126e to your computer and use it in GitHub Desktop.
AirSwap Last Look order
import {
ChainIds,
createOrderERC20,
createOrderERC20Signature,
OrderERC20
} from '@airswap/utils';
import { Server } from '@airswap/libraries';
const signer = process.env.PRIVATE_KEY;
const signerWallet = '0x455777268Bd43C983ba82D9DE4efa0445af99D96';
const senderWallet = '0x5eb2F7511405B0cb0f24aBdC77412Fa1dfE68F3E';
const senderToken = '0x109f93893af4c4b0afc7a9e97b59991260f98313';
const signerToken = '0x689856e2a6eb68fc33099eb2ccba0a5a4e8be52f';
const swapContract = '0xB252Cb6ffFCdFDCbd614a9CcEFcb8683298Fbd1C';
const chainId = ChainIds.PICCADILLY;
async function main(): Promise<void> {
const server = await Server.at('wss://airswap-server-devnet.up.railway.app')
const order = createOrderERC20({
signerWallet,
senderWallet,
signerToken,
senderToken,
signerAmount: '0.1',
senderAmount: '0.1',
});
const signature = await createOrderERC20Signature(
order,
signer as string,
swapContract,
chainId,
);
const signedOrder: OrderERC20 = {
nonce: order.nonce,
expiry: order.expiry,
signerWallet: order.signerWallet,
signerToken: order.signerToken,
signerAmount: order.signerAmount,
senderToken: order.senderToken,
senderAmount: order.senderAmount,
...signature,
};
console.log(signedOrder);
const success = await server.considerOrderERC20(signedOrder);
process.exit(success ? 0 : 1);
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment