Skip to content

Instantly share code, notes, and snippets.

@svanas
Last active Jul 12, 2022
Embed
What would you like to do?
Swap 100 USDC for WETH on Ethereum
const client: IWeb3 = TWeb3.Create(
web3.Ethereum,
web3.eth.infura.endpoint(web3.Ethereum, INFURA_PROJECT_ID)
);
web3.eth.balancer.v2.swap(
client,
owner,
TSwapKind.GivenIn,
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
web3.utils.scale(100, 6), // 100 USDC
0, // limit
web3.Infinite, // deadline
procedure(rcpt: ITxReceipt; err: IError)
begin
if Assigned(err) then
// handle error gracefully
else
// your transaction got mined
end);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment