@agoric/inter-protocol 0.16.2-dev-14b75b9.0.14b75b9 → 0.16.2-dev-d6fae11.0.d6fae11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -16
- package/src/clientSupport.d.ts +27 -72
- package/src/clientSupport.d.ts.map +1 -1
- package/src/clientSupport.js +23 -127
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.16.2-dev-
|
|
3
|
+
"version": "0.16.2-dev-d6fae11.0.d6fae11",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
35
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
36
|
-
"@agoric/governance": "0.10.4-dev-
|
|
37
|
-
"@agoric/internal": "0.3.3-dev-
|
|
38
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
39
|
-
"@agoric/store": "0.9.3-dev-
|
|
40
|
-
"@agoric/time": "0.3.3-dev-
|
|
41
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
42
|
-
"@agoric/vats": "0.15.2-dev-
|
|
43
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
44
|
-
"@agoric/zone": "0.2.3-dev-
|
|
34
|
+
"@agoric/base-zone": "0.1.1-dev-d6fae11.0.d6fae11",
|
|
35
|
+
"@agoric/ertp": "0.16.3-dev-d6fae11.0.d6fae11",
|
|
36
|
+
"@agoric/governance": "0.10.4-dev-d6fae11.0.d6fae11",
|
|
37
|
+
"@agoric/internal": "0.3.3-dev-d6fae11.0.d6fae11",
|
|
38
|
+
"@agoric/notifier": "0.6.3-dev-d6fae11.0.d6fae11",
|
|
39
|
+
"@agoric/store": "0.9.3-dev-d6fae11.0.d6fae11",
|
|
40
|
+
"@agoric/time": "0.3.3-dev-d6fae11.0.d6fae11",
|
|
41
|
+
"@agoric/vat-data": "0.5.3-dev-d6fae11.0.d6fae11",
|
|
42
|
+
"@agoric/vats": "0.15.2-dev-d6fae11.0.d6fae11",
|
|
43
|
+
"@agoric/zoe": "0.26.3-dev-d6fae11.0.d6fae11",
|
|
44
|
+
"@agoric/zone": "0.2.3-dev-d6fae11.0.d6fae11",
|
|
45
45
|
"@endo/captp": "^4.4.8",
|
|
46
46
|
"@endo/errors": "^1.2.13",
|
|
47
47
|
"@endo/eventual-send": "^1.3.4",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"jessie.js": "^0.3.4"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@agoric/smart-wallet": "0.5.4-dev-
|
|
56
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
57
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
55
|
+
"@agoric/smart-wallet": "0.5.4-dev-d6fae11.0.d6fae11",
|
|
56
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-d6fae11.0.d6fae11",
|
|
57
|
+
"@agoric/swingset-vat": "0.32.3-dev-d6fae11.0.d6fae11",
|
|
58
58
|
"@endo/bundle-source": "^4.1.2",
|
|
59
59
|
"@endo/init": "^1.1.12",
|
|
60
60
|
"@endo/promise-kit": "^1.1.13",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"typeCoverage": {
|
|
86
86
|
"atLeast": 95.65
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "d6fae11a6db28b1122089468183eccd4d47b83c9"
|
|
89
89
|
}
|
package/src/clientSupport.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
export function lookupOfferIdForVault(vaultId: string, currentP: Promise<
|
|
2
|
-
export function makeParseAmount(agoricNames: Pick<
|
|
1
|
+
export function lookupOfferIdForVault(vaultId: string, currentP: Promise<CurrentWalletRecord>): Promise<string>;
|
|
2
|
+
export function makeParseAmount(agoricNames: Pick<AgoricNamesRemotes, "brand" | "vbankAsset">, makeError?: (msg: string) => Error): (a: string) => Amount<"nat">;
|
|
3
3
|
export namespace Offers {
|
|
4
|
-
namespace auction {
|
|
5
|
-
export { makeBidOffer as Bid };
|
|
6
|
-
}
|
|
7
4
|
namespace fluxAggregator {
|
|
8
5
|
export { makePushPriceOffer as PushPrice };
|
|
9
6
|
}
|
|
@@ -19,37 +16,9 @@ export namespace Offers {
|
|
|
19
16
|
export { makeAddCollateralOffer as AddCollateral };
|
|
20
17
|
}
|
|
21
18
|
}
|
|
19
|
+
import type { CurrentWalletRecord } from '@agoric/smart-wallet/src/smartWallet.js';
|
|
20
|
+
import type { AgoricNamesRemotes } from '@agoric/vats/tools/board-utils.js';
|
|
22
21
|
import type { Amount } from '@agoric/ertp';
|
|
23
|
-
/**
|
|
24
|
-
* @param {Pick<
|
|
25
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
26
|
-
* 'brand' | 'vbankAsset'
|
|
27
|
-
* >} agoricNames
|
|
28
|
-
* @param {{
|
|
29
|
-
* offerId: string;
|
|
30
|
-
* give: string;
|
|
31
|
-
* maxBuy: string;
|
|
32
|
-
* wantMinimum?: string;
|
|
33
|
-
* } & (
|
|
34
|
-
* | {
|
|
35
|
-
* price: number;
|
|
36
|
-
* }
|
|
37
|
-
* | {
|
|
38
|
-
* discount: number; // -1 to 1. e.g. 0.10 for 10% discount, -0.05 for 5% markup
|
|
39
|
-
* }
|
|
40
|
-
* )} opts
|
|
41
|
-
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
42
|
-
*/
|
|
43
|
-
declare function makeBidOffer(agoricNames: Pick<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes, "brand" | "vbankAsset">, opts: {
|
|
44
|
-
offerId: string;
|
|
45
|
-
give: string;
|
|
46
|
-
maxBuy: string;
|
|
47
|
-
wantMinimum?: string;
|
|
48
|
-
} & ({
|
|
49
|
-
price: number;
|
|
50
|
-
} | {
|
|
51
|
-
discount: number;
|
|
52
|
-
})): import("@agoric/smart-wallet/src/offers.js").OfferSpec;
|
|
53
22
|
/**
|
|
54
23
|
* @param {unknown} _agoricNames
|
|
55
24
|
* @param {{
|
|
@@ -58,26 +27,23 @@ declare function makeBidOffer(agoricNames: Pick<import("@agoric/vats/tools/board
|
|
|
58
27
|
* unitPrice: bigint;
|
|
59
28
|
* }} opts
|
|
60
29
|
* @param {string} previousOffer
|
|
61
|
-
* @returns {
|
|
30
|
+
* @returns {OfferSpec}
|
|
62
31
|
*/
|
|
63
32
|
declare function makePushPriceOffer(_agoricNames: unknown, opts: {
|
|
64
33
|
offerId: string;
|
|
65
34
|
roundId?: bigint;
|
|
66
35
|
unitPrice: bigint;
|
|
67
|
-
}, previousOffer: string):
|
|
36
|
+
}, previousOffer: string): OfferSpec;
|
|
68
37
|
/**
|
|
69
|
-
* @param {Pick<
|
|
70
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
71
|
-
* 'brand'
|
|
72
|
-
* >} agoricNames
|
|
38
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
73
39
|
* @param {Instance} instance
|
|
74
40
|
* @param {{ offerId: string; feePct?: number; pair: [string, string] } & (
|
|
75
41
|
* | { wantMinted: number }
|
|
76
42
|
* | { giveMinted: number }
|
|
77
43
|
* )} opts
|
|
78
|
-
* @returns {
|
|
44
|
+
* @returns {OfferSpec}
|
|
79
45
|
*/
|
|
80
|
-
declare function makePsmSwapOffer({ brand }: Pick<
|
|
46
|
+
declare function makePsmSwapOffer({ brand }: Pick<AgoricNamesRemotes, "brand">, instance: Instance, opts: {
|
|
81
47
|
offerId: string;
|
|
82
48
|
feePct?: number;
|
|
83
49
|
pair: [string, string];
|
|
@@ -85,31 +51,25 @@ declare function makePsmSwapOffer({ brand }: Pick<import("@agoric/vats/tools/boa
|
|
|
85
51
|
wantMinted: number;
|
|
86
52
|
} | {
|
|
87
53
|
giveMinted: number;
|
|
88
|
-
})):
|
|
54
|
+
})): OfferSpec;
|
|
89
55
|
/**
|
|
90
|
-
* @param {Pick<
|
|
91
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
92
|
-
* 'brand'
|
|
93
|
-
* >} agoricNames
|
|
56
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
94
57
|
* @param {{
|
|
95
58
|
* offerId: string;
|
|
96
59
|
* wantMinted: number;
|
|
97
60
|
* giveCollateral: number;
|
|
98
61
|
* collateralBrandKey: string;
|
|
99
62
|
* }} opts
|
|
100
|
-
* @returns {
|
|
63
|
+
* @returns {OfferSpec}
|
|
101
64
|
*/
|
|
102
|
-
declare function makeOpenOffer({ brand }: Pick<
|
|
65
|
+
declare function makeOpenOffer({ brand }: Pick<AgoricNamesRemotes, "brand">, opts: {
|
|
103
66
|
offerId: string;
|
|
104
67
|
wantMinted: number;
|
|
105
68
|
giveCollateral: number;
|
|
106
69
|
collateralBrandKey: string;
|
|
107
|
-
}):
|
|
70
|
+
}): OfferSpec;
|
|
108
71
|
/**
|
|
109
|
-
* @param {Pick<
|
|
110
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
111
|
-
* 'brand'
|
|
112
|
-
* >} agoricNames
|
|
72
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
113
73
|
* @param {{
|
|
114
74
|
* offerId: string;
|
|
115
75
|
* collateralBrandKey?: string;
|
|
@@ -119,50 +79,45 @@ declare function makeOpenOffer({ brand }: Pick<import("@agoric/vats/tools/board-
|
|
|
119
79
|
* wantMinted?: number;
|
|
120
80
|
* }} opts
|
|
121
81
|
* @param {string} previousOffer
|
|
122
|
-
* @returns {
|
|
82
|
+
* @returns {OfferSpec}
|
|
123
83
|
*/
|
|
124
|
-
declare function makeAdjustOffer({ brand }: Pick<
|
|
84
|
+
declare function makeAdjustOffer({ brand }: Pick<AgoricNamesRemotes, "brand">, opts: {
|
|
125
85
|
offerId: string;
|
|
126
86
|
collateralBrandKey?: string;
|
|
127
87
|
giveCollateral?: number;
|
|
128
88
|
wantCollateral?: number;
|
|
129
89
|
giveMinted?: number;
|
|
130
90
|
wantMinted?: number;
|
|
131
|
-
}, previousOffer: string):
|
|
91
|
+
}, previousOffer: string): OfferSpec;
|
|
132
92
|
/**
|
|
133
|
-
* @param {Pick<
|
|
134
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
135
|
-
* 'brand'
|
|
136
|
-
* >} agoricNames
|
|
93
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
137
94
|
* @param {{
|
|
138
95
|
* offerId: string;
|
|
139
96
|
* collateralBrandKey?: string;
|
|
140
97
|
* giveMinted: number;
|
|
141
98
|
* }} opts
|
|
142
99
|
* @param {string} previousOffer
|
|
143
|
-
* @returns {
|
|
100
|
+
* @returns {OfferSpec}
|
|
144
101
|
*/
|
|
145
|
-
declare function makeCloseOffer({ brand }: Pick<
|
|
102
|
+
declare function makeCloseOffer({ brand }: Pick<AgoricNamesRemotes, "brand">, opts: {
|
|
146
103
|
offerId: string;
|
|
147
104
|
collateralBrandKey?: string;
|
|
148
105
|
giveMinted: number;
|
|
149
|
-
}, previousOffer: string):
|
|
106
|
+
}, previousOffer: string): OfferSpec;
|
|
150
107
|
/**
|
|
151
|
-
* @param {Pick<
|
|
152
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
153
|
-
* 'brand'
|
|
154
|
-
* >} agoricNames
|
|
108
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
155
109
|
* @param {{
|
|
156
110
|
* offerId: string;
|
|
157
111
|
* give: number;
|
|
158
112
|
* collateralBrandKey: string;
|
|
159
113
|
* }} opts
|
|
160
|
-
* @returns {
|
|
114
|
+
* @returns {OfferSpec}
|
|
161
115
|
*/
|
|
162
|
-
declare function makeAddCollateralOffer({ brand }: Pick<
|
|
116
|
+
declare function makeAddCollateralOffer({ brand }: Pick<AgoricNamesRemotes, "brand">, opts: {
|
|
163
117
|
offerId: string;
|
|
164
118
|
give: number;
|
|
165
119
|
collateralBrandKey: string;
|
|
166
|
-
}):
|
|
120
|
+
}): OfferSpec;
|
|
121
|
+
import type { OfferSpec } from '@agoric/smart-wallet/src/offers.js';
|
|
167
122
|
export {};
|
|
168
123
|
//# sourceMappingURL=clientSupport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientSupport.d.ts","sourceRoot":"","sources":["clientSupport.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clientSupport.d.ts","sourceRoot":"","sources":["clientSupport.js"],"names":[],"mappings":"AAgKO,+CAJI,MAAM,YACN,OAAO,CAAC,mBAAmB,CAAC,GAC1B,OAAO,CAAC,MAAM,CAAC,CAW3B;AA0EM,6CAJI,IAAI,CAAC,kBAAkB,EAAE,OAAO,GAAG,YAAY,CAAC,cAChD,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,GACpB,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,KAAK,CAAC,CAmCtC;;;;;;;;;;;;;;;;;yCA1QmC,yCAAyC;wCAF1C,mCAAmC;4BAFxB,cAAc;AAgT9D;;;;;;;;;GASG;AACH,kDATW,OAAO,QACP;IACN,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,iBACO,MAAM,GACJ,SAAS,CAerB;AApID;;;;;;;;GAQG;AACH,6CARW,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,YACjC,QAAQ,QACR;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CACnE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GACtB;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CACzB,GACS,SAAS,CA4BrB;AAxKD;;;;;;;;;GASG;AACH,0CATW,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,QACjC;IACN,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,GACS,SAAS,CAuBrB;AAED;;;;;;;;;;;;GAYG;AACH,4CAZW,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,QACjC;IACN,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,iBACO,MAAM,GACJ,SAAS,CAiBrB;AAED;;;;;;;;;GASG;AACH,2CATW,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,QACjC;IACN,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB,iBACO,MAAM,GACJ,SAAS,CAcrB;AA6HD;;;;;;;;GAQG;AACH,mDARW,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,QACjC;IACN,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,MAAM,CAAC;CAC5B,GACS,SAAS,CAuBrB;+BA3S2B,oCAAoC"}
|
package/src/clientSupport.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import { Fail } from '@endo/errors';
|
|
4
3
|
import { AmountMath } from '@agoric/ertp';
|
|
5
|
-
import {
|
|
6
|
-
import { parseRatio } from '@agoric/ertp/src/ratio.js';
|
|
4
|
+
import { Fail } from '@endo/errors';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* @import {Amount, Brand, Payment, Purse} from '@agoric/ertp';
|
|
10
8
|
* @import {Proposal} from '@agoric/zoe';
|
|
9
|
+
* @import {AgoricNamesRemotes} from '@agoric/vats/tools/board-utils.js';
|
|
10
|
+
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
11
|
+
* @import {CurrentWalletRecord} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
12
|
+
* @import {BoardRemote} from '@agoric/internal/src/marshal/board-client-utils.js';
|
|
13
|
+
* @import {OfferMaker} from '@agoric/smart-wallet/src/types.js';
|
|
11
14
|
*/
|
|
12
15
|
|
|
13
16
|
// XXX support other decimal places
|
|
@@ -20,10 +23,7 @@ const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
|
|
|
20
23
|
/**
|
|
21
24
|
* Give/want
|
|
22
25
|
*
|
|
23
|
-
* @param {Pick<
|
|
24
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
25
|
-
* 'brand'
|
|
26
|
-
* >} agoricNames
|
|
26
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
27
27
|
* @param {{ giveMinted?: number; wantMinted?: number }
|
|
28
28
|
* | {
|
|
29
29
|
* collateralBrandKey: string;
|
|
@@ -67,17 +67,14 @@ const makeVaultProposal = ({ brand }, opts) => {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* @param {Pick<
|
|
71
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
72
|
-
* 'brand'
|
|
73
|
-
* >} agoricNames
|
|
70
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
74
71
|
* @param {{
|
|
75
72
|
* offerId: string;
|
|
76
73
|
* wantMinted: number;
|
|
77
74
|
* giveCollateral: number;
|
|
78
75
|
* collateralBrandKey: string;
|
|
79
76
|
* }} opts
|
|
80
|
-
* @returns {
|
|
77
|
+
* @returns {OfferSpec}
|
|
81
78
|
*/
|
|
82
79
|
const makeOpenOffer = ({ brand }, opts) => {
|
|
83
80
|
const proposal = makeVaultProposal({ brand }, opts);
|
|
@@ -103,10 +100,7 @@ const makeOpenOffer = ({ brand }, opts) => {
|
|
|
103
100
|
};
|
|
104
101
|
|
|
105
102
|
/**
|
|
106
|
-
* @param {Pick<
|
|
107
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
108
|
-
* 'brand'
|
|
109
|
-
* >} agoricNames
|
|
103
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
110
104
|
* @param {{
|
|
111
105
|
* offerId: string;
|
|
112
106
|
* collateralBrandKey?: string;
|
|
@@ -116,7 +110,7 @@ const makeOpenOffer = ({ brand }, opts) => {
|
|
|
116
110
|
* wantMinted?: number;
|
|
117
111
|
* }} opts
|
|
118
112
|
* @param {string} previousOffer
|
|
119
|
-
* @returns {
|
|
113
|
+
* @returns {OfferSpec}
|
|
120
114
|
*/
|
|
121
115
|
const makeAdjustOffer = ({ brand }, opts, previousOffer) => {
|
|
122
116
|
// NB: not really a Proposal because the brands are not remotes
|
|
@@ -136,17 +130,14 @@ const makeAdjustOffer = ({ brand }, opts, previousOffer) => {
|
|
|
136
130
|
};
|
|
137
131
|
|
|
138
132
|
/**
|
|
139
|
-
* @param {Pick<
|
|
140
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
141
|
-
* 'brand'
|
|
142
|
-
* >} agoricNames
|
|
133
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
143
134
|
* @param {{
|
|
144
135
|
* offerId: string;
|
|
145
136
|
* collateralBrandKey?: string;
|
|
146
137
|
* giveMinted: number;
|
|
147
138
|
* }} opts
|
|
148
139
|
* @param {string} previousOffer
|
|
149
|
-
* @returns {
|
|
140
|
+
* @returns {OfferSpec}
|
|
150
141
|
*/
|
|
151
142
|
const makeCloseOffer = ({ brand }, opts, previousOffer) => {
|
|
152
143
|
const proposal = makeVaultProposal({ brand }, opts);
|
|
@@ -164,9 +155,7 @@ const makeCloseOffer = ({ brand }, opts, previousOffer) => {
|
|
|
164
155
|
|
|
165
156
|
/**
|
|
166
157
|
* @param {string} vaultId
|
|
167
|
-
* @param {Promise<
|
|
168
|
-
* import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord
|
|
169
|
-
* >} currentP
|
|
158
|
+
* @param {Promise<CurrentWalletRecord>} currentP
|
|
170
159
|
* @returns {Promise<string>} offer id in which the vault was made
|
|
171
160
|
*/
|
|
172
161
|
export const lookupOfferIdForVault = async (vaultId, currentP) => {
|
|
@@ -181,10 +170,7 @@ export const lookupOfferIdForVault = async (vaultId, currentP) => {
|
|
|
181
170
|
};
|
|
182
171
|
|
|
183
172
|
/**
|
|
184
|
-
* @param {Record<
|
|
185
|
-
* string,
|
|
186
|
-
* import('@agoric/internal/src/marshal/board-client-utils.js').BoardRemote
|
|
187
|
-
* >} brands
|
|
173
|
+
* @param {Record<string, BoardRemote>} brands
|
|
188
174
|
* @param {{ wantMinted: number; giveMinted?: undefined }
|
|
189
175
|
* | { giveMinted: number; wantMinted?: undefined }} opts
|
|
190
176
|
* @param {number} [fee]
|
|
@@ -214,16 +200,13 @@ const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
|
|
|
214
200
|
};
|
|
215
201
|
|
|
216
202
|
/**
|
|
217
|
-
* @param {Pick<
|
|
218
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
219
|
-
* 'brand'
|
|
220
|
-
* >} agoricNames
|
|
203
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
221
204
|
* @param {Instance} instance
|
|
222
205
|
* @param {{ offerId: string; feePct?: number; pair: [string, string] } & (
|
|
223
206
|
* | { wantMinted: number }
|
|
224
207
|
* | { giveMinted: number }
|
|
225
208
|
* )} opts
|
|
226
|
-
* @returns {
|
|
209
|
+
* @returns {OfferSpec}
|
|
227
210
|
*/
|
|
228
211
|
const makePsmSwapOffer = ({ brand }, instance, opts) => {
|
|
229
212
|
const method =
|
|
@@ -254,10 +237,7 @@ const makePsmSwapOffer = ({ brand }, instance, opts) => {
|
|
|
254
237
|
};
|
|
255
238
|
|
|
256
239
|
/**
|
|
257
|
-
* @param {Pick<
|
|
258
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
259
|
-
* 'brand' | 'vbankAsset'
|
|
260
|
-
* >} agoricNames
|
|
240
|
+
* @param {Pick<AgoricNamesRemotes, 'brand' | 'vbankAsset'>} agoricNames
|
|
261
241
|
* @param {(msg: string) => Error} makeError error constructor
|
|
262
242
|
* @returns {(a: string) => Amount<'nat'>}
|
|
263
243
|
*/
|
|
@@ -297,91 +277,13 @@ export const makeParseAmount =
|
|
|
297
277
|
};
|
|
298
278
|
|
|
299
279
|
/**
|
|
300
|
-
* @param {Pick<
|
|
301
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
302
|
-
* 'brand' | 'vbankAsset'
|
|
303
|
-
* >} agoricNames
|
|
304
|
-
* @param {{
|
|
305
|
-
* offerId: string;
|
|
306
|
-
* give: string;
|
|
307
|
-
* maxBuy: string;
|
|
308
|
-
* wantMinimum?: string;
|
|
309
|
-
* } & (
|
|
310
|
-
* | {
|
|
311
|
-
* price: number;
|
|
312
|
-
* }
|
|
313
|
-
* | {
|
|
314
|
-
* discount: number; // -1 to 1. e.g. 0.10 for 10% discount, -0.05 for 5% markup
|
|
315
|
-
* }
|
|
316
|
-
* )} opts
|
|
317
|
-
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
318
|
-
*/
|
|
319
|
-
const makeBidOffer = (agoricNames, opts) => {
|
|
320
|
-
assertAllDefined({
|
|
321
|
-
offerId: opts.offerId,
|
|
322
|
-
give: opts.give,
|
|
323
|
-
maxBuy: opts.maxBuy,
|
|
324
|
-
});
|
|
325
|
-
const parseAmount = makeParseAmount(agoricNames);
|
|
326
|
-
const proposal = {
|
|
327
|
-
give: { Bid: parseAmount(opts.give) },
|
|
328
|
-
...(opts.wantMinimum
|
|
329
|
-
? { want: { Collateral: parseAmount(opts.wantMinimum) } }
|
|
330
|
-
: {}),
|
|
331
|
-
};
|
|
332
|
-
const istBrand = proposal.give.Bid.brand;
|
|
333
|
-
const maxBuy = parseAmount(opts.maxBuy);
|
|
334
|
-
|
|
335
|
-
const bounds = (x, lo, hi) => {
|
|
336
|
-
assert(x >= lo && x <= hi);
|
|
337
|
-
return x;
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
assert(
|
|
341
|
-
'price' in opts || 'discount' in opts,
|
|
342
|
-
'must specify price or discount',
|
|
343
|
-
);
|
|
344
|
-
/** @type {import('./auction/auctionBook.js').OfferSpec} */
|
|
345
|
-
const offerArgs =
|
|
346
|
-
'price' in opts
|
|
347
|
-
? {
|
|
348
|
-
maxBuy: parseAmount(opts.maxBuy),
|
|
349
|
-
offerPrice: parseRatio(opts.price, istBrand, maxBuy.brand),
|
|
350
|
-
}
|
|
351
|
-
: {
|
|
352
|
-
maxBuy,
|
|
353
|
-
offerBidScaling: parseRatio(
|
|
354
|
-
(1 - bounds(opts.discount, -1, 1)).toFixed(2),
|
|
355
|
-
istBrand,
|
|
356
|
-
istBrand,
|
|
357
|
-
),
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
/** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
|
|
361
|
-
const offerSpec = {
|
|
362
|
-
id: opts.offerId,
|
|
363
|
-
invitationSpec: {
|
|
364
|
-
source: 'agoricContract',
|
|
365
|
-
instancePath: ['auctioneer'],
|
|
366
|
-
callPipe: [['makeBidInvitation', [maxBuy.brand]]],
|
|
367
|
-
},
|
|
368
|
-
proposal,
|
|
369
|
-
offerArgs,
|
|
370
|
-
};
|
|
371
|
-
return offerSpec;
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* @param {Pick<
|
|
376
|
-
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
|
|
377
|
-
* 'brand'
|
|
378
|
-
* >} agoricNames
|
|
280
|
+
* @param {Pick<AgoricNamesRemotes, 'brand'>} agoricNames
|
|
379
281
|
* @param {{
|
|
380
282
|
* offerId: string;
|
|
381
283
|
* give: number;
|
|
382
284
|
* collateralBrandKey: string;
|
|
383
285
|
* }} opts
|
|
384
|
-
* @returns {
|
|
286
|
+
* @returns {OfferSpec}
|
|
385
287
|
*/
|
|
386
288
|
const makeAddCollateralOffer = ({ brand }, opts) => {
|
|
387
289
|
/** @type {AmountKeywordRecord} */
|
|
@@ -393,7 +295,7 @@ const makeAddCollateralOffer = ({ brand }, opts) => {
|
|
|
393
295
|
),
|
|
394
296
|
};
|
|
395
297
|
|
|
396
|
-
/** @type {
|
|
298
|
+
/** @type {OfferSpec} */
|
|
397
299
|
const offerSpec = {
|
|
398
300
|
id: opts.offerId,
|
|
399
301
|
invitationSpec: {
|
|
@@ -414,7 +316,7 @@ const makeAddCollateralOffer = ({ brand }, opts) => {
|
|
|
414
316
|
* unitPrice: bigint;
|
|
415
317
|
* }} opts
|
|
416
318
|
* @param {string} previousOffer
|
|
417
|
-
* @returns {
|
|
319
|
+
* @returns {OfferSpec}
|
|
418
320
|
*/
|
|
419
321
|
const makePushPriceOffer = (_agoricNames, opts, previousOffer) => {
|
|
420
322
|
return {
|
|
@@ -432,15 +334,9 @@ const makePushPriceOffer = (_agoricNames, opts, previousOffer) => {
|
|
|
432
334
|
};
|
|
433
335
|
|
|
434
336
|
/**
|
|
435
|
-
* @satisfies {Record<
|
|
436
|
-
* string,
|
|
437
|
-
* Record<string, import('@agoric/smart-wallet/src/types.js').OfferMaker>
|
|
438
|
-
* >}
|
|
337
|
+
* @satisfies {Record<string, Record<string, OfferMaker>>}
|
|
439
338
|
*/
|
|
440
339
|
export const Offers = {
|
|
441
|
-
auction: {
|
|
442
|
-
Bid: makeBidOffer,
|
|
443
|
-
},
|
|
444
340
|
fluxAggregator: {
|
|
445
341
|
PushPrice: makePushPriceOffer,
|
|
446
342
|
},
|