Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Implement token swaps in the SDK (#35)
Browse files Browse the repository at this point in the history
* Hey cool we can _swap tokens_ now, man.

* Forgot to commit abigen

* dedupe code

* Make deadline a param

* cleanup

* Really refactor the hell out of this.

* EVEN MORE

* src/swaps => src/tokenswap

* Fix imports

* Move detailedTokenSwapMap to TokenSwap namespace
  • Loading branch information
bleaker0x committed Jan 28, 2022
1 parent aa2d655 commit 3d8ea4e
Show file tree
Hide file tree
Showing 27 changed files with 6,583 additions and 313 deletions.
4 changes: 3 additions & 1 deletion scripts/abigen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ process_abi "contracts/bridge/SynapseBridge.sol" "SynapseBridge"
process_abi "contracts/bridge/SynapseERC20.sol" "SynapseERC20"
process_abi "contracts/bridge/wrappers/L2BridgeZap.sol" "L2BridgeZap"
process_abi "contracts/bridge/wrappers/L1BridgeZap.sol" "L1BridgeZap"
process_abi "contracts/bridge/BridgeConfig.sol" "BridgeConfig"
process_abi "contracts/bridge/BridgeConfig.sol" "BridgeConfig"
process_abi "contracts/bridge/PoolConfig.sol" "PoolConfig"
process_abi "contracts/amm/SwapFlashLoan.sol" "SwapFlashLoan"
386 changes: 386 additions & 0 deletions src/abis/PoolConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,386 @@
const ABI = {
"abi": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "previousAdminRole",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "newAdminRole",
"type": "bytes32"
}
],
"name": "RoleAdminChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "RoleGranted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "RoleRevoked",
"type": "event"
},
{
"inputs": [],
"name": "BRIDGEMANAGER_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "DEFAULT_ADMIN_ROLE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "chainID",
"type": "uint256"
}
],
"name": "getPoolConfig",
"outputs": [
{
"components": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "chainId",
"type": "uint256"
},
{
"internalType": "address",
"name": "poolAddress",
"type": "address"
},
{
"internalType": "bool",
"name": "metaswap",
"type": "bool"
}
],
"internalType": "struct PoolConfig.Pool",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
}
],
"name": "getRoleAdmin",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "getRoleMember",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
}
],
"name": "getRoleMemberCount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "grantRole",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "hasRole",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "renounceRole",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "revokeRole",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "chainID",
"type": "uint256"
},
{
"internalType": "address",
"name": "poolAddress",
"type": "address"
},
{
"internalType": "bool",
"name": "metaswap",
"type": "bool"
}
],
"name": "setPoolConfig",
"outputs": [
{
"components": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "chainId",
"type": "uint256"
},
{
"internalType": "address",
"name": "poolAddress",
"type": "address"
},
{
"internalType": "bool",
"name": "metaswap",
"type": "bool"
}
],
"internalType": "struct PoolConfig.Pool",
"name": "",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
],
"devdoc": {
"kind": "dev",
"methods": {
"getRoleAdmin(bytes32)": {
"details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."
},
"getRoleMember(bytes32,uint256)": {
"details": "Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."
},
"getRoleMemberCount(bytes32)": {
"details": "Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."
},
"grantRole(bytes32,address)": {
"details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."
},
"hasRole(bytes32,address)": {
"details": "Returns `true` if `account` has been granted `role`."
},
"renounceRole(bytes32,address)": {
"details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`."
},
"revokeRole(bytes32,address)": {
"details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."
}
},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
}

export default ABI
Loading

0 comments on commit 3d8ea4e

Please sign in to comment.