Application Memswap Integration Guide
To integrate Memswap into your wallet or application take the following steps:
-
Fetching Quotes - In order to parameterize orders effectively, start by fetching a market quote by a known exchange, such as uniswap or 1inch.
-
Choosing Swap Mode - Decided based on your user’s preferences to present a specific Swap Mode or to allow flexibility for you users
-
Submitting Swaps - Construct the appropriate swap order and submit the intentful approval with the designated matchmaker, if you choose to use one.
-
Following Swap Success - Once the swap is submitted, listen for the IntentSolved event to be emitted from the memswap contract and check that the intent hash from the event is the same as the user’s submitted order
Example references for submitting intents:
ERC20: https://github.com/memswap-protocol/memswap/blob/main/scripts/intent-erc20.ts (opens in a new tab)
ERC721: https://github.com/memswap-protocol/memswap/blob/main/scripts/intent-erc721.ts (opens in a new tab)
Memswap Interface:
Memswap GraphQL API
For easy access to the Memswap contract data, you may choose to integrate with the Memswap GraphQL API.
API Endpoints
- Mainnet: https://memswap-backend-mainnet.up.railway.app (opens in a new tab)
- Goerli: https://memswap-backend-goerli.up.railway.app (opens in a new tab)
Below is an example query for fetching a user’s intent history:
query GetUserIntents($maker: String) {
intents(
where: { maker: $maker }
orderBy: "endTime"
orderDirection: "desc"
) {
id
isBuy
sellToken {
id
isNative
isToken
chainId
decimals
symbol
name
address
icon
}
buyToken {
id
isNative
isToken
chainId
decimals
symbol
name
address
icon
}
maker
solver
source
feeBps
surplusBps
startTime
endTime
isPartiallyFillable
amount
endAmount
startAmountBps
expectedAmountBps
isCancelled
isPreValidated
events
amountFilled
}
}