forked from paraswap/paraswap-dex-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
601 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable no-console */ | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable no-console */ | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable no-console */ | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
[ | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "_quoteToken", "type": "address" }, | ||
{ | ||
"internalType": "address[]", | ||
"name": "_baseTokens", | ||
"type": "address[]" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "previousOwner", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "newOwner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "OwnershipTransferred", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "token", "type": "address" } | ||
], | ||
"name": "addBaseToken", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "allBaseTokens", | ||
"outputs": [ | ||
{ "internalType": "address[]", "name": "", "type": "address[]" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "allBaseTokensLength", | ||
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "getSupportTokens", | ||
"outputs": [ | ||
{ "internalType": "address", "name": "", "type": "address" }, | ||
{ "internalType": "address[]", "name": "", "type": "address[]" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "owner", | ||
"outputs": [{ "internalType": "address", "name": "", "type": "address" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "quoteToken", | ||
"outputs": [{ "internalType": "address", "name": "", "type": "address" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "token", "type": "address" } | ||
], | ||
"name": "removeBaseToken", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "renounceOwnership", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "_quoteToken", "type": "address" } | ||
], | ||
"name": "setQutoeToken", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "newOwner", "type": "address" } | ||
], | ||
"name": "transferOwnership", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { BytesLike } from 'ethers'; | ||
import { defaultAbiCoder } from 'ethers/lib/utils'; | ||
import { extractSuccessAndValue, generalDecoder } from '../../lib/decoders'; | ||
import { MultiResult } from '../../lib/multi-wrapper'; | ||
import { DecimalInfo, TokenInfo, TokenState } from './types'; | ||
|
||
export function tokenInfoDecoder( | ||
result: MultiResult<BytesLike> | BytesLike, | ||
): TokenInfo { | ||
return generalDecoder(result, ['uint192', 'uint16'], undefined, value => ({ | ||
reserve: value[0].toBigInt(), | ||
feeRate: value[1].toBigInt(), | ||
})); | ||
} | ||
|
||
export function decimalInfoDecoder( | ||
result: MultiResult<BytesLike> | BytesLike, | ||
): DecimalInfo { | ||
return generalDecoder( | ||
result, | ||
['tuple(uint64 priceDec, uint64 quoteDec, uint64 baseDec)'], | ||
undefined, | ||
value => ({ | ||
priceDec: value[0].priceDec.toBigInt(), | ||
quoteDec: value[0].quoteDec.toBigInt(), | ||
baseDec: value[0].baseDec.toBigInt(), | ||
}), | ||
); | ||
} | ||
|
||
// This is state from WooOracleV2 contract | ||
export function stateDecoder( | ||
result: MultiResult<BytesLike> | BytesLike, | ||
): TokenState { | ||
return generalDecoder( | ||
result, | ||
['tuple(uint128 price, uint64 spread, uint64 coeff, bool woFeasible)'], | ||
undefined, | ||
value => ({ | ||
price: value[0].toBigInt(), | ||
spread: value[0].toBigInt(), | ||
coeff: value[0].toBigInt(), | ||
}), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Interface } from 'ethers/lib/utils'; | ||
import wooPPV2ABI from '../../abi/woo-fi-v2/WooPPV2.abi.json'; | ||
import wooOracleV2ABI from '../../abi/woo-fi-v2/WooOracleV2.abi.json'; | ||
import wooIntegrationHelper from '../../abi/woo-fi-v2/IntegrationHelper.abi.json'; | ||
import { WooFiV2Interfaces } from './types'; | ||
|
||
export const ifaces: WooFiV2Interfaces = { | ||
PPV2: new Interface(wooPPV2ABI), | ||
oracleV2: new Interface(wooOracleV2ABI), | ||
integrationHelper: new Interface(wooIntegrationHelper), | ||
chainlink: new Interface([ | ||
'function latestRoundData() view returns (tuple(uint80 roundId, ' + | ||
'int256 answer, uint256 startedAt, uint256 updatedAt, ' + | ||
'uint80 answeredInRound))', | ||
]), | ||
erc20BalanceOf: new Interface([ | ||
'function balanceOf(address) view returns (uint256)', | ||
]), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.