-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from nimishpatel19/Bug27-withdrawbalance-error
Bug #27 Can't withdraw full balance at once solved
- Loading branch information
Showing
77 changed files
with
2,620 additions
and
9,865 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 |
---|---|---|
|
@@ -34,9 +34,6 @@ bower_components | |
.DS_Store | ||
Thumbs.db | ||
|
||
# Ignore built ts files | ||
dist/**/* | ||
|
||
# ignore yarn.lock | ||
yarn.lock | ||
|
||
|
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 @@ | ||
export {}; |
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,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const facade_1 = require("../facade"); | ||
describe('account', () => { | ||
it('decode', () => { | ||
const account = new facade_1.Account(facade_1.CHAINS.TERRA); | ||
console.log(account.toData()); | ||
}); | ||
}); |
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 @@ | ||
export {}; |
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
import { AddressProvider, DENOMS } from './provider'; | ||
export interface AddressMap { | ||
mmMarket: string; | ||
mmOverseer: string; | ||
aTerra: string; | ||
} | ||
export declare type AllowedAddressKeys = keyof AddressMap; | ||
export declare class AddressProviderFromJson implements AddressProvider { | ||
private data; | ||
constructor(data: AddressMap); | ||
market(): string; | ||
overseer(): string; | ||
aTerra(denom: DENOMS): string; | ||
} |
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,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AddressProviderFromJson = void 0; | ||
const provider_1 = require("./provider"); | ||
class AddressProviderFromJson { | ||
constructor(data) { | ||
this.data = data; | ||
} | ||
market() { | ||
return this.data.mmMarket; | ||
} | ||
overseer() { | ||
return this.data.mmOverseer; | ||
} | ||
aTerra(denom) { | ||
if (denom == provider_1.DENOMS.UST) { | ||
return this.data.aTerra; | ||
} | ||
return ''; | ||
} | ||
} | ||
exports.AddressProviderFromJson = AddressProviderFromJson; |
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,2 @@ | ||
export * from './from-json'; | ||
export * from './provider'; |
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,14 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./from-json"), exports); | ||
__exportStar(require("./provider"), exports); |
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,9 @@ | ||
export interface AddressProvider { | ||
market(denom: DENOMS): string; | ||
overseer(denom: DENOMS): string; | ||
aTerra(denom: DENOMS): string; | ||
} | ||
export declare enum DENOMS { | ||
UST = "uusd", | ||
AUST = "uaust" | ||
} |
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,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DENOMS = void 0; | ||
var DENOMS; | ||
(function (DENOMS) { | ||
DENOMS["UST"] = "uusd"; | ||
DENOMS["AUST"] = "uaust"; | ||
})(DENOMS = exports.DENOMS || (exports.DENOMS = {})); |
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,10 @@ | ||
import { LCDClientConfig } from '@terra-money/terra.js'; | ||
export interface AnchorConfig { | ||
lcd: LCDClientConfig; | ||
contracts: Contracts; | ||
} | ||
export interface Contracts { | ||
mmMarket: string; | ||
mmOverseer: string; | ||
aTerra: string; | ||
} |
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,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
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,3 @@ | ||
import { AnchorConfig } from '../address-provider/types'; | ||
declare const mainnetDefaultConfig: AnchorConfig; | ||
export default mainnetDefaultConfig; |
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,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const mainnetDefaultConfig = { | ||
lcd: { | ||
URL: 'https://lcd.terra.dev', | ||
chainID: 'columbus-5', | ||
gasPrices: { | ||
uusd: 0.456, | ||
}, | ||
gasAdjustment: 2, | ||
}, | ||
contracts: { | ||
mmMarket: 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s', | ||
aTerra: 'terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu', | ||
mmOverseer: 'terra1tmnqgvg567ypvsvk6rwsga3srp7e3lg6u0elp8', | ||
}, | ||
}; | ||
exports.default = mainnetDefaultConfig; |
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,3 @@ | ||
import { AnchorConfig } from '../address-provider/types'; | ||
declare const testnetDefaultConfig: AnchorConfig; | ||
export default testnetDefaultConfig; |
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,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const testnetDefaultConfig = { | ||
lcd: { | ||
URL: 'https://bombay-lcd.terra.dev', | ||
chainID: 'bombay-12', | ||
gasPrices: { | ||
uusd: 0.15, | ||
}, | ||
gasAdjustment: 2, | ||
}, | ||
contracts: { | ||
mmMarket: 'terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal', | ||
mmOverseer: 'terra1qljxd0y3j3gk97025qvl3lgq8ygup4gsksvaxv', | ||
aTerra: 'terra1ajt556dpzvjwl0kl5tzku3fc3p3knkg9mkv8jl', | ||
}, | ||
}; | ||
exports.default = testnetDefaultConfig; |
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,7 @@ | ||
export * from './market-redeem-stable'; | ||
export * from './market-deposit-stable'; | ||
export * from './query-aust-balance'; | ||
export * from './query-exchange-rate'; | ||
export * from './query-overseer-epoch-state'; | ||
export * from './transfer-cw20'; | ||
export * from './types'; |
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 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./market-redeem-stable"), exports); | ||
__exportStar(require("./market-deposit-stable"), exports); | ||
__exportStar(require("./query-aust-balance"), exports); | ||
__exportStar(require("./query-exchange-rate"), exports); | ||
__exportStar(require("./query-overseer-epoch-state"), exports); | ||
__exportStar(require("./transfer-cw20"), exports); | ||
__exportStar(require("./types"), exports); |
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,16 @@ | ||
import { MsgExecuteContract } from '@terra-money/terra.js'; | ||
import { AddressProvider } from '../address-provider'; | ||
import { DENOMS } from '../address-provider'; | ||
interface Option { | ||
address: string; | ||
currency: DENOMS; | ||
amount: string; | ||
} | ||
/** | ||
* | ||
* @param address Client’s Terra address. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
* @param amount Amount of a stablecoin to deposit. | ||
*/ | ||
export declare const fabricateMarketDepositStableCoin: ({ address, currency, amount, }: Option) => (addressProvider: AddressProvider) => MsgExecuteContract[]; | ||
export {}; |
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,26 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fabricateMarketDepositStableCoin = void 0; | ||
const terra_js_1 = require("@terra-money/terra.js"); | ||
const utils_1 = require("../utils"); | ||
var accAddress = utils_1.Parse.accAddress; | ||
var dec = utils_1.Parse.dec; | ||
/** | ||
* | ||
* @param address Client’s Terra address. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
* @param amount Amount of a stablecoin to deposit. | ||
*/ | ||
const fabricateMarketDepositStableCoin = ({ address, currency, amount, }) => (addressProvider) => { | ||
const mmContractAddress = addressProvider.market(currency); | ||
return [ | ||
new terra_js_1.MsgExecuteContract(accAddress(address), mmContractAddress, { | ||
deposit_stable: {}, | ||
}, | ||
// coins | ||
{ | ||
[`${currency}`]: new terra_js_1.Int(new terra_js_1.Dec(dec(amount)).mul(1000000)).toString(), | ||
}), | ||
]; | ||
}; | ||
exports.fabricateMarketDepositStableCoin = fabricateMarketDepositStableCoin; |
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,15 @@ | ||
import { MsgExecuteContract } from '@terra-money/terra.js'; | ||
import { AddressProvider } from '../address-provider'; | ||
import { DENOMS } from '../address-provider'; | ||
interface Option { | ||
address: string; | ||
currency: DENOMS; | ||
amount: string; | ||
} | ||
/** | ||
* @param address Client’s Terra address. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
* @param amount Amount of a stablecoin to redeem, or amount of an aToken (aTerra) to redeem (specified by currency). | ||
*/ | ||
export declare const fabricateMarketRedeemStable: ({ address, currency, amount, }: Option) => (addressProvider: AddressProvider) => MsgExecuteContract[]; | ||
export {}; |
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,29 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fabricateMarketRedeemStable = void 0; | ||
const terra_js_1 = require("@terra-money/terra.js"); | ||
const create_hook_msg_1 = require("../utils/create-hook-msg"); | ||
const utils_1 = require("../utils"); | ||
var accAddress = utils_1.Parse.accAddress; | ||
var dec = utils_1.Parse.dec; | ||
/** | ||
* @param address Client’s Terra address. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
* @param amount Amount of a stablecoin to redeem, or amount of an aToken (aTerra) to redeem (specified by currency). | ||
*/ | ||
const fabricateMarketRedeemStable = ({ address, currency, amount, }) => (addressProvider) => { | ||
const marketAddress = addressProvider.market(currency); | ||
const aTokenAddress = addressProvider.aTerra(currency); | ||
return [ | ||
new terra_js_1.MsgExecuteContract(accAddress(address), aTokenAddress, { | ||
send: { | ||
contract: marketAddress, | ||
amount: new terra_js_1.Int(new terra_js_1.Dec(dec(amount)).mul(1000000)).toString(), | ||
msg: (0, create_hook_msg_1.createHookMsg)({ | ||
redeem_stable: {}, | ||
}), | ||
}, | ||
}), | ||
]; | ||
}; | ||
exports.fabricateMarketRedeemStable = fabricateMarketRedeemStable; |
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,15 @@ | ||
import { LCDClient } from '@terra-money/terra.js'; | ||
import { AddressProvider, DENOMS } from '../address-provider'; | ||
import { Balance } from './types'; | ||
interface Option { | ||
lcd: LCDClient; | ||
address: string; | ||
market: DENOMS; | ||
} | ||
/** | ||
* @param lcd to connect to terra chain | ||
* @param address Client’s Terra address. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
*/ | ||
export declare const queryAUSTBalance: ({ lcd, address, market }: Option) => (addressProvider: AddressProvider) => Promise<Balance>; | ||
export {}; |
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,28 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.queryAUSTBalance = void 0; | ||
/** | ||
* @param lcd to connect to terra chain | ||
* @param address Client’s Terra address. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
*/ | ||
const queryAUSTBalance = ({ lcd, address, market }) => (addressProvider) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (addressProvider.aTerra(market) === '') { | ||
return { balance: '0' }; | ||
} | ||
return lcd.wasm.contractQuery(addressProvider.aTerra(market), { | ||
balance: { | ||
address: address, | ||
}, | ||
}); | ||
}); | ||
exports.queryAUSTBalance = queryAUSTBalance; |
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,18 @@ | ||
import { LCDClient } from '@terra-money/terra.js'; | ||
import { AddressProvider, DENOMS } from '../address-provider'; | ||
interface Option { | ||
lcd: LCDClient; | ||
market: DENOMS; | ||
block_height?: number; | ||
} | ||
interface EpochStateResponse { | ||
exchange_rate: string; | ||
aterra_supply: string; | ||
} | ||
/** | ||
* @param lcd to connect to terra chain. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
* @param block_height | ||
*/ | ||
export declare const queryMarketEpochState: ({ lcd, market, block_height, }: Option) => (addressProvider: AddressProvider) => Promise<EpochStateResponse>; | ||
export {}; |
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,27 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.queryMarketEpochState = void 0; | ||
/** | ||
* @param lcd to connect to terra chain. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
* @param block_height | ||
*/ | ||
const queryMarketEpochState = ({ lcd, market, block_height, }) => (addressProvider) => __awaiter(void 0, void 0, void 0, function* () { | ||
const marketContractAddress = addressProvider.market(market); | ||
const response = yield lcd.wasm.contractQuery(marketContractAddress, { | ||
epoch_state: { | ||
block_height: block_height, | ||
}, | ||
}); | ||
return response; | ||
}); | ||
exports.queryMarketEpochState = queryMarketEpochState; |
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,18 @@ | ||
import { LCDClient } from '@terra-money/terra.js'; | ||
import { AddressProvider, DENOMS } from '../address-provider'; | ||
interface Option { | ||
lcd: LCDClient; | ||
market: DENOMS; | ||
} | ||
interface EpochStateResponse { | ||
deposit_rate: string; | ||
prev_aterra_supply: string; | ||
prev_exchange_rate: string; | ||
last_executed_height: number; | ||
} | ||
/** | ||
* @param lcd to connect to terra chain. | ||
* @param money currency currency. for now, DENOMS.USSD is supported. | ||
*/ | ||
export declare const queryOverseerEpochState: ({ lcd, market }: Option) => (addressProvider: AddressProvider) => Promise<EpochStateResponse>; | ||
export {}; |
Oops, something went wrong.