Skip to content

Commit

Permalink
feat: adds base support for tc base (#1157)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
towanTG and github-actions[bot] authored Jan 13, 2025
1 parent e5ff01b commit c900df6
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/young-ghosts-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@swapkit/plugin-thorchain": minor
"@swapkit/contracts": minor
---

Adds support for Base Chain on TC
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/

.idea/
dist/
build/
cache/
Expand Down
16 changes: 10 additions & 6 deletions packages/plugins/thorchain/src/tcPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type SwapKitPluginParams,
type SwapParams,
TCAvalancheDepositABI,
TCBaseDepositABI,
TCBscDepositABI,
TCEthereumVaultAbi,
type UTXOChain,
Expand Down Expand Up @@ -74,16 +75,19 @@ function plugin({ getWallet, stagenet = false }: SwapKitPluginParams) {

case Chain.Ethereum:
case Chain.BinanceSmartChain:
case Chain.Base:
case Chain.Avalanche: {
const wallet = getWallet(chain);
const { getChecksumAddressFromAsset } = await import("@swapkit/toolbox-evm");

const abi =
chain === Chain.Avalanche
? TCAvalancheDepositABI
: chain === Chain.BinanceSmartChain
? TCBscDepositABI
: TCEthereumVaultAbi;
const ChainSpecificAbi = {
[Chain.Avalanche]: TCAvalancheDepositABI,
[Chain.Base]: TCBaseDepositABI,
[Chain.BinanceSmartChain]: TCBscDepositABI,
[Chain.Ethereum]: TCEthereumVaultAbi,
};

const abi = ChainSpecificAbi[chain];

return wallet.call<string>({
abi,
Expand Down
154 changes: 154 additions & 0 deletions packages/swapkit/contracts/src/abis/tcEthVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,157 @@ export const TCBscDepositABI = [
type: "function",
},
];

export const TCBaseDepositABI = [
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "to", type: "address" },
{ indexed: true, internalType: "address", name: "asset", type: "address" },
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
{ indexed: false, internalType: "string", name: "memo", type: "string" },
],
name: "Deposit",
type: "event",
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "oldVault", type: "address" },
{ indexed: true, internalType: "address", name: "newVault", type: "address" },
{ indexed: false, internalType: "address", name: "asset", type: "address" },
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
{ indexed: false, internalType: "string", name: "memo", type: "string" },
],
name: "TransferAllowance",
type: "event",
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "vault", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{ indexed: false, internalType: "address", name: "asset", type: "address" },
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
{ indexed: false, internalType: "string", name: "memo", type: "string" },
],
name: "TransferOut",
type: "event",
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "vault", type: "address" },
{ indexed: false, internalType: "address", name: "target", type: "address" },
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
{ indexed: false, internalType: "address", name: "finalAsset", type: "address" },
{ indexed: false, internalType: "address", name: "to", type: "address" },
{ indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
{ indexed: false, internalType: "string", name: "memo", type: "string" },
],
name: "TransferOutAndCall",
type: "event",
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "oldVault", type: "address" },
{ indexed: true, internalType: "address", name: "newVault", type: "address" },
{
components: [
{ internalType: "address", name: "asset", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
],
indexed: false,
internalType: "struct THORChain_Router.Coin[]",
name: "coins",
type: "tuple[]",
},
{ indexed: false, internalType: "string", name: "memo", type: "string" },
],
name: "VaultTransfer",
type: "event",
},
{
inputs: [
{ internalType: "address payable", name: "vault", type: "address" },
{ internalType: "address", name: "asset", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "string", name: "memo", type: "string" },
{ internalType: "uint256", name: "expiration", type: "uint256" },
],
name: "depositWithExpiry",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "router", type: "address" },
{ internalType: "address payable", name: "asgard", type: "address" },
{
components: [
{ internalType: "address", name: "asset", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
],
internalType: "struct THORChain_Router.Coin[]",
name: "coins",
type: "tuple[]",
},
{ internalType: "string", name: "memo", type: "string" },
],
name: "returnVaultAssets",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "router", type: "address" },
{ internalType: "address", name: "newVault", type: "address" },
{ internalType: "address", name: "asset", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "string", name: "memo", type: "string" },
],
name: "transferAllowance",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address payable", name: "to", type: "address" },
{ internalType: "address", name: "asset", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "string", name: "memo", type: "string" },
],
name: "transferOut",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ internalType: "address payable", name: "target", type: "address" },
{ internalType: "address", name: "finalToken", type: "address" },
{ internalType: "address", name: "to", type: "address" },
{ internalType: "uint256", name: "amountOutMin", type: "uint256" },
{ internalType: "string", name: "memo", type: "string" },
],
name: "transferOutAndCall",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "vault", type: "address" },
{ internalType: "address", name: "token", type: "address" },
],
name: "vaultAllowance",
outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
stateMutability: "view",
type: "function",
},
];
8 changes: 7 additions & 1 deletion packages/swapkit/contracts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import { MayaArbitrumVaultAbi, MayaEthereumVaultAbi } from "./abis/mayaEvmVaults
import { pancakeV2 } from "./abis/pancakeV2";
import { pangolin } from "./abis/pangolin";
import { sushiswap } from "./abis/sushiswap";
import { TCAvalancheDepositABI, TCBscDepositABI, TCEthereumVaultAbi } from "./abis/tcEthVault";
import {
TCAvalancheDepositABI,
TCBaseDepositABI,
TCBscDepositABI,
TCEthereumVaultAbi,
} from "./abis/tcEthVault";
import { traderJoe } from "./abis/traderJoe";
import { uniswapV2 } from "./abis/uniswapV2";
import { uniswapV2Leg } from "./abis/uniswapV2Leg";
Expand Down Expand Up @@ -58,6 +63,7 @@ export {
TCEthereumVaultAbi,
TCAvalancheDepositABI,
TCBscDepositABI,
TCBaseDepositABI,
MayaArbitrumVaultAbi,
MayaEthereumVaultAbi,
};
Expand Down

0 comments on commit c900df6

Please sign in to comment.