Skip to content

Commit

Permalink
adding balance module skeleton
Browse files Browse the repository at this point in the history
adding erc20
updating solve intent processes
adding ws decoder helper
adding selector utils
adding solvers and source intents to the db and configs
adding redlock lock function wrapper
adding intent service create and validate for intent
adding intent service feasable function skelleton
adding timestamp to sourceintent model schema
  • Loading branch information
StoyanD committed Aug 13, 2024
1 parent 9c7eb15 commit fa151c6
Show file tree
Hide file tree
Showing 20 changed files with 813 additions and 66 deletions.
35 changes: 28 additions & 7 deletions config/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@ export default {
logger: {
usePino: false,
},
contracts: {
sourceIntents: [
{
network: 'opt-sepolia',
sourceAddress: '0x6B79cD3fE2Eccd3a69c52e621a81d26E75983787',
sourceIntents: [
{
network: 'opt-sepolia',
sourceAddress: '0x6B79cD3fE2Eccd3a69c52e621a81d26E75983787',
},
],
solvers: {
84532: {
solverAddress: '0x5d0cab22a8E2F01CE4482F2CbFE304627d8F1816',
targets: {
//base sepolia USDC
'0xAb1D243b07e99C91dE9E4B80DFc2B07a8332A2f7': {
contractType: 'erc20',
selectors: ['transfer(address,uint256)'],
},
},
],
solvers: [],
network: 'base-sepolia',
},
11155420: {
solverAddress: '0x5d0cab22a8E2F01CE4482F2CbFE304627d8F1816', //todo update to real address
targets: {
//op sepolia USDC
'0x5fd84259d66Cd46123540766Be93DFE6D43130D7': {
contractType: 'erc20',
selectors: ['transfer(address,uint256)'],
},
},
network: 'op-sepolia',
},
},
}
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import { EventEmitterModule } from '@nestjs/event-emitter'
import { RedlockModule } from './nest-redlock/nest-redlock.module'
import { SolveIntentModule } from './source-intent/source-intent.module'
import { SourceIntentModel } from './source-intent/schemas/source-intent.schema'
import { BalanceModule } from './balance/balance.module'

@Module({
imports: [
AlchemyModule,
BalanceModule,
ChainMonitorModule,
EcoConfigModule,
EventEmitterModule.forRoot({
Expand Down
340 changes: 340 additions & 0 deletions src/assets/abis/ERC20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "ERC20",
"sourceName": "contracts/ERC20.sol",
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "name_",
"type": "string"
},
{
"internalType": "string",
"name": "symbol_",
"type": "string"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "allowance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "ERC20InsufficientAllowance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "ERC20InsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "approver",
"type": "address"
}
],
"name": "ERC20InvalidApprover",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "ERC20InvalidReceiver",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "ERC20InvalidSender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "ERC20InvalidSpender",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x6080604052346103d057610aba80380380610019816103d5565b9283398101906060818303126103d05780516001600160401b0381116103d057826100459183016103fa565b60208201519092906001600160401b0381116103d0576040916100699184016103fa565b91015182516001600160401b0381116102d957600354600181811c911680156103c6575b60208210146102b957601f8111610361575b506020601f82116001146102fa57819293946000926102ef575b50508160011b916000199060031b1c1916176003555b81516001600160401b0381116102d957600454600181811c911680156102cf575b60208210146102b957601f8111610254575b50602092601f82116001146101ef57928192936000926101e4575b50508160011b916000199060031b1c1916176004555b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156101b85733156101ce576002548181018091116101b857600255600033815280602052604081208281540190556040519182527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203393a360405161065490816104668239f35b634e487b7160e01b600052601160045260246000fd5b63ec442f0560e01b600052600060045260246000fd5b01519050388061011d565b601f198216936004600052806000209160005b86811061023c5750836001959610610223575b505050811b01600455610133565b015160001960f88460031b161c19169055388080610215565b91926020600181928685015181550194019201610202565b60046000527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f830160051c810191602084106102af575b601f0160051c01905b8181106102a35750610102565b60008155600101610296565b909150819061028d565b634e487b7160e01b600052602260045260246000fd5b90607f16906100f0565b634e487b7160e01b600052604160045260246000fd5b0151905038806100b9565b601f198216906003600052806000209160005b81811061034957509583600195969710610330575b505050811b016003556100cf565b015160001960f88460031b161c19169055388080610322565b9192602060018192868b01518155019401920161030d565b60036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f830160051c810191602084106103bc575b601f0160051c01905b8181106103b0575061009f565b600081556001016103a3565b909150819061039a565b90607f169061008d565b600080fd5b6040519190601f01601f191682016001600160401b038111838210176102d957604052565b81601f820112156103d0578051906001600160401b0382116102d957610429601f8301601f19166020016103d5565b92828452602083830101116103d05760005b82811061045057505060206000918301015290565b8060208092840101518282870101520161043b56fe608080604052600436101561001357600080fd5b60003560e01c90816306fdde031461041157508063095ea7b31461038b57806318160ddd1461036d57806323b872dd14610280578063313ce5671461026457806370a082311461022a57806395d89b4114610109578063a9059cbb146100d85763dd62ed3e1461008257600080fd5b346100d35760403660031901126100d35761009b61052d565b6100a3610543565b6001600160a01b039182166000908152600160209081526040808320949093168252928352819020549051908152f35b600080fd5b346100d35760403660031901126100d3576100fe6100f461052d565b6024359033610559565b602060405160018152f35b346100d35760003660031901126100d35760405160006004548060011c90600181168015610220575b60208310811461020c578285529081156101f05750600114610199575b50819003601f01601f191681019067ffffffffffffffff8211818310176101835761017f829182604052826104e4565b0390f35b634e487b7160e01b600052604160045260246000fd5b905060046000527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b6000905b8282106101da5750602091508201018261014f565b60018160209254838588010152019101906101c5565b90506020925060ff191682840152151560051b8201018261014f565b634e487b7160e01b84526022600452602484fd5b91607f1691610132565b346100d35760203660031901126100d3576001600160a01b0361024b61052d565b1660005260006020526020604060002054604051908152f35b346100d35760003660031901126100d357602060405160128152f35b346100d35760603660031901126100d35761029961052d565b6102a1610543565b6001600160a01b03821660008181526001602081815260408084203385529091529091205491936044359392909181016102e1575b506100fe9350610559565b83811061035057841561033a573315610324576100fe946000526001602052604060002060018060a01b03331660005260205283604060002091039055846102d6565b634a1406b160e11b600052600060045260246000fd5b63e602df0560e01b600052600060045260246000fd5b8390637dc7a0d960e11b6000523360045260245260445260646000fd5b346100d35760003660031901126100d3576020600254604051908152f35b346100d35760403660031901126100d3576103a461052d565b60243590331561033a576001600160a01b031690811561032457336000526001602052604060002082600052602052806040600020556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b346100d35760003660031901126100d35760006003548060011c906001811680156104da575b60208310811461020c578285529081156101f057506001146104835750819003601f01601f191681019067ffffffffffffffff8211818310176101835761017f829182604052826104e4565b905060036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b6000905b8282106104c45750602091508201018261014f565b60018160209254838588010152019101906104af565b91607f1691610437565b91909160208152825180602083015260005b818110610517575060409293506000838284010152601f8019910116010190565b80602080928701015160408286010152016104f6565b600435906001600160a01b03821682036100d357565b602435906001600160a01b03821682036100d357565b6001600160a01b0316908115610608576001600160a01b03169182156105f25760008281528060205260408120548281106105d85791604082827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef958760209652828652038282205586815280845220818154019055604051908152a3565b916064928463391434e360e21b8452600452602452604452fd5b63ec442f0560e01b600052600060045260246000fd5b634b637e8f60e11b600052600060045260246000fdfea2646970667358221220bc33fab0bc4af527fd269c7b93ba3251c267c7e3d8d5d36d7fba4c18ad8a843264736f6c634300081a0033",
"deployedBytecode": "0x608080604052600436101561001357600080fd5b60003560e01c90816306fdde031461041157508063095ea7b31461038b57806318160ddd1461036d57806323b872dd14610280578063313ce5671461026457806370a082311461022a57806395d89b4114610109578063a9059cbb146100d85763dd62ed3e1461008257600080fd5b346100d35760403660031901126100d35761009b61052d565b6100a3610543565b6001600160a01b039182166000908152600160209081526040808320949093168252928352819020549051908152f35b600080fd5b346100d35760403660031901126100d3576100fe6100f461052d565b6024359033610559565b602060405160018152f35b346100d35760003660031901126100d35760405160006004548060011c90600181168015610220575b60208310811461020c578285529081156101f05750600114610199575b50819003601f01601f191681019067ffffffffffffffff8211818310176101835761017f829182604052826104e4565b0390f35b634e487b7160e01b600052604160045260246000fd5b905060046000527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b6000905b8282106101da5750602091508201018261014f565b60018160209254838588010152019101906101c5565b90506020925060ff191682840152151560051b8201018261014f565b634e487b7160e01b84526022600452602484fd5b91607f1691610132565b346100d35760203660031901126100d3576001600160a01b0361024b61052d565b1660005260006020526020604060002054604051908152f35b346100d35760003660031901126100d357602060405160128152f35b346100d35760603660031901126100d35761029961052d565b6102a1610543565b6001600160a01b03821660008181526001602081815260408084203385529091529091205491936044359392909181016102e1575b506100fe9350610559565b83811061035057841561033a573315610324576100fe946000526001602052604060002060018060a01b03331660005260205283604060002091039055846102d6565b634a1406b160e11b600052600060045260246000fd5b63e602df0560e01b600052600060045260246000fd5b8390637dc7a0d960e11b6000523360045260245260445260646000fd5b346100d35760003660031901126100d3576020600254604051908152f35b346100d35760403660031901126100d3576103a461052d565b60243590331561033a576001600160a01b031690811561032457336000526001602052604060002082600052602052806040600020556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b346100d35760003660031901126100d35760006003548060011c906001811680156104da575b60208310811461020c578285529081156101f057506001146104835750819003601f01601f191681019067ffffffffffffffff8211818310176101835761017f829182604052826104e4565b905060036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b6000905b8282106104c45750602091508201018261014f565b60018160209254838588010152019101906104af565b91607f1691610437565b91909160208152825180602083015260005b818110610517575060409293506000838284010152601f8019910116010190565b80602080928701015160408286010152016104f6565b600435906001600160a01b03821682036100d357565b602435906001600160a01b03821682036100d357565b6001600160a01b0316908115610608576001600160a01b03169182156105f25760008281528060205260408120548281106105d85791604082827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef958760209652828652038282205586815280845220818154019055604051908152a3565b916064928463391434e360e21b8452600452602452604452fd5b63ec442f0560e01b600052600060045260246000fd5b634b637e8f60e11b600052600060045260246000fdfea2646970667358221220bc33fab0bc4af527fd269c7b93ba3251c267c7e3d8d5d36d7fba4c18ad8a843264736f6c634300081a0033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Loading

0 comments on commit fa151c6

Please sign in to comment.