Niftyswap SmartRamp

Niftyswap SmartRamp is a direct connection between Wyre's APIs and the Niftyswap protocol. The technology behind our SmartRamp was created in partnership with the Sequence Platform by Horizon.

What is Niftyswap?

Niftyswap is an implementation of Uniswap, a protocol for automated token exchange on Ethereum. While Uniswap is for trading ERC-20 tokens, Niftyswap is a protocol for ERC-1155 tokens. Both are designed to favor ease of use and provide guaranteed access to liquidity on-chain.

Most exchanges maintain an order book and facilitate matches between buyers and sellers. Niftyswap smart contracts hold liquidity reserves of various tokens, and trades are executed directly against these reserves. Prices are set automatically using the constant product $x*y = K$ market maker mechanism, which keeps overall reserves in relative equilibrium. Reserves are pooled between a network of liquidity providers who supply the system with tokens in exchange for a proportional share of transaction fees.

An important feature of Niftyswap is the utilization of a factory/registry contract that deploys a separate exchange contract for each ERC-1155 token contract. These exchange contracts each hold independent reserves of a single fungible ERC-1155 currency and their associated ERC-1155 token id. This allows trades between the Currency and the ERC-1155 tokens based on the relative supplies. For more details, see Specification.

What is built on Niftyswap SmartRamp?

How to Integrate with Niftyswap SmartRamp

📘

High Level Flow

  1. Create SmartScript Wallet Order Reservation
  2. Retrieve Wallet Order Reservation with SmartScript Details
  3. Create an Order
  4. Retrieve Order
  5. Retrieve Transfer

1. Create SmartScript Wallet Order Reservation

The first step is to create a wallet order reservation, which is needed for card processing.

🚧

ERC-1155 Wallet Support

Make sure the destination of your Wallet Order Reservation is a wallet that can receive, hold, and send ERC-1155 tokens. The Niftyswap SmartRamp is natively integrated with the Sequence Wallet.

Key Request AttributeDescription
"dest"To use the Niftyswap SmartRamp the value must be "SMART_SCRIPT_DEFINITION:niftyswapPurchaseNFT"
"tokenIds"The token IDs of the NFTs you are purchasing
"tokensBoughtAmounts"The amount of each token ID you are purchasing
"maxCurrency"The max amount of USDC you are willing to pay for the NFTs
"amountIncludeFees"Must be set to "false" for SmartRamp orders
"maxCurrency"On a scale of 6; therefore, 8.00 should be 8000000
{
    "sourceCurrency": "USD",
    "amountIncludeFees": "false",
    "referrerAccountId": "AC_ZERR2JJFP93",
    "country": "US",
    "dest": "SMART_SCRIPT_DEFINITION:niftyswapPurchaseNFT",
    "paymentMethod": "debit-card",
    "smartScriptParameters": {
       "chainId" : "matic",
       "recipient": "0x5fC6B4DAd2aB87fCeEbEAbe8acc678F00F947E3D",
       "tokenIds": [
           65537,
           65538
       ], "tokensBoughtAmounts": [
            100,
            100
       ], "maxCurrency": 8000000
   }
}
{
    "url": "https://pay.sendwyre.com/purchase?country=US&utm_campaign=AC_ZERR2JJFP93&utm_medium=widget&sourceCurrency=USD&autoRedirect=false&dest=smart_script_invocation%3ASS_2Z4E2Z3HEH&quoteId=U6VG6NT963N&accountId=AC_ZERR2JJFP93&destAmount=8&amountIncludeFees=false&destCurrency=MUSDC&paymentMethod=debit-card&reservation=7YXXNB9HJCZ4MFNE3M3U&utm_source=checkout",
    "reservation": "7YXXNB9HJCZ4MFNE3M3U"
}

2. Retrieve the Wallet Order Reservation

Pass the reservation Id from the Wallet Order Reservation as a parameter to obtain the SmartScript Invocation.

{
    "amount": null,
    "sourceCurrency": "USD",
    "destCurrency": "MUSDC",
    "dest": "smart_script_invocation:SS_2Z4E2Z3HEH",
    "referrerAccountId": "AC_ZERR2JJFP93",
    "autoRedirect": false,
    "sourceAmount": null,
    "destAmount": 8000000,
    "amountIncludeFees": false,
    "street1": null,
    "city": null,
    "state": null,
    "postalCode": null,
    "country": "US",
    "firstName": null,
    "lastName": null,
    "phone": null,
    "email": null,
    "lockFields": [
        "country",
        "destAmount",
        "amountIncludeFees",
        "referrerAccountId",
        "destCurrency",
        "paymentMethod",
        "sourceAmount",
        "sourceCurrency",
        "dest"
    ],
    "redirectUrl": null,
    "failureRedirectUrl": null,
    "paymentMethod": "debit-card",
    "referenceId": null,
    "hideTrackBtn": null,
    "owner": null,
    "xlmMemo": null,
    "smartScriptParameters": {
        "chainId": "matic",
        "recipient": "0x5fC6B4DAd2aB87fCeEbEAbe8acc678F00F947E3D",
        "tokenIds": [
            65537,
            65538
        ],
        "tokensBoughtAmounts": [
            100,
            100
        ],
        "maxCurrency": 8
    },
    "quote": {
        "sourceCurrency": "USD",
        "sourceAmount": 13.24,
        "sourceAmountWithoutFees": 8000000,
        "destCurrency": "MUSDC",
        "destAmount": 8000000,
        "exchangeRate": 1,
        "equivalencies": {
            "CHF": 7.73,
            "MATIC": 11.670654164195022773,
            "ARS": 951.59,
            "MXN": 159.03,
            "CLP": 6644.52,
            "AVAXCUSDC": 8.000000,
            "ZAR": 126.02,
            "INR": 620.44,
            "VND": 185400.00,
            "MUSDC": 8.000000,
            "THB": 273.22,
            "AUD": 11.28,
            "ILS": 26.73,
            "KRW": 10088,
            "JPY": 1022,
            "PLN": 34.56,
            "GBP": 6.37,
            "PHP": 418.02,
            "ISK": 1044.16,
            "HKD": 62.80,
            "EUR": 7.50,
            "COP": 31620.55,
            "DKK": 55.78,
            "USD": 8.00,
            "CAD": 10.24,
            "MYR": 35.12,
            "NOK": 76.96,
            "SGD": 11.00,
            "CZK": 184.65,
            "SEK": 78.69,
            "NZD": 12.40,
            "BRL": 38.44
        },
        "fees": {
            "USD": 5.00,
            "MUSDC": 0.240000
        }
    },
    "smartScriptRequest": true,
    "quoteLockRequest": true
}

3. Create an Order

Learn more about White Label Card Processing.

{
    "reservationId": "7YXXNB9HJCZ4MFNE3M3U",
    "sourceCurrency": "USD",
    "destCurrency": "MUSDC",
    "amount": "8000000",
    "dest": "smart_script_invocation:SS_2Z4E2Z3HEH",
    "referrerAccountId": "AC_ZERR2JJFP93",
    "givenName": "daffy",
    "familyName": "duck",
    "email": "[email protected]",
    "phone": "+18052883333",
    "referenceId": "AC_ZERR2JJFP93",
    "ipAddress": null,
    "address": {
        "street1": "23432 Balboa St",
        "street2": null,
        "city": "San Francisco",
        "state": "CA",
        "postalCode": "94105",
        "country": "US"
    },
	  "debitCard": {
        "number": "4111111111111111",
        "year": 2023,
        "month": "10",
        "cvv": 555
    }
}
{
    "id": "WO_RL6HR8CBDB",
    "createdAt": 1653329575915,
    "owner": "account:AC_GFLY9BPTU4M",
    "status": "RUNNING_CHECKS",
    "orderType": "DOMESTIC",
    "sourceAmount": 13.24,
    "purchaseAmount": 8000000,
    "sourceCurrency": "USD",
    "destCurrency": "MUSDC",
    "transferId": null,
    "dest": "smart_script_invocation:SS_2Z4E2Z3HEH",
    "authCodesRequested": false,
    "blockchainNetworkTx": null,
    "accountId": "AC_GFLY9BPTU4M",
    "paymentMethodName": null
}

4. Retrieve Order

Pass in the Wallet Order Id as a parameter in order to obtain the Transfer Id. Learn more about Wallet Order Reservations.

{
    "id": "WO_RL6HR8CBDB",
    "createdAt": 1653333064000,
    "owner": "account:AC_GFLY9BPTU4M",
    "status": "PROCESSING",
    "orderType": "DOMESTIC",
    "sourceAmount": 13.24,
    "purchaseAmount": 8000000,
    "sourceCurrency": "USD",
    "destCurrency": "MUSDC",
    "transferId": "TF_ZYULJVGCHZX",
    "dest": "smart_script_invocation:SS_2Z4E2Z3HEH",
    "authCodesRequested": false,
    "blockchainNetworkTx": null,
    "accountId": "AC_GFLY9BPTU4M",
    "paymentMethodName": "Visa ending 1111"
}

5. Retrieve Transfer

Pass in the Transfer Id as a parameter to see the status of your SmartScript invocation. Learn more about the Transfer Life Cycle.

{
    "transfer": {
        "id": "TF_ZYULJVGCHZX",
        "status": "COMPLETED",
        "failureReason": null,
        "language": "en",
        "createdAt": 1653333025000,
        "updatedAt": 1653333025000,
        "completedAt": 1653333152000,
        "depositInitiatedAt": 1653333083000,
        "cancelledAt": null,
        "expiresAt": 1653333625000,
        "owner": "account:AC_GFLY9BPTU4M",
        "source": "walletorderholding:WO_RL6HR8CBDB",
        "dest": "smart_script_invocation:SS_2Z4E2Z3HEH",
        "sourceCurrency": "USD",
        "sourceAmount": 13.24,
        "destCurrency": "MUSDC",
        "destAmount": "8000000",
        "atMinFee": false,
        "exchangeRate": 1,
        "desc": null,
        "message": null,
        "totalFees": 5.24,
        "equivalencies": {
            "CHF": 7.72,
            "MATIC": 11.818584214957814638,
            "ARS": 951.56,
            "MXN": 159.16,
            "CLP": 6644.40,
            "AVAXCUSDC": 8.000000,
            "ZAR": 126.06,
            "INR": 620.20,
            "VND": 185400.00,
            "MUSDC": 8.000000,
            "THB": 273.10,
            "AUD": 11.25,
            "ILS": 26.73,
            "KRW": 10084,
            "JPY": 1023,
            "PLN": 34.49,
            "GBP": 6.36,
            "PHP": 418.19,
            "ISK": 1042.07,
            "HKD": 62.80,
            "EUR": 7.48,
            "COP": 31620.55,
            "DKK": 55.67,
            "USD": 8.00,
            "CAD": 10.22,
            "MYR": 35.12,
            "NOK": 76.73,
            "SGD": 10.99,
            "CZK": 184.32,
            "SEK": 78.49,
            "NZD": 12.38,
            "BRL": 38.47
        },
        "feeEquivalencies": {
            "CHF": 5.06,
            "MATIC": 7.742316640862646876,
            "MXN": 104.26,
            "CLP": 4352.16,
            "PAX": 5.240000000000000000,
            "USDT": 5.245770,
            "ZAR": 82.57,
            "USDS": 5.240000,
            "EDI": 0.200829757004976278,
            "VND": 121437.00,
            "MUSDC": 5.240000,
            "LETH": 0.002574277352410512,
            "AUD": 7.37,
            "COMP": 0.072902219757299459,
            "ILS": 17.51,
            "OPUL": 26.496621774522045372,
            "GUSD": 5.24,
            "HKD": 41.13,
            "SYF": 0.050900925286114214,
            "EGBTC": 0.079382053762674329,
            "EUR": 4.90,
            "DKK": 36.46,
            "CAD": 6.70,
            "MYR": 23.00,
            "UMA": 1.422412829766366856,
            "NOK": 50.26,
            "BTC": 0.00017549,
            "AVAX": 0.168190752116749068,
            "CZK": 120.73,
            "SEK": 51.41,
            "PDAI": 5.240000000000000000,
            "USDC": 5.240000,
            "HUSD": 5.24000000,
            "LUSDC": 5.240000,
            "FUSD": 5.24000000,
            "ARS": 623.29,
            "EFLUX": 7.43587019,
            "CRV": 3.844460648822123914,
            "AVAXCUSDC": 5.240000,
            "SUSDC": 5.240000,
            "INR": 406.30,
            "ALGO": 12.002695077252680968,
            "THB": 178.89,
            "CNY": 34.85,
            "KRW": 6608,
            "UNI": 0.909805713248687522,
            "AAVE": 0.045967437962754060,
            "JPY": 670,
            "WBTC": 0.00017507,
            "PLN": 22.59,
            "GBP": 4.17,
            "AUSDT": 5.240000,
            "XLM": 39.110665565585772255,
            "PHP": 273.95,
            "LINK": 0.700534757571973246,
            "SNX": 1.864398878484250359,
            "YFI": 0.000548943870076953,
            "ISK": 682.67,
            "COP": 20742.44,
            "AUSDC": 5.240000,
            "ZUSD": 5.240000,
            "USD": 5.24,
            "WETH": 0.002574277352410512,
            "DAI": 5.240000000000000000,
            "EBTCQ": 0.060920779518783094,
            "SGD": 7.20,
            "MKR": 0.003855564357787370,
            "BAT": 12.893605445688822349,
            "ETH": 0.002574277352410512,
            "NZD": 8.11,
            "BUSD": 5.240000000000000000,
            "BRL": 25.20
        },
        "fees": {
            "USD": 5.00,
            "MUSDC": 0.240000
        },
        "authorizingIp": null,
        "paymentUrl": null,
        "exchangeOrderId": "EX_XRHGXPZYQJL",
        "inExchangeId": null,
        "chargeId": null,
        "depositId": null,
        "sourceTxId": "TF_ZYULJVGCHZX-W",
        "destTxId": "TR_LZGM8Q7APYV",
        "customId": null,
        "buy": true,
        "instantBuy": false,
        "sell": false,
        "exchange": true,
        "send": false,
        "deposit": false,
        "withdrawal": true,
        "reversingSubStatus": null,
        "reversalReason": null,
        "retrievalUrl": "https://dash.sendwyre.com//sign-in",
        "destNickname": null,
        "pendingSubStatus": null,
        "destName": "Smart Script Invocation SS_2Z4E2Z3HEH",
        "sourceName": "Account AC_GFLY9BPTU4M",
        "estimatedArrival": 1653333152000,
        "blockchainTx": null,
        "statusHistories": [
            {
                "id": "AQWW63CAYBM",
                "transferId": "TF_ZYULJVGCHZX",
                "createdAt": 1653333083000,
                "type": "OUTGOING",
                "statusOrder": 0,
                "statusDetail": "Initiating Transfer",
                "state": "INITIATED",
                "failedState": null
            },
            {
                "id": "9L33EBAWJLQ",
                "transferId": "TF_ZYULJVGCHZX",
                "createdAt": 1653333083000,
                "type": "OUTGOING",
                "statusOrder": 200,
                "statusDetail": "Processing Exchange",
                "state": "PENDING",
                "failedState": null
            },
            {
                "id": "UTQDFFGZCBR",
                "transferId": "TF_ZYULJVGCHZX",
                "createdAt": 1653333083000,
                "type": "OUTGOING",
                "statusOrder": 400,
                "statusDetail": "Processing Deposit",
                "state": "PENDING",
                "failedState": null
            },
            {
                "id": "HNJEFEBVMDW",
                "transferId": "TF_ZYULJVGCHZX",
                "createdAt": 1653333152000,
                "type": "OUTGOING",
                "statusOrder": 5100,
                "statusDetail": "Transfer Completed",
                "state": "COMPLETED",
                "failedState": null
            }
        ],
        "documents": [],
        "pusherChannel": "ebe4f41a623cb79460069afc28d91a2f",
        "depositInfo": null,
        "chargeInfo": null
    },
    "aggregateSmartScriptInvocation": {
        "smartScriptInvocation": {
            "id": "SS_2Z4E2Z3HEH",
            "smartScriptDefinition": "niftyswapPurchaseNFT",
            "blockchainNetworkId": "matic",
            "status": "COMPLETED",
            "createdAt": 1653333024000,
            "updatedAt": 1653333151000,
            "completedAt": 1653333151000,
            "expiredAt": null,
            "failedAt": null,
            "failureReason": null,
            "inputs": "{\"chainId\":\"matic\",\"recipient\":\"0x5fC6B4DAd2aB87fCeEbEAbe8acc678F00F947E3D\",\"tokenIds\":[65537,65538],\"tokensBoughtAmounts\":[100,100],\"maxCurrency\":8}",
            "outputs": "Buying following tokensToken Id : [65537] Amount : [100]\nToken Id : [65538] Amount : [100]\nTotal Price in USDC : [8]",
            "ledgerTxId": "TR_LZGM8Q7APYV"
        },
        "smartScriptInvocationTxs": [
            {
                "smartScriptInvocationTx": {
                    "id": "26AMTG9LXC",
                    "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                    "blockchainTxId": "TR_9TM362ZN4V8",
                    "txOrder": 2,
                    "createdAt": 1653333024000,
                    "status": "CONFIRMED"
                },
                "blockchainTx": {
                    "id": "TR_9TM362ZN4V8",
                    "networkTxId": "0x7cdf7df3bde0bb5b3a92ab3235513ae91a386b4710f312592062ebbb66a668d3",
                    "blockTime": 1653333123000,
                    "blockhash": "0x0e72722f89378872a0c7475eb39cd0e5ad493b1c177f2d3e7e7fceee9c3be45a",
                    "amount": 3.21417,
                    "address": "0x9b609bf3a3977ee7254210e0a0d835251540c4d5",
                    "memo": null
                }
            },
            {
                "smartScriptInvocationTx": {
                    "id": "ZWQA863A2G",
                    "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                    "blockchainTxId": "TR_B2MLCHT7ZY2",
                    "txOrder": 1,
                    "createdAt": 1653333024000,
                    "status": "CONFIRMED"
                },
                "blockchainTx": {
                    "id": "TR_B2MLCHT7ZY2",
                    "networkTxId": "0x07c3686898c21fde13da5f8c88f67ef365f19b2de6b138a8e4a72f96c620d03d",
                    "blockTime": 1653333093000,
                    "blockhash": "0x7e6fc9a7d03d1adfa8dcf5626386ab2223bd7749f94263ff4501a774857fc544",
                    "amount": 8,
                    "address": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
                    "memo": null
                }
            }
        ],
        "smartScriptInvocationTxHistories": [
            {
                "id": "2TN6XAMQ2W",
                "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                "smartScriptInvocationTxId": "26AMTG9LXC",
                "createdAt": 1653333024000,
                "statusDetail": "Transaction created waiting for broadcast",
                "status": "WAITING"
            },
            {
                "id": "8Y38A2BNJ7B",
                "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                "smartScriptInvocationTxId": "ZWQA863A2G",
                "createdAt": 1653333118000,
                "statusDetail": "Transaction confirmed on-chain",
                "status": "CONFIRMED"
            },
            {
                "id": "E7PZ4XCN7X6",
                "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                "smartScriptInvocationTxId": "26AMTG9LXC",
                "createdAt": 1653333151000,
                "statusDetail": "Transaction confirmed on-chain",
                "status": "CONFIRMED"
            },
            {
                "id": "FZ3QEAYLEXG",
                "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                "smartScriptInvocationTxId": "26AMTG9LXC",
                "createdAt": 1653333151000,
                "statusDetail": "Transaction confirmed on-chain",
                "status": "CONFIRMED"
            },
            {
                "id": "HRTDAPCXX3R",
                "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                "smartScriptInvocationTxId": "26AMTG9LXC",
                "createdAt": 1653333151000,
                "statusDetail": "Transaction confirmed on-chain",
                "status": "CONFIRMED"
            },
            {
                "id": "JQHFDGWXYQC",
                "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                "smartScriptInvocationTxId": "26AMTG9LXC",
                "createdAt": 1653333119000,
                "statusDetail": "Transaction broadcasted on-chain",
                "status": "PENDING"
            },
            {
                "id": "MYZ7JHGF9D",
                "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                "smartScriptInvocationTxId": "ZWQA863A2G",
                "createdAt": 1653333024000,
                "statusDetail": "Transaction created waiting for broadcast",
                "status": "WAITING"
            },
            {
                "id": "ZG6ZGGVN6EV",
                "smartScriptInvocationId": "SS_2Z4E2Z3HEH",
                "smartScriptInvocationTxId": "ZWQA863A2G",
                "createdAt": 1653333090000,
                "statusDetail": "Transaction broadcasted on-chain",
                "status": "PENDING"
            }
        ]
    },
    "pusherChannel": "ebe4f41a623cb79460069afc28d91a2f",
    "exchangeRate": 1,
    "destCurrency": "MUSDC",
    "sourceAmount": 13.24,
    "sourceCurrency": "USD",
    "createdAt": 1653333025000,
    "dest": "smart_script_invocation:SS_2Z4E2Z3HEH",
    "destAmount": 8000000,
    "fees": {
        "USD": 5.00,
        "MUSDC": 0.240000
    },
    "totalFees": 5.24,
    "customId": null,
    "completedAt": 1653333152000,
    "cancelledAt": null,
    "failureReason": null,
    "blockchainTx": null,
    "expiresAt": 1653333625000,
    "updatedAt": 1653333025000,
    "reversingSubStatus": null,
    "reversalReason": null,
    "estimatedArrival": 1653333152000,
    "pendingSubStatus": null,
    "statusHistories": [
        {
            "id": "AQWW63CAYBM",
            "transferId": "TF_ZYULJVGCHZX",
            "createdAt": 1653333083000,
            "type": "OUTGOING",
            "statusOrder": 0,
            "statusDetail": "Initiating Transfer",
            "state": "INITIATED",
            "failedState": null
        },
        {
            "id": "9L33EBAWJLQ",
            "transferId": "TF_ZYULJVGCHZX",
            "createdAt": 1653333083000,
            "type": "OUTGOING",
            "statusOrder": 200,
            "statusDetail": "Processing Exchange",
            "state": "PENDING",
            "failedState": null
        },
        {
            "id": "UTQDFFGZCBR",
            "transferId": "TF_ZYULJVGCHZX",
            "createdAt": 1653333083000,
            "type": "OUTGOING",
            "statusOrder": 400,
            "statusDetail": "Processing Deposit",
            "state": "PENDING",
            "failedState": null
        },
        {
            "id": "HNJEFEBVMDW",
            "transferId": "TF_ZYULJVGCHZX",
            "createdAt": 1653333152000,
            "type": "OUTGOING",
            "statusOrder": 5100,
            "statusDetail": "Transfer Completed",
            "state": "COMPLETED",
            "failedState": null
        }
    ],
    "message": null,
    "id": "TF_ZYULJVGCHZX",
    "owner": "account:AC_GFLY9BPTU4M",
    "source": "walletorderholding:WO_E9U4UBWBVP",
    "status": "COMPLETED"
}