From a3462203dd98cdae6c27371e58370179a5118cde Mon Sep 17 00:00:00 2001 From: Bruno Barbieri <1247834+brunobar79@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:57:25 -0500 Subject: [PATCH 1/2] @bruno/bump 0.30.0 (#93) * v0.28.0 * v0.30.0 --- sdk/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/package.json b/sdk/package.json index 6632e23..ff1cccd 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,5 +1,5 @@ { - "version": "0.29.0", + "version": "0.30.0", "name": "@rainbow-me/swaps", "license": "GPL-3.0", "main": "dist/index.js", From e926a2fad776da6b0ea635794274224dfcef9be0 Mon Sep 17 00:00:00 2001 From: Wayne Cheng <677680+welps@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:25:27 -0500 Subject: [PATCH 2/2] feat: add getWrappedAssetAddress function (#94) --- sdk/src/wrappedAsset.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sdk/src/wrappedAsset.ts b/sdk/src/wrappedAsset.ts index be8f52e..67f69a2 100644 --- a/sdk/src/wrappedAsset.ts +++ b/sdk/src/wrappedAsset.ts @@ -4,7 +4,7 @@ import { Contract } from '@ethersproject/contracts'; import { StaticJsonRpcProvider } from '@ethersproject/providers'; import { Transaction } from '@ethersproject/transactions'; import { default as WethAbi } from './abi/Weth.json'; -import { EthereumAddress, TransactionOptions } from './types'; +import {EthereumAddress, Quote, SwapType, TransactionOptions} from './types'; /** * Function to wrap a specific amount of the native asset @@ -75,3 +75,21 @@ export const getWrappedAssetMethod = ( ); return instance.estimateGas[name]; }; + +/** + * Get the wrapped asset address from a quote on a wrap/unwrap + * @param quote + * @returns {EthereumAddress} + */ +export const getWrappedAssetAddress = (quote: Quote): EthereumAddress => { + switch (quote.swapType) { + case SwapType.wrap: + return quote.buyTokenAddress as EthereumAddress; + case SwapType.unwrap: + return quote.sellTokenAddress as EthereumAddress; + default: + throw new Error( + `Getting wrapped asset address on a ${quote.swapType} swap is not supported` + ); + } +};