├── .gitignore ├── LICENSE ├── README.md ├── V1(deprecated) ├── README.md ├── buyNftFromAnyChain │ ├── .env.example │ ├── abi │ │ ├── decentralandAbi.ts │ │ ├── erc1155Abi.ts │ │ ├── erc20Abi.ts │ │ ├── erc721Abi.ts │ │ └── treasureMarketplaceAbi.ts │ ├── package.json │ ├── src │ │ ├── decentraland.ts │ │ └── index.ts │ └── tsconfig.json ├── cosmos │ ├── cosmosContractCall │ │ ├── .env.example │ │ ├── README.md │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ └── tsconfig.json │ ├── cosmosMarsRedBankDeposit │ │ ├── .env.example │ │ ├── README.md │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ └── tsconfig.json │ ├── cosmosToCosmosSwap │ │ ├── .env.example │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ └── tsconfig.json │ ├── cosmosToEvmSwap │ │ ├── .env.example │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ └── tsconfig.json │ └── evmToCosmosSwap │ │ ├── .env.example │ │ ├── package.json │ │ ├── src │ │ └── index.ts │ │ └── tsconfig.json ├── crossChainSwap │ ├── .env.example │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── crosschainSwapToCosmos │ ├── .env.example │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── depositFromAnyChainSommelier │ ├── .env.example │ ├── README.md │ ├── abi │ │ ├── erc20Abi.ts │ │ └── sommAbi.ts │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── depositToCosmos │ ├── .env.example │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── stakeFromAnyChain │ ├── .env.example │ ├── abi │ │ └── moonwellGlmrAbi.ts │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json └── stakeFromAnyChainPinjam │ ├── .env.example │ ├── README.md │ ├── abi │ ├── erc20Abi.ts │ ├── pTokens.ts │ └── pinjamStakingPoolAbi.ts │ ├── package.json │ ├── src │ └── index.ts │ └── tsconfig.json └── V2 ├── api ├── CosmostoEVMPostHook │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── bitcoinToEVM_Swap │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── buyNFTonEVM │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── Seaport.ts │ │ ├── Seaport__factory.ts │ │ ├── abi │ │ │ └── erc1155Abi.ts │ │ ├── common.ts │ │ ├── index.ts │ │ ├── openseaService.ts │ │ └── types.ts │ └── tsconfig.json ├── cosmostoCosmosPosthook │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── cosmostoEVMSwap │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── cosmostoEVMandSupplyPosthook │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── evmPrehooktoEVM │ ├── .env.example │ ├── abi │ │ ├── erc20Abi.ts │ │ └── wethAbi.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── evmToEVMSwap │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── evmToEVMSwap_setToAmount │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── evmWithdrawPrehooktoEVM │ ├── .env.example │ ├── abi │ │ └── erc20Abi.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── evmWithdrawPrehooktoEVMDeposit │ ├── .env.example │ ├── abi │ │ └── erc20Abi.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── oldExamples │ ├── mintPolygonNftFromAnyChain │ │ ├── .env.example │ │ ├── abi │ │ │ ├── erc20Abi.ts │ │ │ └── squidEasterEggNftAbi.ts │ │ ├── contracts │ │ │ └── squidEasterEggNft.sol │ │ ├── hardhat.config.js │ │ ├── package.json │ │ ├── scripts │ │ │ └── deploy.js │ │ ├── src │ │ │ └── index.ts │ │ └── tsconfig.json │ ├── repayAaveLoanWithdrawToBinance │ │ ├── .env.example │ │ ├── abi │ │ │ └── aavePoolAbi.ts │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ └── tsconfig.json │ ├── swapArbitrumEthToBaseUsdc │ │ ├── .env.example │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ └── tsconfig.json │ ├── swapAvalancheUsdcToMoonbeamGlmr │ │ ├── .env.example │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ └── tsconfig.json │ └── swapEthereumToFantomAndStake │ │ ├── .env.example │ │ ├── abi │ │ ├── fantomSFC.ts │ │ └── radiantLendingPoolAbi.ts │ │ ├── package.json │ │ ├── src │ │ └── index.ts │ │ └── tsconfig.json ├── solanaToEVM_Swap │ ├── .env.example │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── swapEVMToEVMAndLendPosthook │ ├── .env.example │ ├── abi │ │ ├── erc20Abi.ts │ │ └── radiantLendingPoolAbi.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json └── tx_lookup │ ├── package.json │ └── tx-lookup.js └── sdk ├── evmPrehooktoEVM ├── .env.example ├── abi │ ├── erc20Abi.ts │ └── wethAbi.ts ├── package-lock.json ├── package.json ├── src │ └── index.ts └── tsconfig.json ├── evmToEVMSwap ├── .env.example ├── package-lock.json ├── package.json ├── src │ └── index.ts └── tsconfig.json ├── oldExamples ├── buyNftFromAnyChain │ ├── .env.example │ ├── abi │ │ ├── decentralandAbi.ts │ │ ├── erc1155Abi.ts │ │ ├── erc20Abi.ts │ │ ├── erc721Abi.ts │ │ └── treasureMarketplaceAbi.ts │ ├── package.json │ ├── src │ │ ├── decentraland.ts │ │ └── index.ts │ └── tsconfig.json ├── ethersV5SwapAvalancheUsdcToMoonbeam │ ├── .env.example │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── mintPolygonNftFromAnyChain │ ├── .env.example │ ├── abi │ │ ├── erc20Abi.ts │ │ └── squidEasterEggNftAbi.ts │ ├── contracts │ │ └── squidEasterEggNft.sol │ ├── hardhat.config.js │ ├── package.json │ ├── scripts │ │ └── deploy.js │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── repayAaveLoanWithdrawToBinance │ ├── .env.example │ ├── abi │ │ └── aavePoolAbi.ts │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── swapArbitrumEthToBaseUsdc │ ├── .env.example │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── swapAvalancheUsdcToMoonbeam │ ├── .env.example │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── swapEthereumToFantomAndStake │ ├── .env.example │ ├── abi │ │ └── fantomSFC.ts │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json └── swapPolygonToArbitrumAndLend │ ├── .env.example │ ├── abi │ └── radiantLendingPoolAbi.ts │ ├── package.json │ ├── src │ └── index.ts │ └── tsconfig.json └── swapEVMtoEVMAndLendPosthook ├── .env.example ├── abi └── erc20Abi.ts ├── package-lock.json ├── package.json ├── src └── index.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | /**/node_modules 2 | .env 3 | .DS_Store 4 | yarn.lock 5 | /V1/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Squid examples 2 | 3 | Repository of examples integrating the Squid API, SDK and Widget ✨💜 4 | 5 | ## Instructions 6 | 7 | Requires `node` and `npm` to be installed 8 | 9 | Navigate to the folder you want to try 10 | `cd V2/api/evmToEVMSwap` 11 | 12 | Install packages 13 | `yarn install` 14 | 15 | Copy the .env.example to a file named .env in the same directory, fill in your values. These will not be committed, since .env is in the .gitignore file. 16 | 17 | Run index.js 18 | `yarn start` 19 | 20 | ## How to approach this 21 | 22 | Get straight into code! Run the route example of your choice, understand it, and then start extending. Send some tokens to the Cosmos, buy an NFT across chains, and stake across chains. 23 | 24 | Check out our [docs](https://docs.squidrouter.com) for a deeper look, and some hidden features. 25 | 26 | ## Available V2 Examples 27 | 28 | In this repository we have examples for the following transaction routes: 29 | - EVM Routes 30 | - BTC & Solana Routes 31 | - Cosmos Routes 32 | 33 | - EVM preHooks 34 | - EVM postHooks 35 | - Cosmos PostHooks 36 | 37 | Note, v1 has been deprecated and is no longer publicly available. 38 | 39 | 40 | ## Where to find us 41 | 42 | If you'd like support, or a private walkthrough, we're happy to jump on a chat and help you through anything:) 43 | 44 | Find us here: 45 | [Discord](https://discord.gg/squidrouter) 46 | [Twitter](https://twitter.com/squidrouter) 47 | -------------------------------------------------------------------------------- /V1(deprecated)/README.md: -------------------------------------------------------------------------------- 1 | ## V1 Examples 2 | 3 | This folder contains examples from Squid V1. 4 | -------------------------------------------------------------------------------- /V1(deprecated)/buyNftFromAnyChain/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | AVAX_RPC_ENDPOINT=https://api.avax.network/ext/bc/C/rpc 5 | -------------------------------------------------------------------------------- /V1(deprecated)/buyNftFromAnyChain/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V1(deprecated)/buyNftFromAnyChain/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts", 4 | "start:decentraland": "ts-node src/decentraland.ts" 5 | }, 6 | "dependencies": { 7 | "@0xsquid/sdk": "1.7.0", 8 | "dotenv": "^16.0.3", 9 | "ethers": "^5.7.2", 10 | "typescript": "^5.2.2" 11 | }, 12 | "devDependencies": { 13 | "ts-node": "^10.9.1" 14 | } 15 | } -------------------------------------------------------------------------------- /V1(deprecated)/buyNftFromAnyChain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosContractCall/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | MNEMONIC="" 4 | AXELAR_RPC_ENDPOINT="https://mainnet.rpc.axelar.dev/chain/axelar" 5 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosContractCall/README.md: -------------------------------------------------------------------------------- 1 | # Cosmos To Cosmos Example with Custom Contract Call 2 | 3 | This example shows how to use squid-sdk in order to perform cosmos actions with the custom contract call. 4 | 5 | ## Flow 6 | 1. IBC-Transfer uaxl token from Axelar chain to Osmosis. 7 | 2. Provide swap message for swapping uaxl into axlUSDC on Osmosis as custom contract call. -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosContractCall/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "1.4.6-beta.0", 7 | "@cosmjs/stargate": "^0.30.1", 8 | "dotenv": "^16.0.3" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosContractCall/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Squid } from "@0xsquid/sdk"; 2 | import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; 3 | import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; 4 | import { fromBech32, toBech32 } from "@cosmjs/encoding"; 5 | 6 | // Environment 7 | // add to a file named ".env" to prevent them being uploaded to github 8 | import * as dotenv from "dotenv"; 9 | dotenv.config(); 10 | 11 | const mnemonic = process.env.MNEMONIC; 12 | const axelarRpc = process.env.AXELAR_RPC_ENDPOINT; 13 | 14 | // addresses and IDs 15 | const axelarChainId = "axelar-dojo-1"; 16 | const osmosisChainId = "osmosis-1"; 17 | const uaxlAddressAxelar = "uaxl"; 18 | const uaxlAddressOsmosis = 19 | "ibc/903A61A498756EA560B85A85132D3AEE21B5DEDD41213725D22ABF276EA6945E"; 20 | 21 | // amount of uaxl to send from Axelar to Osmosis 22 | const amount = "1000000"; 23 | 24 | const getSDK = () => { 25 | const squid = new Squid({ 26 | baseUrl: "https://squid-api-git-feat-cosmos-mainmainnet-0xsquid.vercel.app", 27 | }); 28 | return squid; 29 | }; 30 | 31 | (async () => { 32 | const offlineSigner = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { 33 | prefix: "axelar", 34 | }); 35 | 36 | const signerAddress = (await offlineSigner.getAccounts())[0].address; 37 | console.log(`Sender address: ${signerAddress}`); 38 | 39 | const osmosisAddress = deriveCosmosAddress("osmo", signerAddress); 40 | console.log(`Receiver address: ${osmosisAddress}`); 41 | 42 | const signer = await SigningStargateClient.connectWithSigner( 43 | axelarRpc, 44 | offlineSigner 45 | ); 46 | 47 | // instantiate the SDK 48 | const squid = getSDK(); 49 | // init the SDK 50 | await squid.init(); 51 | console.log("Squid inited"); 52 | 53 | const params = { 54 | fromChain: axelarChainId, 55 | fromToken: uaxlAddressAxelar, 56 | fromAmount: amount, 57 | cosmosSignerAddress: signerAddress, 58 | toChain: osmosisChainId, 59 | toToken: uaxlAddressOsmosis, 60 | toAddress: osmosisAddress, // this address will be replaced with contract address 61 | slippage: 3.0, 62 | customCosmosContractCall: { 63 | contract: 64 | "osmo15jw7xccxaxk30lf4xgag8f7aeg53pgkh74e39rv00xfnymldjaas2fk627", 65 | msg: { 66 | wasm: { 67 | contract: 68 | "osmo15jw7xccxaxk30lf4xgag8f7aeg53pgkh74e39rv00xfnymldjaas2fk627", 69 | msg: { 70 | swap_with_action: { 71 | swap_msg: { 72 | token_out_min_amount: "61810", 73 | path: [ 74 | { 75 | pool_id: "812", 76 | token_out_denom: "uosmo", 77 | }, 78 | { 79 | pool_id: "678", 80 | token_out_denom: 81 | "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", 82 | }, 83 | ], 84 | }, 85 | after_swap_action: { 86 | bank_send: { 87 | receiver: osmosisAddress, 88 | }, 89 | }, 90 | local_fallback_address: osmosisAddress, 91 | }, 92 | }, 93 | }, 94 | }, 95 | }, 96 | }; 97 | 98 | const { route } = await squid.getRoute(params); 99 | 100 | const txInfo = (await squid.executeRoute({ 101 | signer, 102 | signerAddress, 103 | route, 104 | })) as DeliverTxResponse; 105 | 106 | const txLink = `https://www.mintscan.io/axelar/txs/${txInfo.transactionHash}`; 107 | console.log(`Finished! You can find your transaction here: ${txLink}`); 108 | })(); 109 | 110 | export const deriveCosmosAddress = ( 111 | chainPrefix: string, 112 | address: string 113 | ): string => { 114 | return toBech32(chainPrefix, fromBech32(address).data); 115 | }; 116 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosContractCall/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosMarsRedBankDeposit/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | MNEMONIC="" 4 | AXELAR_RPC_ENDPOINT="https://mainnet.rpc.axelar.dev/chain/axelar" 5 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosMarsRedBankDeposit/README.md: -------------------------------------------------------------------------------- 1 | # Cosmos To Cosmos Example with deposit into Mars Protocol 2 | 3 | In this example we swap uaxl on Axelar into uosmo on Osmosis and deposit received uosmo into Red Bank on Mars Protocol -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosMarsRedBankDeposit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "1.4.6-beta.0", 7 | "@cosmjs/stargate": "^0.30.1", 8 | "dotenv": "^16.0.3" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosMarsRedBankDeposit/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Squid } from "@0xsquid/sdk"; 2 | import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; 3 | import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; 4 | import { fromBech32, toBech32 } from "@cosmjs/encoding"; 5 | 6 | // Environment 7 | // add to a file named ".env" to prevent them being uploaded to github 8 | import * as dotenv from "dotenv"; 9 | dotenv.config(); 10 | 11 | const mnemonic = process.env.MNEMONIC; 12 | const axelarRpc = process.env.AXELAR_RPC_ENDPOINT; 13 | 14 | // addresses and IDs 15 | const axelarChainId = "axelar-dojo-1"; 16 | const osmosisChainId = "osmosis-1"; 17 | const uaxlAddressAxelar = "uaxl"; 18 | const uosmoAddress = "uosmo"; 19 | 20 | // amount of uaxl to send from Axelar to Osmosis 21 | const amount = "1000000"; 22 | 23 | const getSDK = () => { 24 | const squid = new Squid({ 25 | baseUrl: "https://squid-api-git-feat-cosmos-mainmainnet-0xsquid.vercel.app", 26 | }); 27 | return squid; 28 | }; 29 | 30 | (async () => { 31 | const offlineSigner = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { 32 | prefix: "axelar", 33 | }); 34 | 35 | const signerAddress = (await offlineSigner.getAccounts())[0].address; 36 | console.log(`Sender address: ${signerAddress}`); 37 | 38 | const osmosisAddress = deriveCosmosAddress("osmo", signerAddress); 39 | console.log(`Receiver address: ${osmosisAddress}`); 40 | 41 | const signer = await SigningStargateClient.connectWithSigner( 42 | axelarRpc, 43 | offlineSigner 44 | ); 45 | 46 | // instantiate the SDK 47 | const squid = getSDK(); 48 | // init the SDK 49 | await squid.init(); 50 | console.log("Squid inited"); 51 | 52 | const params = { 53 | fromChain: axelarChainId, 54 | fromToken: uaxlAddressAxelar, 55 | fromAmount: amount, 56 | cosmosSignerAddress: signerAddress, 57 | toChain: osmosisChainId, 58 | toToken: uosmoAddress, 59 | toAddress: osmosisAddress, // this address will be replaced with contract address 60 | slippage: 3.0, 61 | customCosmosContractCall: { 62 | contract: 63 | "osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg", 64 | msg: { 65 | deposit: { 66 | on_behalf_of: osmosisAddress, 67 | }, 68 | }, 69 | }, 70 | }; 71 | 72 | const { route } = await squid.getRoute(params); 73 | 74 | const txInfo = (await squid.executeRoute({ 75 | signer, 76 | signerAddress, 77 | route, 78 | })) as DeliverTxResponse; 79 | 80 | const txLink = `https://www.mintscan.io/axelar/txs/${txInfo.transactionHash}`; 81 | console.log(`Finished! You can find your transaction here: ${txLink}`); 82 | 83 | console.log(`Check your deposited uosmo into Mars Red Bank here: https://app.marsprotocol.io/redbank`); 84 | })(); 85 | 86 | export const deriveCosmosAddress = ( 87 | chainPrefix: string, 88 | address: string 89 | ): string => { 90 | return toBech32(chainPrefix, fromBech32(address).data); 91 | }; 92 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosMarsRedBankDeposit/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosToCosmosSwap/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | MNEMONIC="" 4 | OSMOSIS_RPC_ENDPOINT="https://mainnet.rpc.axelar.dev/chain/osmosis" 5 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosToCosmosSwap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "1.4.6-beta.0", 7 | "@cosmjs/stargate": "^0.30.1", 8 | "dotenv": "^16.0.3" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosToCosmosSwap/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Squid } from "@0xsquid/sdk"; 2 | import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; 3 | import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; 4 | import { fromBech32, toBech32 } from "@cosmjs/encoding"; 5 | 6 | // Environment 7 | // add to a file named ".env" to prevent them being uploaded to github 8 | import * as dotenv from "dotenv"; 9 | dotenv.config(); 10 | 11 | const mnemonic = process.env.MNEMONIC; 12 | const osmosisRpc = process.env.OSMOSIS_RPC_ENDPOINT; 13 | 14 | // addresses and IDs 15 | const axelarChainId = "axelar-dojo-1"; 16 | const osmosisChainId = "osmosis-1"; 17 | const uaxlAddressAxelar = "uaxl"; 18 | const uosmoAddress = "uosmo"; 19 | 20 | // amount of uosmo to swap 21 | const amount = "1000000"; 22 | 23 | const getSDK = () => { 24 | const squid = new Squid({ 25 | baseUrl: "https://squid-api-git-feat-cosmos-mainmainnet-0xsquid.vercel.app", 26 | }); 27 | return squid; 28 | }; 29 | 30 | (async () => { 31 | const offlineSigner = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { 32 | prefix: "osmo", 33 | }); 34 | 35 | const signerAddress = (await offlineSigner.getAccounts())[0].address; 36 | console.log(`Sender address: ${signerAddress}`); 37 | 38 | const axelarAddress = deriveCosmosAddress("axelar", signerAddress); 39 | console.log(`Receiver address: ${axelarAddress}`); 40 | 41 | const signer = await SigningStargateClient.connectWithSigner( 42 | osmosisRpc, 43 | offlineSigner 44 | ); 45 | 46 | // instantiate the SDK 47 | const squid = getSDK(); 48 | // init the SDK 49 | await squid.init(); 50 | console.log("Squid inited"); 51 | 52 | const params = { 53 | fromChain: osmosisChainId, 54 | fromToken: uosmoAddress, 55 | fromAmount: amount, 56 | cosmosSignerAddress: signerAddress, 57 | toChain: axelarChainId, 58 | toToken: uaxlAddressAxelar, 59 | toAddress: axelarAddress, 60 | slippage: 3.0, 61 | }; 62 | 63 | const { route } = await squid.getRoute(params); 64 | 65 | const txInfo = (await squid.executeRoute({ 66 | signer, 67 | signerAddress, 68 | route, 69 | })) as DeliverTxResponse; 70 | 71 | const txLink = `https://www.mintscan.io/osmosis/txs/${txInfo.transactionHash}`; 72 | console.log(`Finished! You can find your transaction here: ${txLink}`); 73 | })(); 74 | 75 | export const deriveCosmosAddress = ( 76 | chainPrefix: string, 77 | address: string 78 | ): string => { 79 | return toBech32(chainPrefix, fromBech32(address).data); 80 | }; 81 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosToCosmosSwap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosToEvmSwap/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | MNEMONIC="" 4 | OSMOSIS_RPC_ENDPOINT="https://mainnet.rpc.axelar.dev/chain/osmosis" 5 | EVM_RECEIVER_ADDRESS="0x00" -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosToEvmSwap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "1.4.6-beta.0", 7 | "@cosmjs/stargate": "^0.30.1", 8 | "dotenv": "^16.0.3" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosToEvmSwap/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Squid } from "@0xsquid/sdk"; 2 | import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; 3 | import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; 4 | import { fromBech32, toBech32 } from "@cosmjs/encoding"; 5 | 6 | // Environment 7 | // add to a file named ".env" to prevent them being uploaded to github 8 | import * as dotenv from "dotenv"; 9 | dotenv.config(); 10 | 11 | const mnemonic = process.env.MNEMONIC; 12 | const osmosisRpc = process.env.OSMOSIS_RPC_ENDPOINT; 13 | const evmToAddress = process.env.EVM_RECEIVER_ADDRESS; 14 | 15 | // addresses and IDs 16 | const osmosisChainId = "osmosis-1"; 17 | const uosmoAddress = "uosmo"; 18 | const avalancheChainId = 43114; 19 | const nativeAvax = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 20 | 21 | // amount of uosmo to swap 22 | const amount = "1000000"; 23 | 24 | const getSDK = () => { 25 | const squid = new Squid({ 26 | baseUrl: "https://squid-api-git-feat-cosmos-mainmainnet-0xsquid.vercel.app", 27 | }); 28 | return squid; 29 | }; 30 | 31 | (async () => { 32 | const offlineSigner = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { 33 | prefix: "osmo", 34 | }); 35 | 36 | const signerAddress = (await offlineSigner.getAccounts())[0].address; 37 | console.log(`Sender address: ${signerAddress}`); 38 | 39 | const signer = await SigningStargateClient.connectWithSigner( 40 | osmosisRpc, 41 | offlineSigner 42 | ); 43 | 44 | // instantiate the SDK 45 | const squid = getSDK(); 46 | // init the SDK 47 | await squid.init(); 48 | console.log("Squid inited"); 49 | 50 | const params = { 51 | fromChain: osmosisChainId, 52 | fromToken: uosmoAddress, 53 | fromAmount: amount, 54 | cosmosSignerAddress: signerAddress, 55 | toChain: avalancheChainId, 56 | toToken: nativeAvax, 57 | toAddress: evmToAddress, 58 | slippage: 3.0, 59 | }; 60 | 61 | const { route } = await squid.getRoute(params); 62 | 63 | const txInfo = (await squid.executeRoute({ 64 | signer, 65 | signerAddress, 66 | route, 67 | })) as DeliverTxResponse; 68 | 69 | const txLink = `https://www.mintscan.io/osmosis/txs/${txInfo.transactionHash}`; 70 | console.log(`Finished! You can find your transaction here: ${txLink}`); 71 | console.log( 72 | `Also track whole tx flow via Axelar Scan - https://axelarscan.io/gmp/${txInfo.transactionHash}` 73 | ); 74 | })(); 75 | 76 | export const deriveCosmosAddress = ( 77 | chainPrefix: string, 78 | address: string 79 | ): string => { 80 | return toBech32(chainPrefix, fromBech32(address).data); 81 | }; 82 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/cosmosToEvmSwap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/evmToCosmosSwap/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | AVAX_RPC_ENDPOINT=https://api.avax.network/ext/bc/C/rpc 5 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/evmToCosmosSwap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "1.4.6-beta.0", 7 | "dotenv": "^16.0.3", 8 | "ethers": "^5.7.2" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/evmToCosmosSwap/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "ethers"; 2 | import { Squid } from "@0xsquid/sdk"; 3 | 4 | // Environment 5 | // add to a file named ".env" to prevent them being uploaded to github 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | const avaxRpcEndpoint = process.env.AVAX_RPC_ENDPOINT; 9 | const privateKey = process.env.PRIVATE_KEY; 10 | 11 | // addresses and IDs 12 | const avalancheId = 43114; 13 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 14 | const osmosisChainId = "osmosis-1"; 15 | const uosmoAddress = "uosmo"; 16 | 17 | // amount of AVAX to send (currently 0.01 AVAX (~$0.10)) 18 | const amount = "10000000000000000"; 19 | 20 | const getSDK = () => { 21 | const squid = new Squid({ 22 | baseUrl: "https://squid-api-git-feat-cosmos-mainmainnet-0xsquid.vercel.app", 23 | }); 24 | return squid; 25 | }; 26 | 27 | (async () => { 28 | // set up your RPC provider and signer 29 | const provider = new ethers.providers.JsonRpcProvider(avaxRpcEndpoint); 30 | const signer = new ethers.Wallet(privateKey, provider); 31 | 32 | // instantiate the SDK 33 | const squid = getSDK(); 34 | // init the SDK 35 | await squid.init(); 36 | console.log("Squid inited"); 37 | 38 | const { route } = await squid.getRoute({ 39 | toAddress: signer.address, 40 | fromChain: avalancheId, 41 | fromToken: nativeToken, 42 | fromAmount: amount, 43 | toChain: osmosisChainId, 44 | toToken: uosmoAddress, 45 | slippage: 1, 46 | // enableExpress: false, // default is true on all chains except Ethereum 47 | // receiveGasOnDestination: true, 48 | }); 49 | 50 | console.log(route.estimate.toAmount); 51 | 52 | const tx = (await squid.executeRoute({ 53 | signer, 54 | route, 55 | })) as ethers.providers.TransactionResponse; 56 | const txReceipt = await tx.wait(); 57 | 58 | const axelarScanLink = 59 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 60 | console.log( 61 | "Finished! Please check Axelarscan for more details: ", 62 | axelarScanLink, 63 | "\n" 64 | ); 65 | 66 | console.log( 67 | "Track status via API call to: https://api.squidrouter.com/v1/status?transactionId=" + 68 | txReceipt.transactionHash, 69 | "\n" 70 | ); 71 | 72 | // It's best to wait a few seconds before checking the status 73 | await new Promise((resolve) => setTimeout(resolve, 5000)); 74 | 75 | const status = await squid.getStatus({ 76 | transactionId: txReceipt.transactionHash, 77 | }); 78 | 79 | console.log("Status: ", status); 80 | })(); 81 | -------------------------------------------------------------------------------- /V1(deprecated)/cosmos/evmToCosmosSwap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/crossChainSwap/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | AVAX_RPC_ENDPOINT=https://api.avax.network/ext/bc/C/rpc 5 | -------------------------------------------------------------------------------- /V1(deprecated)/crossChainSwap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^1.4.1", 7 | "dotenv": "^16.0.3", 8 | "ethers": "^5.7.2" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/crossChainSwap/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "ethers"; 2 | import { Squid } from "@0xsquid/sdk"; 3 | 4 | // Environment 5 | // add to a file named ".env" to prevent them being uploaded to github 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | const avaxRpcEndpoint = process.env.AVAX_RPC_ENDPOINT; 9 | const privateKey = process.env.PRIVATE_KEY; 10 | 11 | // addresses and IDs 12 | const avalancheId = 43114; 13 | const polygonChainId = 137; 14 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 15 | const polygonUsdc = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"; 16 | 17 | // amount of AVAX to send (currently 0.01 AVAX (~$0.10)) 18 | const amount = "10000000000000000"; 19 | 20 | const getSDK = () => { 21 | const squid = new Squid({ 22 | baseUrl: "https://api.squidrouter.com", 23 | }); 24 | return squid; 25 | }; 26 | 27 | (async () => { 28 | // set up your RPC provider and signer 29 | const provider = new ethers.providers.JsonRpcProvider(avaxRpcEndpoint); 30 | const signer = new ethers.Wallet(privateKey, provider); 31 | 32 | // instantiate the SDK 33 | const squid = getSDK(); 34 | // init the SDK 35 | await squid.init(); 36 | console.log("Squid inited"); 37 | 38 | const { route } = await squid.getRoute({ 39 | toAddress: signer.address, 40 | fromChain: avalancheId, 41 | fromToken: nativeToken, 42 | fromAmount: amount, 43 | toChain: polygonChainId, 44 | toToken: polygonUsdc, 45 | slippage: 1, 46 | customContractCalls: [], 47 | // enableExpress: false, // default is true on all chains except Ethereum 48 | // receiveGasOnDestination: true, 49 | }); 50 | 51 | console.log(route.estimate.toAmount); 52 | 53 | const tx = (await squid.executeRoute({ 54 | signer, 55 | route, 56 | })) as ethers.providers.TransactionResponse; 57 | const txReceipt = await tx.wait(); 58 | 59 | const axelarScanLink = 60 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 61 | console.log( 62 | "Finished! Please check Axelarscan for more details: ", 63 | axelarScanLink, 64 | "\n" 65 | ); 66 | 67 | console.log( 68 | "Track status via API call to: https://api.squidrouter.com/v1/status?transactionId=" + 69 | txReceipt.transactionHash, 70 | "\n" 71 | ); 72 | 73 | // It's best to wait a few seconds before checking the status 74 | await new Promise((resolve) => setTimeout(resolve, 5000)); 75 | 76 | const status = await squid.getStatus({ 77 | transactionId: txReceipt.transactionHash, 78 | }); 79 | 80 | console.log("Status: ", status); 81 | })(); 82 | -------------------------------------------------------------------------------- /V1(deprecated)/crossChainSwap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/crosschainSwapToCosmos/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | AVAX_RPC_ENDPOINT=https://api.avax.network/ext/bc/C/rpc 5 | -------------------------------------------------------------------------------- /V1(deprecated)/crosschainSwapToCosmos/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "1.4.8-beta.1", 7 | "dotenv": "^16.0.3", 8 | "ethers": "^5.7.2" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /V1(deprecated)/crosschainSwapToCosmos/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "ethers"; 2 | import { Squid, TokenData } from "@0xsquid/sdk"; 3 | 4 | // Environment 5 | // add to a file named ".env" to prevent them being uploaded to github 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | const avaxRpcEndpoint = process.env.AVAX_RPC_ENDPOINT; 9 | const privateKey = process.env.PRIVATE_KEY; 10 | 11 | // addresses and IDs 12 | const avalancheId = 43114; 13 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 14 | 15 | // amount of AVAX to send (currently 0.01 AVAX (~$0.10)) 16 | const amount = "10000000000000000"; 17 | 18 | const getSDK = () => { 19 | const squid = new Squid({ 20 | baseUrl: "https://squid-api-git-feat-cosmos-maintestnet-0xsquid.vercel.app", 21 | integratorId: "your-integrator-id", // get at https://l19g3aali76.typeform.com/integrator-id 22 | }); 23 | return squid; 24 | }; 25 | 26 | (async () => { 27 | // set up your RPC provider and signer 28 | const provider = new ethers.providers.JsonRpcProvider(avaxRpcEndpoint); 29 | const signer = new ethers.Wallet(privateKey, provider); 30 | 31 | // instantiate the SDK 32 | const squid = getSDK(); 33 | // init the SDK 34 | await squid.init(); 35 | console.log("Squid inited"); 36 | 37 | // to get the token Osmo on Osmosis chain on testnet 38 | const fromToken = squid.tokens.find( 39 | (t) => 40 | t.symbol.toLocaleLowerCase() === "osmo" && t.chainId === "osmo-test-5" 41 | ); 42 | 43 | const params = { 44 | fromChain: 43113, // Avalanche Fuji Tesntet 45 | fromToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // AVAX on Avalanche 46 | fromAmount: "100000000000000000", // 0.1 AVAX 47 | toChain: "osmo-test-5", // Osmosis Testnet 48 | toToken: 49 | "ibc/40F1B2458AEDA66431F9D44F48413240B8D28C072463E2BF53655728683583E3", // nUSDC on Osmosis 50 | toAddress: "osmo16xz3ujtdszrqzzjqpx79wuxya3w27jn9khnumm", // the recipient of the tokens on Osmosis 51 | slippage: 1.0, // 1.00 = 1% max slippage across the entire route 52 | evmFallbackAddress: signer.address, // Fallback address for the EVM Side 53 | quoteOnly: false, // optional, defaults to false, if true there are less params required by the api, but no tx object is returned 54 | }; 55 | 56 | const { route } = await squid.getRoute(params); 57 | 58 | console.log(route.estimate.route.toChain); 59 | 60 | const tx = (await squid.executeRoute({ 61 | signer, 62 | route, 63 | })) as ethers.providers.TransactionResponse; 64 | const txReceipt = await tx.wait(); 65 | 66 | const axelarScanLink = 67 | "https://testnet.axelarscan.io/gmp/" + txReceipt.transactionHash; 68 | console.log( 69 | "Finished! Please check Axelarscan for more details: ", 70 | axelarScanLink, 71 | "\n" 72 | ); 73 | 74 | // console.log( 75 | // "Track status via API call to: https://api.squidrouter.com/v1/status?transactionId=" + 76 | // txReceipt.transactionHash, 77 | // "\n" 78 | // ); 79 | 80 | // // It's best to wait a few seconds before checking the status 81 | // await new Promise((resolve) => setTimeout(resolve, 5000)); 82 | 83 | // const status = await squid.getStatus({ 84 | // transactionId: txReceipt.transactionHash, 85 | // }); 86 | 87 | // console.log("Status: ", status); 88 | })(); 89 | -------------------------------------------------------------------------------- /V1(deprecated)/crosschainSwapToCosmos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/depositFromAnyChainSommelier/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | BNB_RPC_ENDPOINT=https://bsc-dataseed.binance.org/ -------------------------------------------------------------------------------- /V1(deprecated)/depositFromAnyChainSommelier/README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | This example shows how to deposit to the Real Yield USD vault on Arbitrum in one click, using any token on any chain. 4 | 5 | [Sommelier App](https://app.sommelier.finance/strategies/real-yield-usd-arb/manage) 6 | 7 | The route in the example is Binance BNB to Arbitrum USDC, then a custom call sequence to approve the Sommelier Vault contract, then to deposit USDC and receive RYUSD. 8 | 9 | The token you will receive is RYUSD 10 | 11 | Address: 0x392b1e6905bb8449d26af701cdea6ff47bf6e5a8 12 | 13 | Name: Real Yield USD 14 | 15 | ## Quick start 16 | 17 | ```bash 18 | cd V1/depositFromAnyChainSommelier 19 | yarn install 20 | ``` 21 | 22 | Create file `.env` 23 | Copy contents of `.env.example` into `.env` 24 | Add your private key in the env file. (Make sure you have some BNB in your wallet. Get some at [Squid](https://app.squidrouter.com) if you need some) 25 | 26 | ``` 27 | yarn start 28 | ``` 29 | -------------------------------------------------------------------------------- /V1(deprecated)/depositFromAnyChainSommelier/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V1(deprecated)/depositFromAnyChainSommelier/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^1.4.1", 7 | "dotenv": "^16.0.3", 8 | "ethers": "^5.7.2", 9 | "ts-node": "^10.9.2", 10 | "typescript": "^5.4.5" 11 | }, 12 | "devDependencies": { 13 | "@types/node": "^20.12.12" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /V1(deprecated)/depositFromAnyChainSommelier/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Squid } from "@0xsquid/sdk"; 2 | import { ethers } from "ethers"; 3 | 4 | // Environment 5 | // add to a file named ".env" to prevent them being uploaded to github 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | const bnbRpcEndpoint = process.env.BNB_RPC_ENDPOINT; 9 | const privateKey = process.env.PRIVATE_KEY; 10 | 11 | // Squid call types for multicall 12 | const SquidCallType = { 13 | DEFAULT: 0, 14 | FULL_TOKEN_BALANCE: 1, 15 | FULL_NATIVE_BALANCE: 2, 16 | COLLECT_TOKEN_BALANCE: 3, 17 | }; 18 | 19 | // ABIs 20 | import erc20Abi from "../abi/erc20Abi"; 21 | import sommAbi from "../abi/sommAbi"; 22 | 23 | // addresses and IDs 24 | const bnbId = 56; 25 | const arbitrumChainId = 42161; 26 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 27 | const usdcArbitrum = "0xaf88d065e77c8cc2239327c5edb3a432268e5831"; 28 | const sommVaultAddress = "0x392b1e6905bb8449d26af701cdea6ff47bf6e5a8"; 29 | 30 | // amount of BNB to send (currently 0.0001 BNB) 31 | const amount = "100000000000000"; 32 | 33 | const getSDK = () => { 34 | const squid = new Squid({ 35 | baseUrl: "https://api.squidrouter.com", 36 | }); 37 | return squid; 38 | }; 39 | 40 | (async () => { 41 | // set up your RPC provider and signer 42 | const provider = new ethers.providers.JsonRpcProvider(bnbRpcEndpoint); 43 | const signer = new ethers.Wallet(privateKey, provider); 44 | 45 | // instantiate the SDK 46 | const squid = getSDK(); 47 | // init the SDK 48 | await squid.init(); 49 | console.log("Squid inited"); 50 | 51 | // Generate calldatas for postHooks 52 | const erc20Interface = new ethers.utils.Interface(erc20Abi); 53 | const approveSommEncodeData = erc20Interface.encodeFunctionData("approve", [ 54 | sommVaultAddress, 55 | "0", // will be overridden by the full token balance of the multicall after the swap 56 | ]); 57 | 58 | // Generate the encoded data for Squid's multicall to stake on Pinjam, 59 | // crediting deposit to signer's address 60 | const sommInterface = new ethers.utils.Interface(sommAbi); 61 | const depositEncodeData = sommInterface.encodeFunctionData("deposit", [ 62 | "0", // will be overridden by the full token balance of the multicall after the swap 63 | signer.address, 64 | ]); 65 | 66 | // // this step isn't needed for this example, 67 | // // since RYUSD can be minted directly to the signer's account, 68 | // // no ERC20 transfer to the signer is needed 69 | // const transferErc20ToSignerEncodeData = erc20Interface.encodeFunctionData( 70 | // "transfer", 71 | // [signer.address, "0"] 72 | // ); 73 | 74 | const { route } = await squid.getRoute({ 75 | toAddress: signer.address, 76 | fromChain: bnbId, 77 | fromToken: nativeToken, 78 | fromAmount: amount, 79 | toChain: arbitrumChainId, 80 | toToken: usdcArbitrum, 81 | slippage: 1, 82 | customContractCalls: [ 83 | { 84 | callType: SquidCallType.FULL_TOKEN_BALANCE, 85 | target: usdcArbitrum, 86 | value: "0", 87 | callData: approveSommEncodeData, 88 | payload: { 89 | tokenAddress: usdcArbitrum, 90 | inputPos: 1, // the position of the "amount" parameter in the approve function 91 | }, 92 | estimatedGas: "150000", 93 | }, 94 | { 95 | callType: SquidCallType.FULL_TOKEN_BALANCE, 96 | target: sommVaultAddress, 97 | value: "0", 98 | callData: depositEncodeData, 99 | payload: { 100 | tokenAddress: usdcArbitrum, 101 | inputPos: 0, // the position of the "assets" parameter in the deposit function 102 | }, 103 | estimatedGas: "2000000", // overestimate, can be reduced to optimise 104 | }, 105 | ], 106 | }); 107 | 108 | console.log("Route: ", route); 109 | console.log("feeCosts: ", route.estimate.feeCosts); 110 | console.log("signer address, ", signer.address); 111 | console.log("signer balance, ", await signer.getBalance()); 112 | 113 | const tx = (await squid.executeRoute({ 114 | signer, 115 | route, 116 | })) as ethers.providers.TransactionResponse; 117 | 118 | const txReceipt = await tx.wait(); 119 | 120 | const axelarScanLink = 121 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 122 | 123 | console.log( 124 | "Finished! Please check Axelarscan for more details: ", 125 | axelarScanLink, 126 | "\n" 127 | ); 128 | 129 | console.log( 130 | "Track status via API call to: https://api.squidrouter.com/v1/status?transactionId=" + 131 | txReceipt.transactionHash, 132 | "\n" 133 | ); 134 | })(); 135 | -------------------------------------------------------------------------------- /V1(deprecated)/depositFromAnyChainSommelier/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/depositToCosmos/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c4d... private key of the account to send from 4 | AVAX_RPC_ENDPOINT=https://api.avax.network/ext/bc/C/rpc 5 | OSMOSIS_RECIPIENT_ADDRESS= # osmo1... address to send to on osmosis -------------------------------------------------------------------------------- /V1(deprecated)/depositToCosmos/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^1.4.1", 7 | "dotenv": "^16.0.3", 8 | "ethers": "^5.7.2" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/depositToCosmos/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Squid } from "@0xsquid/sdk"; 2 | import { ethers } from "ethers"; 3 | 4 | // Environment 5 | // add to a file named ".env" to prevent them being uploaded to github 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | const avaxRpcEndpoint = process.env.AVAX_RPC_ENDPOINT; 9 | const privateKey = process.env.PRIVATE_KEY; 10 | const osmosisRecipientAddress = process.env.OSMOSIS_RECIPIENT_ADDRESS; 11 | 12 | // addresses and IDs 13 | const avalancheId = 43114; 14 | const osmosisId = "osmosis-1"; 15 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 16 | const osmosisUsdc = "uusdc"; 17 | 18 | // amount of AVAX to send (currently 0.1 AVAX) 19 | const amount = "100000000000000000"; 20 | 21 | const getSDK = () => { 22 | const squid = new Squid({ 23 | baseUrl: "https://api.squidrouter.com", 24 | }); 25 | return squid; 26 | }; 27 | 28 | (async () => { 29 | // set up your RPC provider and signer 30 | const provider = new ethers.providers.JsonRpcProvider(avaxRpcEndpoint); 31 | const signer = new ethers.Wallet(privateKey, provider); 32 | 33 | // instantiate the SDK 34 | const squid = getSDK(); 35 | // init the SDK 36 | await squid.init(); 37 | console.log("Squid inited"); 38 | 39 | const { route } = await squid.getRoute({ 40 | toAddress: osmosisRecipientAddress, 41 | fromChain: avalancheId, 42 | fromToken: nativeToken, 43 | fromAmount: amount, 44 | toChain: osmosisId, 45 | toToken: osmosisUsdc, 46 | slippage: 1, 47 | }); 48 | 49 | console.log( 50 | "Cross chain fee costs for this route: ", 51 | route.estimate.feeCosts 52 | ); 53 | 54 | const tx = (await squid.executeRoute({ 55 | signer, 56 | route, 57 | })) as ethers.providers.TransactionResponse; 58 | 59 | const txReceipt = await tx.wait(); 60 | 61 | const axelarScanLink = 62 | "https://axelarscan.io/transfer/" + txReceipt.transactionHash; 63 | 64 | console.log( 65 | "Finished! Please check Axelarscan for more details: ", 66 | axelarScanLink, 67 | "\n" 68 | ); 69 | 70 | console.log( 71 | "Track status via API call to: https://api.squidrouter.com/v1/status?transactionId=" + 72 | txReceipt.transactionHash, 73 | "\n" 74 | ); 75 | 76 | // // It's best to wait a few seconds before checking the status 77 | await new Promise((resolve) => setTimeout(resolve, 5000)); 78 | 79 | const status = await squid.getStatus({ 80 | transactionId: txReceipt.transactionHash, 81 | }); 82 | 83 | console.log("Status: ", status); 84 | })(); 85 | -------------------------------------------------------------------------------- /V1(deprecated)/depositToCosmos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChain/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | AVAX_RPC_ENDPOINT=https://api.avax.network/ext/bc/C/rpc 5 | -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChain/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^1.4.1", 7 | "dotenv": "^16.0.3", 8 | "ethers": "^5.7.2" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChain/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Squid } from "@0xsquid/sdk"; 2 | import { ethers } from "ethers"; 3 | 4 | // Environment 5 | // add to a file named ".env" to prevent them being uploaded to github 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | const avaxRpcEndpoint = process.env.AVAX_RPC_ENDPOINT; 9 | const privateKey = process.env.PRIVATE_KEY; 10 | 11 | // Squid call types for multicall 12 | const SquidCallType = { 13 | DEFAULT: 0, 14 | FULL_TOKEN_BALANCE: 1, 15 | FULL_NATIVE_BALANCE: 2, 16 | COLLECT_TOKEN_BALANCE: 3, 17 | }; 18 | 19 | // ABIs 20 | import moonwellGlmrAbi from "../abi/moonwellGlmrAbi"; 21 | 22 | // addresses and IDs 23 | const avalancheId = 43114; 24 | const moonbeamId = 1284; 25 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 26 | const moonwellGlmrAddress = "0x091608f4e4a15335145be0A279483C0f8E4c7955"; 27 | 28 | // amount of AVAX to send (currently 0.01 AVAX) 29 | const amount = "10000000000000000"; 30 | 31 | const getSDK = () => { 32 | const squid = new Squid({ 33 | baseUrl: "https://api.squidrouter.com", 34 | }); 35 | return squid; 36 | }; 37 | 38 | (async () => { 39 | // set up your RPC provider and signer 40 | const provider = new ethers.providers.JsonRpcProvider(avaxRpcEndpoint); 41 | const signer = new ethers.Wallet(privateKey, provider); 42 | 43 | // instantiate the SDK 44 | const squid = getSDK(); 45 | // init the SDK 46 | await squid.init(); 47 | console.log("Squid inited"); 48 | 49 | // Generate the encoded data for Squid's multicall to stake on Moonwell and transfer to signer 50 | const moonwellGlmrInterface = new ethers.utils.Interface(moonwellGlmrAbi); 51 | const mintEncodeData = moonwellGlmrInterface.encodeFunctionData("mint"); 52 | const transferMglmrEncodeData = moonwellGlmrInterface.encodeFunctionData( 53 | "transfer", 54 | [signer.address, "0"] 55 | ); 56 | 57 | const { route } = await squid.getRoute({ 58 | toAddress: signer.address, 59 | fromChain: avalancheId, 60 | fromToken: nativeToken, 61 | fromAmount: amount, 62 | toChain: moonbeamId, 63 | toToken: nativeToken, 64 | slippage: 1, 65 | // enableExpress: false, // default is true on all chains except Ethereum 66 | customContractCalls: [ 67 | { 68 | callType: SquidCallType.FULL_NATIVE_BALANCE, 69 | target: moonwellGlmrAddress, 70 | value: "0", // this will be replaced by the full native balance of the multicall after the swap 71 | callData: mintEncodeData, 72 | payload: { 73 | tokenAddress: "0x", // unused in callType 2, dummy value 74 | inputPos: 1, // unused 75 | }, 76 | estimatedGas: "250000", 77 | }, 78 | { 79 | callType: SquidCallType.FULL_TOKEN_BALANCE, 80 | target: moonwellGlmrAddress, 81 | value: "0", 82 | callData: transferMglmrEncodeData, 83 | payload: { 84 | tokenAddress: moonwellGlmrAddress, 85 | inputPos: 1, // use full balance of tokenAddress at position 1 (second argument) 86 | }, 87 | estimatedGas: "50000", 88 | }, 89 | ], 90 | }); 91 | 92 | const tx = (await squid.executeRoute({ 93 | signer, 94 | route, 95 | })) as ethers.providers.TransactionResponse; 96 | 97 | const txReceipt = await tx.wait(); 98 | 99 | const axelarScanLink = 100 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 101 | 102 | console.log( 103 | "Finished! Please check Axelarscan for more details: ", 104 | axelarScanLink, 105 | "\n" 106 | ); 107 | 108 | console.log( 109 | "Track status via API call to: https://api.squidrouter.com/v1/status?transactionId=" + 110 | txReceipt.transactionHash, 111 | "\n" 112 | ); 113 | 114 | // It's best to wait a few seconds before checking the status 115 | await new Promise((resolve) => setTimeout(resolve, 5000)); 116 | 117 | const status = await squid.getStatus({ 118 | transactionId: txReceipt.transactionHash, 119 | }); 120 | 121 | console.log("Status: ", status); 122 | })(); 123 | -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChainPinjam/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | MOONBEAM_RPC_ENDPOINT=https://rpc.api.moonbeam.network 5 | -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChainPinjam/README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | This example shows how to deposit to the lending protocol Pinjam across chains in one click, using any token on any chain. 4 | 5 | [https://app.pinjamlabs.com/](https://app.pinjamlabs.com/) 6 | 7 | The route in the example is Moonbeam GLMR to Kava axlUSDC, then a custom call sequence to approve the pinjam lending contract, then to deposit axlUSDC and receive paxlUSDC. 8 | 9 | The token you will receive is paxlUSDC 10 | 11 | Address: 0x5C91F5d2b7046A138c7D1775BfFEa68d5e95D68d 12 | 13 | Name: Pinjam axlUSDC 14 | 15 | Icon: https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/public/images/assets/usdc.svg 16 | -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChainPinjam/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChainPinjam/abi/pTokens.ts: -------------------------------------------------------------------------------- 1 | const pTokenAbi = [ 2 | { 3 | name: "kava", 4 | symbol: "kava", 5 | address: "0xc86c7c0efbd6a49b35e8714c5f59d99de09a225b", 6 | }, 7 | { 8 | name: "multiusdt", 9 | symbol: "multiusdt", 10 | }, 11 | { 12 | name: "multiusdc", 13 | symbol: "multiusdc", 14 | address: "0xfa9343c3897324496a05fc75abed6bac29f8a40f", 15 | }, 16 | { 17 | name: "multidai", 18 | symbol: "multidai", 19 | address: "0x765277eebeca2e31912c9946eae1021199b39c61", 20 | }, 21 | { 22 | name: "multieth", 23 | symbol: "multieth", 24 | address: "0xe3f5a90f9cb311505cd691a46596599aa1a0ad7d", 25 | }, 26 | { 27 | name: "pKava", 28 | symbol: "pKAVA", 29 | address: "0xb096768a0E4f5d08927C19Df9651293485b21072", 30 | }, 31 | { 32 | name: "vdKava", 33 | symbol: "vdKAVA", 34 | address: "0x13aB1A2e26f0F1022F2286960055847100Bd7218", 35 | }, 36 | { 37 | name: "pUSDT", 38 | symbol: "pUSDT", 39 | address: "0x16831114Dc5e44696f7aFf58C11865F1880E9E2a", 40 | }, 41 | { 42 | name: "vdUSDT", 43 | symbol: "vdUSDT", 44 | address: "0x67EaA3aEc47aAaBc8e5F4904ba15bf2409940244", 45 | }, 46 | { 47 | name: "pUSDC", 48 | symbol: "pUSDC", 49 | address: "0x0a7B71B0613FA58A742CddFC72963ACb9412760c", 50 | }, 51 | { 52 | name: "vdUSDC", 53 | symbol: "vdUSDC", 54 | address: "0x840c1911Bc9919DACd86Cffaf3f1436BAE314cD0", 55 | }, 56 | { 57 | name: "pDai", 58 | symbol: "pDai", 59 | address: "0x2C0cA21e35B6f1C1A33fBD99D21Da1C63ad09e69", 60 | }, 61 | { 62 | name: "vdDai", 63 | symbol: "vdDai", 64 | address: "0xAd58d7E4B70B9cF068246bD1a7Bd2b88f25B8FEf", 65 | }, 66 | { 67 | name: "pETH", 68 | symbol: "pWETH", 69 | address: "0x82Ef01018980740a2C6c0f7cBcf840c42a629dBd", 70 | }, 71 | { 72 | name: "vdETH", 73 | symbol: "vdWETH", 74 | address: "0x9421fFcFD3Edb1b3ca8Ef7B1104016bc529BB840", 75 | }, 76 | { 77 | name: "pinkav", 78 | symbol: "pinkav", 79 | address: "0xE5274E38E91b615D8822e8512a29A16FF1B9C4Af", 80 | }, 81 | { 82 | name: "axlusdc", 83 | symbol: "axlusdc", 84 | address: "0xeb466342c4d449bc9f53a865d5cb90586f405215", 85 | }, 86 | { 87 | name: "axldai", 88 | symbol: "axldai", 89 | address: "0x5c7e299cf531eb66f2a1df637d37abb78e6200c7", 90 | }, 91 | { 92 | name: "usdt", 93 | symbol: "usdt", 94 | address: "0x919c1c267bc06a7039e03fcc2ef738525769109c", 95 | }, 96 | { 97 | name: "paxlUSDC", 98 | symbol: "paxlUSDC", 99 | address: "0x5C91F5d2b7046A138c7D1775BfFEa68d5e95D68d", 100 | }, 101 | { 102 | name: "vdaxlUSDC", 103 | symbol: "vdaxlUSDC", 104 | address: "0xbB9D890D6511598ccC717D2C6C1266007dAa1D78", 105 | }, 106 | { 107 | name: "paxlDAI", 108 | symbol: "paxlDAI", 109 | address: "0x08CcC9665c40004d764E7Ed8F3c345FdE5Ff24d0", 110 | }, 111 | { 112 | name: "vdaxlDAI", 113 | symbol: "vdaxlDAI", 114 | address: "0x65bE004724622CD5FD54FDa4D6d71aaD9DfF9d7b", 115 | }, 116 | { 117 | name: "pUSDT", 118 | symbol: "pUSDT", 119 | address: "0xc662B16F391ade279956283F14835164f1d367fE", 120 | }, 121 | { 122 | name: "vdUSDT", 123 | symbol: "vdUSDT", 124 | address: "0xB36239deC6cc681C0c7a49241fA6d20c7c263229", 125 | }, 126 | ]; 127 | 128 | export default pTokenAbi; 129 | -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChainPinjam/abi/pinjamStakingPoolAbi.ts: -------------------------------------------------------------------------------- 1 | const pinjamStakingPoolAbi = [ 2 | { 3 | inputs: [ 4 | { 5 | internalType: "address", 6 | name: "_underlyingAsset", 7 | type: "address", 8 | }, 9 | { 10 | internalType: "uint256", 11 | name: "_amount", 12 | type: "uint256", 13 | }, 14 | { 15 | internalType: "address", 16 | name: "_to", 17 | type: "address", 18 | }, 19 | { 20 | internalType: "bool", 21 | name: "_depositToVault", 22 | type: "bool", 23 | }, 24 | ], 25 | name: "deposit", 26 | outputs: [], 27 | stateMutability: "nonpayable", 28 | type: "function", 29 | }, 30 | { 31 | inputs: [ 32 | { 33 | internalType: "address", 34 | name: "_underlyingAsset", 35 | type: "address", 36 | }, 37 | { 38 | internalType: "uint256", 39 | name: "_amount", 40 | type: "uint256", 41 | }, 42 | { 43 | internalType: "address", 44 | name: "_to", 45 | type: "address", 46 | }, 47 | ], 48 | name: "withdraw", 49 | outputs: [], 50 | stateMutability: "nonpayable", 51 | type: "function", 52 | }, 53 | { 54 | inputs: [ 55 | { 56 | internalType: "address", 57 | name: "_underlyingAsset", 58 | type: "address", 59 | }, 60 | { 61 | internalType: "uint256", 62 | name: "_amount", 63 | type: "uint256", 64 | }, 65 | { 66 | internalType: "address", 67 | name: "_onBehalfOf", 68 | type: "address", 69 | }, 70 | ], 71 | name: "borrow", 72 | outputs: [], 73 | stateMutability: "nonpayable", 74 | type: "function", 75 | }, 76 | { 77 | inputs: [ 78 | { 79 | internalType: "address", 80 | name: "_underlyingAsset", 81 | type: "address", 82 | }, 83 | { 84 | internalType: "uint256", 85 | name: "_amount", 86 | type: "uint256", 87 | }, 88 | { 89 | internalType: "address", 90 | name: "_to", 91 | type: "address", 92 | }, 93 | ], 94 | name: "repay", 95 | outputs: [], 96 | stateMutability: "nonpayable", 97 | type: "function", 98 | }, 99 | { 100 | inputs: [ 101 | { 102 | internalType: "address", 103 | name: "_user", 104 | type: "address", 105 | }, 106 | ], 107 | name: "getUserData", 108 | outputs: [ 109 | { 110 | internalType: "uint256", 111 | name: "healthFactor", 112 | type: "uint256", 113 | }, 114 | { 115 | internalType: "uint256", 116 | name: "totalCollateralInBaseCurrency", 117 | type: "uint256", 118 | }, 119 | { 120 | internalType: "uint256", 121 | name: "totalDebtInBaseCurrency", 122 | type: "uint256", 123 | }, 124 | { 125 | internalType: "uint256", 126 | name: "avgLtv", 127 | type: "uint256", 128 | }, 129 | { 130 | internalType: "uint256", 131 | name: "avgLiquiditationThreshold", 132 | type: "uint256", 133 | }, 134 | ], 135 | stateMutability: "view", 136 | type: "function", 137 | }, 138 | ]; 139 | 140 | export default pinjamStakingPoolAbi; 141 | -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChainPinjam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^1.4.1", 7 | "dotenv": "^16.0.3", 8 | "ethers": "^5.7.2" 9 | } 10 | } -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChainPinjam/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Squid } from "@0xsquid/sdk"; 2 | import { ethers } from "ethers"; 3 | 4 | // Environment 5 | // add to a file named ".env" to prevent them being uploaded to github 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | const moonbeamRpcEndpoint = process.env.MOONBEAM_RPC_ENDPOINT; 9 | const privateKey = process.env.PRIVATE_KEY; 10 | 11 | // Squid call types for multicall 12 | const SquidCallType = { 13 | DEFAULT: 0, 14 | FULL_TOKEN_BALANCE: 1, 15 | FULL_NATIVE_BALANCE: 2, 16 | COLLECT_TOKEN_BALANCE: 3, 17 | }; 18 | 19 | // ABIs 20 | import pinjamStakingPoolAbi from "../abi/pinjamStakingPoolAbi"; 21 | import erc20Abi from "../abi/erc20Abi"; 22 | 23 | // addresses and IDs 24 | const kavaId = 2222; 25 | const moonbeamId = 1284; 26 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 27 | const pinjamAxlUsdcPoolAddress = "0x11c3d91259b1c2bd804344355c6a255001f7ba1e"; // same as pAxlUsdcAddress? 28 | const axlUsdcKavaAddress = "0xeb466342c4d449bc9f53a865d5cb90586f405215"; 29 | const pAxlUsdcAddress = "0x5c91f5d2b7046a138c7d1775bffea68d5e95d68d"; // not needed, but is the token the user will receive 30 | 31 | // amount of GLMR to send (currently 0.01 AVAX) 32 | const amount = "10000000000000000"; 33 | 34 | const getSDK = () => { 35 | const squid = new Squid({ 36 | baseUrl: "https://api.squidrouter.com", 37 | }); 38 | return squid; 39 | }; 40 | 41 | (async () => { 42 | // set up your RPC provider and signer 43 | const provider = new ethers.providers.JsonRpcProvider(moonbeamRpcEndpoint); 44 | const signer = new ethers.Wallet(privateKey, provider); 45 | 46 | // instantiate the SDK 47 | const squid = getSDK(); 48 | // init the SDK 49 | await squid.init(); 50 | console.log("Squid inited"); 51 | 52 | // Generate the encoded data for Squid's multicall to stake on Pinjam, 53 | // crediting deposit to signer's address 54 | const pinjamStakingPoolInterface = new ethers.utils.Interface( 55 | pinjamStakingPoolAbi 56 | ); 57 | const erc20Interface = new ethers.utils.Interface(erc20Abi); 58 | 59 | // calldatas 60 | const approvePinjamEncodeData = erc20Interface.encodeFunctionData("approve", [ 61 | pinjamAxlUsdcPoolAddress, 62 | "0", 63 | ]); 64 | 65 | const depositEncodeData = pinjamStakingPoolInterface.encodeFunctionData( 66 | "deposit", 67 | [axlUsdcKavaAddress, "0", signer.address, true] 68 | ); 69 | 70 | // // this step isn't needed for this example, 71 | // // since paxlUSDC can be minted directly to the signer's account, 72 | // // no ERC20 transfer to the signer is needed 73 | // const transferErc20ToSignerEncodeData = erc20Interface.encodeFunctionData( 74 | // "transfer", 75 | // [signer.address, "0"] 76 | // ); 77 | 78 | const { route } = await squid.getRoute({ 79 | toAddress: signer.address, 80 | fromChain: moonbeamId, 81 | fromToken: nativeToken, 82 | fromAmount: amount, 83 | toChain: kavaId, 84 | toToken: axlUsdcKavaAddress, 85 | slippage: 1, 86 | customContractCalls: [ 87 | { 88 | callType: SquidCallType.FULL_TOKEN_BALANCE, 89 | target: axlUsdcKavaAddress, 90 | value: "0", // this will be replaced by the full native balance of the multicall after the swap 91 | callData: approvePinjamEncodeData, 92 | payload: { 93 | tokenAddress: axlUsdcKavaAddress, // unused in callType 2, dummy value 94 | inputPos: 1, // unused 95 | }, 96 | estimatedGas: "50000", 97 | }, 98 | { 99 | callType: SquidCallType.FULL_TOKEN_BALANCE, 100 | target: pinjamAxlUsdcPoolAddress, 101 | value: "0", 102 | callData: depositEncodeData, 103 | payload: { 104 | tokenAddress: axlUsdcKavaAddress, 105 | inputPos: 1, 106 | }, 107 | estimatedGas: "250000", 108 | }, 109 | ], 110 | }); 111 | 112 | console.log("Route: ", route); 113 | console.log("feeCosts: ", route.estimate.feeCosts); 114 | console.log("signer address, ", signer.address); 115 | console.log("signer balance, ", await signer.getBalance()); 116 | 117 | const tx = (await squid.executeRoute({ 118 | signer, 119 | route, 120 | })) as ethers.providers.TransactionResponse; 121 | 122 | const txReceipt = await tx.wait(); 123 | 124 | const axelarScanLink = 125 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 126 | 127 | console.log( 128 | "Finished! Please check Axelarscan for more details: ", 129 | axelarScanLink, 130 | "\n" 131 | ); 132 | 133 | console.log( 134 | "Track status via API call to: https://api.squidrouter.com/v1/status?transactionId=" + 135 | txReceipt.transactionHash, 136 | "\n" 137 | ); 138 | 139 | // It's best to wait a few seconds before checking the status 140 | await new Promise((resolve) => setTimeout(resolve, 5000)); 141 | 142 | const status = await squid.getStatus({ 143 | transactionId: txReceipt.transactionHash, 144 | }); 145 | 146 | console.log("Status: ", status); 147 | })(); 148 | -------------------------------------------------------------------------------- /V1(deprecated)/stakeFromAnyChainPinjam/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/CosmostoEVMPostHook/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | MNEMONIC="" 4 | OSMOSIS_RPC_ENDPOINT="https://mainnet.rpc.axelar.dev/chain/osmosis" 5 | EVM_RECEIVER_ADDRESS="0x00" 6 | INTEGRATOR_ID='Apply for a Squid apiplus integratorID here: https://squidrouter.typeform.com/integrator-id if you dont have one' -------------------------------------------------------------------------------- /V2/api/CosmostoEVMPostHook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@cosmjs/proto-signing": "^0.32.4", 7 | "@cosmjs/stargate": "^0.32.4", 8 | "@keplr-wallet/unit": "^0.12.119", 9 | "axios": "^1.7.3", 10 | "cosmjs-types": "^0.9.0", 11 | "dotenv": "^16.4.5", 12 | "ethers": "^5.7.2" 13 | }, 14 | "devDependencies": { 15 | "@types/node": "^20.11.24" 16 | }, 17 | "license": "MIT" 18 | } 19 | -------------------------------------------------------------------------------- /V2/api/CosmostoEVMPostHook/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/bitcoinToEVM_Swap/.env.example: -------------------------------------------------------------------------------- 1 | PRIVATE_KEY=WALLET_PRIVATE_JEY 2 | INTEGRATOR_ID=YOUR_INTEGRATOR_ID 3 | FROM_CHAIN_RPC_ENDPOINT=https://binance.llamarpc.com 4 | -------------------------------------------------------------------------------- /V2/api/bitcoinToEVM_Swap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@solana/web3.js": "^1.95.4", 7 | "axios": "^1.7.7", 8 | "bitcoinjs-lib": "^7.0.0-rc.0", 9 | "bs58": "^6.0.0", 10 | "dotenv": "^16.4.5", 11 | "ecpair": "^3.0.0-rc.0", 12 | "ethers": "^5.7.2", 13 | "tiny-secp256k1": "^2.2.3" 14 | }, 15 | "devDependencies": { 16 | "@types/node": "^20.11.24" 17 | }, 18 | "license": "MIT" 19 | } 20 | -------------------------------------------------------------------------------- /V2/api/bitcoinToEVM_Swap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/buyNFTonEVM/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | # Copy this file to a file called .env in the same directory and fill in the values. 3 | 4 | PRIVATE_KEY="Your private key" 5 | INTEGRATOR_ID="Your Squid Integrator ID: https://squidrouter.typeform.com/integrator-id" 6 | BASE_RPC_ENDPOINT=https://base-rpc.publicnode.com 7 | OPENSEA_API_KEY ='Your Opensea API Key' -------------------------------------------------------------------------------- /V2/api/buyNFTonEVM/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@opensea/seaport-js": "^4.0.4", 7 | "axios": "^1.7.2", 8 | "dotenv": "^16.4.5", 9 | "ethers": "^5.7.2" 10 | }, 11 | "devDependencies": { 12 | "@types/node": "^20.12.12" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /V2/api/buyNFTonEVM/src/common.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type { Listener } from "@ethersproject/providers"; 5 | import type { Event, EventFilter } from "ethers"; 6 | 7 | export interface TypedEvent< 8 | TArgsArray extends Array = any, 9 | TArgsObject = any 10 | > extends Event { 11 | args: TArgsArray & TArgsObject; 12 | } 13 | 14 | export interface TypedEventFilter<_TEvent extends TypedEvent> 15 | extends EventFilter {} 16 | 17 | export interface TypedListener { 18 | (...listenerArg: [...__TypechainArgsArray, TEvent]): void; 19 | } 20 | 21 | type __TypechainArgsArray = T extends TypedEvent ? U : never; 22 | 23 | export interface OnEvent { 24 | ( 25 | eventFilter: TypedEventFilter, 26 | listener: TypedListener 27 | ): TRes; 28 | (eventName: string, listener: Listener): TRes; 29 | } 30 | 31 | export type MinEthersFactory = { 32 | deploy(...a: ARGS[]): Promise; 33 | }; 34 | 35 | export type GetContractTypeFromFactory = F extends MinEthersFactory< 36 | infer C, 37 | any 38 | > 39 | ? C 40 | : never; 41 | 42 | export type GetARGsTypeFromFactory = F extends MinEthersFactory 43 | ? Parameters 44 | : never; 45 | 46 | export type PromiseOrValue = T | Promise; -------------------------------------------------------------------------------- /V2/api/buyNFTonEVM/src/openseaService.ts: -------------------------------------------------------------------------------- 1 | // File: openseaService.ts 2 | 3 | import axios from 'axios'; 4 | import { ethers } from 'ethers'; 5 | import { ReservoirToken, Order, FulfillmentRoot } from './types'; 6 | 7 | const RESERVOIR_API_KEY = process.env.RESERVOIR_API_KEY || "bd4f6241-b568-5982-9015-a2f80c0feacb"; 8 | const OPENSEA_API_KEY = process.env.OPENSEA_API_KEY!; 9 | 10 | export async function fetchNFTData(nftAddress: string, tokenId: string): Promise { 11 | const chainName = "arbitrum"; // Adjust this if you're using a different chain 12 | const reservoirUrl = `https://api-${chainName}.reservoir.tools/tokens/v6?tokens=${nftAddress}:${tokenId}&includeAttributes=false&includeLastSale=false`; 13 | 14 | try { 15 | const response = await axios.get(reservoirUrl, { 16 | headers: { "x-api-key": RESERVOIR_API_KEY } 17 | }); 18 | 19 | if (response.data.tokens && response.data.tokens.length > 0) { 20 | return response.data.tokens[0]; 21 | } else { 22 | throw new Error("NFT data not found"); 23 | } 24 | } catch (error) { 25 | console.error("Error fetching NFT data:", error); 26 | throw error; 27 | } 28 | } 29 | 30 | export async function fetchOpenSeaData(nftAddress: string, tokenId: string): Promise<{ order: Order; fulfillment: FulfillmentRoot }> { 31 | const chainName = "arbitrum"; // Adjust this if you're using a different chain 32 | const openseaOrderUrl = `https://api.opensea.io/v2/orders/${chainName}/seaport/listings?asset_contract_address=${nftAddress}&token_ids=${tokenId}&order_by=eth_price&order_direction=asc&limit=1`; 33 | 34 | try { 35 | const orderResponse = await axios.get(openseaOrderUrl, { 36 | headers: { "X-API-KEY": OPENSEA_API_KEY } 37 | }); 38 | 39 | if (!orderResponse.data.orders || orderResponse.data.orders.length === 0) { 40 | throw new Error("No orders found for this NFT"); 41 | } 42 | 43 | const order: Order = orderResponse.data.orders[0]; 44 | 45 | const fulfillmentResponse = await axios.post( 46 | `https://api.opensea.io/v2/listings/fulfillment_data`, 47 | { 48 | listing: { 49 | hash: order.order_hash, 50 | chain: chainName, 51 | protocol_address: order.protocol_address, 52 | }, 53 | fulfiller: { 54 | address: ethers.constants.AddressZero, // This will be replaced by the actual buyer address 55 | }, 56 | }, 57 | { 58 | headers: { 59 | "X-API-KEY": OPENSEA_API_KEY, 60 | "Content-Type": "application/json", 61 | }, 62 | } 63 | ); 64 | 65 | const fulfillment: FulfillmentRoot = fulfillmentResponse.data; 66 | 67 | return { order, fulfillment }; 68 | } catch (error) { 69 | console.error("Error fetching OpenSea data:", error); 70 | throw error; 71 | } 72 | } -------------------------------------------------------------------------------- /V2/api/buyNFTonEVM/src/types.ts: -------------------------------------------------------------------------------- 1 | import { SquidCallType } from "@0xsquid/sdk/dist/types"; 2 | 3 | export interface FulfillmentRoot { 4 | fulfillment_data: { 5 | transaction: { 6 | input_data: { 7 | parameters: string; 8 | }; 9 | to: string; 10 | value: string; 11 | data: string; 12 | }; 13 | orders: Array<{ 14 | parameters: OrderParameters; 15 | signature: string; 16 | }>; 17 | }; 18 | } 19 | 20 | export interface Order { 21 | order_hash: string; 22 | protocol_address: string; 23 | protocol_data: { 24 | parameters: OrderParameters; 25 | }; 26 | current_price: string; 27 | } 28 | 29 | interface OrderParameters { 30 | offerer: string; 31 | zone: string; 32 | offer: Array<{ 33 | itemType: number; 34 | token: string; 35 | identifierOrCriteria: string; 36 | startAmount: string; 37 | endAmount: string; 38 | }>; 39 | consideration: Array<{ 40 | itemType: number; 41 | token: string; 42 | identifierOrCriteria: string; 43 | startAmount: string; 44 | endAmount: string; 45 | recipient: string; 46 | }>; 47 | orderType: number; 48 | startTime: string; 49 | endTime: string; 50 | zoneHash: string; 51 | salt: string; 52 | conduitKey: string; 53 | totalOriginalConsiderationItems: number; 54 | } 55 | 56 | export interface BuyableItem { 57 | name: string; 58 | description: string; 59 | price: string; 60 | image: string; 61 | contract: string; 62 | platformName: string; 63 | tokenId: string; 64 | collectionAddress: string; 65 | platformData: Order; 66 | nbOfItems: number; 67 | payment: { 68 | type: number; 69 | token: { 70 | symbol: string; 71 | chainId: number; 72 | address: string; 73 | decimals: number; 74 | }; 75 | }; 76 | } 77 | 78 | export interface ReservoirToken { 79 | token: { 80 | contract: string; 81 | tokenId: string; 82 | name?: string; 83 | image?: string; 84 | }; 85 | market?: { 86 | floorAsk?: { 87 | price?: { 88 | amount?: { 89 | decimal?: string; 90 | }; 91 | }; 92 | }; 93 | }; 94 | } 95 | 96 | export interface CheckoutConfig { 97 | item: { 98 | title: string; 99 | subTitle?: string; 100 | imageUrl?: string; 101 | }; 102 | payment: { 103 | nbOfItems: number; 104 | token: { 105 | chainId: number; 106 | address: string; 107 | symbol: string; 108 | }; 109 | unitPrice: string; 110 | }; 111 | customContractCalls: Array<{ 112 | callType: SquidCallType; 113 | target: string; 114 | value: string; 115 | callData: string; 116 | payload: { 117 | tokenAddress: string; 118 | inputPos: number; 119 | }; 120 | estimatedGas: string; 121 | }>; 122 | } -------------------------------------------------------------------------------- /V2/api/buyNFTonEVM/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/cosmostoCosmosPosthook/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | MNEMONIC="" 4 | OSMOSIS_RPC_ENDPOINT=https://osmosis-rpc.polkachu.com 5 | INTEGRATOR_ID='Apply for a Squid apiplus integrator ID here: https://squidrouter.typeform.com/integrator-id if you dont have one' -------------------------------------------------------------------------------- /V2/api/cosmostoCosmosPosthook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@cosmjs/proto-signing": "^0.32.4", 7 | "@cosmjs/stargate": "^0.32.4", 8 | "@keplr-wallet/unit": "^0.12.119", 9 | "axios": "^1.7.3", 10 | "cosmjs-types": "^0.9.0", 11 | "dotenv": "^16.4.5", 12 | "ethers": "^5.7.2" 13 | }, 14 | "devDependencies": { 15 | "@types/node": "^20.11.24" 16 | }, 17 | "license": "MIT" 18 | } 19 | -------------------------------------------------------------------------------- /V2/api/cosmostoCosmosPosthook/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/cosmostoEVMSwap/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | MNEMONIC="" 4 | OSMOSIS_RPC_ENDPOINT="https://mainnet.rpc.axelar.dev/chain/osmosis" 5 | EVM_RECEIVER_ADDRESS="0x00" 6 | INTEGRATOR_ID='Apply for a Squid apiplus integratorID here: https://squidrouter.typeform.com/integrator-id if you dont have one' -------------------------------------------------------------------------------- /V2/api/cosmostoEVMSwap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@cosmjs/proto-signing": "^0.32.4", 7 | "@cosmjs/stargate": "^0.32.4", 8 | "@keplr-wallet/unit": "^0.12.119", 9 | "axios": "^1.7.3", 10 | "cosmjs-types": "^0.9.0", 11 | "dotenv": "^16.4.5", 12 | "ethers": "^5.7.2" 13 | }, 14 | "devDependencies": { 15 | "@types/node": "^20.11.24" 16 | }, 17 | "license": "MIT" 18 | } 19 | -------------------------------------------------------------------------------- /V2/api/cosmostoEVMSwap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/cosmostoEVMandSupplyPosthook/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | MNEMONIC="" 4 | OSMOSIS_RPC_ENDPOINT="https://mainnet.rpc.axelar.dev/chain/osmosis" 5 | EVM_RECEIVER_ADDRESS="0x00" 6 | INTEGRATOR_ID='Apply for a Squid apiplus integratorID here: https://squidrouter.typeform.com/integrator-id if you dont have one' -------------------------------------------------------------------------------- /V2/api/cosmostoEVMandSupplyPosthook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@cosmjs/proto-signing": "^0.32.4", 7 | "@cosmjs/stargate": "^0.32.4", 8 | "@keplr-wallet/unit": "^0.12.119", 9 | "axios": "^1.7.3", 10 | "cosmjs-types": "^0.9.0", 11 | "dotenv": "^16.4.5", 12 | "ethers": "^5.7.2" 13 | }, 14 | "devDependencies": { 15 | "@types/node": "^20.11.24" 16 | }, 17 | "license": "MIT" 18 | } 19 | -------------------------------------------------------------------------------- /V2/api/cosmostoEVMandSupplyPosthook/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/evmPrehooktoEVM/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT=https://arb1.arbitrum.io/rpc 6 | -------------------------------------------------------------------------------- /V2/api/evmPrehooktoEVM/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/api/evmPrehooktoEVM/abi/wethAbi.ts: -------------------------------------------------------------------------------- 1 | const wethAbi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "guy", 21 | type: "address", 22 | }, 23 | { 24 | name: "wad", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "src", 58 | type: "address", 59 | }, 60 | { 61 | name: "dst", 62 | type: "address", 63 | }, 64 | { 65 | name: "wad", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: false, 82 | inputs: [ 83 | { 84 | name: "wad", 85 | type: "uint256", 86 | }, 87 | ], 88 | name: "withdraw", 89 | outputs: [], 90 | payable: false, 91 | stateMutability: "nonpayable", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [], 97 | name: "decimals", 98 | outputs: [ 99 | { 100 | name: "", 101 | type: "uint8", 102 | }, 103 | ], 104 | payable: false, 105 | stateMutability: "view", 106 | type: "function", 107 | }, 108 | { 109 | constant: true, 110 | inputs: [ 111 | { 112 | name: "", 113 | type: "address", 114 | }, 115 | ], 116 | name: "balanceOf", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "uint256", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: true, 129 | inputs: [], 130 | name: "symbol", 131 | outputs: [ 132 | { 133 | name: "", 134 | type: "string", 135 | }, 136 | ], 137 | payable: false, 138 | stateMutability: "view", 139 | type: "function", 140 | }, 141 | { 142 | constant: false, 143 | inputs: [], 144 | name: "deposit", 145 | outputs: [], 146 | payable: true, 147 | stateMutability: "payable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "", 155 | type: "address", 156 | }, 157 | ], 158 | name: "allowance", 159 | outputs: [ 160 | { 161 | name: "", 162 | type: "uint256", 163 | }, 164 | ], 165 | payable: false, 166 | stateMutability: "view", 167 | type: "function", 168 | }, 169 | { 170 | payable: true, 171 | stateMutability: "payable", 172 | type: "fallback", 173 | }, 174 | { 175 | anonymous: false, 176 | inputs: [ 177 | { 178 | indexed: true, 179 | name: "src", 180 | type: "address", 181 | }, 182 | { 183 | indexed: true, 184 | name: "guy", 185 | type: "address", 186 | }, 187 | { 188 | indexed: false, 189 | name: "wad", 190 | type: "uint256", 191 | }, 192 | ], 193 | name: "Approval", 194 | type: "event", 195 | }, 196 | { 197 | anonymous: false, 198 | inputs: [ 199 | { 200 | indexed: true, 201 | name: "src", 202 | type: "address", 203 | }, 204 | { 205 | indexed: true, 206 | name: "dst", 207 | type: "address", 208 | }, 209 | { 210 | indexed: false, 211 | name: "wad", 212 | type: "uint256", 213 | }, 214 | ], 215 | name: "Transfer", 216 | type: "event", 217 | }, 218 | { 219 | anonymous: false, 220 | inputs: [ 221 | { 222 | indexed: true, 223 | name: "dst", 224 | type: "address", 225 | }, 226 | { 227 | indexed: false, 228 | name: "wad", 229 | type: "uint256", 230 | }, 231 | ], 232 | name: "Deposit", 233 | type: "event", 234 | }, 235 | { 236 | anonymous: false, 237 | inputs: [ 238 | { 239 | indexed: true, 240 | name: "src", 241 | type: "address", 242 | }, 243 | { 244 | indexed: false, 245 | name: "wad", 246 | type: "uint256", 247 | }, 248 | ], 249 | name: "Withdrawal", 250 | type: "event", 251 | }, 252 | ]; 253 | 254 | export default wethAbi; 255 | -------------------------------------------------------------------------------- /V2/api/evmPrehooktoEVM/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.5.1", 7 | "dotenv": "^16.3.1", 8 | "ethers": "^5.7.2" 9 | }, 10 | "devDependencies": { 11 | "@types/node": "^20.12.12" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /V2/api/evmPrehooktoEVM/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/evmToEVMSwap/.env.example: -------------------------------------------------------------------------------- 1 | PRIVATE_KEY=WALLET_PRIVATE_JEY 2 | INTEGRATOR_ID=INTEGRATOR_ID 3 | FROM_CHAIN_RPC_ENDPOINT=https://binance.llamarpc.com -------------------------------------------------------------------------------- /V2/api/evmToEVMSwap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.6.7", 7 | "dotenv": "^16.4.5", 8 | "ethers": "^5.7.2" 9 | }, 10 | "devDependencies": { 11 | "@types/node": "^20.11.24" 12 | }, 13 | "license": "MIT" 14 | } 15 | -------------------------------------------------------------------------------- /V2/api/evmToEVMSwap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/evmToEVMSwap_setToAmount/.env.example: -------------------------------------------------------------------------------- 1 | PRIVATE_KEY=WALLET_PRIVATE_JEY 2 | INTEGRATOR_ID=INTEGRATOR_ID 3 | FROM_CHAIN_RPC_ENDPOINT=https://binance.llamarpc.com -------------------------------------------------------------------------------- /V2/api/evmToEVMSwap_setToAmount/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.6.7", 7 | "dotenv": "^16.4.5", 8 | "ethers": "^5.7.2" 9 | }, 10 | "devDependencies": { 11 | "@types/node": "^20.11.24" 12 | }, 13 | "license": "MIT" 14 | } 15 | -------------------------------------------------------------------------------- /V2/api/evmToEVMSwap_setToAmount/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/evmWithdrawPrehooktoEVM/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT= # RPC endpoint URL https://arb1.arbitrum.io/rpc 6 | -------------------------------------------------------------------------------- /V2/api/evmWithdrawPrehooktoEVM/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/api/evmWithdrawPrehooktoEVM/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.5.1", 7 | "dotenv": "^16.3.1", 8 | "ethers": "^5.7.2" 9 | }, 10 | "devDependencies": { 11 | "@types/node": "^20.12.12" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /V2/api/evmWithdrawPrehooktoEVM/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/evmWithdrawPrehooktoEVMDeposit/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT= # RPC endpoint URL https://arb1.arbitrum.io/rpc 6 | -------------------------------------------------------------------------------- /V2/api/evmWithdrawPrehooktoEVMDeposit/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/api/evmWithdrawPrehooktoEVMDeposit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.5.1", 7 | "dotenv": "^16.3.1", 8 | "ethers": "^5.7.2" 9 | }, 10 | "devDependencies": { 11 | "@types/node": "^20.12.12" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /V2/api/evmWithdrawPrehooktoEVMDeposit/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/oldExamples/mintPolygonNftFromAnyChain/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT= # Departing chain RPC endpoint 6 | NFT_CONTRACT_ADDRESS= # Easter egg NFT address 7 | -------------------------------------------------------------------------------- /V2/api/oldExamples/mintPolygonNftFromAnyChain/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: 'name', 6 | outputs: [ 7 | { 8 | name: '', 9 | type: 'string', 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: 'view', 14 | type: 'function', 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: '_spender', 21 | type: 'address', 22 | }, 23 | { 24 | name: '_value', 25 | type: 'uint256', 26 | }, 27 | ], 28 | name: 'approve', 29 | outputs: [ 30 | { 31 | name: '', 32 | type: 'bool', 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: 'nonpayable', 37 | type: 'function', 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: 'totalSupply', 43 | outputs: [ 44 | { 45 | name: '', 46 | type: 'uint256', 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: 'view', 51 | type: 'function', 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: '_from', 58 | type: 'address', 59 | }, 60 | { 61 | name: '_to', 62 | type: 'address', 63 | }, 64 | { 65 | name: '_value', 66 | type: 'uint256', 67 | }, 68 | ], 69 | name: 'transferFrom', 70 | outputs: [ 71 | { 72 | name: '', 73 | type: 'bool', 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: 'nonpayable', 78 | type: 'function', 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: 'decimals', 84 | outputs: [ 85 | { 86 | name: '', 87 | type: 'uint8', 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: 'view', 92 | type: 'function', 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: '_owner', 99 | type: 'address', 100 | }, 101 | ], 102 | name: 'balanceOf', 103 | outputs: [ 104 | { 105 | name: 'balance', 106 | type: 'uint256', 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: 'view', 111 | type: 'function', 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: 'symbol', 117 | outputs: [ 118 | { 119 | name: '', 120 | type: 'string', 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: 'view', 125 | type: 'function', 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: '_to', 132 | type: 'address', 133 | }, 134 | { 135 | name: '_value', 136 | type: 'uint256', 137 | }, 138 | ], 139 | name: 'transfer', 140 | outputs: [ 141 | { 142 | name: '', 143 | type: 'bool', 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: 'nonpayable', 148 | type: 'function', 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: '_owner', 155 | type: 'address', 156 | }, 157 | { 158 | name: '_spender', 159 | type: 'address', 160 | }, 161 | ], 162 | name: 'allowance', 163 | outputs: [ 164 | { 165 | name: '', 166 | type: 'uint256', 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: 'view', 171 | type: 'function', 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: 'payable', 176 | type: 'fallback', 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: 'owner', 184 | type: 'address', 185 | }, 186 | { 187 | indexed: true, 188 | name: 'spender', 189 | type: 'address', 190 | }, 191 | { 192 | indexed: false, 193 | name: 'value', 194 | type: 'uint256', 195 | }, 196 | ], 197 | name: 'Approval', 198 | type: 'event', 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: 'from', 206 | type: 'address', 207 | }, 208 | { 209 | indexed: true, 210 | name: 'to', 211 | type: 'address', 212 | }, 213 | { 214 | indexed: false, 215 | name: 'value', 216 | type: 'uint256', 217 | }, 218 | ], 219 | name: 'Transfer', 220 | type: 'event', 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/api/oldExamples/mintPolygonNftFromAnyChain/contracts/squidEasterEggNft.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 6 | 7 | contract squidEasterEggNft is ERC721 { 8 | uint256 private _currentTokenId = 0; 9 | string private _baseTokenURI; 10 | mapping(address => bool) private _minted; 11 | 12 | constructor(string memory name, string memory symbol, string memory baseTokenURI_) 13 | ERC721(name, symbol) 14 | { 15 | _baseTokenURI = baseTokenURI_; 16 | } 17 | 18 | function mint(address _receiver) external { 19 | require(!_minted[_receiver], "You have already minted this NFT."); 20 | _minted[_receiver] = true; 21 | _currentTokenId += 1; 22 | uint256 newItemId = _currentTokenId; 23 | _safeMint(_receiver, newItemId); 24 | } 25 | 26 | function _baseURI() internal view override returns (string memory) { 27 | return _baseTokenURI; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /V2/api/oldExamples/mintPolygonNftFromAnyChain/hardhat.config.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | require('@nomiclabs/hardhat-ethers'); 3 | require('@nomiclabs/hardhat-web3'); 4 | require('@nomiclabs/hardhat-etherscan'); 5 | require('hardhat-contract-sizer'); 6 | 7 | const PRIVATE_KEY = process.env.PRIVATE_KEY; 8 | const API_KEY = process.env.API_KEY; 9 | const RPC_KEY = process.env.RPC_KEY; 10 | 11 | module.exports = { 12 | networks: { 13 | localhost: { 14 | url: 'http://127.0.0.1:8545', 15 | }, 16 | testnet: { 17 | url: `https://polygon-mumbai.infura.io/v3/${RPC_KEY}`, 18 | chainId: 80001, 19 | accounts: [`0x${PRIVATE_KEY}`], 20 | }, 21 | }, 22 | etherscan: { 23 | apiKey: { 24 | polygonMumbai: API_KEY, 25 | }, 26 | }, 27 | contractSizer: { 28 | runOnCompile: true, 29 | }, 30 | mocha: {}, 31 | abiExporter: { 32 | path: './build/contracts', 33 | clear: true, 34 | flat: true, 35 | spacing: 2, 36 | }, 37 | solidity: { 38 | version: '0.8.17', 39 | settings: { 40 | optimizer: { 41 | enabled: true, 42 | runs: 200, 43 | }, 44 | }, 45 | }, 46 | gasReporter: { 47 | currency: 'USD', 48 | enabled: true, 49 | gasPrice: 50, 50 | }, 51 | }; 52 | -------------------------------------------------------------------------------- /V2/api/oldExamples/mintPolygonNftFromAnyChain/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@nomiclabs/hardhat-ethers": "^2.2.3", 7 | "@nomiclabs/hardhat-etherscan": "^3.1.7", 8 | "@nomiclabs/hardhat-web3": "^2.0.0", 9 | "@openzeppelin/contracts": "^4.9.3", 10 | "axios": "^1.5.1", 11 | "dotenv": "^16.3.1", 12 | "ethers": "^5.7.2", 13 | "hardhat-contract-sizer": "^2.10.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /V2/api/oldExamples/mintPolygonNftFromAnyChain/scripts/deploy.js: -------------------------------------------------------------------------------- 1 | async function main() { 2 | const verify = async (contractAddress, args) => { 3 | console.log('Verifying contract...'); 4 | try { 5 | await run('verify:verify', { 6 | address: contractAddress, 7 | constructorArguments: args, 8 | }); 9 | } catch (e) { 10 | if (e.message.toLowerCase().includes('already verified')) { 11 | console.log('Already verified!'); 12 | } else { 13 | console.log(e); 14 | } 15 | } 16 | }; 17 | 18 | const SquidEasterEggNft = await ethers.getContractFactory('squidEasterEggNft'); 19 | 20 | const name = 'Squid Easter Egg'; 21 | const symbol = 'SQUIDEGG'; 22 | const baseTokenURI = 'egg'; 23 | 24 | const squidEasterEggNft = await SquidEasterEggNft.deploy(name, symbol, baseTokenURI); 25 | await squidEasterEggNft.deployed(); 26 | console.log('SquidEasterEggNft deployed to:', squidEasterEggNft.address); 27 | 28 | console.log('Waiting for blocks confirmations...'); 29 | await squidEasterEggNft.deployTransaction.wait(6); 30 | console.log('Confirmed!'); 31 | 32 | const squidEasterEggNftArgs = [name, symbol, baseTokenURI]; 33 | await verify(squidEasterEggNft.address, squidEasterEggNftArgs); 34 | 35 | console.log('SquidEasterEggNft deployed to:', squidEasterEggNft.address); 36 | } 37 | 38 | main() 39 | .then(() => process.exit(0)) 40 | .catch((error) => { 41 | console.error(error); 42 | process.exit(1); 43 | }); 44 | -------------------------------------------------------------------------------- /V2/api/oldExamples/mintPolygonNftFromAnyChain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/oldExamples/repayAaveLoanWithdrawToBinance/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | BASE_RPC_ENDPOINT= # Base RPC endpoint 6 | AAVE_LENDING_POOL_ADDRESS= # Address of the Aave lending pool 7 | BINANCE_ADDRESS= # Binance address to withdraw to 8 | -------------------------------------------------------------------------------- /V2/api/oldExamples/repayAaveLoanWithdrawToBinance/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.5.1", 7 | "dotenv": "^16.3.1", 8 | "ethers": "^5.7.2" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /V2/api/oldExamples/repayAaveLoanWithdrawToBinance/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapArbitrumEthToBaseUsdc/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | ARBITRUM_RPC_ENDPOINT=https://goerli-rollup.arbitrum.io/rpc 5 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapArbitrumEthToBaseUsdc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.5.1", 7 | "dotenv": "^16.3.1", 8 | "ethers": "^5.7.2" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapArbitrumEthToBaseUsdc/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import axios from "axios"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const arbitrumRpcEndpoint: string = process.env.ARBITRUM_RPC_ENDPOINT!; 12 | 13 | // Define chain and token addresses 14 | const arbitrumChainId = "42161"; // Arbitrum 15 | const baseChainId = "8453"; // Base 16 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 17 | const baseUsdc = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"; 18 | 19 | // Define amount to be sent 20 | const amount = "10000000000000000"; 21 | 22 | // Set up JSON RPC provider and signer 23 | const provider = new ethers.providers.JsonRpcProvider(arbitrumRpcEndpoint); 24 | const signer = new ethers.Wallet(privateKey, provider); 25 | 26 | const getRoute = async (params: any) => { 27 | try { 28 | const result = await axios.post( 29 | "https://v2.api.squidrouter.com/v2/route", 30 | params, 31 | { 32 | headers: { 33 | "x-integrator-id": integratorId, 34 | "Content-Type": "application/json", 35 | }, 36 | } 37 | ); 38 | const requestId = result.headers["x-request-id"]; 39 | return { data: result.data, requestId: requestId }; 40 | } catch (error) { 41 | // Log the error response if it's available. 42 | if (error.response) { 43 | console.error("API error:", error.response.data); 44 | } 45 | console.error("Error with parameters:", params); 46 | throw error; 47 | } 48 | }; 49 | 50 | const getStatus = async (params: any) => { 51 | try { 52 | const result = await axios.get("https://api.squidrouter.com/v1/status", { 53 | params: { 54 | transactionId: params.transactionId, 55 | requestId: params.requestId, 56 | fromChainId: params.fromChainId, 57 | toChainId: params.toChainId, 58 | }, 59 | headers: { 60 | "x-integrator-id": integratorId, 61 | }, 62 | }); 63 | return result.data; 64 | } catch (error) { 65 | if (error.response) { 66 | console.error("API error:", error.response.data); 67 | } 68 | console.error("Error with parameters:", params); 69 | throw error; 70 | } 71 | }; 72 | 73 | (async () => { 74 | // Set up parameters for swapping tokens 75 | const params = { 76 | fromAddress: signer.address, 77 | fromChain: arbitrumChainId, 78 | fromToken: nativeToken, 79 | fromAmount: amount, 80 | toChain: baseChainId, 81 | toToken: baseUsdc, 82 | toAddress: signer.address, 83 | slippage: 1, 84 | }; 85 | 86 | console.log("Parameters:", params); 87 | 88 | // Get the swap route using Squid API 89 | const routeResult = await getRoute(params); 90 | const route = routeResult.data.route; 91 | const requestId = routeResult.requestId; 92 | console.log("Calculated route:", route); 93 | console.log("requestId:", requestId); 94 | 95 | const transactionRequest = route.transactionRequest; 96 | 97 | // Execute the swap transaction 98 | const contract = new ethers.Contract( 99 | transactionRequest.targetAddress, 100 | [], 101 | signer 102 | ); 103 | 104 | const tx = await contract.send(transactionRequest.data, { 105 | value: transactionRequest.value, 106 | gasPrice: await provider.getGasPrice(), 107 | gasLimit: transactionRequest.gasLimit, 108 | }); 109 | const txReceipt = await tx.wait(); 110 | 111 | // Show the transaction receipt with Axelarscan link 112 | const axelarScanLink = 113 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 114 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 115 | 116 | // Wait a few seconds before checking the status 117 | await new Promise((resolve) => setTimeout(resolve, 5000)); 118 | 119 | // Retrieve the transaction's route status 120 | const getStatusParams = { 121 | transactionId: txReceipt.transactionHash, 122 | requestId: requestId, 123 | fromChainId: arbitrumChainId, 124 | toChainId: baseChainId, 125 | }; 126 | const status = await getStatus(getStatusParams); 127 | 128 | // Display the route status 129 | console.log(`Route status: ${status.squidTransactionStatus}`); 130 | })(); 131 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapArbitrumEthToBaseUsdc/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapAvalancheUsdcToMoonbeamGlmr/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | AVALANCHE_RPC_ENDPOINT= 5 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapAvalancheUsdcToMoonbeamGlmr/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.5.1", 7 | "dotenv": "^16.3.1", 8 | "ethers": "^5.7.2" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapAvalancheUsdcToMoonbeamGlmr/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import axios from "axios"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const avalancheRpcEndpoint: string = process.env.AVALANCHE_RPC_ENDPOINT!; 12 | 13 | // Define chain and token addresses 14 | const avalancheChainId = "43114"; // Avalanche 15 | const moonbeamChainId = "1284"; // Moonbeam 16 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 17 | const avalancheUsdc = "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664"; // USDC.e 18 | 19 | // Define amount to be sent 20 | const amount = "10000"; 21 | 22 | // Set up JSON RPC provider and signer 23 | const provider = new ethers.providers.JsonRpcProvider(avalancheRpcEndpoint); 24 | const signer = new ethers.Wallet(privateKey, provider); 25 | 26 | const getRoute = async (params: any) => { 27 | try { 28 | const result = await axios.post( 29 | "https://v2.api.squidrouter.com/v2/route", 30 | params, 31 | { 32 | headers: { 33 | "x-integrator-id": integratorId, 34 | "Content-Type": "application/json", 35 | }, 36 | } 37 | ); 38 | const requestId = result.headers["x-request-id"]; 39 | return { data: result.data, requestId: requestId }; 40 | } catch (error) { 41 | // Log the error response if it's available. 42 | if (error.response) { 43 | console.error("API error:", error.response.data); 44 | } 45 | console.error("Error with parameters:", params); 46 | throw error; 47 | } 48 | }; 49 | 50 | const getStatus = async (params: any) => { 51 | try { 52 | const result = await axios.get("https://api.squidrouter.com/v1/status", { 53 | params: { 54 | transactionId: params.transactionId, 55 | requestId: params.requestId, 56 | fromChainId: params.fromChainId, 57 | toChainId: params.toChainId, 58 | }, 59 | headers: { 60 | "x-integrator-id": integratorId, 61 | }, 62 | }); 63 | return result.data; 64 | } catch (error) { 65 | if (error.response) { 66 | console.error("API error:", error.response.data); 67 | } 68 | console.error("Error with parameters:", params); 69 | throw error; 70 | } 71 | }; 72 | 73 | (async () => { 74 | // Set up parameters for swapping tokens 75 | const params = { 76 | fromAddress: signer.address, 77 | fromChain: avalancheChainId, 78 | fromToken: avalancheUsdc, 79 | fromAmount: amount, 80 | toChain: moonbeamChainId, 81 | toToken: nativeToken, 82 | toAddress: signer.address, 83 | slippage: 1, 84 | }; 85 | 86 | console.log("Parameters:", params); 87 | 88 | // Get the swap route using Squid API 89 | const routeResult = await getRoute(params); 90 | const route = routeResult.data.route; 91 | const requestId = routeResult.requestId; 92 | console.log("Calculated route:", route); 93 | console.log("requestId:", requestId); 94 | 95 | const transactionRequest = route.transactionRequest; 96 | 97 | // Execute the swap transaction 98 | const contract = new ethers.Contract( 99 | transactionRequest.targetAddress, 100 | [], 101 | signer 102 | ); 103 | 104 | const tx = await contract.send(transactionRequest.data, { 105 | value: transactionRequest.value, 106 | gasPrice: await provider.getGasPrice(), 107 | gasLimit: transactionRequest.gasLimit, 108 | }); 109 | const txReceipt = await tx.wait(); 110 | 111 | // Show the transaction receipt with Axelarscan link 112 | const axelarScanLink = 113 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 114 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 115 | 116 | // Wait a few seconds before checking the status 117 | await new Promise((resolve) => setTimeout(resolve, 5000)); 118 | 119 | // Retrieve the transaction's route status 120 | const getStatusParams = { 121 | transactionId: txReceipt.transactionHash, 122 | requestId: requestId, 123 | fromChainId: avalancheChainId, 124 | toChainId: moonbeamChainId, 125 | }; 126 | const status = await getStatus(getStatusParams); 127 | 128 | // Display the route status 129 | console.log(`Route status: ${status.squidTransactionStatus}`); 130 | })(); 131 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapAvalancheUsdcToMoonbeamGlmr/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapEthereumToFantomAndStake/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | ETHEREUM_RPC_ENDPOINT= # Ethereum RPC endpoint 6 | STAKING_CONTRACT_ADDRESS= # Fantom staking contract address 7 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapEthereumToFantomAndStake/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.5.1", 7 | "dotenv": "^16.3.1", 8 | "ethers": "^5.7.2" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapEthereumToFantomAndStake/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import axios from "axios"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const ethereumRpcEndpoint: string = process.env.ETHEREUM_RPC_ENDPOINT!; 12 | const stakingContractAddress: string = process.env.STAKING_CONTRACT_ADDRESS!; 13 | 14 | // Define chain and token addresses 15 | const ethereumId = "1"; // Ethereum 16 | const fantomId = "250"; // Fantom 17 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 18 | const ethereumUsdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; 19 | 20 | // Define amount to swap and stake 21 | const amountToSwap = "10000000000000000"; 22 | 23 | // Import staking contract ABI 24 | import stakingContractAbi from "../abi/fantomSFC"; 25 | 26 | // Set up JSON RPC provider and signer 27 | const provider = new ethers.providers.JsonRpcProvider(ethereumRpcEndpoint); 28 | const signer = new ethers.Wallet(privateKey, provider); 29 | 30 | const getRoute = async (params: any) => { 31 | try { 32 | const result = await axios.post( 33 | "https://v2.api.squidrouter.com/v2/route", 34 | params, 35 | { 36 | headers: { 37 | "x-integrator-id": integratorId, 38 | "Content-Type": "application/json", 39 | }, 40 | } 41 | ); 42 | const requestId = result.headers["x-request-id"]; 43 | return { data: result.data, requestId: requestId }; 44 | } catch (error) { 45 | // Log the error response if it's available. 46 | if (error.response) { 47 | console.error("API error:", error.response.data); 48 | } 49 | console.error("Error with parameters:", params); 50 | throw error; 51 | } 52 | }; 53 | 54 | const getStatus = async (params: any) => { 55 | try { 56 | const result = await axios.get("https://api.squidrouter.com/v1/status", { 57 | params: { 58 | transactionId: params.transactionId, 59 | requestId: params.requestId, 60 | fromChainId: params.fromChainId, 61 | toChainId: params.toChainId, 62 | }, 63 | headers: { 64 | "x-integrator-id": integratorId, 65 | }, 66 | }); 67 | return result.data; 68 | } catch (error) { 69 | if (error.response) { 70 | console.error("API error:", error.response.data); 71 | } 72 | console.error("Error with parameters:", params); 73 | throw error; 74 | } 75 | }; 76 | 77 | // Create contract interface and encode delegate (Fantom staking) function 78 | const stakingContractInterface = new ethers.utils.Interface(stakingContractAbi); 79 | const delegateEncodedData = stakingContractInterface.encodeFunctionData( 80 | "delegate", 81 | [amountToSwap] 82 | ); 83 | 84 | (async () => { 85 | // Set up parameters for swapping tokens and staking 86 | const params = { 87 | fromAddress: signer.address, 88 | fromChain: ethereumId, 89 | fromToken: ethereumUsdc, 90 | fromAmount: amountToSwap, 91 | toChain: fantomId, 92 | toToken: nativeToken, 93 | toAddress: signer.address, 94 | slippage: 1, 95 | quoteOnly: false, 96 | // Customize contract call for staking on Fantom 97 | postHook: [ 98 | { 99 | callType: 1, // SquidCallType.FULL_TOKEN_BALANCE 100 | target: stakingContractAddress, 101 | value: "0", 102 | callData: delegateEncodedData, 103 | payload: { 104 | tokenAddress: ethereumUsdc, 105 | inputPos: 0, 106 | }, 107 | estimatedGas: "50000", 108 | }, 109 | ], 110 | }; 111 | 112 | console.log("Parameters:", params); 113 | 114 | // Get the swap route using Squid API 115 | const routeResult = await getRoute(params); 116 | const route = routeResult.data.route; 117 | const requestId = routeResult.requestId; 118 | console.log("Calculated route:", route); 119 | console.log("requestId:", requestId); 120 | console.log("Calculated fee costs:", route.estimate.feeCosts); 121 | 122 | const transactionRequest = route.transactionRequest; 123 | 124 | // Execute the swap and staking transaction 125 | const contract = new ethers.Contract( 126 | transactionRequest.targetAddress, 127 | stakingContractAbi, 128 | signer 129 | ); 130 | const tx = await contract.send(transactionRequest.data, { 131 | value: transactionRequest.value, 132 | gasPrice: await provider.getGasPrice(), 133 | gasLimit: transactionRequest.gasLimit, 134 | }); 135 | const txReceipt = await tx.wait(); 136 | 137 | // Show the transaction receipt with Axelarscan link 138 | const axelarScanLink = 139 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 140 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 141 | 142 | // Wait a few seconds before checking the status 143 | await new Promise((resolve) => setTimeout(resolve, 5000)); 144 | 145 | // Retrieve the transaction's route status 146 | const getStatusParams = { 147 | transactionId: txReceipt.transactionHash, 148 | requestId: requestId, 149 | fromChainId: ethereumId, 150 | toChainId: fantomId, 151 | }; 152 | const status = await getStatus(getStatusParams); 153 | 154 | // Display the route status 155 | console.log(`Route status: ${status.squidTransactionStatus}`); 156 | })(); 157 | -------------------------------------------------------------------------------- /V2/api/oldExamples/swapEthereumToFantomAndStake/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/solanaToEVM_Swap/.env.example: -------------------------------------------------------------------------------- 1 | PRIVATE_KEY=WALLET_PRIVATE_JEY 2 | INTEGRATOR_ID=YOUR_INTEGRATOR_ID 3 | FROM_CHAIN_RPC_ENDPOINT=https://binance.llamarpc.com 4 | -------------------------------------------------------------------------------- /V2/api/solanaToEVM_Swap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@chainflip/sdk": "^1.6.6", 7 | "@solana/web3.js": "^1.95.4", 8 | "axios": "^1.7.7", 9 | "bs58": "^6.0.0", 10 | "dotenv": "^16.4.5", 11 | "ethers": "^5.7.2" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^20.11.24" 15 | }, 16 | "license": "MIT" 17 | } 18 | -------------------------------------------------------------------------------- /V2/api/solanaToEVM_Swap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/api/swapEVMToEVMAndLendPosthook/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT= # RPC endpoint URL 6 | RADIANT_LENDING_POOL_ADDRESS= # Radiant Capital `lendingPool` address 7 | USDC_ARBITRUM_ADDRESS="0xff970a61a04b1ca14834a43f5de4533ebddb5cc8" # Arbitrum USDC.e address 8 | -------------------------------------------------------------------------------- /V2/api/swapEVMToEVMAndLendPosthook/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/api/swapEVMToEVMAndLendPosthook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "axios": "^1.5.1", 7 | "dotenv": "^16.3.1", 8 | "ethers": "^5.7.2" 9 | }, 10 | "devDependencies": { 11 | "@types/node": "^20.12.12" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /V2/api/swapEVMToEVMAndLendPosthook/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/api/tx_lookup/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "transaction-lookup", 3 | "version": "1.0.0", 4 | "description": "Script to lookup transactions across Axelar and Squid APIs", 5 | "main": "tx-lookup.js", 6 | "type": "module", 7 | "scripts": { 8 | "start": "node tx-lookup.js" 9 | }, 10 | "keywords": [ 11 | "blockchain", 12 | "transaction", 13 | "axelar", 14 | "squid" 15 | ], 16 | "author": "", 17 | "license": "ISC", 18 | "dependencies": { 19 | "node-fetch": "^3.3.2" 20 | } 21 | } -------------------------------------------------------------------------------- /V2/api/tx_lookup/tx-lookup.js: -------------------------------------------------------------------------------- 1 | import fetch from 'node-fetch'; 2 | 3 | // Configuration - Set your values here 4 | const CONFIG = { 5 | txHash: '0x80bb655a8ef1b3cdb24636f8506096cc23631b0116861e71671a5ba6fd94fef3', //axelar tx example 0x3fbb62833fefe6b3fe53d463b2777d1569ff234d5752b2ee6bd39abed8281d62 6 | integratorId: 'YOUR_INTEGRATOR_ID', 7 | fromChainId: '56', // Optional - set to null or remove if not needed 8 | toChainId: '42161' // Optional - set to null or remove if not needed 9 | }; 10 | 11 | // API endpoints 12 | const AXELAR_API = 'https://api.axelarscan.io/gmp/searchGMP'; //Axelarscan API documentation:https://docs.axelarscan.io/gmp#searchGMP 13 | const SQUID_API = 'https://v2.api.squidrouter.com/v2/rfq/order'; 14 | 15 | async function lookupTransaction() { 16 | try { 17 | // Validate txHash 18 | if (!CONFIG.txHash.startsWith('0x')) { 19 | throw new Error('Transaction hash must start with 0x'); 20 | } 21 | 22 | // Validate integratorId 23 | if (!CONFIG.integratorId || CONFIG.integratorId === 'YOUR_INTEGRATOR_ID') { 24 | throw new Error('Please set your integrator ID in the CONFIG object'); 25 | } 26 | 27 | // Build Axelar request body 28 | const axelarBody = { 29 | size: 1, 30 | txHash: CONFIG.txHash 31 | }; 32 | 33 | // Add optional chain IDs if they exist 34 | if (CONFIG.fromChainId) axelarBody.fromChainId = CONFIG.fromChainId; 35 | if (CONFIG.toChainId) axelarBody.toChainId = CONFIG.toChainId; 36 | 37 | console.log('Checking Axelar API...'); 38 | const axelarResponse = await fetch(AXELAR_API, { 39 | method: 'POST', 40 | headers: { 41 | 'Content-Type': 'application/json' 42 | }, 43 | body: JSON.stringify(axelarBody) 44 | }); 45 | 46 | if (!axelarResponse.ok) { 47 | throw new Error(`Axelar API error: ${axelarResponse.status}`); 48 | } 49 | 50 | const axelarData = await axelarResponse.json(); 51 | 52 | // If Axelar found the transaction, return it 53 | if (axelarData.data && axelarData.data.length > 0) { 54 | console.log('Transaction found in Axelar:'); 55 | console.log(JSON.stringify(axelarData, null, 2)); 56 | return; 57 | } 58 | 59 | console.log('No transaction found in Axelar, trying Squid API...'); 60 | 61 | // Try Squid API as fallback 62 | const squidResponse = await fetch(SQUID_API, { 63 | method: 'POST', 64 | headers: { 65 | 'Content-Type': 'application/json', 66 | 'x-integrator-id': CONFIG.integratorId 67 | }, 68 | body: JSON.stringify({ 69 | hash: CONFIG.txHash 70 | }) 71 | }); 72 | 73 | if (!squidResponse.ok) { 74 | throw new Error(`Squid API error: ${squidResponse.status}`); 75 | } 76 | 77 | const squidData = await squidResponse.json(); 78 | console.log('Transaction found in Squid:'); 79 | console.log(JSON.stringify(squidData, null, 2)); 80 | 81 | } catch (error) { 82 | console.error('Error:', error.message); 83 | process.exit(1); 84 | } 85 | } 86 | 87 | // Run the lookup 88 | lookupTransaction(); -------------------------------------------------------------------------------- /V2/sdk/evmPrehooktoEVM/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT=https://arb1.arbitrum.io/rpc 6 | -------------------------------------------------------------------------------- /V2/sdk/evmPrehooktoEVM/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/sdk/evmPrehooktoEVM/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.7.0", 7 | "@0xsquid/squid-types": "^0.1.27", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "dotenv": "^16.3.1", 10 | "ethers": "^6.8.1" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /V2/sdk/evmPrehooktoEVM/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/sdk/evmToEVMSwap/.env.example: -------------------------------------------------------------------------------- 1 | PRIVATE_KEY=PRIVATE_KEY 2 | INTEGRATOR_ID=INTEGRATOR_ID 3 | FROM_CHAIN_RPC_ENDPOINT=https://binance.llamarpc.com -------------------------------------------------------------------------------- /V2/sdk/evmToEVMSwap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.9.3", 7 | "@0xsquid/squid-types": "^0.1.145", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "axios": "^1.6.7", 10 | "dotenv": "^16.4.5", 11 | "ethers": "^6.8.1" 12 | }, 13 | "license": "MIT" 14 | } 15 | -------------------------------------------------------------------------------- /V2/sdk/evmToEVMSwap/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/sdk/oldExamples/buyNftFromAnyChain/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | AVAX_RPC_ENDPOINT=https://api.avax.network/ext/bc/C/rpc 5 | INTEGRATOR_ID= # your integrator id https://form.typeform.com/to/cqFtqSvX 6 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/buyNftFromAnyChain/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/buyNftFromAnyChain/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts", 4 | "start:decentraland": "ts-node src/decentraland.ts" 5 | }, 6 | "dependencies": { 7 | "@0xsquid/sdk": "2.8.0-beta.0", 8 | "@0xsquid/squid-types": "^0.1.28", 9 | "dotenv": "^16.0.3", 10 | "ethers": "^6.7.1", 11 | "typescript": "^5.2.2" 12 | }, 13 | "devDependencies": { 14 | "ts-node": "^10.9.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/buyNftFromAnyChain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } -------------------------------------------------------------------------------- /V2/sdk/oldExamples/ethersV5SwapAvalancheUsdcToMoonbeam/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | AVALANCHE_RPC_ENDPOINT= 6 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/ethersV5SwapAvalancheUsdcToMoonbeam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.8.1-beta.0", 7 | "@0xsquid/squid-types": "^0.1.27", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "dotenv": "^16.3.1", 10 | "ethers": "^5.7.2" 11 | } 12 | } -------------------------------------------------------------------------------- /V2/sdk/oldExamples/ethersV5SwapAvalancheUsdcToMoonbeam/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import { Squid } from "@0xsquid/sdk"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const avalancheRpcEndpoint: string = process.env.AVALANCHE_RPC_ENDPOINT!; 12 | 13 | // Define chain and token addresses 14 | const avalancheChainId = "43114"; // Avalanche 15 | const moonbeamChainId = "1284"; // Moonbeam 16 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 17 | const avalancheUsdc = "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664"; // USDC.e 18 | 19 | // Define amount to be sent 20 | const amount = "10000"; // 0.01 USDC 21 | 22 | // Function to get Squid SDK instance 23 | const getSDK = (): Squid => { 24 | const squid = new Squid({ 25 | baseUrl: "https://v2.api.squidrouter.com", 26 | integratorId: integratorId, 27 | }); 28 | return squid; 29 | }; 30 | 31 | // Main function 32 | (async () => { 33 | // Set up JSON RPC provider and signer 34 | const provider = new ethers.providers.JsonRpcProvider(avalancheRpcEndpoint); 35 | const signer = new ethers.Wallet(privateKey, provider); 36 | 37 | // Initialize Squid SDK 38 | const squid = getSDK(); 39 | await squid.init(); 40 | console.log("Initialized Squid SDK"); 41 | 42 | // Set up parameters for swapping tokens 43 | const params = { 44 | fromAddress: signer.address, 45 | fromChain: avalancheChainId, 46 | fromToken: avalancheUsdc, 47 | fromAmount: amount, 48 | toChain: moonbeamChainId, 49 | toToken: nativeToken, 50 | toAddress: signer.address, 51 | slippage: 1, 52 | quoteOnly: false, 53 | }; 54 | 55 | console.log("Parameters:", params); 56 | 57 | // Get the swap route using Squid SDK 58 | const { route, requestId } = await squid.getRoute(params); 59 | console.log("Calculated route:", route.estimate.toAmount); 60 | 61 | // // Execute the swap transaction 62 | const tx = (await squid.executeRoute({ 63 | signer, 64 | route, 65 | })) as unknown as ethers.providers.TransactionResponse; 66 | const txReceipt = await tx.wait(); 67 | 68 | // Show the transaction receipt with Axelarscan link 69 | const axelarScanLink = 70 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 71 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 72 | 73 | // Wait a few seconds before checking the status 74 | await new Promise((resolve) => setTimeout(resolve, 5000)); 75 | 76 | // Retrieve the transaction's route status 77 | const getStatusParams = { 78 | transactionId: txReceipt.transactionHash, 79 | requestId: requestId, 80 | fromChainId: avalancheChainId, 81 | toChainId: moonbeamChainId, 82 | }; 83 | const status = await squid.getStatus(getStatusParams); 84 | 85 | // Display the route status 86 | console.log(`Route status: ${status.squidTransactionStatus}`); 87 | })(); 88 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/ethersV5SwapAvalancheUsdcToMoonbeam/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/mintPolygonNftFromAnyChain/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT= # Departing chain RPC endpoint 6 | NFT_CONTRACT_ADDRESS= # Easter egg NFT address 7 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/mintPolygonNftFromAnyChain/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: 'name', 6 | outputs: [ 7 | { 8 | name: '', 9 | type: 'string', 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: 'view', 14 | type: 'function', 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: '_spender', 21 | type: 'address', 22 | }, 23 | { 24 | name: '_value', 25 | type: 'uint256', 26 | }, 27 | ], 28 | name: 'approve', 29 | outputs: [ 30 | { 31 | name: '', 32 | type: 'bool', 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: 'nonpayable', 37 | type: 'function', 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: 'totalSupply', 43 | outputs: [ 44 | { 45 | name: '', 46 | type: 'uint256', 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: 'view', 51 | type: 'function', 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: '_from', 58 | type: 'address', 59 | }, 60 | { 61 | name: '_to', 62 | type: 'address', 63 | }, 64 | { 65 | name: '_value', 66 | type: 'uint256', 67 | }, 68 | ], 69 | name: 'transferFrom', 70 | outputs: [ 71 | { 72 | name: '', 73 | type: 'bool', 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: 'nonpayable', 78 | type: 'function', 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: 'decimals', 84 | outputs: [ 85 | { 86 | name: '', 87 | type: 'uint8', 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: 'view', 92 | type: 'function', 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: '_owner', 99 | type: 'address', 100 | }, 101 | ], 102 | name: 'balanceOf', 103 | outputs: [ 104 | { 105 | name: 'balance', 106 | type: 'uint256', 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: 'view', 111 | type: 'function', 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: 'symbol', 117 | outputs: [ 118 | { 119 | name: '', 120 | type: 'string', 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: 'view', 125 | type: 'function', 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: '_to', 132 | type: 'address', 133 | }, 134 | { 135 | name: '_value', 136 | type: 'uint256', 137 | }, 138 | ], 139 | name: 'transfer', 140 | outputs: [ 141 | { 142 | name: '', 143 | type: 'bool', 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: 'nonpayable', 148 | type: 'function', 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: '_owner', 155 | type: 'address', 156 | }, 157 | { 158 | name: '_spender', 159 | type: 'address', 160 | }, 161 | ], 162 | name: 'allowance', 163 | outputs: [ 164 | { 165 | name: '', 166 | type: 'uint256', 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: 'view', 171 | type: 'function', 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: 'payable', 176 | type: 'fallback', 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: 'owner', 184 | type: 'address', 185 | }, 186 | { 187 | indexed: true, 188 | name: 'spender', 189 | type: 'address', 190 | }, 191 | { 192 | indexed: false, 193 | name: 'value', 194 | type: 'uint256', 195 | }, 196 | ], 197 | name: 'Approval', 198 | type: 'event', 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: 'from', 206 | type: 'address', 207 | }, 208 | { 209 | indexed: true, 210 | name: 'to', 211 | type: 'address', 212 | }, 213 | { 214 | indexed: false, 215 | name: 'value', 216 | type: 'uint256', 217 | }, 218 | ], 219 | name: 'Transfer', 220 | type: 'event', 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/mintPolygonNftFromAnyChain/contracts/squidEasterEggNft.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 6 | 7 | contract squidEasterEggNft is ERC721 { 8 | uint256 private _currentTokenId = 0; 9 | string private _baseTokenURI; 10 | mapping(address => bool) private _minted; 11 | 12 | constructor(string memory name, string memory symbol, string memory baseTokenURI_) 13 | ERC721(name, symbol) 14 | { 15 | _baseTokenURI = baseTokenURI_; 16 | } 17 | 18 | function mint(address _receiver) external { 19 | require(!_minted[_receiver], "You have already minted this NFT."); 20 | _minted[_receiver] = true; 21 | _currentTokenId += 1; 22 | uint256 newItemId = _currentTokenId; 23 | _safeMint(_receiver, newItemId); 24 | } 25 | 26 | function _baseURI() internal view override returns (string memory) { 27 | return _baseTokenURI; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/mintPolygonNftFromAnyChain/hardhat.config.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | require('@nomiclabs/hardhat-ethers'); 3 | require('@nomiclabs/hardhat-web3'); 4 | require('@nomiclabs/hardhat-etherscan'); 5 | require('hardhat-contract-sizer'); 6 | 7 | const PRIVATE_KEY = process.env.PRIVATE_KEY; 8 | const API_KEY = process.env.API_KEY; 9 | const RPC_KEY = process.env.RPC_KEY; 10 | 11 | module.exports = { 12 | networks: { 13 | localhost: { 14 | url: 'http://127.0.0.1:8545', 15 | }, 16 | testnet: { 17 | url: `https://polygon-mumbai.infura.io/v3/${RPC_KEY}`, 18 | chainId: 80001, 19 | accounts: [`0x${PRIVATE_KEY}`], 20 | }, 21 | }, 22 | etherscan: { 23 | apiKey: { 24 | polygonMumbai: API_KEY, 25 | }, 26 | }, 27 | contractSizer: { 28 | runOnCompile: true, 29 | }, 30 | mocha: {}, 31 | abiExporter: { 32 | path: './build/contracts', 33 | clear: true, 34 | flat: true, 35 | spacing: 2, 36 | }, 37 | solidity: { 38 | version: '0.8.17', 39 | settings: { 40 | optimizer: { 41 | enabled: true, 42 | runs: 200, 43 | }, 44 | }, 45 | }, 46 | gasReporter: { 47 | currency: 'USD', 48 | enabled: true, 49 | gasPrice: 50, 50 | }, 51 | }; 52 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/mintPolygonNftFromAnyChain/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.7.0", 7 | "@0xsquid/squid-types": "^0.1.27", 8 | "@nomiclabs/hardhat-ethers": "^2.2.3", 9 | "@nomiclabs/hardhat-etherscan": "^3.1.7", 10 | "@nomiclabs/hardhat-web3": "^2.0.0", 11 | "@openzeppelin/contracts": "^4.9.3", 12 | "dotenv": "^16.3.1", 13 | "ethers": "^5.7.2", 14 | "hardhat-contract-sizer": "^2.10.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/mintPolygonNftFromAnyChain/scripts/deploy.js: -------------------------------------------------------------------------------- 1 | async function main() { 2 | const verify = async (contractAddress, args) => { 3 | console.log('Verifying contract...'); 4 | try { 5 | await run('verify:verify', { 6 | address: contractAddress, 7 | constructorArguments: args, 8 | }); 9 | } catch (e) { 10 | if (e.message.toLowerCase().includes('already verified')) { 11 | console.log('Already verified!'); 12 | } else { 13 | console.log(e); 14 | } 15 | } 16 | }; 17 | 18 | const SquidEasterEggNft = await ethers.getContractFactory('squidEasterEggNft'); 19 | 20 | const name = 'Squid Easter Egg'; 21 | const symbol = 'SQUIDEGG'; 22 | const baseTokenURI = 'egg'; 23 | 24 | const squidEasterEggNft = await SquidEasterEggNft.deploy(name, symbol, baseTokenURI); 25 | await squidEasterEggNft.deployed(); 26 | console.log('SquidEasterEggNft deployed to:', squidEasterEggNft.address); 27 | 28 | console.log('Waiting for blocks confirmations...'); 29 | await squidEasterEggNft.deployTransaction.wait(6); 30 | console.log('Confirmed!'); 31 | 32 | const squidEasterEggNftArgs = [name, symbol, baseTokenURI]; 33 | await verify(squidEasterEggNft.address, squidEasterEggNftArgs); 34 | 35 | console.log('SquidEasterEggNft deployed to:', squidEasterEggNft.address); 36 | } 37 | 38 | main() 39 | .then(() => process.exit(0)) 40 | .catch((error) => { 41 | console.error(error); 42 | process.exit(1); 43 | }); 44 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/mintPolygonNftFromAnyChain/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import { Squid } from "@0xsquid/sdk"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from the .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const rpcEndpoint: string = process.env.RPC_ENDPOINT!; 12 | const nftContractAddress: string = process.env.NFT_CONTRACT_ADDRESS!; 13 | 14 | // Define chain and token addresses 15 | const fromChainId = "1"; // Define departing chain, set to Ethereum by default 16 | const polygonId = "137"; // Polygon 17 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; // Define departing token 18 | 19 | // Define amount to be sent 20 | const amount = "10000000000000000"; 21 | 22 | // Import necessary ABI's 23 | import erc20Abi from "../abi/erc20Abi"; 24 | import nftContractAbi from "../abi/squidEasterEggNftAbi"; 25 | 26 | // Function to get Squid SDK instance 27 | const getSDK = (): Squid => { 28 | const squid = new Squid({ 29 | baseUrl: "https://v2.api.squidrouter.com", 30 | integratorId: integratorId, 31 | }); 32 | return squid; 33 | }; 34 | 35 | // Main function 36 | (async () => { 37 | // Set up JSON RPC provider and signer for source chain (Ethereum) 38 | const provider = new ethers.providers.JsonRpcProvider(rpcEndpoint); 39 | const signer = new ethers.Wallet(privateKey, provider); 40 | 41 | // Initialize Squid SDK 42 | const squid = getSDK(); 43 | await squid.init(); 44 | console.log("Initialized Squid SDK"); 45 | 46 | // Create contract interfaces and encode calldata 47 | const nftContractInterface = new ethers.utils.Interface(nftContractAbi); 48 | const mintEncodedData = nftContractInterface.encodeFunctionData("mint", [ 49 | signer.address, 50 | ]); 51 | 52 | const erc20ContractInterface = new ethers.utils.Interface(erc20Abi); 53 | const transferRemainingBalanceEncodeData = 54 | erc20ContractInterface.encodeFunctionData("transfer", [ 55 | signer.address, 56 | "0", 57 | ]); 58 | 59 | // Set up parameters for swapping tokens and minting NFT on Polygon 60 | const params = { 61 | fromAddress: signer.address, 62 | fromChain: fromChainId, 63 | fromToken: nativeToken, 64 | fromAmount: amount, 65 | toChain: polygonId, 66 | toToken: nativeToken, 67 | toAddress: signer.address, 68 | slippage: 1, 69 | quoteOnly: false, 70 | // Customize contract call for minting NFT on Polygon 71 | postHook: [ 72 | { 73 | callType: 0, // SquidCallType.DEFAULT 74 | target: nftContractAddress, 75 | value: "0", 76 | callData: mintEncodedData, 77 | payload: { 78 | tokenAddress: nativeToken, 79 | inputPos: 1, 80 | }, 81 | estimatedGas: "50000", 82 | }, 83 | { 84 | callType: 1, // SquidCallType.FULL_TOKEN_BALANCE 85 | target: nativeToken, 86 | value: "0", 87 | callData: transferRemainingBalanceEncodeData, 88 | payload: { 89 | tokenAddress: nativeToken, 90 | inputPos: 1, 91 | }, 92 | estimatedGas: "50000", 93 | }, 94 | ], 95 | }; 96 | 97 | console.log("Parameters:", params); 98 | 99 | // Get the swap route using Squid SDK 100 | const { route, requestId } = await squid.getRoute(params); 101 | console.log("Calculated route:", route.estimate.toAmount); 102 | 103 | // Execute the swap and minting transaction 104 | const tx = (await squid.executeRoute({ 105 | signer, 106 | route, 107 | })) as unknown as ethers.providers.TransactionResponse; 108 | const txReceipt = await tx.wait(); 109 | 110 | // Show the transaction receipt with Axelarscan link 111 | const axelarScanLink = 112 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 113 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 114 | 115 | // Wait a few seconds before checking the status 116 | await new Promise((resolve) => setTimeout(resolve, 5000)); 117 | 118 | // Retrieve the transaction's route status 119 | const getStatusParams = { 120 | transactionId: txReceipt.transactionHash, 121 | requestId: requestId, 122 | fromChainId: fromChainId, 123 | toChainId: polygonId, 124 | }; 125 | const status = await squid.getStatus(getStatusParams); 126 | 127 | // Display the route status 128 | console.log(`Route status: ${status.squidTransactionStatus}`); 129 | })(); 130 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/mintPolygonNftFromAnyChain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/repayAaveLoanWithdrawToBinance/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | BASE_RPC_ENDPOINT= # Base RPC endpoint 6 | AAVE_LENDING_POOL_ADDRESS= # Address of the Aave lending pool 7 | BINANCE_ADDRESS= # Binance address to withdraw to 8 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/repayAaveLoanWithdrawToBinance/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.7.0", 7 | "@0xsquid/squid-types": "^0.1.27", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "dotenv": "^16.3.1", 10 | "ethers": "^5.7.2" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/repayAaveLoanWithdrawToBinance/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import { Squid } from "@0xsquid/sdk"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const ethereumRpcEndpoint: string = process.env.ETHEREUM_RPC_ENDPOINT!; 12 | const aavePoolAddress: string = process.env.AAVE_POOL_ADDRESS!; 13 | const binanceAddress: string = process.env.BINANCE_ADDRESS!; 14 | 15 | // Define chain and token addresses 16 | const ethereumId = "1"; // Ethereum 17 | const binanceSmartChainId = "56"; // Binance Smart Chain 18 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 19 | 20 | // Define asset, amount, interest rate mode, and address 21 | const repayAsset = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; // The address of the borrowed underlying asset previously borrowed 22 | const repayAmount = "10000000000000000"; // The amount to repay - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` 23 | const repayInterestRateMode = 1; // The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable 24 | const repayOnBehalfOf = "0x0000000000000000000000000000000000000000"; // The address of the user who will get their debt reduced/removed. Should be the address of the user calling the function if they want to reduce/remove their own debt, or the address of any other other borrower whose debt should be removed 25 | 26 | // Import Aave lending pool ABI 27 | import aavePoolAbi from "../abi/aavePoolAbi"; 28 | 29 | // Function to get Squid SDK instance 30 | const getSDK = (): Squid => { 31 | const squid = new Squid({ 32 | baseUrl: "https://v2.api.squidrouter.com", 33 | integratorId: integratorId, 34 | }); 35 | return squid; 36 | }; 37 | 38 | // Main function 39 | (async () => { 40 | // Set up JSON RPC provider and signer 41 | const provider = new ethers.providers.JsonRpcProvider(ethereumRpcEndpoint); 42 | const signer = new ethers.Wallet(privateKey, provider); 43 | 44 | // Initialize Squid SDK 45 | const squid = getSDK(); 46 | await squid.init(); 47 | console.log("Initialized Squid SDK"); 48 | 49 | // Create contract interface and encode repay function for Aave 50 | const aaveLendingPoolInterface = new ethers.utils.Interface(aavePoolAbi); 51 | const repayEncodedData = aaveLendingPoolInterface.encodeFunctionData( 52 | "repay", 53 | [repayAsset, repayAmount, repayInterestRateMode, repayOnBehalfOf] 54 | ); 55 | 56 | // Set up parameters for repaying the loan, swapping tokens, and withdrawing 57 | const params = { 58 | fromAddress: signer.address, 59 | fromChain: ethereumId, 60 | fromToken: repayAsset, 61 | fromAmount: repayAmount, 62 | toChain: binanceSmartChainId, 63 | toToken: nativeToken, 64 | toAddress: binanceAddress, 65 | slippage: 1, 66 | quoteOnly: false, 67 | // Customize pre-hooks for repaying the loan 68 | preHooks: [ 69 | { 70 | callType: 0, // SquidCallType.DEFAULT 71 | target: aavePoolAddress, 72 | value: "0", 73 | callData: repayEncodedData, 74 | estimatedGas: "50000", 75 | payload: { 76 | tokenAddress: repayAsset, 77 | inputPos: 1, 78 | }, 79 | }, 80 | ], 81 | }; 82 | 83 | console.log("Parameters:", params); 84 | 85 | // Get the swap route using Squid SDK 86 | const { route, requestId } = await squid.getRoute(params); 87 | console.log("Calculated route: ", route.estimate.toAmount); 88 | console.log("Calculated fee costs: ", route.estimate.feeCosts); 89 | 90 | // Execute the repayment, swap, and withdrawal transaction 91 | const tx = (await squid.executeRoute({ 92 | signer, 93 | route, 94 | })) as unknown as ethers.providers.TransactionResponse; 95 | const txReceipt = await tx.wait(); 96 | 97 | // Show the transaction receipt with Axelarscan link 98 | const axelarScanLink = 99 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 100 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 101 | 102 | // Wait a few seconds before checking the status 103 | await new Promise((resolve) => setTimeout(resolve, 5000)); 104 | 105 | // Retrieve the transaction's route status 106 | const getStatusParams = { 107 | transactionId: txReceipt.transactionHash, 108 | requestId: requestId, 109 | fromChainId: ethereumId, 110 | toChainId: binanceSmartChainId, 111 | }; 112 | const status = await squid.getStatus(getStatusParams); 113 | 114 | // Display the route status 115 | console.log(`Route status: ${status.squidTransactionStatus}`); 116 | })(); 117 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/repayAaveLoanWithdrawToBinance/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapArbitrumEthToBaseUsdc/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | ARBITRUM_RPC_ENDPOINT=https://goerli-rollup.arbitrum.io/rpc 6 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapArbitrumEthToBaseUsdc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.7.0", 7 | "@0xsquid/squid-types": "^0.1.27", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "dotenv": "^16.3.1", 10 | "ethers": "^5.7.2" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapArbitrumEthToBaseUsdc/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import { Squid } from "@0xsquid/sdk"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const arbitrumRpcEndpoint: string = process.env.ARBITRUM_RPC_ENDPOINT!; 12 | 13 | // Define chain and token addresses 14 | const arbitrumChainId = "42161"; // Arbitrum 15 | const baseChainId = "8453"; // Base 16 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 17 | const baseUsdc = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"; 18 | 19 | // Define amount to be sent 20 | const amount = "10000000000000000"; 21 | 22 | // Function to get Squid SDK instance 23 | const getSDK = (): Squid => { 24 | const squid = new Squid({ 25 | baseUrl: "https://v2.api.squidrouter.com", 26 | integratorId: integratorId, 27 | }); 28 | return squid; 29 | }; 30 | 31 | // Main function 32 | (async () => { 33 | // Set up JSON RPC provider and signer 34 | const provider = new ethers.providers.JsonRpcProvider(arbitrumRpcEndpoint); 35 | const signer = new ethers.Wallet(privateKey, provider); 36 | 37 | // Initialize Squid SDK 38 | const squid = getSDK(); 39 | await squid.init(); 40 | console.log("Initialized Squid SDK"); 41 | 42 | // Set up parameters for swapping tokens 43 | const params = { 44 | fromAddress: signer.address, 45 | fromChain: arbitrumChainId, 46 | fromToken: nativeToken, 47 | fromAmount: amount, 48 | toChain: baseChainId, 49 | toToken: baseUsdc, 50 | toAddress: signer.address, 51 | slippage: 1, 52 | quoteOnly: false, 53 | }; 54 | 55 | console.log("Parameters:", params); 56 | 57 | // Get the swap route using Squid SDK 58 | const { route, requestId } = await squid.getRoute(params); 59 | console.log("Calculated route:", route.estimate.toAmount); 60 | 61 | // Execute the swap transaction 62 | const tx = (await squid.executeRoute({ 63 | signer, 64 | route, 65 | })) as unknown as ethers.providers.TransactionResponse; 66 | const txReceipt = await tx.wait(); 67 | 68 | // Show the transaction receipt with Axelarscan link 69 | const axelarScanLink = 70 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 71 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 72 | 73 | // Wait a few seconds before checking the status 74 | await new Promise((resolve) => setTimeout(resolve, 5000)); 75 | 76 | // Retrieve the transaction's route status 77 | const getStatusParams = { 78 | transactionId: txReceipt.transactionHash, 79 | requestId: requestId, 80 | fromChainId: arbitrumChainId, 81 | toChainId: baseChainId, 82 | }; 83 | const status = await squid.getStatus(getStatusParams); 84 | 85 | // Display the route status 86 | console.log(`Route status: ${status.squidTransactionStatus}`); 87 | })(); 88 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapArbitrumEthToBaseUsdc/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapAvalancheUsdcToMoonbeam/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | AVALANCHE_RPC_ENDPOINT= # Avalanche RPC endpoint 6 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapAvalancheUsdcToMoonbeam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.8.0-beta.0", 7 | "@0xsquid/squid-types": "^0.1.28", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "dotenv": "^16.3.1", 10 | "ethers": "6.7.1" 11 | } 12 | } -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapAvalancheUsdcToMoonbeam/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import { Squid } from "@0xsquid/sdk"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const avalancheRpcEndpoint: string = process.env.AVALANCHE_RPC_ENDPOINT!; 12 | 13 | // Define chain and token addresses 14 | const avalancheChainId = "43114"; // Avalanche 15 | const moonbeamChainId = "1284"; // Moonbeam 16 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 17 | const avalancheUsdc = "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664"; // USDC.e 18 | 19 | // Define amount to be sent 20 | const amount = "1000000000"; // 0.01 USDC 21 | 22 | // Function to get Squid SDK instance 23 | const getSDK = (): Squid => { 24 | const squid = new Squid({ 25 | baseUrl: "https://v2.api.squidrouter.com", 26 | integratorId: integratorId, 27 | }); 28 | return squid; 29 | }; 30 | 31 | // Main function 32 | (async () => { 33 | // Set up JSON RPC provider and signer 34 | const provider = new ethers.JsonRpcProvider(avalancheRpcEndpoint); 35 | const signer = new ethers.Wallet(privateKey, provider); 36 | 37 | // Initialize Squid SDK 38 | const squid = getSDK(); 39 | await squid.init(); 40 | console.log("Initialized Squid SDK"); 41 | 42 | // Set up parameters for swapping tokens 43 | const params = { 44 | fromAddress: signer.address, 45 | fromChain: avalancheChainId, 46 | fromToken: avalancheUsdc, 47 | fromAmount: amount, 48 | toChain: moonbeamChainId, 49 | toToken: nativeToken, 50 | toAddress: signer.address, 51 | slippage: 1, 52 | quoteOnly: false, 53 | }; 54 | 55 | console.log("Parameters:", params); 56 | 57 | // Get the swap route using Squid SDK 58 | const { route, requestId } = await squid.getRoute(params); 59 | console.log("Calculated route:", route.estimate.toAmount); 60 | 61 | const { isApproved, message } = await squid.isRouteApproved({ 62 | route, 63 | sender: signer.address, 64 | }); 65 | 66 | // check if route is approved 67 | if (!isApproved) { 68 | console.log("Route is not approved, approving now..."); 69 | const approve = await squid.approveRoute({ signer, route }); 70 | signer.provider.getNetwork; 71 | } 72 | console.log("Route is approved"); 73 | 74 | // Execute the swap transaction 75 | const tx = (await squid.executeRoute({ 76 | signer, 77 | route, 78 | })) as unknown as ethers.TransactionResponse; 79 | const txReceipt = await tx.wait(); 80 | 81 | // Show the transaction receipt with Axelarscan link 82 | const axelarScanLink = "https://axelarscan.io/gmp/" + txReceipt.hash; 83 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 84 | 85 | // Wait a few seconds before checking the status 86 | await new Promise((resolve) => setTimeout(resolve, 5000)); 87 | 88 | // Retrieve the transaction's route status 89 | const getStatusParams = { 90 | transactionId: txReceipt.hash, 91 | requestId: requestId, 92 | fromChainId: avalancheChainId, 93 | toChainId: moonbeamChainId, 94 | }; 95 | const status = await squid.getStatus(getStatusParams); 96 | 97 | // Display the route status 98 | console.log(`Route status: ${status.squidTransactionStatus}`); 99 | })(); 100 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapAvalancheUsdcToMoonbeam/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapEthereumToFantomAndStake/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | ETHEREUM_RPC_ENDPOINT= # Ethereum RPC endpoint 6 | STAKING_CONTRACT_ADDRESS= # Fantom staking contract address 7 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapEthereumToFantomAndStake/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.7.0", 7 | "@0xsquid/squid-types": "^0.1.27", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "dotenv": "^16.3.1", 10 | "ethers": "^5.7.2" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapEthereumToFantomAndStake/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import { Squid } from "@0xsquid/sdk"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const ethereumRpcEndpoint: string = process.env.ETHEREUM_RPC_ENDPOINT!; 12 | const stakingContractAddress: string = process.env.STAKING_CONTRACT_ADDRESS!; 13 | 14 | // Define chain and token addresses 15 | const ethereumId = "1"; // Ethereum 16 | const fantomId = "250"; // Fantom 17 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; 18 | const ethereumUsdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; 19 | 20 | // Define amount to swap and stake 21 | const amountToSwap = "10000000000000000"; 22 | 23 | // Import staking contract ABI 24 | import stakingContractAbi from "../abi/fantomSFC"; 25 | 26 | // Function to get Squid SDK instance 27 | const getSDK = (): Squid => { 28 | const squid = new Squid({ 29 | baseUrl: "https://v2.api.squidrouter.com", 30 | integratorId: integratorId, 31 | }); 32 | return squid; 33 | }; 34 | 35 | // Main function 36 | (async () => { 37 | // Set up JSON RPC provider and signer 38 | const provider = new ethers.providers.JsonRpcProvider(ethereumRpcEndpoint); 39 | const signer = new ethers.Wallet(privateKey, provider); 40 | 41 | // Initialize Squid SDK 42 | const squid = getSDK(); 43 | await squid.init(); 44 | console.log("Initialized Squid SDK"); 45 | 46 | // Create contract interface and encode delegate (Fantom staking) function 47 | const stakingContractInterface = new ethers.utils.Interface( 48 | stakingContractAbi 49 | ); 50 | const delegateEncodedData = stakingContractInterface.encodeFunctionData( 51 | "delegate", 52 | [amountToSwap] 53 | ); 54 | 55 | // Set up parameters for swapping tokens and staking 56 | const params = { 57 | fromAddress: signer.address, 58 | fromChain: ethereumId, 59 | fromToken: ethereumUsdc, 60 | fromAmount: amountToSwap, 61 | toChain: fantomId, 62 | toToken: nativeToken, 63 | toAddress: signer.address, 64 | slippage: 1, 65 | quoteOnly: false, 66 | // Customize contract call for staking on Fantom 67 | postHook: [ 68 | { 69 | callType: 1, // SquidCallType.FULL_TOKEN_BALANCE 70 | target: stakingContractAddress, 71 | value: "0", 72 | callData: delegateEncodedData, 73 | payload: { 74 | tokenAddress: ethereumUsdc, 75 | inputPos: 0, 76 | }, 77 | estimatedGas: "50000", 78 | }, 79 | ], 80 | }; 81 | 82 | console.log("Parameters:", params); 83 | 84 | // Get the swap route using Squid SDK 85 | const { route, requestId } = await squid.getRoute(params); 86 | console.log("Calculated route:", route.estimate.toAmount); 87 | console.log("Calculated fee costs: ", route.estimate.feeCosts); 88 | 89 | // Execute the swap and staking transaction 90 | const tx = (await squid.executeRoute({ 91 | signer, 92 | route, 93 | })) as unknown as ethers.providers.TransactionResponse; 94 | const txReceipt = await tx.wait(); 95 | 96 | // Show the transaction receipt with Axelarscan link 97 | const axelarScanLink = 98 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 99 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 100 | 101 | // Wait a few seconds before checking the status 102 | await new Promise((resolve) => setTimeout(resolve, 5000)); 103 | 104 | // Retrieve the transaction's route status 105 | const getStatusParams = { 106 | transactionId: txReceipt.transactionHash, 107 | requestId: requestId, 108 | fromChainId: ethereumId, 109 | toChainId: fantomId, 110 | }; 111 | const status = await squid.getStatus(getStatusParams); 112 | 113 | // Display the route status 114 | console.log(`Route status: ${status.squidTransactionStatus}`); 115 | })(); 116 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapEthereumToFantomAndStake/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapPolygonToArbitrumAndLend/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT= # RPC endpoint URL 6 | RADIANT_LENDING_POOL_ADDRESS= # Radiant Capital `lendingPool` address 7 | USDC_ARBITRUM_ADDRESS= # Arbitrum USDC.e address 8 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapPolygonToArbitrumAndLend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.7.0", 7 | "@0xsquid/squid-types": "^0.1.27", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "dotenv": "^16.3.1", 10 | "ethers": "^5.7.2" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapPolygonToArbitrumAndLend/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary libraries 2 | import { Squid } from "@0xsquid/sdk"; 3 | import { ethers } from "ethers"; 4 | 5 | // Load environment variables from the .env file 6 | import * as dotenv from "dotenv"; 7 | dotenv.config(); 8 | 9 | const privateKey: string = process.env.PRIVATE_KEY!; 10 | const integratorId: string = process.env.INTEGRATOR_ID!; // get one at https://form.typeform.com/to/cqFtqSvX 11 | const rpcEndpoint: string = process.env.RPC_ENDPOINT!; 12 | const radiantLendingPoolAddress = process.env.RADIANT_LENDING_POOL_ADDRESS!; 13 | const usdcArbitrumAddress = process.env.USDC_ARBITRUM_ADDRESS!; 14 | 15 | // Define chain and token addresses 16 | const polygonId = "137"; // Polygon 17 | const arbitrumId = "42161"; // Arbitrum 18 | const nativeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; // Define departing token 19 | 20 | // Define amount to be sent 21 | const amount = "10000000000000000"; 22 | 23 | // Import Radiant lending pool ABI 24 | import radiantLendingPoolAbi from "../abi/radiantLendingPoolAbi"; 25 | 26 | // Function to get Squid SDK instance 27 | const getSDK = (): Squid => { 28 | const squid = new Squid({ 29 | baseUrl: "https://v2.api.squidrouter.com", 30 | integratorId: integratorId, 31 | }); 32 | return squid; 33 | }; 34 | 35 | // Main function 36 | (async () => { 37 | // Set up JSON RPC provider and signer for source chain (Ethereum) 38 | const provider = new ethers.providers.JsonRpcProvider(rpcEndpoint); 39 | const signer = new ethers.Wallet(privateKey, provider); 40 | 41 | // Initialize Squid SDK 42 | const squid = getSDK(); 43 | await squid.init(); 44 | console.log("Initialized Squid SDK"); 45 | 46 | // Create contract interface and encode deposit function for Radiant lending pool 47 | const radiantLendingPoolInterface = new ethers.utils.Interface( 48 | radiantLendingPoolAbi 49 | ); 50 | const depositEncodedData = radiantLendingPoolInterface.encodeFunctionData( 51 | "deposit", 52 | [ 53 | usdcArbitrumAddress, 54 | "0", // Placeholder for dynamic balance 55 | signer.address, 56 | 0, 57 | ] 58 | ); 59 | 60 | // Set up parameters for swapping tokens and depositing into Radiant lending pool 61 | const params = { 62 | fromAddress: signer.address, 63 | fromChain: polygonId, 64 | fromToken: nativeToken, 65 | fromAmount: amount, 66 | toChain: arbitrumId, 67 | toToken: usdcArbitrumAddress, 68 | toAddress: signer.address, 69 | slippage: 1, 70 | quoteOnly: false, 71 | // Customize contract call for depositing on Arbitrum 72 | postHook: [ 73 | { 74 | callType: 1, // SquidCallType.FULL_TOKEN_BALANCE 75 | target: radiantLendingPoolAddress, 76 | value: "0", 77 | callData: depositEncodedData, 78 | payload: { 79 | tokenAddress: usdcArbitrumAddress, 80 | inputPos: 1, 81 | }, 82 | estimatedGas: "50000", 83 | }, 84 | ], 85 | }; 86 | 87 | console.log("Parameters:", params); 88 | 89 | // Get the swap route using Squid SDK 90 | const { route, requestId } = await squid.getRoute(params); 91 | console.log("Calculated route:", route.estimate.toAmount); 92 | 93 | // Execute the swap and deposit transaction 94 | const tx = (await squid.executeRoute({ 95 | signer, 96 | route, 97 | })) as unknown as ethers.providers.TransactionResponse; 98 | const txReceipt = await tx.wait(); 99 | 100 | // Show the transaction receipt with Axelarscan link 101 | const axelarScanLink = 102 | "https://axelarscan.io/gmp/" + txReceipt.transactionHash; 103 | console.log(`Finished! Check Axelarscan for details: ${axelarScanLink}`); 104 | 105 | // Wait a few seconds before checking the status 106 | await new Promise((resolve) => setTimeout(resolve, 5000)); 107 | 108 | // Retrieve the transaction's route status 109 | const getStatusParams = { 110 | transactionId: txReceipt.transactionHash, 111 | requestId: requestId, 112 | fromChainId: polygonId, 113 | toChainId: arbitrumId, 114 | }; 115 | const status = await squid.getStatus(getStatusParams); 116 | 117 | // Display the route status 118 | console.log(`Route status: ${status.squidTransactionStatus}`); 119 | })(); 120 | -------------------------------------------------------------------------------- /V2/sdk/oldExamples/swapPolygonToArbitrumAndLend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /V2/sdk/swapEVMtoEVMAndLendPosthook/.env.example: -------------------------------------------------------------------------------- 1 | # Copy this file to a file called .env in the same directory and fill in the values. 2 | 3 | PRIVATE_KEY= # 1a2b3c... your private key 4 | INTEGRATOR_ID= # Squid integratorId can be obtained from https://l19g3aali76.typeform.com/integrator-id 5 | RPC_ENDPOINT= https://bsc-dataseed.binance.org/ 6 | -------------------------------------------------------------------------------- /V2/sdk/swapEVMtoEVMAndLendPosthook/abi/erc20Abi.ts: -------------------------------------------------------------------------------- 1 | const erc20Abi = [ 2 | { 3 | constant: true, 4 | inputs: [], 5 | name: "name", 6 | outputs: [ 7 | { 8 | name: "", 9 | type: "string", 10 | }, 11 | ], 12 | payable: false, 13 | stateMutability: "view", 14 | type: "function", 15 | }, 16 | { 17 | constant: false, 18 | inputs: [ 19 | { 20 | name: "_spender", 21 | type: "address", 22 | }, 23 | { 24 | name: "_value", 25 | type: "uint256", 26 | }, 27 | ], 28 | name: "approve", 29 | outputs: [ 30 | { 31 | name: "", 32 | type: "bool", 33 | }, 34 | ], 35 | payable: false, 36 | stateMutability: "nonpayable", 37 | type: "function", 38 | }, 39 | { 40 | constant: true, 41 | inputs: [], 42 | name: "totalSupply", 43 | outputs: [ 44 | { 45 | name: "", 46 | type: "uint256", 47 | }, 48 | ], 49 | payable: false, 50 | stateMutability: "view", 51 | type: "function", 52 | }, 53 | { 54 | constant: false, 55 | inputs: [ 56 | { 57 | name: "_from", 58 | type: "address", 59 | }, 60 | { 61 | name: "_to", 62 | type: "address", 63 | }, 64 | { 65 | name: "_value", 66 | type: "uint256", 67 | }, 68 | ], 69 | name: "transferFrom", 70 | outputs: [ 71 | { 72 | name: "", 73 | type: "bool", 74 | }, 75 | ], 76 | payable: false, 77 | stateMutability: "nonpayable", 78 | type: "function", 79 | }, 80 | { 81 | constant: true, 82 | inputs: [], 83 | name: "decimals", 84 | outputs: [ 85 | { 86 | name: "", 87 | type: "uint8", 88 | }, 89 | ], 90 | payable: false, 91 | stateMutability: "view", 92 | type: "function", 93 | }, 94 | { 95 | constant: true, 96 | inputs: [ 97 | { 98 | name: "_owner", 99 | type: "address", 100 | }, 101 | ], 102 | name: "balanceOf", 103 | outputs: [ 104 | { 105 | name: "balance", 106 | type: "uint256", 107 | }, 108 | ], 109 | payable: false, 110 | stateMutability: "view", 111 | type: "function", 112 | }, 113 | { 114 | constant: true, 115 | inputs: [], 116 | name: "symbol", 117 | outputs: [ 118 | { 119 | name: "", 120 | type: "string", 121 | }, 122 | ], 123 | payable: false, 124 | stateMutability: "view", 125 | type: "function", 126 | }, 127 | { 128 | constant: false, 129 | inputs: [ 130 | { 131 | name: "_to", 132 | type: "address", 133 | }, 134 | { 135 | name: "_value", 136 | type: "uint256", 137 | }, 138 | ], 139 | name: "transfer", 140 | outputs: [ 141 | { 142 | name: "", 143 | type: "bool", 144 | }, 145 | ], 146 | payable: false, 147 | stateMutability: "nonpayable", 148 | type: "function", 149 | }, 150 | { 151 | constant: true, 152 | inputs: [ 153 | { 154 | name: "_owner", 155 | type: "address", 156 | }, 157 | { 158 | name: "_spender", 159 | type: "address", 160 | }, 161 | ], 162 | name: "allowance", 163 | outputs: [ 164 | { 165 | name: "", 166 | type: "uint256", 167 | }, 168 | ], 169 | payable: false, 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | payable: true, 175 | stateMutability: "payable", 176 | type: "fallback", 177 | }, 178 | { 179 | anonymous: false, 180 | inputs: [ 181 | { 182 | indexed: true, 183 | name: "owner", 184 | type: "address", 185 | }, 186 | { 187 | indexed: true, 188 | name: "spender", 189 | type: "address", 190 | }, 191 | { 192 | indexed: false, 193 | name: "value", 194 | type: "uint256", 195 | }, 196 | ], 197 | name: "Approval", 198 | type: "event", 199 | }, 200 | { 201 | anonymous: false, 202 | inputs: [ 203 | { 204 | indexed: true, 205 | name: "from", 206 | type: "address", 207 | }, 208 | { 209 | indexed: true, 210 | name: "to", 211 | type: "address", 212 | }, 213 | { 214 | indexed: false, 215 | name: "value", 216 | type: "uint256", 217 | }, 218 | ], 219 | name: "Transfer", 220 | type: "event", 221 | }, 222 | ]; 223 | 224 | export default erc20Abi; 225 | -------------------------------------------------------------------------------- /V2/sdk/swapEVMtoEVMAndLendPosthook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "ts-node src/index.ts" 4 | }, 5 | "dependencies": { 6 | "@0xsquid/sdk": "^2.9.3", 7 | "@0xsquid/squid-types": "^0.1.145", 8 | "@openzeppelin/contracts": "^4.9.3", 9 | "dotenv": "^16.3.1", 10 | "ethers": "^6.8.1" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /V2/sdk/swapEVMtoEVMAndLendPosthook/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | --------------------------------------------------------------------------------